@@ -36,6 +36,11 @@ public ExternalRefProcessor(ResolverCache cache, OpenAPI openAPI) {
3636 }
3737
3838 public String processRefToExternalSchema (String $ref , RefFormat refFormat ) {
39+ String renamedRef = cache .getRenamedRef ($ref );
40+ if (renamedRef != null ) {
41+ return renamedRef ;
42+ }
43+
3944 final Schema schema = cache .loadRef ($ref , refFormat , Schema .class );
4045
4146 if (schema == null ) {
@@ -52,7 +57,7 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
5257 schemas = new LinkedHashMap <>();
5358 }
5459
55- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
60+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , schemas . keySet () );
5661
5762 Schema existingModel = schemas .get (possiblyConflictingDefinitionName );
5863
@@ -111,6 +116,11 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
111116 }
112117
113118 public String processRefToExternalResponse (String $ref , RefFormat refFormat ) {
119+ String renamedRef = cache .getRenamedRef ($ref );
120+ if (renamedRef != null ) {
121+ return renamedRef ;
122+ }
123+
114124 final ApiResponse response = cache .loadRef ($ref , refFormat , ApiResponse .class );
115125
116126 if (response == null ) {
@@ -127,7 +137,7 @@ public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
127137 responses = new LinkedHashMap <>();
128138 }
129139
130- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
140+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , responses . keySet () );
131141
132142 ApiResponse existingResponse = responses .get (possiblyConflictingDefinitionName );
133143
@@ -161,6 +171,11 @@ public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
161171 }
162172
163173 public String processRefToExternalRequestBody (String $ref , RefFormat refFormat ) {
174+ String renamedRef = cache .getRenamedRef ($ref );
175+ if (renamedRef != null ) {
176+ return renamedRef ;
177+ }
178+
164179 final RequestBody body = cache .loadRef ($ref , refFormat , RequestBody .class );
165180
166181 if (body == null ) {
@@ -177,7 +192,7 @@ public String processRefToExternalRequestBody(String $ref, RefFormat refFormat)
177192 bodies = new LinkedHashMap <>();
178193 }
179194
180- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
195+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , bodies . keySet () );
181196
182197 RequestBody existingBody = bodies .get (possiblyConflictingDefinitionName );
183198
@@ -211,6 +226,11 @@ public String processRefToExternalRequestBody(String $ref, RefFormat refFormat)
211226 }
212227
213228 public String processRefToExternalHeader (String $ref , RefFormat refFormat ) {
229+ String renamedRef = cache .getRenamedRef ($ref );
230+ if (renamedRef != null ) {
231+ return renamedRef ;
232+ }
233+
214234 final Header header = cache .loadRef ($ref , refFormat , Header .class );
215235
216236 if (header == null ) {
@@ -227,7 +247,7 @@ public String processRefToExternalHeader(String $ref, RefFormat refFormat) {
227247 headers = new LinkedHashMap <>();
228248 }
229249
230- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
250+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , headers . keySet () );
231251
232252 Header existingHeader = headers .get (possiblyConflictingDefinitionName );
233253
@@ -261,6 +281,11 @@ public String processRefToExternalHeader(String $ref, RefFormat refFormat) {
261281 }
262282
263283 public String processRefToExternalSecurityScheme (String $ref , RefFormat refFormat ) {
284+ String renamedRef = cache .getRenamedRef ($ref );
285+ if (renamedRef != null ) {
286+ return renamedRef ;
287+ }
288+
264289 final SecurityScheme securityScheme = cache .loadRef ($ref , refFormat , SecurityScheme .class );
265290
266291 if (securityScheme == null ) {
@@ -277,7 +302,7 @@ public String processRefToExternalSecurityScheme(String $ref, RefFormat refForma
277302 securitySchemeMap = new LinkedHashMap <>();
278303 }
279304
280- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
305+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , securitySchemeMap . keySet () );
281306
282307 SecurityScheme existingSecurityScheme = securitySchemeMap .get (possiblyConflictingDefinitionName );
283308
@@ -311,6 +336,11 @@ public String processRefToExternalSecurityScheme(String $ref, RefFormat refForma
311336 }
312337
313338 public String processRefToExternalLink (String $ref , RefFormat refFormat ) {
339+ String renamedRef = cache .getRenamedRef ($ref );
340+ if (renamedRef != null ) {
341+ return renamedRef ;
342+ }
343+
314344 final Link link = cache .loadRef ($ref , refFormat , Link .class );
315345
316346 if (link == null ) {
@@ -327,7 +357,7 @@ public String processRefToExternalLink(String $ref, RefFormat refFormat) {
327357 links = new LinkedHashMap <>();
328358 }
329359
330- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
360+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , links . keySet () );
331361
332362 Link existingLink = links .get (possiblyConflictingDefinitionName );
333363
@@ -361,6 +391,11 @@ public String processRefToExternalLink(String $ref, RefFormat refFormat) {
361391 }
362392
363393 public String processRefToExternalExample (String $ref , RefFormat refFormat ) {
394+ String renamedRef = cache .getRenamedRef ($ref );
395+ if (renamedRef != null ) {
396+ return renamedRef ;
397+ }
398+
364399 final Example example = cache .loadRef ($ref , refFormat , Example .class );
365400
366401 if (example == null ) {
@@ -377,7 +412,7 @@ public String processRefToExternalExample(String $ref, RefFormat refFormat) {
377412 examples = new LinkedHashMap <>();
378413 }
379414
380- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
415+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , examples . keySet () );
381416
382417 Example existingExample = examples .get (possiblyConflictingDefinitionName );
383418
@@ -411,6 +446,11 @@ public String processRefToExternalExample(String $ref, RefFormat refFormat) {
411446 }
412447
413448 public String processRefToExternalParameter (String $ref , RefFormat refFormat ) {
449+ String renamedRef = cache .getRenamedRef ($ref );
450+ if (renamedRef != null ) {
451+ return renamedRef ;
452+ }
453+
414454 final Parameter parameter = cache .loadRef ($ref , refFormat , Parameter .class );
415455
416456 if (parameter == null ) {
@@ -427,7 +467,7 @@ public String processRefToExternalParameter(String $ref, RefFormat refFormat) {
427467 parameters = new LinkedHashMap <>();
428468 }
429469
430- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
470+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , parameters . keySet () );
431471
432472 Parameter existingParameters = parameters .get (possiblyConflictingDefinitionName );
433473
@@ -461,6 +501,11 @@ public String processRefToExternalParameter(String $ref, RefFormat refFormat) {
461501 }
462502
463503 public String processRefToExternalCallback (String $ref , RefFormat refFormat ) {
504+ String renamedRef = cache .getRenamedRef ($ref );
505+ if (renamedRef != null ) {
506+ return renamedRef ;
507+ }
508+
464509 final Callback callback = cache .loadRef ($ref , refFormat , Callback .class );
465510
466511 if (callback == null ) {
@@ -477,7 +522,7 @@ public String processRefToExternalCallback(String $ref, RefFormat refFormat) {
477522 callbacks = new LinkedHashMap <>();
478523 }
479524
480- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
525+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , callback . keySet () );
481526
482527 Callback existingCallback = callbacks .get (possiblyConflictingDefinitionName );
483528
0 commit comments