GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: Add test showing how @JsonSubTypes can be used with @Schema-oneOf annotations by Mattias-Sehlstedt · Pull Request #5030 · swagger-api/swagger-core

Conversation

@Mattias-Sehlstedt

@Mattias-Sehlstedt Mattias-Sehlstedt commented Dec 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

TL;DR: I have introduced a test showing how one can circumvent the fact that a @JsonSubtypes will always produce an allOf polymorphic structure (that also breaks if a oneOf @Schema is specified at the same time). This is a reoccurring questions I get, so I would like to collect the solution in a location where it can have two purposes (showing the behavior of the ModelResolver, but also at the same time being a reference that I can share for how to adjust for the scenario).


I have many times had discussions regarding how polymorphic models can be constructed/expressed when exposing an OpenApi specification by using springdoc (which relies on swagger-core). Some examples being springdoc/springdoc-openapi#3054 and springdoc/springdoc-openapi#3103.

The scenario is that @JsonSubtypes has to be used to guide Jackson in the deserialization process, but the specification provider prefers to expose the polymorphism with a oneOf structure rather than a allOf structure. My current understanding is that this can be realized by having the parent class own the @JsonSubTypes, while it also implements an interface carrying a @Schema annotation containing a oneOf definition.

My preferred solution would be that it should be configurable whether the @JsonSubTypes is processed (I.e., an explicit @Schema annotation should take precedence over it). I know that this can be realized by providing a custom ModelResolver, but given its current size it is cumbersome to override it. I would have preferred if the ModelResolver had an isolated method responsible for it, so I could just define a ModelResolver that overrides only that method.

I understand that this is a difficult thing to achieve, so thus I elect to add illustrative tests to show the current behavior before I attempt anything. This since it is helpful to add tests for common use-cases even if I do not even introduce any change in behavior with a later PR.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

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

Screenshots / Additional Context

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
daniel-kmiecik
daniel-kmiecik reviewed Jan 22, 2026
View reviewed changes
Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

daniel-kmiecik
daniel-kmiecik reviewed Jan 22, 2026
View reviewed changes
Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

daniel-kmiecik
daniel-kmiecik requested changes Jan 27, 2026
View reviewed changes
Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../swagger-core/src/test/java/io/swagger/v3/core/resolving/JsonSubTypesAndSchemaOneOfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Mattias-Sehlstedt
Mattias-Sehlstedt force-pushed the test-json-subtypes-together-with-schema-oneof branch from 99f65c9 to d97c4cf Compare January 27, 2026 17:04
@Mattias-Sehlstedt
test: Add test showing how JsonSubtypes and Schema oneOf annotations …
dd8de3d
…behave together
@Mattias-Sehlstedt
Mattias-Sehlstedt force-pushed the test-json-subtypes-together-with-schema-oneof branch from d97c4cf to dd8de3d Compare January 27, 2026 17:06
Mattias-Sehlstedt
Mattias-Sehlstedt commented Jan 27, 2026
View reviewed changes
Comment thread ...es/swagger-core/src/test/java/io/swagger/v3/core/converting/override/CustomResolverTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@daniel-kmiecik

daniel-kmiecik commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

@Mattias-Sehlstedt Just FYI: After making changes in response to code review comments, please leave comments unresolved. The person doing the code review will decide whether your changes are sufficient and will either close them or ask for further changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daniel-kmiecik

daniel-kmiecik commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

@Mattias-Sehlstedt thanks for the PR — really appreciate your contribution!
Your changes will be available in the next release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daniel-kmiecik
daniel-kmiecik approved these changes Jan 28, 2026
View reviewed changes
@daniel-kmiecik
daniel-kmiecik merged commit adf4597 into swagger-api:master Jan 28, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Mattias-Sehlstedt

Mattias-Sehlstedt commented Jan 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thanks for your feedback and support @daniel-kmiecik!

@Mattias-Sehlstedt Just FYI: After making changes in response to code review comments, please leave comments unresolved. The person doing the code review will decide whether your changes are sufficient and will either close them or ask for further changes.

Will make sure to do it that way in the future. Is there any preferred way that people generally want to get notified of review comments being acted upon? Or do they generally want to find i themselves (I know that a lot of people ask for a lot of things in these projects). I was thinking for example if it is a difference between a single comment at the end "I have acted upon all review comments" vs one comment/reaction for each review comment.

So far for me email notifications have worked well, but I can imagine it getting out of hand fast.

Edit: I have of course also forgotten the "request review" button that exists, which most likely is what should be used.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mattias-Sehlstedt
Mattias-Sehlstedt deleted the test-json-subtypes-together-with-schema-oneof branch January 28, 2026 10:47
@daniel-kmiecik

