Skip to content
Merged
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 @@ -313,6 +313,9 @@ public PathItem processRefToExternalPathItem(String $ref, RefFormat refFormat) {
if (response.getLinks() != null) {
processRefLinks(response.getLinks(), $ref);
}
if (response.getHeaders() != null) {
processRefHeaders(response.getHeaders(), $ref);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3476,4 +3476,16 @@ public void testIssue1902_component_example_not_parse_ordinal_json() {
Example expectedExample = openAPI.getComponents().getExamples().get("Things");
assertNotNull(expectedExample);
}

@Test
public void testIssue_1746_headers_relative_paths() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue-1746/petstore.yml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();


assertEquals(openAPI.getPaths().get("/pets").getGet().getResponses().get("200").getHeaders().get("x-next").get$ref(), "#/components/headers/LocationInHeaders");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

links:
userRepository:
operationId: getRepository
requestBody: '$response.body#/slug'
headers:
X-Rate-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
headers:
LocationInHeaders:
description: A link to the next page of responses
schema:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: myParam
in: query
description: Param
required: true
schema:
$ref: 'def.yml#/components/schemas/Pet'
- name: myParam2
in: query
description: Param2
required: true
schema:
$ref: './def.yml#/components/schemas/Pet'
- name: myParam3
in: query
description: Param3
required: true
schema:
$ref: '../pets/def.yml#/components/schemas/Pet'
responses:
"200":
description: A paged array of pets
headers:
x-next:
$ref: "./def.yml#/components/headers/LocationInHeaders"
content:
application/json:
schema:
$ref: "./def.yml#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "./def.yml#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: New guest added to event list
content:
application/json:
schema:
properties:
test:
type: string
examples:
testExamples:
$ref: "../petstore.yml#/components/schemas/DateWithExample"
links:
userRepository:
$ref: 'def.yml#/components/links/userRepository'
default:
description: unexpected error
content:
application/json:
schema:
$ref: "./def.yml#/components/schemas/Error"
example:
$ref: "../petstore.yml#/components/schemas/DateWithExample"

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
$ref: "./pets/pets.yml"

components:
schemas:
Date:
type: string
format: date
DateWithExample:
$ref: '#/components/schemas/Date'
description: Date schema extended with a `default` value... Or not?
default: 2000-01-01