OpenAPITools / OpenAPITools/openapi-generator

Enhance useSpringBoot3 feature

Open
#18,337 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Generate the Spring code,
  2. Change build.gradle to use newer version springframework:
    id 'org.springframework.boot' version '3.2.4'
  3. Add more dependencies in build.gradle to support using SpringBoot 3.2.4
  4. Build successfully, Then start the App: gradle bootRun
  5. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.