From 2b4ba8e74262e1e08b4ff693471d932a7e6cfd14 Mon Sep 17 00:00:00 2001 From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:40:57 +0200 Subject: [PATCH] chore: remove intermediate fix methods for OAS31 exclusive constraints and null-only additional properties --- .../org/springdoc/core/utils/SchemaUtils.java | 28 --------------- .../springdoc/core/utils/SpringDocUtils.java | 35 ------------------- 2 files changed, 63 deletions(-) diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SchemaUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SchemaUtils.java index e34a98a40..1521fb7af 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SchemaUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SchemaUtils.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; -import io.swagger.v3.oas.models.SpecVersion; import io.swagger.v3.oas.models.media.Schema; import jakarta.validation.OverridesAttribute; import jakarta.validation.constraints.DecimalMax; @@ -296,7 +295,6 @@ else if (OPENAPI_STRING_TYPE.equals(type)) { schema.setMaximum(BigDecimal.valueOf(((Range) anno).max())); } }); - fixOAS31ExclusiveConstraints(schema); if (schema!=null && annotatedNotNull(annotations)) { String specVersion = schema.getSpecVersion().name(); if (!"V30".equals(specVersion)) { @@ -563,30 +561,4 @@ private static JsonProperty getJsonProperty(Field f) { if (g != null) return g.getAnnotation(JsonProperty.class); return null; } - - /** - * Swagger-core 2.2.49 introduced so that {@link Positive} and {@link Negative} are introspected. - * It does not correctly use the fact that exclusiveMinimum/exclusiveMaximum are values in OAS31. - *

- * Tracked under swagger-core#5170. - * - * @param schema the schema to fix - */ - public static void fixOAS31ExclusiveConstraints(Schema schema) { - if (schema == null) { - return; - } - if (schema.getSpecVersion().equals(SpecVersion.V31)) { - if (schema.getExclusiveMaximumValue() != null && schema.getMaximum() != null) { - if (schema.getMaximum().compareTo(schema.getExclusiveMaximumValue()) == 0) { - schema.setMaximum(null); - } - } - if (schema.getExclusiveMinimumValue() != null && schema.getMinimum() != null) { - if (schema.getMinimum().compareTo(schema.getExclusiveMinimumValue()) == 0) { - schema.setMinimum(null); - } - } - } - } } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java index e956f68b3..2c6ffc6a8 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java @@ -30,7 +30,6 @@ import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; -import java.util.Set; import java.util.function.Predicate; import com.fasterxml.jackson.core.type.TypeReference; @@ -180,40 +179,6 @@ else if (schema.getItems() != null && schema.getItems().getType() != null if (schema.getProperties() != null) { schema.getProperties().forEach((key, value) -> handleSchemaTypes(value)); } - fixNullOnlyAdditionalProperties(schema); - } - } - - /** - * Fix additionalProperties incorrectly set to {"type": "null"} when @Nullable - * propagates from a Map field to its Object value type (resolved as "any type" = {}). - *

- * Tracked under swagger-core#5115. - * - * @param schema the schema to fix - */ - public static void fixNullOnlyAdditionalProperties(Schema schema) { - if (schema == null) { - return; - } - Object additionalProperties = schema.getAdditionalProperties(); - if (additionalProperties instanceof Schema addPropSchema) { - boolean isNullOnlyType = false; - Set types = addPropSchema.getTypes(); - if (types != null && types.size() == 1 && types.contains("null")) { - isNullOnlyType = true; - } - else if (types == null && "null".equals(addPropSchema.getType())) { - isNullOnlyType = true; - } - if (isNullOnlyType && addPropSchema.get$ref() == null - && addPropSchema.getProperties() == null && addPropSchema.getFormat() == null) { - addPropSchema.setTypes(null); - addPropSchema.setType(null); - } - } - if (schema.getProperties() != null) { - schema.getProperties().values().forEach(prop -> fixNullOnlyAdditionalProperties((Schema) prop)); } }