avaje-http
avaje-http copied to clipboard
Now we can find controllers in other jar files
I have tried something, it was a lot of work and I am not sure if it is a good thing but it works. I now can locate controllers in other jar files and add them to the openapi.json file
So it could be a solution for #51
But as I said it kind of is a large change on top of your code. It seems to work and I have compared the openapi.json that is created on a few types of parameters / returns types. With and without lists etc.
One thing that is also important to mention you need to add the following to your pom file to keep the parameter names so they can be used for generating the openapi.json file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-parameters</compilerArgument>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<parameters>true</parameters>
</configuration>
</plugin>
Please let me know if it could be something useful or not... Tijs
I think we should be able to "merge" the openapi.json files. Something like load each of the openapi.json files as resources and then merge the models.
Apologies this has taken me so long to back on this.
No problem, I have also been a bit busy lately. I did look at merging the json files again and found something interesting: https://github.com/kpramesh2212/openapi-merger-plugin
I did not try it but seems like a nice tool if it works.
Other thing I found was this: https://stackoverflow.com/questions/39945039/java-merge-json-files
The first one seems the best choice to look at because it is made for openapi files.
Library for this (but it is written in Kotlin) https://github.com/savvasdalkitsis/json-merge It is a single file, so it will literally be super trivial to convert to Java, I could probably send a gist here for a Java port of it (using Jackson so it can be used as a good reference).
https://github.com/flipkart-incubator/zjsonpatch should be used in this case. We can merge until we have one large document, but we should ensure the current projects' openapi.json is the last document to be "appended" so that we end up with its other fields being the ones that take effect.
Trivial example:
JsonNode merge(JsonNode mainNode, JsonNode updateNode) throws Exception {
// generate a patch between the main and update JSON objects
JsonNode patchNode = JsonDiff.asJson(mainNode, updateNode);
// apply the patch to the main JSON object to create a new merged object
JsonNode mergedNode = JsonPatch.fromJson(patchNode).apply(mainNode);
return mergedNode;
}