1
1
package io .swagger .v3 .parser .util ;
2
2
3
+ import io .swagger .v3 .oas .models .Components ;
3
4
import io .swagger .v3 .oas .models .OpenAPI ;
4
5
import io .swagger .v3 .oas .models .Operation ;
5
6
import io .swagger .v3 .oas .models .PathItem ;
7
+ import io .swagger .v3 .oas .models .Paths ;
6
8
import io .swagger .v3 .oas .models .callbacks .Callback ;
7
9
import io .swagger .v3 .oas .models .examples .Example ;
8
10
import io .swagger .v3 .oas .models .headers .Header ;
@@ -57,50 +59,51 @@ public ResolverFully(boolean aggregateCombinators) {
57
59
private Map <String , Schema > resolvedProperties = new HashMap <>();
58
60
59
61
public void resolveFully (OpenAPI openAPI ) {
60
- if (openAPI .getComponents () != null && openAPI .getComponents ().getRequestBodies () != null ) {
61
- requestBodies = openAPI .getComponents ().getRequestBodies ();
62
+ Components components = openAPI .getComponents ();
63
+ if (components != null && components .getRequestBodies () != null ) {
64
+ requestBodies = components .getRequestBodies ();
62
65
if (requestBodies == null ) {
63
66
requestBodies = new HashMap <>();
64
67
}
65
68
}
66
69
67
- if (openAPI . getComponents () != null && openAPI . getComponents () .getSchemas () != null ) {
68
- schemas = openAPI . getComponents () .getSchemas ();
70
+ if (components != null && components .getSchemas () != null ) {
71
+ schemas = components .getSchemas ();
69
72
if (schemas == null ) {
70
73
schemas = new HashMap <>();
71
74
}
72
75
}
73
76
74
- if (openAPI . getComponents () != null && openAPI . getComponents () .getExamples () != null ) {
75
- examples = openAPI . getComponents () .getExamples ();
77
+ if (components != null && components .getExamples () != null ) {
78
+ examples = components .getExamples ();
76
79
if (examples == null ) {
77
80
examples = new HashMap <>();
78
81
}
79
82
}
80
83
81
- if (openAPI . getComponents () != null && openAPI . getComponents () .getHeaders () != null ) {
82
- headers = openAPI . getComponents () .getHeaders ();
84
+ if (components != null && components .getHeaders () != null ) {
85
+ headers = components .getHeaders ();
83
86
if (headers == null ) {
84
87
headers = new HashMap <>();
85
88
}
86
89
}
87
90
88
- if (openAPI . getComponents () != null && openAPI . getComponents () .getParameters () != null ) {
89
- parameters = openAPI . getComponents () .getParameters ();
91
+ if (components != null && components .getParameters () != null ) {
92
+ parameters = components .getParameters ();
90
93
if (parameters == null ) {
91
94
parameters = new HashMap <>();
92
95
}
93
96
}
94
- if (openAPI . getComponents () != null && openAPI . getComponents () .getLinks () != null ) {
95
- links = openAPI . getComponents () .getLinks ();
97
+ if (components != null && components .getLinks () != null ) {
98
+ links = components .getLinks ();
96
99
if (links == null ) {
97
100
links = new HashMap <>();
98
101
}
99
102
}
100
-
101
- if (openAPI . getPaths () != null ) {
102
- for (String pathname : openAPI . getPaths () .keySet ()) {
103
- PathItem pathItem = openAPI . getPaths () .get (pathname );
103
+ Paths paths = openAPI . getPaths ();
104
+ if (paths != null ) {
105
+ for (String pathname : paths .keySet ()) {
106
+ PathItem pathItem = paths .get (pathname );
104
107
resolvePath (pathItem );
105
108
}
106
109
}
@@ -278,7 +281,6 @@ public Schema resolveSchema(Schema schema) {
278
281
// if we make it without a resolution loop, we can update the reference
279
282
resolvedModels .put (ref , model );
280
283
281
-
282
284
return model ;
283
285
284
286
}else {
@@ -289,15 +291,7 @@ public Schema resolveSchema(Schema schema) {
289
291
if (schema instanceof ArraySchema ) {
290
292
ArraySchema arrayModel = (ArraySchema ) schema ;
291
293
if (arrayModel .getItems ().get$ref () != null ) {
292
- String ref = arrayModel .getItems ().get$ref ();
293
- ref = ref .substring (ref .lastIndexOf ("/" ) + 1 );
294
- if (resolvedModels .get (ref ) == null ) {
295
- arrayModel .setItems (resolveSchema (arrayModel .getItems ()));
296
- }else {
297
- arrayModel .setItems (resolvedModels .get (ref ));
298
- //validar que tan profundo estoy en la recursion para cortar con la asignacion de propiedades.
299
- arrayModel .getItems ().set$ref (arrayModel .getItems ().get$ref ());
300
- }
294
+ arrayModel .setItems (resolveSchema (arrayModel .getItems ()));
301
295
} else {
302
296
arrayModel .setItems (arrayModel .getItems ());
303
297
}
0 commit comments