[JAVA] beta3 adds springfox import in spring generator
See original GitHub issueDescription
I have upgraded from beta2 to beta3 and the java spring code generated from the api yaml file contains the import:
springfox.documentation.annotations.ApiIgnore
but the compiler fails on this import.
openapi-generator version
beta3, was working in beta2
OpenAPI declaration file content or url
paths:
/endpoint:
post:
summary: Whatever
tags:
- endpoint
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Whatever'
responses:
"201":
content:
application/json:
schema:
$ref: '#/components/schemas/Something'
"400":
$ref: '#/components/responses/BadRequest'
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
"500":
$ref: '#/components/responses/InternalServerError'
Command line used for generation
mvn clean generate-sources
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${version.plugin.openapi.generator}</version>
<configuration>
<generateModels>true</generateModels>
<generateApi>true</generateApi>
<generateSupportingFiles>true</generateSupportingFiles>
<generateAliasAsModel>true</generateAliasAsModel>
<generatorName>spring</generatorName>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModelDocumentation>true</generateModelDocumentation>
<generateApiTests>true</generateApiTests>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<serializableModel>true</serializableModel>
<dateLibrary>java8</dateLibrary>
<library>spring-boot</library>
<ensureUniqueParams>false</ensureUniqueParams>
<useBeanValidation>true</useBeanValidation>
</configOptions>
<!-- enable configHelp to see all the available configOptions -->
</configuration>
<executions>
<execution>
<id>generate-model</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<modelPackage>whatever.api.model</modelPackage>
<apiPackage>whatever.api.model</apiPackage>
<invokerPackage>whatever.api.model</invokerPackage>
<inputSpec>${project.build.resources[0].directory}/api/whatever.yaml</inputSpec>
</configuration>
</execution>
</executions>
</plugin>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Documentation for the spring Generator
Generates a Java SpringBoot Server application using the SpringDoc integration. #CONFIG OPTIONS. These options may be applied as additional- ...
Read more >Added Springfox Swagger-UI and it's not working, what am I ...
When spring finds a simple path with just one variable swagger cannot intercept the URLs. Found by investigating various ideas in comments.
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 >Setting Up Swagger 2 with a Spring REST API - Baeldung
In this tutorial, we'll look at Swagger 2 for a Spring REST web service, using the Springfox implementation of the Swagger 2 specification....
Read more >Migrating from SpringFox - Springdoc-openapi
Remove springfox and swagger 2 dependencies. Add springdoc-openapi-ui dependency instead. <dependency> <groupId> ...
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
I’m getting sick of it. With every new version of the generator there is new stuff that’s gonna be imported and can’t be disabled.
The openapi-generator is a mature library and can’t add those things randomly. Backwards compability shall be the main goal on every change.
Here it is doubly bad because who’s using SpringFox after all the years of stagnation? It took them years to release their version 3. I think springdoc-openapi is the current way to go. But the openapi-generator only supports SpringFox without chance of disabling it or changing it to springdoc-openapi.
The
apiFirst
configuration only works heartlessly ifdelegatePattern
is activated. Then the delegates are missing.The problem seems to be coming from here: https://github.com/OpenAPITools/openapi-generator/blob/c974c512ff590c797db9f3e93c079017d65d3dcd/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java#L456
There are a few way around it: use
apiFirst=true
,reactive=true
or add the Springfox dependency to yourpom.xml
. They might work for you, but they are not enough for my usecase.Later edit: the Springfox dependency I was referring to should be
io.springfox:springfox-swagger2:3.0.0