OpenAPITools / OpenAPITools/openapi-generator
[BUG] Api.mustache template is applying a global Tag to all the endpoints
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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
While building openApiGenerate, the api.mustache template file is taking a tag from the spec.yaml file and adding it as a global tag to the V1Api class(shown below).
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.5.0")
@Validated
@Tag(name = "fga", description = "the fga API")
public interface V1Api {
//all the endpoints go here
}
This is causing all the endpoints to be categorized under that specific tag even though the tag should only contain endpoints with the tag in the spec.yaml file.
openapi-generator version
3.0.1
Suggest a fix
By removing this line in the api.mustache file, we can get rid of the global tag.
{{#swagger2AnnotationLibrary}}
@Tag(name = "{{{tagName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{tagName}}} API"{{/tagDescription}})
{{/swagger2AnnotationLibrary}}
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 modules/openapi-generator/src/main/resources/JavaSpring/api.mustache at the referenced @Tag block and compare the generated V1Api behavior with the tags in the spec.yaml. Done means the generated class no longer applies one global tag to every endpoint, while endpoints retain only the tags assigned to them in the specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100