OpenAPITools / OpenAPITools/openapi-generator
[REQ] Log a warning for use of allOf without discriminator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
No, common usage errors.
Describe the solution you'd like
Evaluate models after parsing, and if any are allOf, but the target schema doesn't have a discriminator field, trigger this as a warning.
We currently only display warnings if there are already errors in the spec (see https://github.com/OpenAPITools/openapi-generator/blob/f43c720b08496e1144ce64317bc060277e4acec2/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java#L458).
I think warnings should be moved out of the error condition and display those plus the one suggestion in this PR regardless of errors.
We'd need to define whether or not setting the strict spec flag to false would hide this warning.
Describe alternatives you've considered
n/a
Additional context
I was emailed directly by a user whose team upgraded from OpenAPI 2.0 to OpenAPI 3.0 documentation. His team didn't understand why base classes would generate in the 3.x branch but not in the 4.x branch. I explained to him that it was common for people to miss that the spec requires a discriminator property, because it's not a very intuitive requirement. Ideally, our tooling should provide this information to all users.
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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java around the existing warning condition, then trace where parsed models expose allOf and discriminator information. Clarify whether strict-spec=false suppresses this warning; done means the warning appears for the requested schema case regardless of unrelated spec errors, with coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100