Skip to content

Fix JsonSchema cloning after early Swagger schema resolution - #3396

Merged
bnasslahsen merged 1 commit into
springdoc:mainfrom
Shubchynskyi:fix/3395-isolated-json31-mapper
Nov 4, 2026
Merged

bnasslahsen merged 1 commit into
springdoc:mainfrom
Shubchynskyi:fix/3395-isolated-json31-mapper

Conversation

@Shubchynskyi

Copy link
Copy Markdown
Contributor

When swagger-core resolves a schema before ObjectMapperProvider is initialized, Jackson can cache a JsonSchema deserializer without SchemaTypeMixin. Cloning a schema with a scalar type then fails and returns the original instance, allowing parameter validation constraints to modify a shared schema.

Enable ACCEPT_SINGLE_VALUE_AS_ARRAY on an ObjectReader for JsonSchema class targets using the shared Json31.mapper(). The setting applies to that read while preserving mapper configuration, schema runtime types, and the existing behavior of separate custom mappers.

Regression tests warm a real deserializer before provider initialization, verify that @Min applies to an independent clone for OpenAPI 3.0 and 3.1, and cover mapper customization compatibility and the unchanged global feature setting.

Validation:

  • Windows / Temurin JDK 21: eight affected modules pass (1060 tests), plus selected javadoc/UI tests and fresh-JVM OpenAPI 3.0/3.1 endpoint smoke tests.
  • Ubuntu / Temurin JDK 21: the complete 25-module Maven reactor and MCP frontend build pass (1852 tests, zero failures/errors/skips). Manual CI run.

Tested source commit: 7d47c97c743dc49ff48474eeb76efca1d2724e63.

Fixes #3395

Read scalar OpenAPI 3.1 types with a per-read Jackson setting when cloning
JsonSchema through the shared Swagger mapper. Preserve mapper configuration
and avoid modifying the original schema when parameter constraints are applied.

Fixes springdoc#3395
@bnasslahsen
bnasslahsen merged commit 246d057 into springdoc:main Nov 4, 2026
bnasslahsen added a commit that referenced this pull request Nov 4, 2026
KotlinNullablePropertyCustomizer (#3399) introspects through the serialization context,
as Jackson 3 removed SerializationConfig.introspect. ObjectMapperProviderCompatibilityTest
(#3396) registers its naming strategy as a mapper customizer, as Jackson 3 mappers are
immutable, and the app27 test uses the Jackson 3 naming annotations.

Signed-off-by: Badr NASS LAHSEN <badr.nasslahsen@gmail.com>
bnasslahsen added a commit that referenced this pull request Nov 4, 2026
Copy the user's OpenAPI bean, the servers, schemas and API responses with the exact deep
copy of swagger-core 3.0.0 instead of a JSON round trip, which lost the state that is not
serialized and needed the workaround of #3396 for OpenAPI 3.1 schemas.
cloneViaJson stays for other objects. RequestSchemaCloningTest now checks that the copy is
independent and keeps the schema state, rather than the Jackson 2 deserializer cache.

Signed-off-by: Badr NASS LAHSEN <badr.nasslahsen@gmail.com>
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.

#3314 fix has no effect if swagger-core resolved a schema before ObjectMapperProvider was created

2 participants