OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.51k stars 6.51k forks source link

[BUG][JAVA] useTags property of JAXRS-SPEC does not handle operations with multiple tags #18461

Open mancusi opened 5 months ago

mancusi commented 5 months ago

Bug Report Checklist

Description

The useTags additionalProperty of the jaxrs-spec generator ignores operations with multiple tags due to code here.

This means that an Api class is only generated for the first tag in the list rather than every tag.

openapi-generator version

7.5.0 -- it is not a regression.

OpenAPI declaration file content or url

Example spec here. The endpoint has two tags petV1 and petV2. I would expect PetV1Api and PetV2Api to be generated but only PetV2Api is generated due to the bug.

Generation Details

Generated with openapi-generator generate -g jaxrs-spec -i openapi.yaml --additional-properties=useTags=true

Steps to reproduce
  1. Download example gist as openapi.yaml
  2. Run the following openapi-generator command: openapi-generator generate -g jaxrs-spec -i openapi.yaml --additional-properties=useTags=true
Suggest a fix

The issue is that additional tags are ignored due to the line here. Adding every tag on the operation would allow multiple API files to be generated.

wing328 commented 5 months ago

have you tried enabling the openapi normalizer rule KEEP_ONLY_FIRST_TAG_IN_OPERATION ?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

(we may enable this rule by default in next release)

mancusi commented 5 months ago

Ah this is actually the opposite of what I'm looking for. If I have an operation with two tags: One and Two I'd expect that operation to be part of both the generated OneApi interface and TwoApi interface.