-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize relative ref paths to avoid duplicating schemas #2105
Open
ctreatma
wants to merge
3
commits into
swagger-api:master
Choose a base branch
from
ctreatma:collapse-equivalent-refs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+482
−2
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
modules/swagger-parser-v3/src/test/resources/oas3.fetched/components/schemas/Error.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: Error responses are included with 4xx and 5xx HTTP responses from the | ||
API service. Either "error" or "errors" will be set. | ||
properties: | ||
error: | ||
description: A description of the error that caused the request to fail. | ||
type: string | ||
errors: | ||
description: A list of errors that contributed to the request failing. | ||
items: | ||
description: An error message that contributed to the request failing. | ||
type: string | ||
type: array | ||
type: object |
26 changes: 26 additions & 0 deletions
26
modules/swagger-parser-v3/src/test/resources/oas3.fetched/components/schemas/Event.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
properties: | ||
body: | ||
type: string | ||
created_at: | ||
format: date-time | ||
type: string | ||
href: | ||
type: string | ||
id: | ||
format: uuid | ||
type: string | ||
interpolated: | ||
type: string | ||
relationships: | ||
items: | ||
$ref: './Href.yaml' | ||
type: array | ||
state: | ||
type: string | ||
type: | ||
type: string | ||
modified_by: | ||
type: object | ||
ip: | ||
type: string | ||
type: object |
8 changes: 8 additions & 0 deletions
8
modules/swagger-parser-v3/src/test/resources/oas3.fetched/components/schemas/EventList.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
properties: | ||
events: | ||
items: | ||
$ref: './Event.yaml' | ||
type: array | ||
meta: | ||
$ref: './Meta.yaml' | ||
type: object |
6 changes: 6 additions & 0 deletions
6
modules/swagger-parser-v3/src/test/resources/oas3.fetched/components/schemas/Href.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
properties: | ||
href: | ||
type: string | ||
required: | ||
- href | ||
type: object |
18 changes: 18 additions & 0 deletions
18
modules/swagger-parser-v3/src/test/resources/oas3.fetched/components/schemas/Meta.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
properties: | ||
first: | ||
$ref: './Href.yaml' | ||
last: | ||
$ref: './Href.yaml' | ||
next: | ||
$ref: './Href.yaml' | ||
previous: | ||
$ref: './Href.yaml' | ||
self: | ||
$ref: './Href.yaml' | ||
total: | ||
type: integer | ||
current_page: | ||
type: integer | ||
last_page: | ||
type: integer | ||
type: object |
40 changes: 40 additions & 0 deletions
40
modules/swagger-parser-v3/src/test/resources/oas3.fetched/openapi3.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
openapi: 3.0.0 | ||
info: | ||
version: 1.0.0 | ||
title: Example Duplicate Refs API | ||
contact: | ||
email: support@example.com | ||
name: Example API Team | ||
description: | | ||
Sample API spec to validate handling of different file paths that reference the same file | ||
license: | ||
name: Equinix Metal | ||
url: https://metal.equinix.com/legal/ | ||
termsOfService: https://metal.equinix.com/legal/ | ||
servers: | ||
- url: https://api.example.com/duplicateRefs | ||
components: | ||
schemas: | ||
Error: | ||
$ref: "./components/schemas/Error.yaml" | ||
Event: | ||
$ref: "./components/schemas/Event.yaml" | ||
EventList: | ||
$ref: "./components/schemas/EventList.yaml" | ||
paths: | ||
/connections/{connection_id}/ports/{id}/events: | ||
$ref: ./paths/connections/connection_id/ports/id/events.yaml | ||
/devices/{id}/events: | ||
$ref: ./paths/devices/id/events.yaml | ||
/events: | ||
$ref: ./paths/events.yaml | ||
/events/{id}: | ||
$ref: ./paths/events/id.yaml | ||
/organizations/{id}/events: | ||
$ref: ./paths/organizations/id/events.yaml | ||
/projects/{id}/events: | ||
$ref: ./paths/projects/id/events.yaml | ||
/routes/{id}/events: | ||
$ref: ./paths/routes/id/events.yaml | ||
/virtual-circuits/{id}/events: | ||
$ref: ./paths/virtual-circuits/id/events.yaml |
39 changes: 39 additions & 0 deletions
39
...ger-parser-v3/src/test/resources/oas3.fetched/paths/connections/connection_id/events.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
get: | ||
description: Returns a list of the interconnection events | ||
operationId: findInterconnectionEvents | ||
parameters: | ||
- description: Interconnection UUID | ||
in: path | ||
name: connection_id | ||
required: true | ||
schema: | ||
format: uuid | ||
type: string | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/EventList.yaml" | ||
description: ok | ||
"401": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/Error.yaml" | ||
description: unauthorized | ||
"403": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/Error.yaml" | ||
description: forbidden | ||
"404": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/Error.yaml" | ||
description: not found | ||
summary: Retrieve interconnection events | ||
tags: | ||
- Events |
46 changes: 46 additions & 0 deletions
46
...r-v3/src/test/resources/oas3.fetched/paths/connections/connection_id/ports/id/events.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
get: | ||
description: Returns a list of the interconnection port events | ||
operationId: findInterconnectionPortEvents | ||
parameters: | ||
- description: Interconnection UUID | ||
in: path | ||
name: connection_id | ||
required: true | ||
schema: | ||
format: uuid | ||
type: string | ||
- description: Interconnection Port UUID | ||
in: path | ||
name: id | ||
required: true | ||
schema: | ||
format: uuid | ||
type: string | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../../../components/schemas/Event.yaml" | ||
description: ok | ||
"401": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../../../components/schemas/Error.yaml" | ||
description: unauthorized | ||
"403": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../../../components/schemas/Error.yaml" | ||
description: forbidden | ||
"404": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../../../components/schemas/Error.yaml" | ||
description: not found | ||
summary: Retrieve interconnection port events | ||
tags: | ||
- Events |
39 changes: 39 additions & 0 deletions
39
modules/swagger-parser-v3/src/test/resources/oas3.fetched/paths/devices/id/events.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
get: | ||
description: Returns a list of events pertaining to a specific device | ||
operationId: findDeviceEvents | ||
parameters: | ||
- description: Device UUID | ||
in: path | ||
name: id | ||
required: true | ||
schema: | ||
format: uuid | ||
type: string | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/EventList.yaml" | ||
description: ok | ||
"401": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/Error.yaml" | ||
description: unauthorized | ||
"403": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/Error.yaml" | ||
description: forbidden | ||
"404": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../../components/schemas/Error.yaml" | ||
description: not found | ||
summary: Retrieve device's events | ||
tags: | ||
- Events |
20 changes: 20 additions & 0 deletions
20
modules/swagger-parser-v3/src/test/resources/oas3.fetched/paths/events.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
get: | ||
description: Returns a list of the current user’s events | ||
operationId: findEvents | ||
parameters: | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../components/schemas/EventList.yaml" | ||
description: ok | ||
"401": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../components/schemas/Error.yaml" | ||
description: unauthorized | ||
summary: Retrieve current user's events | ||
tags: | ||
- Events |
39 changes: 39 additions & 0 deletions
39
modules/swagger-parser-v3/src/test/resources/oas3.fetched/paths/events/id.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
get: | ||
description: Returns a single event if the user has access | ||
operationId: findEventById | ||
parameters: | ||
- description: Event UUID | ||
in: path | ||
name: id | ||
required: true | ||
schema: | ||
format: uuid | ||
type: string | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../components/schemas/Event.yaml" | ||
description: ok | ||
"401": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../components/schemas/Error.yaml" | ||
description: unauthorized | ||
"403": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../components/schemas/Error.yaml" | ||
description: forbidden | ||
"404": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../../components/schemas/Error.yaml" | ||
description: not found | ||
summary: Retrieve an event | ||
tags: | ||
- Events |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To minimize impact on existing tests, this normalizes with a leading
./
. It might be preferable to leave that out in normalized paths, but that would require changes to a number of tests that currently explicitly check for paths starting with./
.