5
5
import io .swagger .v3 .oas .models .PathItem ;
6
6
import io .swagger .v3 .oas .models .callbacks .Callback ;
7
7
import io .swagger .v3 .oas .models .examples .Example ;
8
+ import io .swagger .v3 .oas .models .headers .Header ;
8
9
import io .swagger .v3 .oas .models .links .Link ;
9
10
import io .swagger .v3 .oas .models .media .ArraySchema ;
10
11
import io .swagger .v3 .oas .models .media .ComposedSchema ;
@@ -50,6 +51,7 @@ public ResolverFully(boolean aggregateCombinators) {
50
51
private Map <String , Example > examples ;
51
52
private Map <String , Parameter > parameters ;
52
53
private Map <String , RequestBody > requestBodies ;
54
+ private Map <String , Header > headers ;
53
55
private Map <String , Link > links ;
54
56
55
57
public void resolveFully (OpenAPI openAPI ) {
@@ -74,6 +76,12 @@ public void resolveFully(OpenAPI openAPI) {
74
76
}
75
77
}
76
78
79
+ if (openAPI .getComponents () != null && openAPI .getComponents ().getHeaders () != null ) {
80
+ headers = openAPI .getComponents ().getHeaders ();
81
+ if (headers == null ) {
82
+ headers = new HashMap <>();
83
+ }
84
+ }
77
85
78
86
if (openAPI .getComponents () != null && openAPI .getComponents ().getParameters () != null ) {
79
87
parameters = openAPI .getComponents ().getParameters ();
@@ -85,7 +93,6 @@ public void resolveFully(OpenAPI openAPI) {
85
93
links = openAPI .getComponents ().getLinks ();
86
94
if (links == null ) {
87
95
links = new HashMap <>();
88
-
89
96
}
90
97
}
91
98
@@ -174,6 +181,21 @@ public void resolvePath(PathItem pathItem){
174
181
}
175
182
}
176
183
}
184
+
185
+ Map <String , Header > headers = response .getHeaders ();
186
+ if (headers != null ) {
187
+ for (Map .Entry <String , Header > header : headers .entrySet ()) {
188
+ Header value = header .getValue ();
189
+ Header resolvedValue = value .get$ref () != null ? resolveHeader (value ) : value ;
190
+ Map <String , Example > examples = resolvedValue .getExamples ();
191
+ if (examples != null ) {
192
+ Map <String ,Example > resolved = resolveExample (examples );
193
+ resolvedValue .setExamples (resolved );
194
+ }
195
+ header .setValue (resolvedValue );
196
+ }
197
+ }
198
+
177
199
Map <String , Link > links = response .getLinks ();
178
200
if (links != null ) {
179
201
for (Map .Entry <String , Link > link : links .entrySet ()) {
@@ -187,6 +209,18 @@ public void resolvePath(PathItem pathItem){
187
209
}
188
210
}
189
211
212
+ public Header resolveHeader (Header header ){
213
+ RefFormat refFormat = computeRefFormat (header .get$ref ());
214
+ String $ref = header .get$ref ();
215
+ if (!isAnExternalRefFormat (refFormat )){
216
+ if (headers != null && !headers .isEmpty ()) {
217
+ String referenceKey = computeDefinitionName ($ref );
218
+ return headers .getOrDefault (referenceKey , header );
219
+ }
220
+ }
221
+ return header ;
222
+ }
223
+
190
224
public Link resolveLink (Link link ){
191
225
RefFormat refFormat = computeRefFormat (link .get$ref ());
192
226
String $ref = link .get$ref ();
0 commit comments