Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION][JAVA] Is support for swagger UI 3.0 present? #8703

Open
martindekov opened this issue Feb 15, 2021 · 10 comments
Open

[QUESTION][JAVA] Is support for swagger UI 3.0 present? #8703

martindekov opened this issue Feb 15, 2021 · 10 comments

Comments

@martindekov
Copy link

martindekov commented Feb 15, 2021

Description

Hello, I noticed that when I generate the code the generated Swagger UI Configuration class in OpenAPIDocumentationConfig.java has annotation @EnableSwagger2. And at the same time I couldn't find how to remove this annotation since springfox which works with swagger 3.0 requires this annotation to be removed.

My question is swagger UI 3.0 supported, is there a configuration to switch this as the generator also generates the UI (please correct me if I am wrong) along with the clients for the API?

openapi-generator version

5.0.1

OpenAPI declaration file content or url

Its valid I just want the generated UI to be swagger 3.0 and not swagger 2.0

Command line used for generation

java -jar $SCRIPTDIR/openapi-generator-cli.jar generate --generator-name spring --config $SCRIPTDIR/config-spring.json --output ./model -i ./api.yaml

Steps to reproduce

N/A

Related issues/PRs

#5803
#6108

Suggest a fix/enhancement

Not really familiar with the codebase of this project so I was not able to find how the OpenAPIDocumentationConfig.java is generated. But I suppose if a flag is added with the swagger ui version to the cli the file can be generated properly as per
https://github.com/springfox/springfox/blob/master/README.md#spring-boot-applications

@drexduarte
Copy link

drexduarte commented Mar 26, 2021

I'm facing the same issue here. I've tried several solutions in order to display the swagger-ui according to OAS 3 model. I tried to switch from springfox 2.9.2 to springdoc and also tried to upgrade springfox to version 3.0.0 but none of my atempts worked. Seems that the generated code still depends on springfox 2.x classes like RelativePathProvider. Is there any workaround to generate the OAS 3 documentation?

@dipika154
Copy link

dipika154 commented Jun 8, 2021

I am also facing same issue . When I have updated to swagger version 3, spring generator is generating OpenAPIDocumentationConfig with swagger 2 annotation and it is also using class RelativePathProvider in imports which is removed in version 3 of swagger. Any solution to resolve this?

@dipika154
Copy link

Is there any fix available for this problem yet?

@Blubb324
Copy link

Blubb324 commented Aug 28, 2021

This topic is still relevant and occurs in current version: openapi-generator-maven-plugin: 5.2.1

The class OpenAPIDocumentationConfig.java is still generated and just compatible with springfox 2.9.x because of using import springfox.documentation.spring.web.paths.RelativePathProvider within class.

@fengkaijia
Copy link
Contributor

SpringFox 3 requires OpenAPI 3 annotations, which is currently been worked on #5803 (MR #6306).

@martindekov
Copy link
Author

Technically the version of the Swagger UI with those annotations is 3.17.1 which is Swagger UI 3.0. You can check by generating the swagger definitions and running your application with them, then typing in the browser console:

JSON.stringify(versions)

You will see:

"{"swaggerUi":{"version":"3.17.1","gitRevision":"ga6656ced","gitDirty":...

So this is inconsistency is misleading springfox 3.0+ does not mean swagger UI version 3.0+.

Check out this: https://swagger.io/docs/open-source-tools/swagger-ui/usage/version-detection/

@jojyc
Copy link

jojyc commented Nov 3, 2021

Does anyone have any working solution for this issue? I am using Springboot 2.5.6 and OpenApi Generator 5.3.0

@DamasFoux
Copy link

Hey,
Is there a solution to this problem?
The generator generates code which uses RelativePathProvider and EnableSwagger2 and both are deprecated by new springfox versions.

we are using:

<plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>5.3.0</version>
</plugin>

springfox dependency:

 <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>3.0.0</version>
    </dependency>

@mgrossmann
Copy link

Same problem as reported by @DamasFoux
Is there any news regarding this problem?

Best, Mike

@ishat03
Copy link

ishat03 commented Jun 23, 2022

It is passing with openapitools version 6.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants