OpenAPITools / OpenAPITools/openapi-generator
[BUG] [DefaultGenerator] Multi tags Webhooks generation overwrite generated API file
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When webhooks are defined with multiple tags, and a tag is shared with a "normal" API, the webhook [by tag] file generation is overwriting the just generated >API file with same tag.
So after API file was created with operations related to path described by OAS file, content is overwritten with the operation related to the webhooks definition because of Webhooks is also having the sametag value : it create same file name
openapi-generator version
master branch (commit #74044c3427)
OpenAPI declaration file content or url
gist: link
Generation Details
java -jar ./modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i foo-multiTagsAndWebhooks.yaml -g java -o output --additional-properties=library=apache-httpclient
Steps to reproduce
Execute the generation based onto above command line options
Related issues/PRs
Suggest a fix
Issue is coming from sequence (https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L1304-L1309):
// apis
List<OperationsMap> allOperations = new ArrayList<>();
generateApis(files, allOperations, allModels);
// webhooks
List<WebhooksMap> allWebhooks = new ArrayList<>();
generateWebhooks(files, allWebhooks, allModels);
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 with the generateApis and generateWebhooks calls in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java around lines 1304-1309. Run the provided Java generation command with the linked foo-multiTagsAndWebhooks.yaml reproduction, then inspect the generated API file. Done means webhook generation no longer overwrites the API generated for a shared tag.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100