From 9a6cdf6a686c0d5331aeec62f751aca79ef594b1 Mon Sep 17 00:00:00 2001
From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com>
Date: Wed, 11 Mar 2026 13:39:40 +0100
Subject: [PATCH] Upgrade swagger-core from version 2.2.43 to 2.2.45
---
pom.xml | 2 +-
.../SpringDocRequiredModule.java | 5 +-
...stDelegatingMethodParameterCustomizer.java | 2 +-
.../core/fn/builders/schema/Builder.java | 2 +-
.../builders/securityrequirement/Builder.java | 23 +++
.../core/service/AbstractRequestService.java | 45 ++---
.../core/service/GenericParameterService.java | 2 +-
.../core/service/OpenAPIService.java | 10 +-
.../core/utils/SpringDocAnnotationsUtils.java | 12 +-
.../test/resources/results/3.0.1/app102.json | 6 +-
.../test/resources/results/3.1.0/app102.json | 4 +-
.../api/v30/app173/SpringDocApp173Test.java | 4 +-
.../api/v31/app173/SpringDocApp173Test.java | 4 +-
.../api/v31/app245/HelloController.java | 60 ++++---
.../springdoc/api/v31/app245/HelloWorld.java | 48 +++++
.../api/v31/app245/SpringDocApp245Test.java | 33 +---
.../org/springdoc/api/v31/app245/Views.java | 29 +++
.../api/v31/app249/HelloController.java | 30 ++++
.../api/v31/app249/SpringDocApp249Test.java | 31 ++++
.../test/resources/results/3.0.1/app102.json | 6 +-
.../test/resources/results/3.0.1/app150.json | 3 +-
.../test/resources/results/3.0.1/app173.json | 4 +-
.../test/resources/results/3.1.0/app102.json | 4 +-
.../test/resources/results/3.1.0/app108.json | 4 +-
.../test/resources/results/3.1.0/app124.json | 12 +-
.../test/resources/results/3.1.0/app126.json | 4 +-
.../test/resources/results/3.1.0/app173.json | 4 +-
.../test/resources/results/3.1.0/app180.json | 1 +
.../test/resources/results/3.1.0/app188.json | 4 +-
.../test/resources/results/3.1.0/app197.json | 8 +-
.../test/resources/results/3.1.0/app2.json | 80 ++++++---
.../test/resources/results/3.1.0/app202.json | 8 +-
.../test/resources/results/3.1.0/app245.json | 169 ++++++++++++++++++
.../test/resources/results/3.1.0/app51.json | 8 +-
.../test/resources/results/3.1.0/app60.json | 8 +-
.../test/resources/results/3.1.0/app7.json | 1 -
.../test/resources/results/3.1.0/app75.json | 4 +-
.../test/resources/results/3.0.1/app10.json | 21 ++-
.../test/resources/results/3.0.1/app11.json | 21 ++-
.../test/resources/results/3.0.1/app12.json | 18 +-
.../test/resources/results/3.0.1/app16.json | 21 ++-
.../test/resources/results/3.0.1/app17.json | 21 ++-
.../test/resources/results/3.0.1/app20.json | 21 ++-
.../test/resources/results/3.0.1/app21.json | 21 ++-
.../test/resources/results/3.0.1/app22.json | 21 ++-
.../test/resources/results/3.0.1/app23.json | 18 +-
.../test/resources/results/3.0.1/app25.json | 21 ++-
.../test/resources/results/3.0.1/app26.json | 21 ++-
.../test/resources/results/3.0.1/app29.json | 21 ++-
.../test/resources/results/3.0.1/app34.json | 21 ++-
.../test/resources/results/3.0.1/app36.json | 18 +-
.../test/resources/results/3.0.1/app37.json | 21 ++-
.../test/resources/results/3.0.1/app4.json | 18 +-
.../test/resources/results/3.0.1/app6.json | 18 +-
.../test/resources/results/3.0.1/app8.json | 21 ++-
.../test/resources/results/3.0.1/app9.json | 24 ++-
.../test/resources/results/3.1.0/app10.json | 18 +-
.../test/resources/results/3.1.0/app11.json | 14 +-
.../test/resources/results/3.1.0/app12.json | 12 +-
.../test/resources/results/3.1.0/app16.json | 18 +-
.../test/resources/results/3.1.0/app17.json | 14 +-
.../test/resources/results/3.1.0/app20.json | 14 +-
.../test/resources/results/3.1.0/app21.json | 14 +-
.../test/resources/results/3.1.0/app22.json | 14 +-
.../test/resources/results/3.1.0/app23.json | 16 +-
.../test/resources/results/3.1.0/app25.json | 18 +-
.../test/resources/results/3.1.0/app26.json | 14 +-
.../test/resources/results/3.1.0/app29.json | 14 +-
.../test/resources/results/3.1.0/app34.json | 18 +-
.../test/resources/results/3.1.0/app36.json | 26 +--
.../test/resources/results/3.1.0/app37.json | 14 +-
.../test/resources/results/3.1.0/app4.json | 12 +-
.../test/resources/results/3.1.0/app6.json | 30 +++-
.../test/resources/results/3.1.0/app8.json | 14 +-
.../test/resources/results/3.1.0/app9.json | 16 +-
.../test/resources/results/3.0.1/app1.json | 18 +-
.../test/resources/results/3.0.1/app11.json | 18 +-
.../test/resources/results/3.0.1/app2.json | 21 ++-
.../test/resources/results/3.0.1/app3.json | 18 +-
.../test/resources/results/3.0.1/app4.json | 21 ++-
.../test/resources/results/3.0.1/app5.json | 18 +-
.../test/resources/results/3.0.1/app6.json | 21 ++-
.../test/resources/results/3.0.1/app7.json | 18 +-
.../test/resources/results/3.0.1/app8.json | 21 ++-
.../test/resources/results/3.0.1/app9.json | 20 ++-
.../resources/results/3.0.1/app9wrong.json | 18 +-
.../test/resources/results/3.1.0/app1.json | 12 +-
.../resources/results/3.1.0/app10-direct.json | 8 +-
.../results/3.1.0/app10-via_dto.json | 4 +-
.../test/resources/results/3.1.0/app11.json | 14 +-
.../test/resources/results/3.1.0/app12.json | 2 +-
.../test/resources/results/3.1.0/app13.json | 12 +-
.../test/resources/results/3.1.0/app2.json | 14 +-
.../test/resources/results/3.1.0/app3.json | 12 +-
.../test/resources/results/3.1.0/app4.json | 14 +-
.../test/resources/results/3.1.0/app5.json | 12 +-
.../test/resources/results/3.1.0/app6.json | 14 +-
.../test/resources/results/3.1.0/app7.json | 12 +-
.../test/resources/results/3.1.0/app8.json | 14 +-
.../test/resources/results/3.1.0/app9.json | 12 +-
.../test/resources/results/3.0.1/app102.json | 6 +-
.../test/resources/results/3.0.1/app150.json | 3 +-
.../test/resources/results/3.1.0/app102.json | 4 +-
.../test/resources/results/3.1.0/app108.json | 1 +
.../test/resources/results/3.1.0/app126.json | 4 +-
.../test/resources/results/3.1.0/app2.json | 80 ++++++---
.../test/resources/results/3.1.0/app51.json | 8 +-
.../test/resources/results/3.1.0/app60.json | 8 +-
.../test/resources/results/3.1.0/app75.json | 4 +-
.../test/resources/results/3.0.1/app12.json | 1 +
.../test/resources/results/3.1.0/app12.json | 2 +-
111 files changed, 1286 insertions(+), 584 deletions(-)
create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app245/HelloWorld.java
create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app245/Views.java
create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app249/HelloController.java
create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app249/SpringDocApp249Test.java
create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app245.json
diff --git a/pom.xml b/pom.xml
index c4713270e..62f66544b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,7 @@
0.7.0
1.5.0
- 2.2.43
+ 2.2.45
5.32.0
1.13.1
0.9.1
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocRequiredModule.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocRequiredModule.java
index 60379850d..e4edc5679 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocRequiredModule.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocRequiredModule.java
@@ -30,7 +30,8 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import io.swagger.v3.core.jackson.SwaggerAnnotationIntrospector;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.apache.commons.lang3.StringUtils;
+
+import static org.springdoc.core.utils.SpringDocAnnotationsUtils.hasADefaultValue;
/**
* The type Spring doc required module.
@@ -57,7 +58,7 @@ public Boolean hasRequiredMarker(AnnotatedMember annotatedMember) {
if (schemaAnnotation.required() || requiredMode == Schema.RequiredMode.REQUIRED) {
return true;
}
- else if (requiredMode == Schema.RequiredMode.NOT_REQUIRED || StringUtils.isNotEmpty(schemaAnnotation.defaultValue())) {
+ else if (requiredMode == Schema.RequiredMode.NOT_REQUIRED || hasADefaultValue(schemaAnnotation)) {
return false;
}
}
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/DataRestDelegatingMethodParameterCustomizer.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/DataRestDelegatingMethodParameterCustomizer.java
index 50aa45695..454b70af2 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/DataRestDelegatingMethodParameterCustomizer.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/DataRestDelegatingMethodParameterCustomizer.java
@@ -1122,7 +1122,7 @@ private String getDescription(String parameterName, String originalDescription)
* @return the default value
*/
private String getDefaultValue(String parameterName, PageableDefault pageableDefault, String defaultSchemaVal) {
- String defaultValue = null;
+ String defaultValue = defaultSchemaVal;
switch (parameterName) {
case "size":
if (pageableDefault != null) {
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/schema/Builder.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/schema/Builder.java
index 5ea175794..3115083e3 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/schema/Builder.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/schema/Builder.java
@@ -197,7 +197,7 @@ public class Builder {
/**
* Provides a default value.
*/
- private String defaultValue = "";
+ private String defaultValue = Schema.DEFAULT_SENTINEL;
/**
* Provides a discriminator property value.
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/securityrequirement/Builder.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/securityrequirement/Builder.java
index 80c089231..71c47dc47 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/securityrequirement/Builder.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/fn/builders/securityrequirement/Builder.java
@@ -29,6 +29,7 @@
import java.lang.annotation.Annotation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityRequirementEntry;
/**
* The type Security requirement builder.
@@ -47,6 +48,12 @@ public class Builder {
*/
private String[] scopes = {};
+ /**
+ * If multiple requirements apply at the same time, use this value instead of {@link #name} and {@link #scopes}.
+ * If any one of multiple security schemes is required, use multiple {@link SecurityRequirement} annotations instead.
+ *
Exactly one of this and {@link #name} must be set.
+ */
+ private SecurityRequirementEntry[] securityRequirementEntries = {};
/**
* Instantiates a new Security requirement builder.
@@ -85,6 +92,17 @@ public Builder scopes(String[] scopes) {
return this;
}
+ /**
+ * SecurityRequirementEntries security requirement builder.
+ *
+ * @param securityRequirementEntries the securityRequirementEntries
+ * @return the security requirement builder
+ */
+ public Builder securityRequirementEntries(SecurityRequirementEntry[] securityRequirementEntries) {
+ this.securityRequirementEntries = securityRequirementEntries;
+ return this;
+ }
+
/**
* Build security requirement.
*
@@ -106,6 +124,11 @@ public String name() {
public String[] scopes() {
return scopes;
}
+
+ @Override
+ public SecurityRequirementEntry[] combine() {
+ return securityRequirementEntries;
+ }
};
}
}
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java
index 54609b445..f6f67c98a 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/AbstractRequestService.java
@@ -35,22 +35,10 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.Principal;
+import java.time.LocalDate;
import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.TimeZone;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -639,14 +627,8 @@ public Parameter buildParam(ParameterInfo parameterInfo, Components components,
Schema> schema = parameterBuilder.calculateSchema(components, parameterInfo, null,
jsonView);
if (parameterInfo.getDefaultValue() != null && schema != null) {
- Object defaultValue = parameterInfo.getDefaultValue();
- // Cast default value
PrimitiveType primitiveType = PrimitiveType.fromTypeAndFormat(schema.getType(), schema.getFormat());
- if (primitiveType != null) {
- Schema> primitiveSchema = primitiveType.createProperty();
- primitiveSchema.setDefault(parameterInfo.getDefaultValue());
- defaultValue = primitiveSchema.getDefault();
- }
+ Object defaultValue = castDefaultValue(primitiveType, parameterInfo.getDefaultValue());
schema.setDefault(defaultValue);
}
parameter.setSchema(schema);
@@ -654,6 +636,27 @@ public Parameter buildParam(ParameterInfo parameterInfo, Components components,
return parameter;
}
+ /**
+ * Cast the default value so that it matches the {@link PrimitiveType}
+ *
+ * @param primitiveType the primitive type
+ * @param defaultValue the default value
+ * @return the cast default value
+ */
+ private Object castDefaultValue(PrimitiveType primitiveType, Object defaultValue) {
+ if (primitiveType != null) {
+ Schema> primitiveSchema = primitiveType.createProperty();
+ if (primitiveType.equals(PrimitiveType.DATE) && defaultValue instanceof LocalDate localDate) {
+ defaultValue = localDate.toString();
+ }
+ primitiveSchema.setDefault(defaultValue);
+ if (primitiveSchema.getDefault() != null) {
+ defaultValue = primitiveSchema.getDefault();
+ }
+ }
+ return defaultValue;
+ }
+
/**
* Apply bean validator annotations.
*
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java
index d759699f9..ce35fd323 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java
@@ -357,7 +357,7 @@ private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Com
if (schema == null && parameterDoc.array() != null) {
schema = AnnotationsUtils.getSchema(parameterDoc.schema(), parameterDoc.array(), true, parameterDoc.array().schema().implementation(), components, jsonView, propertyResolverUtils.isOpenapi31()).orElse(null);
// default value not set by swagger-core for array !
- if (schema != null) {
+ if (schema != null && SpringDocAnnotationsUtils.hasADefaultValue(parameterDoc.array().arraySchema())) {
Object defaultValue = SpringDocAnnotationsUtils.resolveDefaultValue(parameterDoc.array().arraySchema().defaultValue(), objectMapperProvider.jsonMapper());
schema.setDefault(defaultValue);
}
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java
index 325090829..8064c81d2 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java
@@ -51,6 +51,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.core.jackson.TypeNameResolver;
import io.swagger.v3.core.util.AnnotationsUtils;
+import io.swagger.v3.core.util.Json;
+import io.swagger.v3.core.util.Json31;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Webhook;
@@ -58,10 +60,7 @@
import io.swagger.v3.oas.annotations.security.SecuritySchemes;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
-import io.swagger.v3.oas.models.Components;
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.Paths;
+import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
@@ -76,6 +75,7 @@
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
import org.springdoc.core.properties.SpringDocConfigProperties;
import org.springdoc.core.providers.JavadocProvider;
+import org.springdoc.core.providers.ObjectMapperProvider;
import org.springdoc.core.utils.PropertyResolverUtils;
import org.springframework.beans.BeansException;
@@ -247,7 +247,7 @@ public OpenAPI build(Locale locale) {
calculatedOpenAPI.setPaths(new Paths());
}
else {
- calculatedOpenAPI = cloneViaJson(openAPI, OpenAPI.class, new ObjectMapper());
+ calculatedOpenAPI = cloneViaJson(openAPI, OpenAPI.class, ObjectMapperProvider.createJson(springDocConfigProperties));
}
if (apiDef.isPresent()) {
diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java
index 770cf372a..ab4e4a131 100644
--- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java
+++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java
@@ -468,6 +468,16 @@ private static boolean isArray(io.swagger.v3.oas.annotations.media.Content annot
return isArray;
}
+ /**
+ * Whether the schema has defined a default value.
+ *
+ * @param schema The schema annotation
+ * @return Whether the schema annotation has defined a default value
+ */
+ public static boolean hasADefaultValue(io.swagger.v3.oas.annotations.media.Schema schema) {
+ return schema != null && !schema.defaultValue().equals(io.swagger.v3.oas.annotations.media.Schema.DEFAULT_SENTINEL);
+ }
+
/**
* Resolve default value object.
*
@@ -519,7 +529,7 @@ public static Optional