Skip to content

Conversation

@xeulbn
Copy link

@xeulbn xeulbn commented Jan 10, 2026

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:

  • raw Object properties
  • List<Object> item schemas
  • Map<String, Object> additionalProperties schemas

Fixes: #4682

Type of Change

  • 🐛 Bug fix
  • 🧪 Tests

Checklist

  • I have added/updated tests as needed
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

The tests were executed locally with:

mvn -pl modules/swagger-core -Dtest=ObjectFieldOas31ReproTest test

Before (OAS 3.1)

Before

After (OAS 3.1)

After

@xeulbn xeulbn changed the title Fix OAS 3.1 schema generation for raw Object properties fix : OAS 3.1 schema generation for raw Object properties Jan 10, 2026
@xeulbn xeulbn changed the title fix : OAS 3.1 schema generation for raw Object properties fix: OAS 3.1 schema generation for raw Object properties Jan 10, 2026
@daniel-kmiecik
Copy link
Collaborator

@xeulbn please also check for errors in builds and code scanning jobs.

@xeulbn
Copy link
Author

xeulbn commented Jan 28, 2026

Sorry I missed the comment before the build test.
I’ll check the build results and update the commit accordingly.

@xeulbn
Copy link
Author

xeulbn commented Jan 28, 2026

The build failure was caused by the updated OAS 3.1 handling for raw Object, which changes the expected YAML output in ModelResolverOAS31Test:

  • status type: [string, number] → [object, string, number]
  • extraObject: {} → { type: object }

I updated the OAS 3.1 expected output accordingly.

Verified locally on JDK 17 with:
mvn -pl modules/swagger-core test

All tests passed.
Thanks for the review and the helpful feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG properties of type Object do not have any type information when generating open api 3.1.0

2 participants