Skip to content

Commit 1d3c7ea

Browse files
author
yugi
committed
move applySchemaResolution check to method
1 parent 3c7b61f commit 1d3c7ea

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ public ObjectMapper objectMapper() {
140140

141141
@Override
142142
public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> next) {
143-
144-
145-
boolean applySchemaResolution =
146-
!openapi31 ||
147-
(Boolean.parseBoolean(System.getProperty(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY, "false")) ||
148-
Boolean.parseBoolean(System.getenv(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY)));
149143
boolean isPrimitive = false;
150144
Schema model = null;
151145
List<String> requiredProps = new ArrayList<>();
@@ -477,7 +471,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
477471
}
478472
if (isObjectSchema(addPropertiesSchema) && pName != null) {
479473
if (context.getDefinedModels().containsKey(pName)) {
480-
if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution) {
474+
if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution()) {
481475
addPropertiesSchema = context.getDefinedModels().get(pName);
482476
} else {
483477
// create a reference for the items
@@ -529,7 +523,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
529523
}
530524
if (isObjectSchema(items) && pName != null) {
531525
if (context.getDefinedModels().containsKey(pName)) {
532-
if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution) {
526+
if (Schema.SchemaResolution.INLINE.equals(containerResolvedSchemaResolution) && applySchemaResolution()) {
533527
items = context.getDefinedModels().get(pName);
534528
} else {
535529
// create a reference for the items
@@ -751,7 +745,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
751745
property = context.resolve(aType);
752746
property = clone(property);
753747
Schema ctxProperty = null;
754-
if (!applySchemaResolution) {
748+
if (!applySchemaResolution()) {
755749
Optional<Schema> reResolvedProperty = AnnotationsUtils.getSchemaFromAnnotation(ctxSchema, annotatedType.getComponents(), null, openapi31, property, schemaResolution, context);
756750
if (reResolvedProperty.isPresent()) {
757751
property = reResolvedProperty.get();
@@ -835,7 +829,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
835829
}
836830
}
837831
} else if (property.get$ref() != null) {
838-
if (applySchemaResolution) {
832+
if (applySchemaResolution()) {
839833
if (Schema.SchemaResolution.ALL_OF.equals(resolvedSchemaResolution) && ctxProperty != null) {
840834
property = new Schema()
841835
.addAllOfItem(ctxProperty)
@@ -3123,4 +3117,10 @@ protected Schema buildRefSchemaIfObject(Schema schema, ModelConverterContext con
31233117
}
31243118
return result;
31253119
}
3120+
3121+
protected boolean applySchemaResolution() {
3122+
return !openapi31 ||
3123+
(Boolean.parseBoolean(System.getProperty(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY, "false")) ||
3124+
Boolean.parseBoolean(System.getenv(Schema.APPLY_SCHEMA_RESOLUTION_PROPERTY)));
3125+
}
31263126
}

0 commit comments

Comments
 (0)