fix: core: preserve OAS 3.1 numeric exclusive validation constraints in composed schemas#23053
Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom Feb 25, 2026
Merged
Conversation
2e4be72 to
2469074
Compare
Member
|
lgtm. thanks for the contribution |
davidricodias
pushed a commit
to davidricodias/openapi-generator
that referenced
this pull request
Mar 11, 2026
…in composed schemas (OpenAPITools#23053) * test: add test case for `ExclusiveMinMax Test` (OpenAPITools#22943) * feat: Compatibility with exclusiveMinimum in OpenAPI 3.0.0 vs. 3.1.0 (OpenAPITools#22943) --------- Co-authored-by: 葉宗原 TsungYuan Yeh <tsungyuan.yeh@tpisoftware.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)PR Description Summary
Description
This PR fixes a regression where OpenAPI 3.1 numeric
exclusiveMinimumandexclusiveMaximumconstraints were lost during code generation, particularly when using model composition (allOf) with$ref.About Core Logic
Previously, in #22981, handling for OAS 3.1 numeric exclusive constraints was introduced in
OpenAPINormalizer.java. However, due to the wayOpenAPINormalizerruns early in the pipeline and how it handles recursive schema resolution, constraints were often lost when a model was defined usingallOfcombined with$ref. The normalization would skip referenced schemas or fail to persist the flags through the flattening process.This PR synchronizes the "stricter-wins" validation logic into
ModelUtils#syncValidationProperties. By handling the conversion from 3.1 numeric values to 3.0 boolean flags at this later stage (duringCodegenPropertypopulation), we ensure that:Notably, this implementation serves as a reliable fail-safe. Even if the normalization logic in
OpenAPINormalizer(introduced in #22981) were to be disabled or reverted, the newExclusiveMinMaxTest.javawill still pass. While a revert might cause the specific internal tests inOpenAPINormalizerTestto fail, the focus of this PR is ensuring the behavioral correctness of the final code generation output.About Test Case
The tests introduced in #22981 (
OpenAPINormalizerTest.java) verified the state of the intermediateSchemaobjects but did not validate the finalCodegenPropertyoutput, which is what templates actually use.I have added
ExclusiveMinMaxTest.java, which rewrites and expands these tests to:CodegenProperty.allOfinheritance correctly propagates exclusive constraints from parent schemas to child properties.Validation
Verified the fix using:
./mvnw -pl modules/openapi-generator test -Dtest=ExclusiveMinMaxTestAll tests passed, confirming that constraints are now correctly mapped to the generated model properties.
Ran
./bin/generate-samples.sh. No changes observed in existing samples, indicating no regressions for legacy OAS 2.0/3.0 specifications.Summary by cubic
Fixes preservation of OAS 3.1 numeric exclusiveMinimum/exclusiveMaximum in generated models and composed schemas, and keeps OAS 3.0 behavior intact.
Written for commit 2469074. Summary will update on new commits.