micronaut-openapi
micronaut-openapi copied to clipboard
Support for Multiple OpenAPI Definitions
It would be nice to support multiple OpenAPI definitions.
For Example, I may have 2 different controllers with different sets of operations, and I want to divide these into multiple definitions.
The way to achieve this would be 2 different modules in a multi project build
Thanks for the tip @graemerocher . Would there need to be 2 different application contexts then?
No you can have module1
and module2
then an app
module that depends on the 2 modules that contains your Application
class with the main method to run it.
Perfect, thanks.
Seems to be unnecessary overhead to converting to multi-module setup just for outputting to different yaml files for openapi spec. Perhaps we can leverage the Swagger @Tag
annotation to achieve grouping?
I second this. The typical use case would be a v2 API in parallel with a v1.
What is currently the best way to generate different swagger files, ie: one swagger file with all endpoints and another swagger file with a subset (using filtering or a list of package names for example).
I tried using the swagger-gradle-plugin to do this but it doesn't resolve the Micronaut http annotations.
The way to achieve this would be 2 different modules in a multi project build
@graemerocher, who would that work? I have an application with the @OpenAPIDefinition annotation and then depend on modules with Controllers (Swagger annotations). With the micronaut-openapi
dependency, it will not pick up the controllers by default, but I have to reference them via @OpenApiInclude. Which is cumbersome, but works.
One thing I noticed is, that it won't generate the components (response models). When I move the controller into the application model and remove the @OpenApiInclude annotation, the generated OpenApi spec looks like expected.
Added multiple OpenAPI definitions here: https://github.com/micronaut-projects/micronaut-openapi/pull/1067
You can use micronaut versioning for this or OpenAPIGroup annotations.
Try using micronaut OpenAPI 4.10.0 (when it will be released)