@@ -141,6 +141,11 @@ public ObjectMapper objectMapper() {
141
141
@ Override
142
142
public Schema resolve (AnnotatedType annotatedType , ModelConverterContext context , Iterator <ModelConverter > next ) {
143
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 )));
144
149
boolean isPrimitive = false ;
145
150
Schema model = null ;
146
151
List <String > requiredProps = new ArrayList <>();
@@ -449,7 +454,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
449
454
).collect (Collectors .toList ()));
450
455
}
451
456
452
-
457
+ Schema . SchemaResolution containerResolvedSchemaResolution = AnnotationsUtils . resolveSchemaResolution ( this . schemaResolution , resolvedSchemaAnnotation );
453
458
if (keyType != null && valueType != null ) {
454
459
if (ReflectionUtils .isSystemTypeNotArray (type ) && !annotatedType .isSchemaProperty () && !annotatedType .isResolveAsRef ()) {
455
460
context .resolve (new AnnotatedType ().components (annotatedType .getComponents ()).type (valueType ).jsonViewAnnotation (annotatedType .getJsonViewAnnotation ()));
@@ -471,9 +476,13 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
471
476
pName = addPropertiesSchema .getName ();
472
477
}
473
478
if (isObjectSchema (addPropertiesSchema ) && pName != null ) {
474
- // create a reference for the items
475
479
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
+ }
477
486
}
478
487
} else if (addPropertiesSchema .get$ref () != null ) {
479
488
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
519
528
pName = items .getName ();
520
529
}
521
530
if (isObjectSchema (items ) && pName != null ) {
522
- // create a reference for the items
523
531
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
+ }
525
538
}
526
539
} else if (items .get$ref () != null ) {
527
540
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
738
751
property = context .resolve (aType );
739
752
property = clone (property );
740
753
Schema ctxProperty = null ;
741
- if (openapi31 ) {
754
+ if (! applySchemaResolution ) {
742
755
Optional <Schema > reResolvedProperty = AnnotationsUtils .getSchemaFromAnnotation (ctxSchema , annotatedType .getComponents (), null , openapi31 , property , schemaResolution , context );
743
756
if (reResolvedProperty .isPresent ()) {
744
757
property = reResolvedProperty .get ();
@@ -822,7 +835,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
822
835
}
823
836
}
824
837
} else if (property .get$ref () != null ) {
825
- if (! openapi31 ) {
838
+ if (applySchemaResolution ) {
826
839
if (Schema .SchemaResolution .ALL_OF .equals (resolvedSchemaResolution ) && ctxProperty != null ) {
827
840
property = new Schema ()
828
841
.addAllOfItem (ctxProperty )
0 commit comments