Skip to content

Commit

Permalink
move applySchemaResolution check to method
Browse files Browse the repository at this point in the history
  • Loading branch information
yugi committed Nov 19, 2024
1 parent 3c7b61f commit 1d3c7ea
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ public ObjectMapper objectMapper() {

@Override
public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> 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<String> requiredProps = new ArrayList<>();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Schema> reResolvedProperty = AnnotationsUtils.getSchemaFromAnnotation(ctxSchema, annotatedType.getComponents(), null, openapi31, property, schemaResolution, context);
if (reResolvedProperty.isPresent()) {
property = reResolvedProperty.get();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -3123,4 +3117,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)));
}
}

0 comments on commit 1d3c7ea

Please sign in to comment.