openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open mancusi opened this issue 1 year ago • 2 comments

Bug Report Checklist

  • [X] Have you provided a full/minimal spec to reproduce the issue?
  • [X] Have you validated the input using an OpenAPI validator (example)?
  • [X] Have you tested with the latest master to confirm the issue still exists?
  • [X] Have you searched for related issues/PRs?
  • [X] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
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.

mancusi avatar Apr 22 '24 22:04 mancusi

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)

wing328 avatar Apr 23 '24 02:04 wing328

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.

mancusi avatar Apr 23 '24 16:04 mancusi