OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Spring] Wrong Api Classes Generated for spring-cloud library (Only DefaultApi, instead of one per endpoint)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
- Whenever
spring-cloudlibrary is used forspringgenerator, onlyDefaultApiis generated. - Whenever
spring-bootlibrary is selected, multiple Api classes are generated.
I believe the correct behaviour would be creating separate API classes just like for spring-boot, due to separation of responsabilities.
openapi-generator version
4.0.2
OpenAPI declaration file content or url
openapi: 3.0.2
paths:
/hello:
description: Hello World API
get:
summary: GET Hello World
operationId: getHelloWorld
parameters:
- in: query
name: name
required: true
schema:
type: string
responses:
200:
description: oi
content:
text/plain:
schema:
type: string
/bye:
description: Bye World API
get:
summary: GET Bye World
operationId: getByeWorld
parameters:
- in: query
name: name
required: true
schema:
type: string
responses:
200:
description: oi
content:
text/plain:
schema:
type: string
Command line used for generation
java -jar openapi-generator-cli.jar generate -i spec.yaml -g spring --library spring-cloud
Steps to reproduce
- Get the spec
- Run the command line
- DefaultApi.java will be generated instead of HelloApi.java and ByeApi.java
Related issues/PRs
Couldn't find any similar issues.
Suggest a fix
I couldn't be sure what exactly the error is, but I suspect it is caused by this line, that excludes cloud library from the logic:
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 by reproducing the issue with the supplied OpenAPI YAML and the java -jar openapi-generator-cli.jar generate -i spec.yaml -g spring --library spring-cloud command. Inspect modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java around line 437, which the report identifies as relevant. Done means the spring-cloud output contains separate HelloApi.java and ByeApi.java classes rather than only DefaultApi.java.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100