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 @@ -199,10 +199,16 @@ protected void updateRefs(Parameter param, String pathRef) {
if (param.get$ref() != null){
param.set$ref(computeRef(param.get$ref(), pathRef));
}
if(param.getSchema() != null) {
if (param.getSchema() != null) {
updateRefs(param.getSchema(), pathRef);
}
if(param.getContent() != null) {
if (param.getExamples() != null) {
Map<String, Example> examples = param.getExamples();
for (Example example : examples.values()) {
updateRefs(example, pathRef);
}
}
if (param.getContent() != null) {
Map<String, MediaType> content = param.getContent();
for (String key: content.keySet()) {
MediaType mediaType = content.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,24 @@ public void testIssue2081() {
assertEquals(openAPI.getComponents().getSchemas().get("PetCreate").getProperties().size(), 2);
}

@Test(description = "should resolve nested relative references in examples")
public void testIssue2229() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue-2229/openapi-rest.yml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();

Map<String, Example> parameterExamples = openAPI.getPaths().get("/api/v1/rules").getGet().getParameters().get(0).getExamples();
assertEquals(parameterExamples.get("default").get$ref(), "#/components/examples/StatusQueryParameter");

assertNotNull(openAPI.getComponents(), "should have resolved the components");
assertNotNull(openAPI.getComponents().getExamples(), "should have resolved the examples");
Set<String> exampleNames = new HashSet<>();
exampleNames.add("StatusQueryParameter");
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,2 @@
StatusQueryParameter:
value: 'ACTIVE'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
openapi: 3.0.3
info:
title: Rules
contact:
name: myname
email: zzz@mail.com
description: API desgined for creating, updating, retrieving, and deleting rules and reference entities (reasons, processes).
version: 1.0.2
security:
- itxBearerAuth: []
servers:
- description: The localhost API server.
url: '{protocol}://localhost:{port}'
variables:
protocol:
default: 'http'
port:
default: "8080"
tags:
- name: Rule
description: A rule defines when a product should be restricted from certain business processes based on specific conditions.
paths:
/api/v1/rules:
$ref: './paths/rules/rules.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
get:
tags:
- Rule
summary: Search rules (paginated)
description: My description
operationId: searchRulesPaginated
parameters:
- name: status
in: query
description: Filter by rule status (ACTIVE, INACTIVE, ARCHIVED).
required: false
schema:
type: string
enum: [ ACTIVE, INACTIVE, ARCHIVED ]
description: "Current lifecycle status of the rule."
examples:
default:
$ref: '../../examples/rule/rule-parameters.yml#/StatusQueryParameter'
responses:
'200':
description: OK - Paginated list of rules successfully retrieved.
content:
application/json:
schema:
type: object