Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<central-publishing-maven-plugin.version>0.7.0
</central-publishing-maven-plugin.version>
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
<swagger-api.version>2.2.48</swagger-api.version>
<swagger-api.version>2.2.49</swagger-api.version>
<swagger-ui.version>5.32.2</swagger-ui.version>
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
<jjwt.version>0.9.1</jjwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,6 @@ protected OpenAPI getOpenApi(String serverBaseUrl, Locale locale) {
}
getPaths(mappingsMap, finalLocale, openAPI);

if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion())
handleComponentSchemaTypes(openAPI);

if (springDocConfigProperties.isTrimKotlinIndent())
this.trimIndent(openAPI);

Expand Down Expand Up @@ -458,20 +455,6 @@ private void trimIndent(OpenAPI openAPI) {
trimPaths(openAPI);
}

/**
* Fix component schemas for OAS 3.1 post-processing.
*
* @param openAPI the open api
*/
private static void handleComponentSchemaTypes(OpenAPI openAPI) {
if (openAPI.getComponents() == null || openAPI.getComponents().getSchemas() == null) {
return;
}
for (Schema<?> schema : openAPI.getComponents().getSchemas().values()) {
SpringDocUtils.fixNullOnlyAdditionalProperties(schema);
}
}

/**
* Trim the indent for descriptions in the 'components' of open api.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.core.util.Yaml31;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.core.util.PrimitiveType;
import io.swagger.v3.oas.models.media.Schema;
import org.springdoc.core.mixins.SortedOpenAPIMixin;
import org.springdoc.core.mixins.SortedOpenAPIMixin31;
Expand Down Expand Up @@ -81,14 +80,10 @@ public ObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties)
if (springDocConfigProperties.isExplicitObjectSchema()) {
System.setProperty(Schema.EXPLICIT_OBJECT_SCHEMA_PROPERTY, "true");
}
else {
PrimitiveType.explicitObjectType = false;
}
}
else {
jsonMapper = Json.mapper();
yamlMapper = Yaml.mapper();
PrimitiveType.explicitObjectType = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
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.Constraint;
import jakarta.validation.OverridesAttribute;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
Expand Down Expand Up @@ -296,6 +296,7 @@ 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)) {
Expand Down Expand Up @@ -541,4 +542,30 @@ 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.
* <p>
* Tracked under <a href="https://github.com/swagger-api/swagger-core/issues/5170">swagger-core#5170</a>.
*
* @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);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ else if (schema.getItems() != null && schema.getItems().getType() != null
/**
* Fix additionalProperties incorrectly set to {"type": "null"} when @Nullable
* propagates from a Map field to its Object value type (resolved as "any type" = {}).
* <p>
* Tracked under <a href="https://github.com/swagger-api/swagger-core/issues/5115">swagger-core#5115</a>.
*
* @param schema the schema to fix
*/
Expand Down
Loading