Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ private void processRefExamples(Map<String, Example> examples, String $ref) {
if (example.get$ref() != null) {
RefFormat ref = computeRefFormat(example.get$ref());
if (isAnExternalRefFormat(ref)) {
processRefExample(example, $ref);
processRefExample(example, file);
} else {
processRefToExternalExample(file + example.get$ref(), RefFormat.RELATIVE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,20 @@ public void testIssue2081() {
assertEquals(openAPI.getComponents().getSchemas().get("PetCreate").getProperties().size(), 2);
}

@Test(description = "should resolve nested referenced examples even when parent reference contains path parameter")
public void testIssue2244() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue-2244/openapi.yaml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();

assertNotNull(openAPI.getComponents().getExamples(), "should have resolved the component examples");
Set<String> exampleNames = new HashSet<>();
exampleNames.add("ReproducerExample");
assertEquals(openAPI.getComponents().getExamples().keySet(), exampleNames);
}

@Test(description = "responses should be inline")
public void testFullyResolveResponses() {
ParseOptions options = new ParseOptions();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
openapi: 3.0.3

components:
schemas:
ReproducerObject:
type: object
properties:
id:
type: integer
examples:
ReproducerExample:
value:
id: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3

info:
title: Reproducer
description: Reproducer for the issue
version: 1.0.0

paths:
/reproducers/{id}:
$ref: "operations.yaml#/paths/~1reproducers~1{id}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
openapi: 3.0.3

paths:
/reproducers/{id}:
post:
description: Reproducer
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "components.yaml#/components/schemas/ReproducerObject"
examples:
normal:
$ref: "components.yaml#/components/examples/ReproducerExample"