micronaut-openapi icon indicating copy to clipboard operation
micronaut-openapi copied to clipboard

Support for Multiple OpenAPI Definitions

Open brianwyka opened this issue 4 years ago • 7 comments

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.

brianwyka avatar May 07 '20 13:05 brianwyka

The way to achieve this would be 2 different modules in a multi project build

graemerocher avatar May 11 '20 07:05 graemerocher

Thanks for the tip @graemerocher . Would there need to be 2 different application contexts then?

brianwyka avatar May 11 '20 12:05 brianwyka

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.

graemerocher avatar May 11 '20 13:05 graemerocher

Perfect, thanks.

brianwyka avatar May 11 '20 13:05 brianwyka

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?

brianwyka avatar Feb 03 '21 18:02 brianwyka

I second this. The typical use case would be a v2 API in parallel with a v1.

kevin-wise avatar Jan 04 '22 17:01 kevin-wise

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.

joseFilA avatar Mar 23 '22 18:03 joseFilA

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.

abedurftig avatar Oct 28 '22 08:10 abedurftig

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)

altro3 avatar Jul 02 '23 13:07 altro3