protected Discriminator resolveDiscriminator(JavaType type, ModelConverterContext context) { io.swagger.v3.oas.annotations.media.Schema declaredSchemaAnnotation = AnnotationsUtils.getSchemaDeclaredAnnotation(type.getRawClass()); String disc = (declaredSchemaAnnotation == null) ? "" : declaredSchemaAnnotation.discriminatorProperty(); if (disc.isEmpty()) { // longer method would involve AnnotationIntrospector.findTypeResolver(...) but: JsonTypeInfo typeInfo = type.getRawClass().getDeclaredAnnotation(JsonTypeInfo.class); if (typeInfo != null) { disc = typeInfo.property(); } } if (!disc.isEmpty()) { Discriminator discriminator = new Discriminator() .propertyName(disc); if (declaredSchemaAnnotation != null) { DiscriminatorMapping mappings[] = declaredSchemaAnnotation.discriminatorMapping(); if (mappings != null && mappings.length > 0) { for (DiscriminatorMapping mapping : mappings) { if (!mapping.value().isEmpty() && !mapping.schema().equals(Void.class)) { discriminator.mapping(mapping.value(), constructRef(context.resolve(new AnnotatedType().type(mapping.schema())).getName())); } } } } return discriminator; } return null; }
Pair<String, String> refName = extractSimpleName(prop.get$ref()); if (!StringUtils.isBlank(refName.getRight())) { // skip if didn't resolve simple name prop.set$ref(constructRef(toSnakeCase(refName.getLeft()), refName.getRight()));
schema = new Schema().$ref(constructRef(pName));
innerSchema = new Schema().$ref(constructRef(innerSchema.getName())); implSchema = new Schema().$ref(constructRef(implSchema.getName())); addPropertiesSchema = new Schema().$ref(constructRef(pName)); items = new Schema().$ref(constructRef(pName)); property = new Schema().$ref(constructRef(pName)); model = new Schema().$ref(constructRef(model.getName()));
protected Discriminator resolveDiscriminator(JavaType type, ModelConverterContext context) { io.swagger.v3.oas.annotations.media.Schema declaredSchemaAnnotation = AnnotationsUtils.getSchemaDeclaredAnnotation(type.getRawClass()); String disc = (declaredSchemaAnnotation == null) ? "" : declaredSchemaAnnotation.discriminatorProperty(); if (disc.isEmpty()) { // longer method would involve AnnotationIntrospector.findTypeResolver(...) but: JsonTypeInfo typeInfo = type.getRawClass().getDeclaredAnnotation(JsonTypeInfo.class); if (typeInfo != null) { disc = typeInfo.property(); } } if (!disc.isEmpty()) { Discriminator discriminator = new Discriminator() .propertyName(disc); if (declaredSchemaAnnotation != null) { DiscriminatorMapping mappings[] = declaredSchemaAnnotation.discriminatorMapping(); if (mappings != null && mappings.length > 0) { for (DiscriminatorMapping mapping : mappings) { if (!mapping.value().isEmpty() && !mapping.schema().equals(Void.class)) { discriminator.mapping(mapping.value(), constructRef(context.resolve(new AnnotatedType().type(mapping.schema())).getName())); } } } } return discriminator; } return null; }
innerSchema = new Schema().$ref(constructRef(innerSchema.getName())); implSchema = new Schema().$ref(constructRef(implSchema.getName())); addPropertiesSchema = new Schema().$ref(constructRef(pName)); items = new Schema().$ref(constructRef(pName)); property = new Schema().$ref(constructRef(pName)); model = new Schema().$ref(constructRef(model.getName()));