OpenAPITools / OpenAPITools/openapi-generator

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

Open
#18,461 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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?
  • [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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaJAXRSServerCodegen.java at the referenced useTags handling. Reproduce with the linked OpenAPI gist and the jaxrs-spec generation command using useTags=true. Done means an operation with tags petV1 and petV2 generates both PetV1Api and PetV2Api.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.