From f73fdd2af95dea0708f3e1defbd1a83ab9dbab1e Mon Sep 17 00:00:00 2001 From: Andreas Hufler Date: Thu, 27 Mar 2025 17:13:51 +0100 Subject: [PATCH 1/2] use proper metadata for swagger additional data --- .../toolbox/swagger/SwaggerMeta.java | 20 +++++ .../toolbox/swagger/SwaggerMetaUtil.java | 68 ++++++++++++++++ .../type/CustomTypeModelConverter.java | 80 ++++++++++++------- .../type/CustomTypePropertyCustomizer.java | 36 +++++---- 4 files changed, 161 insertions(+), 43 deletions(-) create mode 100644 src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java create mode 100644 src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java new file mode 100644 index 0000000..3bf84a7 --- /dev/null +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java @@ -0,0 +1,20 @@ +package it.aboutbits.springboot.toolbox.swagger; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SwaggerMeta { + private String originalTypeFqn; + @JsonProperty("isIdentity") + private boolean isIdentity = false; + @JsonProperty("isNestedStructure") + private boolean isNestedStructure = false; + @JsonProperty("isMap") + private boolean isMap = false; + private String mapKeyTypeFqn; +} diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java new file mode 100644 index 0000000..cdac19e --- /dev/null +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java @@ -0,0 +1,68 @@ +package it.aboutbits.springboot.toolbox.swagger; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.NonNull; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.lang.Nullable; + +@Slf4j +public final class SwaggerMetaUtil { + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + private SwaggerMetaUtil() { + } + + @SneakyThrows(JsonProcessingException.class) + public static String setMapKeyTypeFqn(@Nullable String currentMeta, @NonNull String value) { + var meta = getSwaggerMeta(currentMeta); + meta.setMapKeyTypeFqn(value); + + return OBJECT_MAPPER.writeValueAsString(meta); + } + + @SneakyThrows(JsonProcessingException.class) + public static String setIsMap(@Nullable String currentMeta, boolean value) { + var meta = getSwaggerMeta(currentMeta); + meta.setMap(value); + + return OBJECT_MAPPER.writeValueAsString(meta); + } + + @SneakyThrows(JsonProcessingException.class) + public static String setOriginalTypeFqn(@Nullable String currentMeta, @NonNull String value) { + var meta = getSwaggerMeta(currentMeta); + meta.setOriginalTypeFqn(value); + + return OBJECT_MAPPER.writeValueAsString(meta); + } + + @SneakyThrows(JsonProcessingException.class) + public static String setIsIdentity(@Nullable String currentMeta, boolean value) { + var meta = getSwaggerMeta(currentMeta); + meta.setIdentity(value); + + return OBJECT_MAPPER.writeValueAsString(meta); + } + + @SneakyThrows(JsonProcessingException.class) + public static String setIsNestedStructure(@Nullable String currentMeta, boolean value) { + var meta = getSwaggerMeta(currentMeta); + meta.setNestedStructure(value); + + return OBJECT_MAPPER.writeValueAsString(meta); + } + + private static SwaggerMeta getSwaggerMeta(String currentMeta) { + var meta = new SwaggerMeta(); + if (currentMeta != null) { + try { + meta = OBJECT_MAPPER.readValue(currentMeta, SwaggerMeta.class); + } catch (JsonProcessingException e) { + log.warn("error processing meta for swagger: {}", currentMeta); + } + } + return meta; + } +} diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java index f0aa8cf..106243b 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java @@ -5,8 +5,10 @@ import io.swagger.v3.core.converter.ModelConverterContext; import io.swagger.v3.oas.models.media.Schema; import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; +import it.aboutbits.springboot.toolbox.swagger.SwaggerMetaUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; +import it.aboutbits.springboot.toolbox.type.identity.EntityId; import java.math.BigDecimal; import java.math.BigInteger; @@ -23,36 +25,56 @@ public Schema resolve( var type = annotatedType.getType(); - if (type instanceof Class clazz && CustomType.class.isAssignableFrom(clazz)) { - var constructor = RecordReflectionUtil.getCanonicalConstructor(clazz); - var wrappedType = constructor.getParameters()[0].getType(); + if (type instanceof Class clazz) { + Schema result = null; + if (CustomType.class.isAssignableFrom(clazz)) { + var constructor = RecordReflectionUtil.getCanonicalConstructor(clazz); + var wrappedType = constructor.getParameters()[0].getType(); + var isIdentity = false; - if (Short.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Short.TYPE)); - } - if (Integer.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Integer.TYPE)); - } - if (Long.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Long.TYPE)); - } - if (BigInteger.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Long.TYPE)); - } - if (Float.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Float.TYPE)); - } - if (Double.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Double.TYPE)); - } - if (BigDecimal.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Double.TYPE)); - } - if (ScaledBigDecimal.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(Double.TYPE)); - } - if (String.class.isAssignableFrom(wrappedType)) { - return context.resolve(new AnnotatedType(String.class)); + if (EntityId.class.isAssignableFrom(clazz)) { + isIdentity = true; + } + + + if (Short.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Short.TYPE)); + } + if (Integer.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Integer.TYPE)); + } + if (Long.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Long.TYPE)); + } + if (BigInteger.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Long.TYPE)); + } + if (Float.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Float.TYPE)); + } + if (Double.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Double.TYPE)); + } + if (BigDecimal.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Double.TYPE)); + } + if (ScaledBigDecimal.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Double.TYPE)); + } + if (String.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(String.class)); + } + + if (result != null) { + var description = SwaggerMetaUtil.setOriginalTypeFqn( + result.getDescription(), + ((Class) type).getName() + ); + description = SwaggerMetaUtil.setIsIdentity(description, isIdentity); + result.setDescription(description); + + return result; + } } } diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java index d34f3a5..bad3375 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java @@ -4,6 +4,7 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.oas.models.media.Schema; import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; +import it.aboutbits.springboot.toolbox.swagger.SwaggerMetaUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import it.aboutbits.springboot.toolbox.type.identity.EntityId; @@ -26,18 +27,20 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { // We set the enum name as the description because swagger treats each usage as a new enum. // This way we can preserve the information about the original enum type. if (rawClass.isEnum()) { - var displayName = rawClass.getCanonicalName().replace(rawClass.getPackage().getName() + ".", ""); - property.setDescription(displayName); + var displayName = rawClass.getName(); // .replace(rawClass.getPackage().getName() + ".", ""); + property.setDescription(SwaggerMetaUtil.setOriginalTypeFqn(property.getDescription(), displayName)); } } if (type instanceof SimpleType simpleType && CustomType.class.isAssignableFrom(simpleType.getRawClass())) { var rawClass = simpleType.getRawClass(); - var displayName = rawClass.getSimpleName(); + var displayName = rawClass.getName(); // .getSimpleName(); + var isIdentity = false; Class wrappedType; if (EntityId.class.isAssignableFrom(rawClass)) { + isIdentity = true; displayName = resolveEntityIdDisplayName(rawClass); } @@ -48,10 +51,14 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { wrappedType = constructor.getParameters()[0].getType(); } + var description = SwaggerMetaUtil.setOriginalTypeFqn(property.getDescription(), displayName); + description = SwaggerMetaUtil.setIsIdentity(description, isIdentity); + description = SwaggerMetaUtil.setIsIdentity(description, isIdentity); + if (Short.class.isAssignableFrom(wrappedType)) { property.type("integer"); property.format(""); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -59,7 +66,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (Integer.class.isAssignableFrom(wrappedType)) { property.type("integer"); property.format("int32"); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -67,7 +74,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (Long.class.isAssignableFrom(wrappedType)) { property.type("integer"); property.format("int64"); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -75,7 +82,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (BigInteger.class.isAssignableFrom(wrappedType)) { property.type("integer"); property.format("int64"); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -83,7 +90,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (Float.class.isAssignableFrom(wrappedType)) { property.type("number"); property.format("float"); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -91,7 +98,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (Double.class.isAssignableFrom(wrappedType)) { property.type("number"); property.format("double"); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -99,7 +106,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (BigDecimal.class.isAssignableFrom(wrappedType)) { property.type("number"); property.format(""); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -108,7 +115,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (ScaledBigDecimal.class.isAssignableFrom(wrappedType)) { property.type("number"); property.format(""); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -116,7 +123,7 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (String.class.isAssignableFrom(wrappedType)) { property.type("string"); property.format(null); - property.setDescription(displayName); + property.setDescription(description); property.setProperties(null); property.set$ref(null); return property; @@ -129,10 +136,11 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { @NonNull private static String resolveEntityIdDisplayName(Class rawClass) { - var parent = rawClass.getEnclosingClass(); + return rawClass.getName(); +/* var parent = rawClass.getEnclosingClass(); if (parent != null) { return parent.getSimpleName() + "." + rawClass.getSimpleName(); } - return rawClass.getSimpleName(); + return rawClass.getSimpleName();*/ } } From db0c8c7f0f36cf6e59e4307246e3f24840d2e220 Mon Sep 17 00:00:00 2001 From: Andreas Hufler Date: Fri, 28 Mar 2025 12:20:27 +0100 Subject: [PATCH 2/2] cleanup --- .../toolbox/swagger/SwaggerMeta.java | 10 +- .../toolbox/swagger/SwaggerMetaUtil.java | 6 +- .../type/CustomTypeModelConverter.java | 8 +- .../type/CustomTypePropertyCustomizer.java | 197 ++++++++---------- 4 files changed, 98 insertions(+), 123 deletions(-) diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java index 3bf84a7..20308aa 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java @@ -9,12 +9,12 @@ @Setter @JsonInclude(JsonInclude.Include.NON_NULL) public class SwaggerMeta { - private String originalTypeFqn; + private String originalTypeFqn = null; @JsonProperty("isIdentity") - private boolean isIdentity = false; + private Boolean isIdentity = null; @JsonProperty("isNestedStructure") - private boolean isNestedStructure = false; + private Boolean isNestedStructure = null; @JsonProperty("isMap") - private boolean isMap = false; - private String mapKeyTypeFqn; + private Boolean isMap = null; + private String mapKeyTypeFqn = null; } diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java index cdac19e..5332d0b 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMetaUtil.java @@ -25,7 +25,7 @@ public static String setMapKeyTypeFqn(@Nullable String currentMeta, @NonNull Str @SneakyThrows(JsonProcessingException.class) public static String setIsMap(@Nullable String currentMeta, boolean value) { var meta = getSwaggerMeta(currentMeta); - meta.setMap(value); + meta.setIsMap(!value ? null : true); return OBJECT_MAPPER.writeValueAsString(meta); } @@ -41,7 +41,7 @@ public static String setOriginalTypeFqn(@Nullable String currentMeta, @NonNull S @SneakyThrows(JsonProcessingException.class) public static String setIsIdentity(@Nullable String currentMeta, boolean value) { var meta = getSwaggerMeta(currentMeta); - meta.setIdentity(value); + meta.setIsIdentity(!value ? null : true); return OBJECT_MAPPER.writeValueAsString(meta); } @@ -49,7 +49,7 @@ public static String setIsIdentity(@Nullable String currentMeta, boolean value) @SneakyThrows(JsonProcessingException.class) public static String setIsNestedStructure(@Nullable String currentMeta, boolean value) { var meta = getSwaggerMeta(currentMeta); - meta.setNestedStructure(value); + meta.setIsNestedStructure(!value ? null : true); return OBJECT_MAPPER.writeValueAsString(meta); } diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java index 106243b..4f66df2 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java @@ -30,12 +30,6 @@ public Schema resolve( if (CustomType.class.isAssignableFrom(clazz)) { var constructor = RecordReflectionUtil.getCanonicalConstructor(clazz); var wrappedType = constructor.getParameters()[0].getType(); - var isIdentity = false; - - if (EntityId.class.isAssignableFrom(clazz)) { - isIdentity = true; - } - if (Short.class.isAssignableFrom(wrappedType)) { result = context.resolve(new AnnotatedType(Short.TYPE)); @@ -66,6 +60,8 @@ public Schema resolve( } if (result != null) { + var isIdentity = EntityId.class.isAssignableFrom(clazz); + var description = SwaggerMetaUtil.setOriginalTypeFqn( result.getDescription(), ((Class) type).getName() diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java index bad3375..bd58893 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java @@ -8,7 +8,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import it.aboutbits.springboot.toolbox.type.identity.EntityId; -import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springdoc.core.customizers.PropertyCustomizer; @@ -24,123 +23,103 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { if (type instanceof SimpleType simpleType) { var rawClass = simpleType.getRawClass(); - // We set the enum name as the description because swagger treats each usage as a new enum. - // This way we can preserve the information about the original enum type. - if (rawClass.isEnum()) { - var displayName = rawClass.getName(); // .replace(rawClass.getPackage().getName() + ".", ""); - property.setDescription(SwaggerMetaUtil.setOriginalTypeFqn(property.getDescription(), displayName)); + if (rawClass.getName().contains(".") && !rawClass.getName().startsWith("java.")) { + property.setDescription(SwaggerMetaUtil.setOriginalTypeFqn( + property.getDescription(), + rawClass.getName() + )); } - } - if (type instanceof SimpleType simpleType && CustomType.class.isAssignableFrom(simpleType.getRawClass())) { - var rawClass = simpleType.getRawClass(); + if (CustomType.class.isAssignableFrom(simpleType.getRawClass())) { + Class wrappedType; + if (rawClass.equals(EntityId.class)) { + wrappedType = simpleType.getBindings().getBoundType(0).getRawClass(); + } else { + var constructor = RecordReflectionUtil.getCanonicalConstructor(rawClass); + wrappedType = constructor.getParameters()[0].getType(); + } - var displayName = rawClass.getName(); // .getSimpleName(); - var isIdentity = false; + var isIdentity = EntityId.class.isAssignableFrom(rawClass); - Class wrappedType; - if (EntityId.class.isAssignableFrom(rawClass)) { - isIdentity = true; - displayName = resolveEntityIdDisplayName(rawClass); - } - - if (rawClass.equals(EntityId.class)) { - wrappedType = simpleType.getBindings().getBoundType(0).getRawClass(); - } else { - var constructor = RecordReflectionUtil.getCanonicalConstructor(rawClass); - wrappedType = constructor.getParameters()[0].getType(); - } + var description = SwaggerMetaUtil.setIsIdentity(property.getDescription(), isIdentity); - var description = SwaggerMetaUtil.setOriginalTypeFqn(property.getDescription(), displayName); - description = SwaggerMetaUtil.setIsIdentity(description, isIdentity); - description = SwaggerMetaUtil.setIsIdentity(description, isIdentity); + if (Short.class.isAssignableFrom(wrappedType)) { + property.type("integer"); + property.format(""); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (Integer.class.isAssignableFrom(wrappedType)) { + property.type("integer"); + property.format("int32"); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (Long.class.isAssignableFrom(wrappedType)) { + property.type("integer"); + property.format("int64"); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (BigInteger.class.isAssignableFrom(wrappedType)) { + property.type("integer"); + property.format("int64"); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (Float.class.isAssignableFrom(wrappedType)) { + property.type("number"); + property.format("float"); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (Double.class.isAssignableFrom(wrappedType)) { + property.type("number"); + property.format("double"); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (BigDecimal.class.isAssignableFrom(wrappedType)) { + property.type("number"); + property.format(""); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } - if (Short.class.isAssignableFrom(wrappedType)) { - property.type("integer"); - property.format(""); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - if (Integer.class.isAssignableFrom(wrappedType)) { - property.type("integer"); - property.format("int32"); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - if (Long.class.isAssignableFrom(wrappedType)) { - property.type("integer"); - property.format("int64"); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - if (BigInteger.class.isAssignableFrom(wrappedType)) { - property.type("integer"); - property.format("int64"); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - if (Float.class.isAssignableFrom(wrappedType)) { - property.type("number"); - property.format("float"); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; + if (ScaledBigDecimal.class.isAssignableFrom(wrappedType)) { + property.type("number"); + property.format(""); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (String.class.isAssignableFrom(wrappedType)) { + property.type("string"); + property.format(null); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + log.warn("Property {} of type WrappedValue: Can not resolve parameter type!", property.getName()); } - if (Double.class.isAssignableFrom(wrappedType)) { - property.type("number"); - property.format("double"); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - if (BigDecimal.class.isAssignableFrom(wrappedType)) { - property.type("number"); - property.format(""); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - - if (ScaledBigDecimal.class.isAssignableFrom(wrappedType)) { - property.type("number"); - property.format(""); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - if (String.class.isAssignableFrom(wrappedType)) { - property.type("string"); - property.format(null); - property.setDescription(description); - property.setProperties(null); - property.set$ref(null); - return property; - } - log.warn("Property {} of type WrappedValue: Can not resolve parameter type!", property.getName()); } return property; } - - @NonNull - private static String resolveEntityIdDisplayName(Class rawClass) { - return rawClass.getName(); -/* var parent = rawClass.getEnclosingClass(); - if (parent != null) { - return parent.getSimpleName() + "." + rawClass.getSimpleName(); - } - return rawClass.getSimpleName();*/ - } }