swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.39k stars 2.19k forks source link

Swagger2 with multiple Resteasy applications does not work properly #3565

Open jarirajari opened 4 years ago

jarirajari commented 4 years ago

My Java web application is based on Spring boot 2 framework with Resteasy. I don't use web.xml or Spring's xml, but only annotations. I have multiple applications (@ApplicationPath) under the root context e.g. "/apis/api/authn" and "/apis/api/authz". Each application has multiple resources configured.

Observed When I retrieve the openapi document (e.g. /api-docs/openapi.json), only the lastly registered Resteasy application's API is available as openapi.json. I can see Resteasy doing its scan and can verify that the last application is the one that is used for generating the documentation.

Expected With default configuration, I was expecting to see all of the resources of all applications in one openapi document or, if possible, they could be separated by Swagger context or even the possibility to have a Swagger app per Resteasy app would be enough

Some previous issues that I have found, but the solutions don't work for me.

And possibly https://github.com/swagger-api/swagger-core/issues/3011

Noticed that scanner runs only once, and that I think the problem lies in https://github.com/swagger-api/swagger-core/blob/7f89e8fade0e867f5b25478c515a8f38a79d9563/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/BaseOpenApiResource.java

Digging more on Resteasy side (ResteasyEmbeddedServletInitializer): https://github.com/resteasy/resteasy-spring-boot/blob/master/resteasy-spring-boot-starter/src/main/java/org/jboss/resteasy/springboot/ResteasyEmbeddedServletInitializer.java

       <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2</artifactId>
            <version>2.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-core</artifactId>
            <version>2.1.2</version>
            <scope>compile</scope>
        </dependency>
selemxmn commented 4 years ago

@jarirajari Did you find a solution please ?