Skip to content

Commit b945af5

Browse files
committed
Upgrade swagger-core from version 2.2.48 to 2.2.49 - fixes #3284
1 parent 15aef21 commit b945af5

5 files changed

Lines changed: 31 additions & 24 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<central-publishing-maven-plugin.version>0.7.0
5959
</central-publishing-maven-plugin.version>
6060
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
61-
<swagger-api.version>2.2.48</swagger-api.version>
61+
<swagger-api.version>2.2.49</swagger-api.version>
6262
<swagger-ui.version>5.32.2</swagger-ui.version>
6363
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
6464
<jjwt.version>0.9.1</jjwt.version>

springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,6 @@ protected OpenAPI getOpenApi(String serverBaseUrl, Locale locale) {
402402
}
403403
getPaths(mappingsMap, finalLocale, openAPI);
404404

405-
if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion())
406-
handleComponentSchemaTypes(openAPI);
407-
408405
if (springDocConfigProperties.isTrimKotlinIndent())
409406
this.trimIndent(openAPI);
410407

@@ -475,20 +472,6 @@ private void trimIndent(OpenAPI openAPI) {
475472
trimPaths(openAPI);
476473
}
477474

478-
/**
479-
* Fix component schemas for OAS 3.1 post-processing.
480-
*
481-
* @param openAPI the open api
482-
*/
483-
private static void handleComponentSchemaTypes(OpenAPI openAPI) {
484-
if (openAPI.getComponents() == null || openAPI.getComponents().getSchemas() == null) {
485-
return;
486-
}
487-
for (Schema<?> schema : openAPI.getComponents().getSchemas().values()) {
488-
SpringDocUtils.fixNullOnlyAdditionalProperties(schema);
489-
}
490-
}
491-
492475
/**
493476
* Trim the indent for descriptions in the 'components' of open api.
494477
*

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import io.swagger.v3.core.util.Yaml;
3636
import io.swagger.v3.core.util.Yaml31;
3737
import io.swagger.v3.oas.models.OpenAPI;
38-
import io.swagger.v3.core.util.PrimitiveType;
3938
import io.swagger.v3.oas.models.media.Schema;
4039
import org.springdoc.core.mixins.SortedOpenAPIMixin;
4140
import org.springdoc.core.mixins.SortedOpenAPIMixin31;
@@ -81,14 +80,10 @@ public ObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties)
8180
if (springDocConfigProperties.isExplicitObjectSchema()) {
8281
System.setProperty(Schema.EXPLICIT_OBJECT_SCHEMA_PROPERTY, "true");
8382
}
84-
else {
85-
PrimitiveType.explicitObjectType = false;
86-
}
8783
}
8884
else {
8985
jsonMapper = Json.mapper();
9086
yamlMapper = Yaml.mapper();
91-
PrimitiveType.explicitObjectType = null;
9287
}
9388
}
9489

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SchemaUtils.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import com.fasterxml.jackson.annotation.JsonProperty;
2222
import io.swagger.v3.oas.annotations.Parameter;
2323
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
24+
import io.swagger.v3.oas.models.SpecVersion;
2425
import io.swagger.v3.oas.models.media.Schema;
25-
import jakarta.validation.Constraint;
2626
import jakarta.validation.OverridesAttribute;
2727
import jakarta.validation.constraints.DecimalMax;
2828
import jakarta.validation.constraints.DecimalMin;
@@ -305,6 +305,7 @@ else if (OPENAPI_STRING_TYPE.equals(type)) {
305305
schema.setMaximum(BigDecimal.valueOf(((Range) anno).max()));
306306
}
307307
});
308+
fixOAS31ExclusiveConstraints(schema);
308309
if (schema!=null && annotatedNotNull(annotations)) {
309310
String specVersion = schema.getSpecVersion().name();
310311
if (!"V30".equals(specVersion)) {
@@ -550,4 +551,30 @@ private static JsonProperty getJsonProperty(Field f) {
550551
if (g != null) return g.getAnnotation(JsonProperty.class);
551552
return null;
552553
}
554+
555+
/**
556+
* Swagger-core 2.2.49 introduced so that {@link Positive} and {@link Negative} are introspected.
557+
* It does not correctly use the fact that exclusiveMinimum/exclusiveMaximum are values in OAS31.
558+
* <p>
559+
* Tracked under <a href="https://github.com/swagger-api/swagger-core/issues/5170">swagger-core#5170</a>.
560+
*
561+
* @param schema the schema to fix
562+
*/
563+
public static void fixOAS31ExclusiveConstraints(Schema<?> schema) {
564+
if (schema == null) {
565+
return;
566+
}
567+
if (schema.getSpecVersion().equals(SpecVersion.V31)) {
568+
if (schema.getExclusiveMaximumValue() != null && schema.getMaximum() != null) {
569+
if (schema.getMaximum().compareTo(schema.getExclusiveMaximumValue()) == 0) {
570+
schema.setMaximum(null);
571+
}
572+
}
573+
if (schema.getExclusiveMinimumValue() != null && schema.getMinimum() != null) {
574+
if (schema.getMinimum().compareTo(schema.getExclusiveMinimumValue()) == 0) {
575+
schema.setMinimum(null);
576+
}
577+
}
578+
}
579+
}
553580
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ else if (schema.getItems() != null && schema.getItems().getType() != null
187187
/**
188188
* Fix additionalProperties incorrectly set to {"type": "null"} when @Nullable
189189
* propagates from a Map field to its Object value type (resolved as "any type" = {}).
190+
* <p>
191+
* Tracked under <a href="https://github.com/swagger-api/swagger-core/issues/5115">swagger-core#5115</a>.
190192
*
191193
* @param schema the schema to fix
192194
*/

0 commit comments

Comments
 (0)