@@ -37,6 +37,11 @@ public ExternalRefProcessor(ResolverCache cache, OpenAPI openAPI) {
3737 }
3838
3939 public String processRefToExternalSchema (String $ref , RefFormat refFormat ) {
40+ String renamedRef = cache .getRenamedRef ($ref );
41+ if (renamedRef != null ) {
42+ return renamedRef ;
43+ }
44+
4045 final Schema schema = cache .loadRef ($ref , refFormat , Schema .class );
4146
4247 if (schema == null ) {
@@ -56,7 +61,7 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
5661 schemas = new LinkedHashMap <>();
5762 }
5863
59- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
64+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , schemas . keySet () );
6065
6166 Schema existingModel = schemas .get (possiblyConflictingDefinitionName );
6267
@@ -115,6 +120,11 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
115120 }
116121
117122 public String processRefToExternalResponse (String $ref , RefFormat refFormat ) {
123+ String renamedRef = cache .getRenamedRef ($ref );
124+ if (renamedRef != null ) {
125+ return renamedRef ;
126+ }
127+
118128 final ApiResponse response = cache .loadRef ($ref , refFormat , ApiResponse .class );
119129
120130 if (response == null ) {
@@ -134,7 +144,7 @@ public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
134144 responses = new LinkedHashMap <>();
135145 }
136146
137- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
147+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , responses . keySet () );
138148
139149 ApiResponse existingResponse = responses .get (possiblyConflictingDefinitionName );
140150
@@ -168,6 +178,11 @@ public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
168178 }
169179
170180 public String processRefToExternalRequestBody (String $ref , RefFormat refFormat ) {
181+ String renamedRef = cache .getRenamedRef ($ref );
182+ if (renamedRef != null ) {
183+ return renamedRef ;
184+ }
185+
171186 final RequestBody body = cache .loadRef ($ref , refFormat , RequestBody .class );
172187
173188 if (body == null ) {
@@ -187,7 +202,7 @@ public String processRefToExternalRequestBody(String $ref, RefFormat refFormat)
187202 bodies = new LinkedHashMap <>();
188203 }
189204
190- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
205+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , bodies . keySet () );
191206
192207 RequestBody existingBody = bodies .get (possiblyConflictingDefinitionName );
193208
@@ -221,6 +236,11 @@ public String processRefToExternalRequestBody(String $ref, RefFormat refFormat)
221236 }
222237
223238 public String processRefToExternalHeader (String $ref , RefFormat refFormat ) {
239+ String renamedRef = cache .getRenamedRef ($ref );
240+ if (renamedRef != null ) {
241+ return renamedRef ;
242+ }
243+
224244 final Header header = cache .loadRef ($ref , refFormat , Header .class );
225245
226246 if (header == null ) {
@@ -240,7 +260,7 @@ public String processRefToExternalHeader(String $ref, RefFormat refFormat) {
240260 headers = new LinkedHashMap <>();
241261 }
242262
243- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
263+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , headers . keySet () );
244264
245265 Header existingHeader = headers .get (possiblyConflictingDefinitionName );
246266
@@ -274,6 +294,11 @@ public String processRefToExternalHeader(String $ref, RefFormat refFormat) {
274294 }
275295
276296 public String processRefToExternalSecurityScheme (String $ref , RefFormat refFormat ) {
297+ String renamedRef = cache .getRenamedRef ($ref );
298+ if (renamedRef != null ) {
299+ return renamedRef ;
300+ }
301+
277302 final SecurityScheme securityScheme = cache .loadRef ($ref , refFormat , SecurityScheme .class );
278303
279304 if (securityScheme == null ) {
@@ -293,7 +318,7 @@ public String processRefToExternalSecurityScheme(String $ref, RefFormat refForma
293318 securitySchemeMap = new LinkedHashMap <>();
294319 }
295320
296- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
321+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , securitySchemeMap . keySet () );
297322
298323 SecurityScheme existingSecurityScheme = securitySchemeMap .get (possiblyConflictingDefinitionName );
299324
@@ -327,6 +352,11 @@ public String processRefToExternalSecurityScheme(String $ref, RefFormat refForma
327352 }
328353
329354 public String processRefToExternalLink (String $ref , RefFormat refFormat ) {
355+ String renamedRef = cache .getRenamedRef ($ref );
356+ if (renamedRef != null ) {
357+ return renamedRef ;
358+ }
359+
330360 final Link link = cache .loadRef ($ref , refFormat , Link .class );
331361
332362 if (link == null ) {
@@ -346,7 +376,7 @@ public String processRefToExternalLink(String $ref, RefFormat refFormat) {
346376 links = new LinkedHashMap <>();
347377 }
348378
349- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
379+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , links . keySet () );
350380
351381 Link existingLink = links .get (possiblyConflictingDefinitionName );
352382
@@ -380,6 +410,11 @@ public String processRefToExternalLink(String $ref, RefFormat refFormat) {
380410 }
381411
382412 public String processRefToExternalExample (String $ref , RefFormat refFormat ) {
413+ String renamedRef = cache .getRenamedRef ($ref );
414+ if (renamedRef != null ) {
415+ return renamedRef ;
416+ }
417+
383418 final Example example = cache .loadRef ($ref , refFormat , Example .class );
384419
385420 if (example == null ) {
@@ -399,7 +434,7 @@ public String processRefToExternalExample(String $ref, RefFormat refFormat) {
399434 examples = new LinkedHashMap <>();
400435 }
401436
402- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
437+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , examples . keySet () );
403438
404439 Example existingExample = examples .get (possiblyConflictingDefinitionName );
405440
@@ -433,6 +468,11 @@ public String processRefToExternalExample(String $ref, RefFormat refFormat) {
433468 }
434469
435470 public String processRefToExternalParameter (String $ref , RefFormat refFormat ) {
471+ String renamedRef = cache .getRenamedRef ($ref );
472+ if (renamedRef != null ) {
473+ return renamedRef ;
474+ }
475+
436476 final Parameter parameter = cache .loadRef ($ref , refFormat , Parameter .class );
437477
438478 if (parameter == null ) {
@@ -452,7 +492,7 @@ public String processRefToExternalParameter(String $ref, RefFormat refFormat) {
452492 parameters = new LinkedHashMap <>();
453493 }
454494
455- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
495+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , parameters . keySet () );
456496
457497 Parameter existingParameters = parameters .get (possiblyConflictingDefinitionName );
458498
@@ -486,6 +526,11 @@ public String processRefToExternalParameter(String $ref, RefFormat refFormat) {
486526 }
487527
488528 public String processRefToExternalCallback (String $ref , RefFormat refFormat ) {
529+ String renamedRef = cache .getRenamedRef ($ref );
530+ if (renamedRef != null ) {
531+ return renamedRef ;
532+ }
533+
489534 final Callback callback = cache .loadRef ($ref , refFormat , Callback .class );
490535
491536 if (callback == null ) {
@@ -505,7 +550,7 @@ public String processRefToExternalCallback(String $ref, RefFormat refFormat) {
505550 callbacks = new LinkedHashMap <>();
506551 }
507552
508- final String possiblyConflictingDefinitionName = computeDefinitionName ($ref );
553+ final String possiblyConflictingDefinitionName = computeDefinitionName ($ref , callback . keySet () );
509554
510555 Callback existingCallback = callbacks .get (possiblyConflictingDefinitionName );
511556
0 commit comments