diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java index 026d8a6a0b..2e5ea01248 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java @@ -140,12 +140,6 @@ public ObjectMapper objectMapper() { @Override public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator next) { - - - boolean applySchemaResolution = - !openapi31 || - (Boolean.parseBoolean(System.getProperty(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY, "false")) || - Boolean.parseBoolean(System.getenv(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY))); boolean isPrimitive = false; Schema model = null; List requiredProps = new ArrayList<>(); @@ -477,7 +471,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context } if (isObjectSchema(addPropertiesSchema) && pName != null) { if (context.getDefinedModels().containsKey(pName)) { - if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution) { + if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution()) { addPropertiesSchema = context.getDefinedModels().get(pName); } else { // create a reference for the items @@ -529,7 +523,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context } if (isObjectSchema(items) && pName != null) { if (context.getDefinedModels().containsKey(pName)) { - if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution) { + if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution()) { items = context.getDefinedModels().get(pName); } else { // create a reference for the items @@ -751,7 +745,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context property = context.resolve(aType); property = clone(property); Schema ctxProperty = null; - if (!applySchemaResolution) { + if (!applySchemaResolution()) { Optional reResolvedProperty = AnnotationsUtils.getSchemaFromAnnotation(ctxSchema, annotatedType.getComponents(), null, openapi31, property, schemaResolution, context); if (reResolvedProperty.isPresent()) { property = reResolvedProperty.get(); @@ -835,7 +829,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context } } } else if (property.get$ref() != null) { - if (applySchemaResolution) { + if (applySchemaResolution()) { if (Schema.SchemaResolution.ALL_OF.equals(resolvedSchemaResolution) && ctxProperty != null) { property = new Schema() .addAllOfItem(ctxProperty) @@ -3126,4 +3120,10 @@ protected Schema buildRefSchemaIfObject(Schema schema, ModelConverterContext con } return result; } + + protected boolean applySchemaResolution() { + return !openapi31 || + (Boolean.parseBoolean(System.getProperty(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY, "false")) || + Boolean.parseBoolean(System.getenv(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY))); + } }