Skip to content

Commit db35cb7

Browse files
committed
Fix to correctly resolve local examples when they are in relative files. Issue #853
Signed-off-by: Jehandad Kamal <[email protected]>
1 parent 7d41e02 commit db35cb7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/PathsProcessor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.swagger.v3.oas.models.Operation;
77
import io.swagger.v3.oas.models.PathItem;
88
import io.swagger.v3.oas.models.callbacks.Callback;
9+
import io.swagger.v3.oas.models.examples.Example;
910
import io.swagger.v3.oas.models.media.ArraySchema;
1011
import io.swagger.v3.oas.models.media.ComposedSchema;
1112
import io.swagger.v3.oas.models.media.MediaType;
@@ -168,6 +169,20 @@ protected void updateLocalRefs(ApiResponse response, String pathRef) {
168169
if (mediaType.getSchema() != null) {
169170
updateLocalRefs(mediaType.getSchema(), pathRef);
170171
}
172+
Map<String, Example> examples = content.get(key).getExamples();
173+
if (examples != null) {
174+
for( Example example:examples.values()){
175+
updateLocalRefs(example, pathRef);
176+
}
177+
}
178+
}
179+
}
180+
}
181+
182+
protected void updateLocalRefs(Example example, String pathRef) {
183+
if(example.get$ref() != null) {
184+
if(isLocalRef(example.get$ref())) {
185+
example.set$ref(computeLocalRef(example.get$ref(), pathRef));
171186
}
172187
}
173188
}

0 commit comments

Comments
 (0)