daniel-kmiecik commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

@Mattias-Sehlstedt everyone is different and has their own preferences. When we (as maintainers) take action, we give the contributor some time to respond to the code review. The length of time is not set in stone. It depends on many factors.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mattias-Sehlstedt Mattias-Sehlstedt mentioned this pull request Sep 19, 2026
feat: optionally compose @JsonSubTypes parents into oneOf #5320
Merged
8 of 11 tasks
vpelikh added a commit to vpelikh/swagger-core that referenced this pull request Sep 26, 2026
@vpelikh
refactor: make resolveSubtypes overridable
7cc12ab
resolveSubtypes() was private, so a downstream ModelResolver subclass could
not influence or disable subtype resolution. Make it protected. This is a pure
visibility change with no behavior change, and provides an extension point for
consumers who need to customize polymorphic schema generation (see
swagger-api#5030).

Adds ResolveSubtypesExtensionPointTest, which subclass-overrides
resolveSubtypes and verifies the override is invoked.

(cherry picked from commit f57102e)
vpelikh added a commit to vpelikh/swagger-core that referenced this pull request Sep 26, 2026
@vpelikh
feat: optionally compose @JsonSubTypes parents into oneOf
b625bb8
Adds an opt-in (json-subtypes-oneof system property / ModelResolver.jsonSubTypesOneOf)
that composes a @JsonSubTypes or @Schema(subTypes) parent into a self-referencing
oneOf: the parent gets a oneOf to its subtypes while the subtypes keep allOf to the
parent.

The cyclic allOf <-> oneOf shape is off by default because swagger-ui,
openapi-generator and others dislike it, so the default output is unchanged from
3.0.0. When enabled, resolveSubtypes() replaces the parent model with a
ComposedSchema whose oneOf references the resolved subtypes (using the resolved
@JsonView-aware names) and re-reads the parent from the context; an explicit
@Schema(oneOf) wins over the automatic composition to avoid a recursive
allOf <-> oneOf.

resolveSubtypes() is now protected instead of private, providing an extension
point for downstream ModelResolver subclasses that need to customize or disable
subtype resolution (see swagger-api#5030).
ewaostrowska pushed a commit to vpelikh/swagger-core that referenced this pull request Oct 12, 2026
@vpelikh @ewaostrowska
feat: optionally compose @JsonSubTypes parents into oneOf
dd57eb6
Adds an opt-in (json-subtypes-oneof system property / ModelResolver.jsonSubTypesOneOf)
that composes a @JsonSubTypes or @Schema(subTypes) parent into a self-referencing
oneOf: the parent gets a oneOf to its subtypes while the subtypes keep allOf to the
parent.

The cyclic allOf <-> oneOf shape is off by default because swagger-ui,
openapi-generator and others dislike it, so the default output is unchanged from
3.0.0. When enabled, resolveSubtypes() replaces the parent model with a
ComposedSchema whose oneOf references the resolved subtypes (using the resolved
@JsonView-aware names) and re-reads the parent from the context; an explicit
@Schema(oneOf) wins over the automatic composition to avoid a recursive
allOf <-> oneOf.

resolveSubtypes() is now protected instead of private, providing an extension
point for downstream ModelResolver subclasses that need to customize or disable
subtype resolution (see swagger-api#5030).
cesmarvin pushed a commit to scm-manager/scm-manager that referenced this pull request Oct 13, 2026
renovate-idp @pfeuffer
Update dependency io.swagger.core.v3:swagger-core-jakarta to v2.2.55 …
f5f4ff4
…(develop) - abandoned

This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [io.swagger.core.v3:swagger-core-jakarta](https://github.com/swagger-api/swagger-core) | `2.2.26` → `2.2.55` | ![age](https://developer.mend.io/api/mc/badges/age/maven/io.swagger.core.v3:swagger-core-jakarta/2.2.55?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.swagger.core.v3:swagger-core-jakarta/2.2.26/2.2.55?slim=true) |

---

### Release Notes

<details>
<summary>swagger-api/swagger-core (io.swagger.core.v3:swagger-core-jakarta)</summary>

### [`v2.2.55`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.55): Swagger-core 2.2.55 released!

- chore: update dependency-check-maven to 12.2.2 ([#&#8203;5299](swagger-api/swagger-core#5299))
- chore: remove ACTIONS\_ALLOW\_UNSECURE\_COMMANDS from workflows ([#&#8203;5293](swagger-api/swagger-core#5293))
- chore(deps-dev): bump org.jboss.arquillian.testng:arquillian-testng-container from 1.9.3.Final to 1.10.2.Final ([#&#8203;5285](swagger-api/swagger-core#5285))
- chore(deps): bump org.sonatype.central:central-publishing-maven-plugin from 0.10.0 to 0.11.0 ([#&#8203;5284](swagger-api/swagger-core#5284))
- chore(deps): bump slf4j-version from 2.0.17 to 2.0.18 ([#&#8203;5283](swagger-api/swagger-core#5283))
- fix: \_isSetType now detects indirect Set implementations ([#&#8203;5265](swagger-api/swagger-core#5265))

### [`v2.2.54`](https://github.com/swagger-api/swagger-core/blob/HEAD/CHANGELOG.md#2254---2026-08-18)

##### Fixed

- Java 8 date/time types (`OffsetTime`, `Duration`, `LocalTime`) now map by default
  to the correct OpenAPI Formats Registry strings (`"time"`, `"duration"`, `"time-local"`)
  instead of an unusable expanded object. ([#&#8203;5172](swagger-api/swagger-core#5172))
- `LocalDateTime` deserialization from an existing OpenAPI spec now correctly
  round-trips through the new `TimeSchema`/`DurationSchema`/`DateTimeLocalSchema`/
  `TimeLocalSchema` classes instead of falling back to a generic `StringSchema`.

##### Added

- `PrimitiveType.enableJava8Formats()` — opt-in to map `LocalDateTime` to the
  registry-compliant `"date-time-local"` format (default remains `"date-time"`
  for backward compatibility).

##### Deprecated

- `PrimitiveType.enablePartialTime()` — prefer the new default `"time-local"`
  mapping for `LocalTime`; kept for callers who specifically need the
  non-registry `"partial-time"` format.

### [`v2.2.53`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.53): Swagger-core 2.2.53 released!

- chore: update Jackson to 2.22.1 ([#&#8203;5258](swagger-api/swagger-core#5258))
- refactor: replace `writer(new DefaultPrettyPrinter())` with `writerWithDefaultPrettyPrinter()` ([#&#8203;5252](swagger-api/swagger-core#5252))
- fix: Stabilize CI Maven and Gradle builds ([#&#8203;5238](swagger-api/swagger-core#5238))
- test: remove system.out.println from tests ([#&#8203;5236](swagger-api/swagger-core#5236))
- chore: bump dependencies ([#&#8203;5229](swagger-api/swagger-core#5229))
- refactor: simplify type handling in ModelDeserializer ([#&#8203;5227](swagger-api/swagger-core#5227))
- Revert "hotfix: temporarily allow Release workflow to skip mvn deploy to recover 2.2.52 ([#&#8203;5220](swagger-api/swagger-core#5220))" ([#&#8203;5223](swagger-api/swagger-core#5223))
- chore(deps-dev): bump org.codehaus.groovy:groovy from 3.0.23 to 3.0.25 ([#&#8203;5216](swagger-api/swagger-core#5216))
- chore(deps): bump commons-cli:commons-cli from 1.9.0 to 1.11.0 ([#&#8203;5209](swagger-api/swagger-core#5209))
- chore(deps-dev): bump commons-codec:commons-codec from 1.17.2 to 1.22.0 ([#&#8203;5208](swagger-api/swagger-core#5208))
- fix: emit $ref for array items when cycle guard suppresses implementation processing ([#&#8203;5205](swagger-api/swagger-core#5205))
- Restore inner property name from map key in handleUnwrapped ([#&#8203;5193](swagger-api/swagger-core#5193))
- Honor PropertyNamingStrategy for get/is-prefixed property names ([#&#8203;5192](swagger-api/swagger-core#5192))
- fix: let explicit [@&#8203;Schema](https://github.com/Schema)(format) override type-derived format ([#&#8203;5185](swagger-api/swagger-core#5185)) ([#&#8203;5186](swagger-api/swagger-core#5186))
- docs: update format of javadoc to produce a functional link ([#&#8203;5182](swagger-api/swagger-core#5182))
- fix: exclude overridable annotation values when parsing composed annotations ([#&#8203;5179](swagger-api/swagger-core#5179))
- fix: negative and positive validation annotations uses relevant OAS 3.1 syntax ( [#&#8203;5170](swagger-api/swagger-core#5170)) ([#&#8203;5171](swagger-api/swagger-core#5171))

### [`v2.2.52`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.52): Swagger-core 2.2.52 released!

- chore(deps): bump jackson-version from 2.21.1 to 2.22.0 ([#&#8203;5203](swagger-api/swagger-core#5203))
- chore(deps): bump maven.version from 3.9.14 to 3.9.16 ([#&#8203;5195](swagger-api/swagger-core#5195))
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from 3.5.0 to 3.5.6 ([#&#8203;5190](swagger-api/swagger-core#5190))
- chore(deps): bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.12.0 ([#&#8203;5157](swagger-api/swagger-core#5157))
- fix: Avoid locale-dependent NumberFormat in IntegerSchema ([#&#8203;5140](swagger-api/swagger-core#5140))
- fix: ensure that [@&#8203;Nullable](https://github.com/Nullable) does not incorrectly affect object schemas ([#&#8203;5124](swagger-api/swagger-core#5124))

### [`v2.2.51`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.51): Swagger-core 2.2.51 released!

- chore(deps-dev): bump logback-version from 1.5.25 to 1.5.32 ([#&#8203;5149](swagger-api/swagger-core#5149))
- chore(deps): bump slf4j-version from 2.0.9 to 2.0.17 ([#&#8203;5137](swagger-api/swagger-core#5137))

### [`v2.2.50`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.50): Swagger-core 2.2.50 released!

- fix: serialize a boolean schema example value as a JsonNode ([#&#8203;5173](swagger-api/swagger-core#5173))
- chore: migrate from tibdex/github-app-token to actions/create-github-app-token ([#&#8203;5169](swagger-api/swagger-core#5169))
- fix: resolve Validation Meta annotations not working ([#&#8203;4886](swagger-api/swagger-core#4886)) ([#&#8203;4986](swagger-api/swagger-core#4986))

### [`v2.2.49`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.49): Swagger-core 2.2.49 released!

- fix(gradle-plugin): avoid eager classpath resolution in Gradle plugin ([#&#8203;5164](swagger-api/swagger-core#5164))
- fix: ensure deduplication of required items in Schema ([#&#8203;5163](swagger-api/swagger-core#5163))
- fix: add support for Positive, PositiveOrZero, Negative, and NegativeOrZero validation constraints ([#&#8203;5162](swagger-api/swagger-core#5162))
- chore(deps): bump org.codehaus.plexus:plexus-utils from 3.6.0 to 3.6.1 in /modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta ([#&#8203;5155](swagger-api/swagger-core#5155))
- chore(deps): bump org.codehaus.plexus:plexus-utils from 3.6.0 to 3.6.1 ([#&#8203;5147](swagger-api/swagger-core#5147))
- Regenerate maven wrapper after bumping ([#&#8203;5143](swagger-api/swagger-core#5143))
- Bump build-helper-maven-plugin to 3.6.1 ([#&#8203;5141](swagger-api/swagger-core#5141))
- chore: bump Apache Maven to 3.9.14 and maven-wrapper to 3.3.4 ([#&#8203;5139](swagger-api/swagger-core#5139))
- Update apache maven distributionUrl to 3.9.9 fixing npe on snapshot deploy step ([#&#8203;5138](swagger-api/swagger-core#5138))
- ci: add -e flag to deploy command for full stacktrace on failure ([#&#8203;5134](swagger-api/swagger-core#5134))
- Update sonatype central-publishing-maven-plugin to 0.10.0 ([#&#8203;5133](swagger-api/swagger-core#5133))
- fix: exclude bridge methods from [@&#8203;JsonValue](https://github.com/JsonValue) enum detection ([#&#8203;5127](swagger-api/swagger-core#5127)) ([#&#8203;5128](swagger-api/swagger-core#5128))
- fix: OAS 3.1 schema generation for raw Object properties is controlled with explicit-object-schema flag ([#&#8203;5112](swagger-api/swagger-core#5112))
- chore(deps): bump org.apache.maven.plugins:maven-plugin-plugin from 3.6.4 to 3.15.2 ([#&#8203;5110](swagger-api/swagger-core#5110))
- chore(deps-dev): bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.4.0 ([#&#8203;5109](swagger-api/swagger-core#5109))
- chore(deps): bump org.yaml:snakeyaml from 2.3 to 2.6 ([#&#8203;5108](swagger-api/swagger-core#5108))
- fix(gradle-plugin): add .convention() defaults to Property<T> fields in ResolveTask ([#&#8203;5065](swagger-api/swagger-core#5065))

### [`v2.2.48`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.48): Swagger-core 2.2.48 released!

- fix: move env under deploy step from under integration tests ([#&#8203;5129](swagger-api/swagger-core#5129))
- fix: revert DEFAULT\_SENTINEL for defaultValue ([#&#8203;5123](swagger-api/swagger-core#5123))
- fix: AnnotationUtils cache misses due to reinstantiation of ModelConverterContext ([#&#8203;5114](swagger-api/swagger-core#5114))
- fix: add so that the Java Deprecated annotation is considered a processable annotation type ([#&#8203;5099](swagger-api/swagger-core#5099))

### [`v2.2.47`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.47): Swagger-core 2.2.47 released!

- chore(deps): bump org.codehaus.plexus:plexus-utils from 4.0.2 to 4.0.3 in /modules/swagger-eclipse-transformer-maven-plugin ([#&#8203;5118](swagger-api/swagger-core#5118))
- Update gh actions ([#&#8203;5106](swagger-api/swagger-core#5106))
- fix: re-add a null guard for setDefaultSchema ([#&#8203;5089](swagger-api/swagger-core#5089))
- refactor how the size constraint is applied to a parameter ([#&#8203;5080](swagger-api/swagger-core#5080))
- fix: do not process a nullable annotation for container items ([#&#8203;5079](swagger-api/swagger-core#5079))
- fix: treat number example as number and not string ([#&#8203;5062](swagger-api/swagger-core#5062))
- \[Feature]: Provide a BOM module for managing dependencies ([#&#8203;4966](swagger-api/swagger-core#4966)) ([#&#8203;4987](swagger-api/swagger-core#4987))

### [`v2.2.46`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.46): Swagger-core 2.2.46 released!

- bug fix for test - reset enumAsRef value in the test to default ([#&#8203;5092](swagger-api/swagger-core#5092))

### [`v2.2.45`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.45): Swagger-core 2.2.45 released!

- fix: ensure sentinel values are handled correctly in defaultValue mer… ([#&#8203;5078](swagger-api/swagger-core#5078))
- chore: update jackson dependencies ([#&#8203;5075](swagger-api/swagger-core#5075))
- chore(deps-dev): bump ch.qos.logback:logback-core from 1.5.22 to 1.5.25 ([#&#8203;5072](swagger-api/swagger-core#5072))
- nit: Renamed `GericModelConverter` into `GenericModelConverter` ([#&#8203;5066](swagger-api/swagger-core#5066))
- fix: treat streams with arraySchema annotation as array type ([#&#8203;5013](swagger-api/swagger-core#5013)) ([#&#8203;5064](swagger-api/swagger-core#5064))

### [`v2.2.44`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.44): Swagger-core 2.2.44 released!

- fix: add empty default value ([#&#8203;4838](swagger-api/swagger-core#4838)) ([#&#8203;5063](swagger-api/swagger-core#5063))
- fix: null values in examples, example and default ([#&#8203;4339](swagger-api/swagger-core#4339), [#&#8203;4229](swagger-api/swagger-core#4229)) ([#&#8203;5060](swagger-api/swagger-core#5060))
- fix: do not set schema.nullable for OAS 3.1 ([#&#8203;5059](swagger-api/swagger-core#5059))
- fix: calculate sibling properties based upon whether the schema is the array or the item in the array ([#&#8203;5055](swagger-api/swagger-core#5055))
- fix: OAS 3.1 schema generation for raw Object properties ([#&#8203;5034](swagger-api/swagger-core#5034))
- feat: Multiple SecurityRequirement annotations with AND condition [#&#8203;3556](swagger-api/swagger-core#3556) ([#&#8203;5025](swagger-api/swagger-core#5025))
- bug fix propertyNames schema is not removed as unreferenced by SpecFilter [#&#8203;5017](swagger-api/swagger-core#5017) ([#&#8203;5020](swagger-api/swagger-core#5020))
- 5001: Add support for [@&#8203;Nullable](https://github.com/Nullable) annotations in OpenAPI 3.1 schemas ([#&#8203;5018](swagger-api/swagger-core#5018))

### [`v2.2.43`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.43): Swagger-core 2.2.43 released!

- fix: add missing [@&#8203;ArraysSchema](https://github.com/ArraysSchema).arraySchema properties ([#&#8203;5049](swagger-api/swagger-core#5049))
- refactor: introduce class responsible for how bean validation annotations affect schemas ([#&#8203;5047](swagger-api/swagger-core#5047))
- fix: treat example values starting with numbers as strings ([#&#8203;5046](swagger-api/swagger-core#5046))
- refactor: add an overloaded method for resolving required so that the field type can be utilized ([#&#8203;5042](swagger-api/swagger-core#5042))
- test: Add test showing how [@&#8203;JsonSubTypes](https://github.com/JsonSubTypes) can be used with [@&#8203;Schema-oneOf](https://github.com/Schema-oneOf) annotations ([#&#8203;5030](swagger-api/swagger-core#5030))
- chore: update commons-lang3 to 3.20 ([#&#8203;5026](swagger-api/swagger-core#5026))

### [`v2.2.42`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.42): Swagger-core 2.2.42 released!

- fix: apply minItems/minLength from @&#8203;NotEmpty/[@&#8203;NotBlank](https://github.com/NotBlank) regardless of requiredMode ([#&#8203;5033](swagger-api/swagger-core#5033))
- chore: update logback-core dependency ([#&#8203;5029](swagger-api/swagger-core#5029))

### [`v2.2.41`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.41): Swagger-core 2.2.41 released!

- Fix/annotated type caching 5003 ([#&#8203;5005](swagger-api/swagger-core#5005))
- [#&#8203;4852](swagger-api/swagger-core#4852) Unit test and fix to allow recursive models to process without StackOverflow  ([#&#8203;5004](swagger-api/swagger-core#5004))
- fix: Refactor JsonAssert and apply to json/yaml assertions ([#&#8203;5002](swagger-api/swagger-core#5002))
- fix: use arraySchema when deciding required of an array ([#&#8203;4998](swagger-api/swagger-core#4998))
- fix: NotBlank and NotEmpty annotations follow NotNull behavior ([#&#8203;4968](swagger-api/swagger-core#4968))

### [`v2.2.40`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.40): Swagger-core 2.2.40 released!

- fix: remove superfluous ref for a composed schema. Fixes [#&#8203;4959](swagger-api/swagger-core#4959) ([#&#8203;5000](swagger-api/swagger-core#5000))
- Bump classgraph version to 4.8.184 ([#&#8203;4992](swagger-api/swagger-core#4992))
- fix(test): Make serialization tests robust against key reordering ([#&#8203;4990](swagger-api/swagger-core#4990))

### [`v2.2.39`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.39): Swagger-core 2.2.39 released!

- chore: remove System.out and printStackTrace to align with Sonar rules S106 and S1148 ([#&#8203;4988](swagger-api/swagger-core#4988))
- fix: adjust docs about RequiredMode.AUTO + small refactor ([#&#8203;4982](swagger-api/swagger-core#4982))
- Fix a non-deterministic assertion in ServletUtilsTest ([#&#8203;4981](swagger-api/swagger-core#4981))
- Fix(core): Prevent redundant schema resolution by fixing AnnotatedType equality ([#&#8203;4975](swagger-api/swagger-core#4975))

### [`v2.2.38`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.38): Swagger-core 2.2.38 released!

- honor array schema description when generating OpenAPI 3.1 ([#&#8203;4942](swagger-api/swagger-core#4942))

### [`v2.2.37`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.37): Swagger-core 2.2.37 released!

- fix: prevent leaking properties to enum schema when Schema#implementa… ([#&#8203;4970](swagger-api/swagger-core#4970))
- refs enumAsRef Issue 4932 ([#&#8203;4969](swagger-api/swagger-core#4969))
- fix: add booleanSchemaValue to Schema's hashCode and equals ([#&#8203;4958](swagger-api/swagger-core#4958))
- fix: Fix missing items on nested [@&#8203;ArraySchema](https://github.com/ArraySchema) items in OAS 3.1 ([#&#8203;4949](swagger-api/swagger-core#4949))

### [`v2.2.36`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.36): Swagger-core 2.2.36 released!

- fix: Fix ClassCastException on resolving JsonSchema. This solves issu… ([#&#8203;4950](swagger-api/swagger-core#4950))

### [`v2.2.35`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.35): Swagger-core 2.2.35 released!

- chore: bump jackson versions to 2.19.2 ([#&#8203;4943](swagger-api/swagger-core#4943))
- Bump github classgraph version to 4.8.181 ([#&#8203;4940](swagger-api/swagger-core#4940))
- chore: update common lang3 to 3.18 ([#&#8203;4938](swagger-api/swagger-core#4938))
- chore: add GitHub issue and pull request templates ([#&#8203;4934](swagger-api/swagger-core#4934))
- docs: provide a better formatting for README ([#&#8203;4930](swagger-api/swagger-core#4930))
- Revert temp workarounds for sonatype 502 ([#&#8203;4922](swagger-api/swagger-core#4922))
- Ticket-4910 | Added FailedApiResponse.java ([#&#8203;4911](swagger-api/swagger-core#4911))

### [`v2.2.34`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.34): Swagger-core 2.2.34 released!

- fix: add condition for prefixing parameter ([#&#8203;4916](swagger-api/swagger-core#4916))

### [`v2.2.33`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.33): Swagger-core 2.2.33 released!

- fix: refs [#&#8203;4907](swagger-api/swagger-core#4907) - fix 'openapi.openapi' field processing for 3.1 ([#&#8203;4912](swagger-api/swagger-core#4912))
- fix 1.5 README update ([#&#8203;4902](swagger-api/swagger-core#4902))

### [`v2.2.32`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.32): Swagger-core 2.2.32 released!

- Add $dynamicRef ([#&#8203;4891](swagger-api/swagger-core#4891))
- chore: migrate Sonatype OSSRH to Central Portal ([#&#8203;4890](swagger-api/swagger-core#4890))

### [`v2.2.31`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.31): Swagger-core 2.2.31 released!

- Consistent usage of TestNG ([#&#8203;4885](swagger-api/swagger-core#4885))
- refs [#&#8203;4878](swagger-api/swagger-core#4878) - fix model resolution for global path parameters with openAPI 3.1 ([#&#8203;4884](swagger-api/swagger-core#4884))
- fix Schema/JSONSchema instance creation for oas31 ([#&#8203;4883](swagger-api/swagger-core#4883))
- issue-4850: fix extensions 'x-' prefix decoration for oas 3.1 ([#&#8203;4880](swagger-api/swagger-core#4880))
- Add support for jakarta.validation.constraints.Email ([#&#8203;4876](swagger-api/swagger-core#4876))
- Include Nonnull annotation from Jakarta Annotations for required items ([#&#8203;4875](swagger-api/swagger-core#4875))
- feat: Support other types than string in enum schemas ([#&#8203;4874](swagger-api/swagger-core#4874))
- refs [#&#8203;4065](swagger-api/swagger-core#4065) - fix 'explode' resolution for parameters ([#&#8203;4873](swagger-api/swagger-core#4873))
- Add unittest for v3.1 which has both ref and description ([#&#8203;4815](swagger-api/swagger-core#4815))

### [`v2.2.30`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.30): Swagger-core 2.2.30 released!

- refs [#&#8203;4862](swagger-api/swagger-core#4862) - resolve [@&#8203;notblank](https://github.com/notblank) / [@&#8203;notempty](https://github.com/notempty) as required ([#&#8203;4870](swagger-api/swagger-core#4870))
- fix ArbitrarySchema ([#&#8203;4869](swagger-api/swagger-core#4869))
- update Schema resolution and casting - add `explicit-object-schema` and `use-arbitrary-schema` sys/env props ([#&#8203;4868](swagger-api/swagger-core#4868))
- refs [#&#8203;4859](swagger-api/swagger-core#4859), refs [#&#8203;4860](swagger-api/swagger-core#4860) - fix minLength and ModelResolver compatibility break ([#&#8203;4867](swagger-api/swagger-core#4867))
- fix patternproperties handling in SpecFilter ([#&#8203;4818](swagger-api/swagger-core#4818))

### [`v2.2.29`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.29): Swagger-core 2.2.29 released!

- add better support for validation groups ([#&#8203;4853](swagger-api/swagger-core#4853))
- fix: Replace $ in the FQN of the class ([#&#8203;4803](swagger-api/swagger-core#4803))
- \[BUGFIX] Jackson/[@&#8203;JsonUnwrapped](https://github.com/JsonUnwrapped) - unwrapping fails when innerModel.$ref not null ([#&#8203;4597](swagger-api/swagger-core#4597)

**NOTE**:

[ModelResolver.addRequiredItem](https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java#L3218) breaks compatibility in this version, please use 2.2.30 to get back to a compatible release

### [`v2.2.28`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.28): Swagger-core 2.2.28 released!

- fix DateSchema enum and default serialization ([#&#8203;4830](swagger-api/swagger-core#4830))
- update deps (Jackson to 2.18.2, fix quotes in tests) ([#&#8203;4828](swagger-api/swagger-core#4828))
- fix [#&#8203;4316](swagger-api/swagger-core#4316) - additionalProperties and ArraySchema.implementation processing ([#&#8203;4823](swagger-api/swagger-core#4823))
- allow specifying openAPI version (e.g. 3.0.4, 3.1.1) ([#&#8203;4816](swagger-api/swagger-core#4816))
- Fix: Avoid caching AnnotationIntrospector to support custom module loading ([#&#8203;4728](swagger-api/swagger-core#4728))

### [`v2.2.27`](https://github.com/swagger-api/swagger-core/releases/tag/v2.2.27): Swagger-core 2.2.27 released!

- fix: [swagger-api/swagger-ui#10220](swagger-api/swagger-ui#10220) ([#&#8203;4806](swagger-api/swagger-core#4806))
- Fix for record component annotations on fields with JsonProperty annotations ([#&#8203;4795](swagger-api/swagger-core#4795))
- Fix java.lang.NullPointerException and remove stack trace output from ModelResolver ([#&#8203;4793](swagger-api/swagger-core#4793))
- Move applySchemaResolution check to a method ([#&#8203;4791](swagger-api/swagger-core#4791))
- feat(gradle-plugin): enable lazy evaluation, implicit task dependencies and fixing `setEncoding` ([#&#8203;4761](swagger-api/swagger-core#4761))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Berlin)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMy4xIiwidXBkYXRlZEluVmVyIjoiNDQuMTMuMSIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AiLCJsYWJlbHMiOltdfQ==-->
ewaostrowska pushed a commit to vpelikh/swagger-core that referenced this pull request Oct 13, 2026
@vpelikh @ewaostrowska
feat: optionally compose @JsonSubTypes parents into oneOf
e1e665d
Adds an opt-in (json-subtypes-oneof system property / ModelResolver.jsonSubTypesOneOf)
that composes a @JsonSubTypes or @Schema(subTypes) parent into a self-referencing
oneOf: the parent gets a oneOf to its subtypes while the subtypes keep allOf to the
parent.

The cyclic allOf <-> oneOf shape is off by default because swagger-ui,
openapi-generator and others dislike it, so the default output is unchanged from
3.0.0. When enabled, resolveSubtypes() replaces the parent model with a
ComposedSchema whose oneOf references the resolved subtypes (using the resolved
@JsonView-aware names) and re-reads the parent from the context; an explicit
@Schema(oneOf) wins over the automatic composition to avoid a recursive
allOf <-> oneOf.

resolveSubtypes() is now protected instead of private, providing an extension
point for downstream ModelResolver subclasses that need to customize or disable
subtype resolution (see swagger-api#5030).
ewaostrowska pushed a commit to vpelikh/swagger-core that referenced this pull request Oct 14, 2026
@vpelikh @ewaostrowska
feat: optionally compose @JsonSubTypes parents into oneOf
71d796a
Adds an opt-in (json-subtypes-oneof system property / ModelResolver.jsonSubTypesOneOf)
that composes a @JsonSubTypes or @Schema(subTypes) parent into a self-referencing
oneOf: the parent gets a oneOf to its subtypes while the subtypes keep allOf to the
parent.

The cyclic allOf <-> oneOf shape is off by default because swagger-ui,
openapi-generator and others dislike it, so the default output is unchanged from
3.0.0. When enabled, resolveSubtypes() replaces the parent model with a
ComposedSchema whose oneOf references the resolved subtypes (using the resolved
@JsonView-aware names) and re-reads the parent from the context; an explicit
@Schema(oneOf) wins over the automatic composition to avoid a recursive
allOf <-> oneOf.

resolveSubtypes() is now protected instead of private, providing an extension
point for downstream ModelResolver subclasses that need to customize or disable
subtype resolution (see swagger-api#5030).
ewaostrowska added a commit that referenced this pull request Oct 14, 2026
@vpelikh @ewaostrowska
feat: optionally compose @JsonSubTypes parents into oneOf (#5320)
6e29b02
* feat: optionally compose @JsonSubTypes parents into oneOf

Adds an opt-in (json-subtypes-oneof system property / ModelResolver.jsonSubTypesOneOf)
that composes a @JsonSubTypes or @Schema(subTypes) parent into a self-referencing
oneOf: the parent gets a oneOf to its subtypes while the subtypes keep allOf to the
parent.

The cyclic allOf <-> oneOf shape is off by default because swagger-ui,
openapi-generator and others dislike it, so the default output is unchanged from
3.0.0. When enabled, resolveSubtypes() replaces the parent model with a
ComposedSchema whose oneOf references the resolved subtypes (using the resolved
@JsonView-aware names) and re-reads the parent from the context; an explicit
@Schema(oneOf) wins over the automatic composition to avoid a recursive
allOf <-> oneOf.

resolveSubtypes() is now protected instead of private, providing an extension
point for downstream ModelResolver subclasses that need to customize or disable
subtype resolution (see #5030).

* make oneOf use only resolved subtypes, clean up and additional tests

* change back resolveSubtypes to private, skip `composeParentAsOneOf` when `@Schema(oneOf)` is present instead of returning early

---------

Co-authored-by: Ewa Ostrowska <[email protected]>
@Mattias-Sehlstedt Mattias-Sehlstedt mentioned this pull request Oct 23, 2026
feat: add configuration setting so the polymorphic converter can generate its oneOfs as refs springdoc/springdoc-openapi#3390
Merged
@Mattias-Sehlstedt Mattias-Sehlstedt mentioned this pull request Nov 24, 2026
[Bug]: Sealed class with @JsonSubTypes and @Schema(oneOf) loses its inherited properties (regression from #5322) #5422
Open
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daniel-kmiecik daniel-kmiecik daniel-kmiecik approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Mattias-Sehlstedt @daniel-kmiecik
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.