@@ -141,6 +141,11 @@ public ObjectMapper objectMapper() {
141141 @ Override
142142 public Schema resolve (AnnotatedType annotatedType , ModelConverterContext context , Iterator <ModelConverter > next ) {
143143
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 )));
144149 boolean isPrimitive = false ;
145150 Schema model = null ;
146151 List <String > requiredProps = new ArrayList <>();
@@ -449,7 +454,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
449454 ).collect (Collectors .toList ()));
450455 }
451456
452-
457+ Schema . SchemaResolution containerResolvedSchemaResolution = AnnotationsUtils . resolveSchemaResolution ( this . schemaResolution , resolvedSchemaAnnotation );
453458 if (keyType != null && valueType != null ) {
454459 if (ReflectionUtils .isSystemTypeNotArray (type ) && !annotatedType .isSchemaProperty () && !annotatedType .isResolveAsRef ()) {
455460 context .resolve (new AnnotatedType ().components (annotatedType .getComponents ()).type (valueType ).jsonViewAnnotation (annotatedType .getJsonViewAnnotation ()));
@@ -471,9 +476,13 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
471476 pName = addPropertiesSchema .getName ();
472477 }
473478 if (isObjectSchema (addPropertiesSchema ) && pName != null ) {
474- // create a reference for the items
475479 if (context .getDefinedModels ().containsKey (pName )) {
476- addPropertiesSchema = new Schema ().$ref (constructRef (pName ));
480+ if (Schema .SchemaResolution .INLINE .equals (containerResolvedSchemaResolution ) && applySchemaResolution ) {
481+ addPropertiesSchema = context .getDefinedModels ().get (pName );
482+ } else {
483+ // create a reference for the items
484+ addPropertiesSchema = new Schema ().$ref (constructRef (pName ));
485+ }
477486 }
478487 } else if (addPropertiesSchema .get$ref () != null ) {
479488 addPropertiesSchema = new Schema ().$ref (StringUtils .isNotEmpty (addPropertiesSchema .get$ref ()) ? addPropertiesSchema .get$ref () : addPropertiesSchema .getName ());
@@ -519,9 +528,13 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
519528 pName = items .getName ();
520529 }
521530 if (isObjectSchema (items ) && pName != null ) {
522- // create a reference for the items
523531 if (context .getDefinedModels ().containsKey (pName )) {
524- items = new Schema ().$ref (constructRef (pName ));
532+ if (Schema .SchemaResolution .INLINE .equals (containerResolvedSchemaResolution ) && applySchemaResolution ) {
533+ items = context .getDefinedModels ().get (pName );
534+ } else {
535+ // create a reference for the items
536+ items = new Schema ().$ref (constructRef (pName ));
537+ }
525538 }
526539 } else if (items .get$ref () != null ) {
527540 items = new Schema ().$ref (StringUtils .isNotEmpty (items .get$ref ()) ? items .get$ref () : items .getName ());
@@ -738,7 +751,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
738751 property = context .resolve (aType );
739752 property = clone (property );
740753 Schema ctxProperty = null ;
741- if (openapi31 ) {
754+ if (! applySchemaResolution ) {
742755 Optional <Schema > reResolvedProperty = AnnotationsUtils .getSchemaFromAnnotation (ctxSchema , annotatedType .getComponents (), null , openapi31 , property , schemaResolution , context );
743756 if (reResolvedProperty .isPresent ()) {
744757 property = reResolvedProperty .get ();
@@ -822,7 +835,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
822835 }
823836 }
824837 } else if (property .get$ref () != null ) {
825- if (! openapi31 ) {
838+ if (applySchemaResolution ) {
826839 if (Schema .SchemaResolution .ALL_OF .equals (resolvedSchemaResolution ) && ctxProperty != null ) {
827840 property = new Schema ()
828841 .addAllOfItem (ctxProperty )
0 commit comments