Upgrading to springfox-boot-starter version 3 causes compilation errors in generated OpenAPIDocumentationConfig class
See original GitHub issueI must be missing something obvious when migrating to springfox-boot-starter version 3.
I have a small simple spring boot demo project, for generating server code based on an OpenAPI version 3 (OAS3) file. It is working with springfox-swagger2 version 2.9.2, but it generates OAS2 json file in api-docs (I would like OAS3). It’s using the following dependencies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- Required for swagger code generation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- Required for openapi-generator-maven-plugin >= 4.2.3 (3.3.4 does not need it) -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
I am trying to upgrade to springfox-boot-starter version 3.0.0. Following the migration instructions, I removed the swagger2 dependency:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- Required for swagger code generation -->
<!-- For new projects [ref: https://github.com/springfox/springfox] -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<!-- Required for openapi-generator-maven-plugin >= 4.2.3 (3.3.4 does not need it) -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
However, I am getting some issues:
- Generated class
OpenAPIDocumentationConfig
has a@EnableSwagger2
annotation. As migration instructions tells to remove those, I didn’t expect the generator to include it in the code. Generated classes shouldn’t be edited manually. - And the following compilation errors:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR
[INFO] -------------------------------------------------------------
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[14,48] cannot find symbol
symbol: class RelativePathProvider
location: package springfox.documentation.spring.web.paths
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[50,53] cannot find symbol
symbol: class RelativePathProvider
location: class es.fnmt.ceres.rest.autec.poc.config.OpenAPIDocumentationConfig
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[44,31] incompatible types: es.fnmt.ceres.rest.autec.poc.config.OpenAPIDocumentationConfig.BasePathAwareRelativePathProvider cannot be converted to springfox.documentation.PathProvider
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[58,9] method does not override or implement a method from a supertype
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[60,91] cannot find symbol
symbol: method applicationPath()
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[63,9] method does not override or implement a method from a supertype
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:9 (1 by maintainers)
Top Results From Across the Web
java - Spring Boot 2.6.0 / Spring fox 3 - Failed to start bean ...
This problem's caused by a bug in Springfox. It's making an assumption about how Spring MVC is set up that doesn't always hold...
Read more >Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same issue here
Same issue here…