diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aa47ee35..7a099d201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.8.3] - 2025-01-12 + +### Added +- #2851 - Refine condition, for ignoring types when using PolymorphicModelConverter + ## [2.8.2] - 2025-01-12 ### Added @@ -12,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - #2846 - ClassCastException with spring-data-rest and openapi version 3.1 bug -- #2844 - PageableObject and SortObject are called Pageablenull and Sortnull i +- #2844 - PageableObject and SortObject are called Pageablenull and Sortnull ## [2.8.1] - 2025-01-06 diff --git a/pom.xml b/pom.xml index ea992c2c9..d75d95c4e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.springdoc springdoc-openapi - 2.8.2 + 2.8.3 pom Spring openapi documentation Spring openapi documentation @@ -35,7 +35,7 @@ scm:git:git@github.com:springdoc/springdoc-openapi.git scm:git:git@github.com:springdoc/springdoc-openapi.git - v2.8.2 + v2.8.3 diff --git a/springdoc-openapi-starter-common/pom.xml b/springdoc-openapi-starter-common/pom.xml index a355db7d5..fdf0c891f 100644 --- a/springdoc-openapi-starter-common/pom.xml +++ b/springdoc-openapi-starter-common/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.2 + 2.8.3 springdoc-openapi-starter-common diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java index 929115c4e..7fbfa420b 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java @@ -69,8 +69,7 @@ public Schema resolve( Iterator chain ) { JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); - if (javaType != null) { - if (RepresentationModel.class.isAssignableFrom(javaType.getRawClass())) { + if (javaType != null && RepresentationModel.class.isAssignableFrom(javaType.getRawClass())) { Schema schema = chain.next().resolve(type, context, chain); String schemaName = schema.get$ref().substring(Components.COMPONENTS_SCHEMAS_REF.length()); Schema original = context.getDefinedModels().get(schemaName); @@ -84,7 +83,6 @@ public Schema resolve( arraySchema.set$ref(AnnotationsUtils.COMPONENTS_REF + "Links"); } return schema; - } } return chain.hasNext() ? chain.next().resolve(type, context, chain) : null; } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java index 2a8b57b41..893971491 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java @@ -44,6 +44,7 @@ import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.springdoc.core.providers.ObjectMapperProvider; @@ -68,7 +69,7 @@ public class PolymorphicModelConverter implements ModelConverter { * The constant PARENT_TYPES_TO_IGNORE. */ private static final List TYPES_TO_SKIP = Collections.synchronizedList(new ArrayList<>()); - + static { PARENT_TYPES_TO_IGNORE.add("JsonSchema"); PARENT_TYPES_TO_IGNORE.add("Pageable"); @@ -121,7 +122,10 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato PARENT_TYPES_TO_IGNORE.add(javaType.getRawClass().getSimpleName()); } else if (field.isAnnotationPresent(io.swagger.v3.oas.annotations.media.Schema.class)) { - TYPES_TO_SKIP.add(field.getType().getSimpleName()); + io.swagger.v3.oas.annotations.media.Schema declaredSchema = field.getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class); + if (ArrayUtils.isNotEmpty(declaredSchema.oneOf()) || ArrayUtils.isNotEmpty(declaredSchema.allOf())) { + TYPES_TO_SKIP.add(field.getType().getSimpleName()); + } } } if (chain.hasNext()) { @@ -133,7 +137,7 @@ else if (field.isAnnotationPresent(io.swagger.v3.oas.annotations.media.Schema.cl if (resolvedSchema == null || resolvedSchema.get$ref() == null) { return resolvedSchema; } - if(resolvedSchema.get$ref().contains(Components.COMPONENTS_SCHEMAS_REF)) { + if (resolvedSchema.get$ref().contains(Components.COMPONENTS_SCHEMAS_REF)) { String schemaName = resolvedSchema.get$ref().substring(Components.COMPONENTS_SCHEMAS_REF.length()); Schema existingSchema = context.getDefinedModels().get(schemaName); if (existingSchema != null && (existingSchema.getOneOf() != null || existingSchema.getAllOf() != null)) { @@ -162,7 +166,7 @@ private Schema composePolymorphicSchema(AnnotatedType type, Schema schema, Colle if (isConcreteClass(type)) result.addOneOfItem(schema); JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); Class clazz = javaType.getRawClass(); - if(TYPES_TO_SKIP.stream().noneMatch(typeToSkip -> typeToSkip.equals(clazz.getSimpleName()))) + if (TYPES_TO_SKIP.stream().noneMatch(typeToSkip -> typeToSkip.equals(clazz.getSimpleName()))) composedSchemas.forEach(result::addOneOfItem); return result; } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java index 636ccc229..281fd4eda 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java @@ -249,8 +249,7 @@ private void updateRequestBodySchemaProperties(String key, Schema referencedSche if (entry.getValue().getItems()!=null) referencedSchema.addProperty(propId, new ArraySchema().items(new StringSchema())); else - referencedSchema.addProperty(propId, new StringSchema()); { - } + referencedSchema.addProperty(propId, new StringSchema()); } } } diff --git a/springdoc-openapi-starter-webflux-api/pom.xml b/springdoc-openapi-starter-webflux-api/pom.xml index 7c13c829b..893cb8a49 100644 --- a/springdoc-openapi-starter-webflux-api/pom.xml +++ b/springdoc-openapi-starter-webflux-api/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.2 + 2.8.3 springdoc-openapi-starter-webflux-api diff --git a/springdoc-openapi-starter-webflux-ui/pom.xml b/springdoc-openapi-starter-webflux-ui/pom.xml index 1893687d5..53149fb6d 100644 --- a/springdoc-openapi-starter-webflux-ui/pom.xml +++ b/springdoc-openapi-starter-webflux-ui/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.2 + 2.8.3 springdoc-openapi-starter-webflux-ui diff --git a/springdoc-openapi-starter-webmvc-api/pom.xml b/springdoc-openapi-starter-webmvc-api/pom.xml index ba30771db..15d4e81a2 100644 --- a/springdoc-openapi-starter-webmvc-api/pom.xml +++ b/springdoc-openapi-starter-webmvc-api/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.2 + 2.8.3 springdoc-openapi-starter-webmvc-api diff --git a/springdoc-openapi-starter-webmvc-ui/pom.xml b/springdoc-openapi-starter-webmvc-ui/pom.xml index 6e79cc8ea..d6e5c5012 100644 --- a/springdoc-openapi-starter-webmvc-ui/pom.xml +++ b/springdoc-openapi-starter-webmvc-ui/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi - 2.8.2 + 2.8.3 springdoc-openapi-starter-webmvc-ui diff --git a/springdoc-openapi-tests/pom.xml b/springdoc-openapi-tests/pom.xml index 6da52c0cd..3a0f7742e 100644 --- a/springdoc-openapi-tests/pom.xml +++ b/springdoc-openapi-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi org.springdoc - 2.8.2 + 2.8.3 pom 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml index a9115f87a..a2e88373c 100644 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml index c1864832e..a7d466bbe 100644 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml index a4e997646..928a2ec12 100644 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 springdoc-openapi-data-rest-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml index 01fd244fa..330302a8e 100644 --- a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml index b247d1d08..2006bc868 100644 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml index a0634cf53..06038d67d 100644 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi-tests - 2.8.2 + 2.8.3 springdoc-openapi-groovy-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml index 159fb82cd..34d96b765 100644 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 springdoc-openapi-hateoas-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml index f39da3113..8f9f984cd 100644 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml @@ -2,7 +2,7 @@ org.springdoc springdoc-openapi-tests - 2.8.2 + 2.8.3 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml index 60f82a007..9f40a8eb4 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 springdoc-openapi-kotlin-webflux-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml index a29e4d2bc..1611223f7 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi-tests org.springdoc - 2.8.2 + 2.8.3 4.0.0 springdoc-openapi-kotlin-webmvc-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml index 1b56ed4e5..313d51cd2 100644 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml @@ -3,7 +3,7 @@ org.springdoc springdoc-openapi-tests - 2.8.2 + 2.8.3 springdoc-openapi-security-tests