OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java][Spring] Generator does not generate interfaces for all the tags on a path
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The spring server code generator does not generate the interfaces for all the tags specific in a path/operation
openapi-generator version
master
OpenAPI declaration file content or url
paths:
/group1/op1:
get:
tags:
- tag1
- tag3
operationId: op1
responses:
'200':
description: Ok
Command line used for generation
enable the codegen option useTags (true)
Steps to reproduce
Just run a open api yaml file with single path having multiple tags
Expectation is that multiple interface classes will be generated with the same API operation
Related issues/PRs
Suggest a fix/enhancement
There is piece of code in SpringCodeGen method preProcessOpenAPI to reset the tags on a operation to the first tag if there are multiple tags specified for an operation
'''
if (operation.getTags().size() > 0) {
String tag = operation.getTags().get(0);
operation.setTags(Arrays.asList(tag));
}
'''
I am not sure about the intent of this code, but removing this piece of code worked as expected.
Please let me know if I can create a PR by removing these changes
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 in SpringCodeGen.preProcessOpenAPI, focusing on the useTags option and the code that resets an operation's tags to its first tag. Reproduce the issue with the supplied single-path YAML and verify that generation produces interfaces for each operation tag without losing the shared operation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100