OpenAPITools / OpenAPITools/openapi-generator
[BUG] OpenAPI Normalizer - Unnecessary allOf wrapping for oneOf/anyOf items with discriminator labels
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?
- 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 OpenAPINormalizer wraps oneOf and anyOf items into allOf compositions when they have discriminator labels (e.g., title field).
openapi-generator version
OpenAPI declaration file content or url
Pet:
oneOf:
- title: dog
description: "A dog pet"
$ref: '#/components/schemas/Dog'
- title: cat
description: "A cat pet"
$ref: '#/components/schemas/Cat'
- title: bird
description: "A bird pet"
$ref: '#/components/schemas/Bird'
Actual:
Pet:
oneOf:
- allOf:
- $ref: '#/components/schemas/Dog'
title: dog
description: "A dog pet"
- allOf:
- $ref: '#/components/schemas/Cat'
title: cat
description: "A cat pet"
- allOf:
- $ref: '#/components/schemas/Bird'
title: bird
description: "A bird pet"
discriminator:
propertyName: petType
expected. For oneOf/anyOf discriminator labels, we should leave them unchanged.
Pet:
oneOf:
- title: dog
description: "A dog pet"
$ref: '#/components/schemas/Dog'
- title: cat
description: "A cat pet"
$ref: '#/components/schemas/Cat'
- title: bird
description: "A bird pet"
$ref: '#/components/schemas/Bird'
discriminator:
propertyName: petType
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Implement context-aware normalization. skip normalization for oneOf/anyOf items, but keep normalizing regular properties.
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 at the OpenAPINormalizer entry point and reproduce the issue with the supplied Pet schema using oneOf and discriminator labels. Trace how oneOf/anyOf items are normalized, then verify that these labeled items remain unchanged while regular properties continue to be normalized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100