OpenAPITools / OpenAPITools/openapi-generator
Enhance useSpringBoot3 feature
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I'm using latest OpenAPI Gen version 7.4.0. With under Gradle configuration, I use Gradle to generate SpringBoot source code.
openApiGenerate {
generatorName = 'spring'
inputSpec = "${project.projectDir}/src/main/resources/instrumentAPI.yaml".toString()
outputDir = "${project.buildDir}/generated"
apiPackage = "com.bns.pxv.instr.api"
invokerPackage = "com.bns.pxv.instr.invoker"
modelPackage = "com.bns.pxv.instr.model"
}
The generated code having org.springframework.boot:spring-boot-starter-parent:2.7.15 in pom.xml. This is a quite old version.
Is there a way to specify which starter version to use when generating source code?
If I manually change the version in pom.xml, and add more dependencies with newer starter-parent version needing, compiling code is ok, but when I bring up the App, I cannot open the OpenAPI Swagger Doc page when connecting to the APP.
openapi-generator version
7.4.0
OpenAPI declaration file content or url
And OpeAPI file shall be able to replicate the issue.
But I have this task in my build.gradle to generate the Spring Code:
openApiGenerate {
generatorName = 'spring'
inputSpec = "${project.projectDir}/src/main/resources/openapi.yaml".toString()
outputDir = "${project.buildDir}/generated"
}
Command line used for generation
gradle openApiGenerate
Steps to reproduce
- Generate the Spring code,
- Change build.gradle to use newer version springframework:
id 'org.springframework.boot' version '3.2.4' - Add more dependencies in build.gradle to support using SpringBoot 3.2.4
- Build successfully, Then start the App: gradle bootRun
- Accessing the URL from browser, http://localhost:8080/swagger-ui.html, got this error
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Apr 08 19:55:29 EDT 2024
There was an unexpected error (type=Not Found, status=404).
Related issues/PRs
N/A
Suggest a fix/enhancement
N/A. I'm seeking answer to see if it is possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the spring generator configuration in build.gradle and inspect the generated pom.xml and Spring Boot 3.2.4 reproduction described in the issue. Determine how useSpringBoot3 should select the starter version and preserve Swagger UI behavior, then verify the generated application with gradle bootRun and the documented Swagger URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring-boot
- Domain
- api, backend, build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100