-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: OAS 3.1 schema generation for raw Object properties #5034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
...s/swagger-core/src/test/java/io/swagger/v3/core/serialization/ObjectFieldOas31ReproTest.java
Outdated
Show resolved
Hide resolved
...s/swagger-core/src/test/java/io/swagger/v3/core/serialization/ObjectFieldOas31ReproTest.java
Outdated
Show resolved
Hide resolved
modules/swagger-core/src/main/java/io/swagger/v3/core/util/PrimitiveType.java
Outdated
Show resolved
Hide resolved
|
@xeulbn please also check for errors in builds and code scanning jobs. |
|
Sorry I missed the comment before the build test. |
|
The build failure was caused by the updated OAS 3.1 handling for raw
I updated the OAS 3.1 expected output accordingly. Verified locally on JDK 17 with: All tests passed. |
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 Object were rendered as an empty schema ({}).
In the OAS 3.1 path, PrimitiveType.OBJECT#createProperty31() returned an empty
JsonSchema without populating Schema#types. Since OpenAPI 3.1 relies on
JSON Schema semantics and uses types during serialization, the missing type
information caused the schema to be emitted as {}.
To resolve this, the OAS 3.1 schema generation for raw Object types has 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)