fix: OAS 3.1 schema generation for raw Object properties #5034
+92
−1
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.
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
Related issue: #4682
This PR fixes an issue in OpenAPI 3.1 schema generation where properties
declared as raw Java
Objectare rendered as an empty schema ({}),instead of an explicit
objectschema.The issue does not occur in OAS 3.0.x, but appears in OAS 3.1 due to the
JSON Schema–based handling of types, where
Schema#getTypes()is usedinstead of
Schema#getType()during serialization.To address this, the OAS 3.1 schema generation for raw
Objecttypeshas been updated to explicitly set
types = ["object"].Additionally, regression tests have been added to cover:
ObjectpropertiesList<Object>item schemasMap<String, Object>additionalProperties schemasFixes: #4682
Type of Change
Checklist
Screenshots / Additional Context
The tests were executed locally with:
mvn -pl modules/swagger-core -Dtest=ObjectFieldOas31ReproTest testBefore (OAS 3.1)
After (OAS 3.1)