[BUG][JavaSpring] Not wanted automatic inserted tags if there're ones in OpenAPI definition
See original GitHub issue
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
From the openapi definition (see below) when I open it in the online editor https://editor.swagger.io/ I get the following swagger-ui page. Only the tags present in the definition appear.
When I use the JavaSpring generator with the same openapi definition, the generated java interface contains @Tag annotation on the generated interface deduced from endpoint path, with automatic generated description value.
And the swagger-ui page display it in addition to the one already present in the definition.
I don’t want the generated tag because I define mine directly in the definition. I don’t found an option (in the documentation nor in the api.mustashe) to avoid this generation.
openapi-generator version
v5.4.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: API example
version: "1.0.0"
description: "OpenAPI definition to illustrate the issue xxx"
tags:
- name: authentication
description: "All API concerning authentification."
paths:
/auth/login:
get:
tags:
- authentication
summary: API for login
operationId: authLogin
security: []
parameters: []
responses:
'200':
description: "OK"
content:
text/html:
schema:
type: string
'401':
description: "Unauthorized"
content:
text/html:
schema:
type: string
Generation Details
The genererated interface contains :
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Tag(name = "auth", description = "the auth API") public interface AuthApi { [...] /** * GET /auth/login : API for login * */ @Operation( operationId = "authLogin", summary = "API for login", tags = { "authentication" }, [...]
Steps to reproduce
Clear
Related issues/PRs
Clear
Suggest a fix
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Grouping Operations With Tags - Swagger
You can assign a list of tags to each API operation. Tagged operations may be handled differently by tools and libraries. For example,...
Read more >Using OpenAPI and Swagger UI - Quarkus
Roughly 15 minutes. An IDE. JDK 11+ installed with JAVA_HOME configured appropriately. Apache Maven 3.8.6. Optionally the Quarkus CLI if you want to...
Read more >Adding tags to an API - IBM
You can include tags in API definition. Such tags are added to the OpenAPI definition of the API but are not used by...
Read more >OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used...
Read more >F.A.Q - Springdoc-openapi
How can I define multiple OpenAPI definitions in one Spring Boot project? ... OAS 3 was released in July 2017, and there was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When I use this option, the generated interface name start with the tag name
AuthenticationApi
instead of the endpoint nameAuthApi.
, ok but that is not what I want. And the automatic annotation@Tag(name="Authentication", description)"the Authentication API"
is still generated above the interface declaration, and it is this annotation that causes the wrong tag entry in swagger-ui.The expected output should be :
=> without any tag annotation on the interface if there are tags in the openapi definition
In the openapi yaml definition the tags are associated only with operations
/auth/login
, not with the root path of endpoints/auth
, so I think we can’t associate to the interfaceAuthApi
the tag present in the definition.Moreover, an operation can receive several tags. In the definition with the prefix
auth
, I can definine an operationauth/login
with the tagauthentication
and another operationauth/status
without any tag so that the generator should not affect the tagauthentication
neither to the common rootauth
nor to theAuthApi
interface.I feel like there should just be a new option
disableTagAnnotation
(default to false for backward compatibility) to not generate the@tag
annotation on interfaces.You need to fork this openapi-generator application from github. Change the code and compile your own binaries and use that.
On Fri, 2 Dec 2022, 11:50 anitha2010, @.***> wrote: