-
Notifications
You must be signed in to change notification settings - Fork 254
chore: implement test cases for types of References in an OpenApi document #2352
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
Open
MaggieKimani1
wants to merge
8
commits into
main
Choose a base branch
from
feat-handle-relative-references
base: main
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.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a01f21d
feat: register schemas with an identifier
MaggieKimani1 e59fbe6
chore: add test cases for references in OpenApi docs
MaggieKimani1 0212484
chore: remove unimplemented test cases
MaggieKimani1 486ee28
chore: adds recursion for resolving nested subschemas
MaggieKimani1 42a5a2d
chore: remove unused variable
MaggieKimani1 cd4d411
Update src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs
MaggieKimani1 a6e2546
chore: implement PR feedback
MaggieKimani1 aa5292f
chore: clean up
MaggieKimani1 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
test/Microsoft.OpenApi.Readers.Tests/V31Tests/ReferenceSamples/OAS-schemas.yaml
This file contains hidden or 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 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: OpenAPI document containing reusable components | ||
version: 1.0.0 | ||
components: | ||
schemas: | ||
person: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
address: | ||
type: object | ||
properties: | ||
street: | ||
type: string | ||
city: | ||
type: string |
13 changes: 13 additions & 0 deletions
13
...Microsoft.OpenApi.Readers.Tests/V31Tests/ReferenceSamples/componentExternalReference.yaml
This file contains hidden or 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 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Example of reference object in a component object | ||
version: 1.0.0 | ||
paths: | ||
/item: | ||
get: | ||
security: | ||
- customapikey: [] | ||
components: | ||
securitySchemes: | ||
customapikey: | ||
$ref: ./customApiKey.yaml#/components/securityschemes/customapikey |
11 changes: 11 additions & 0 deletions
11
test/Microsoft.OpenApi.Readers.Tests/V31Tests/ReferenceSamples/customApiKey.yaml
This file contains hidden or 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,11 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Example of reference object pointing to a parameter | ||
version: 1.0.0 | ||
paths: {} | ||
components: | ||
securitySchemes: | ||
customapikey: | ||
type: apiKey | ||
name: x-api-key | ||
in: header |
11 changes: 11 additions & 0 deletions
11
test/Microsoft.OpenApi.Readers.Tests/V31Tests/ReferenceSamples/examples.yaml
This file contains hidden or 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,11 @@ | ||
# file for examples (examples.yaml) | ||
openapi: 3.1.0 | ||
info: | ||
title: OpenAPI document containing examples for reuse | ||
version: 1.0.0 | ||
components: | ||
examples: | ||
item-list: | ||
value: | ||
- name: thing | ||
description: a thing |
14 changes: 14 additions & 0 deletions
14
....OpenApi.Readers.Tests/V31Tests/ReferenceSamples/externalComponentSubschemaReference.yaml
This file contains hidden or 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,14 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Reference to an external OpenApi document component | ||
version: 1.0.0 | ||
paths: | ||
/person/{id}: | ||
get: | ||
responses: | ||
200: | ||
description: ok | ||
content: | ||
application/json: | ||
schema: | ||
$ref: 'OAS-schemas.yaml#/components/schemas/person/properties/address' |
15 changes: 15 additions & 0 deletions
15
test/Microsoft.OpenApi.Readers.Tests/V31Tests/ReferenceSamples/inlineExternalReference.yaml
This file contains hidden or 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,15 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Example of reference object pointing to an example object in an OpenAPI document | ||
version: 1.0.0 | ||
paths: | ||
/items: | ||
get: | ||
responses: | ||
'200': | ||
description: sample description | ||
content: | ||
application/json: | ||
examples: | ||
item-list: | ||
$ref: './examples.yaml#/components/examples/item-list' |
14 changes: 14 additions & 0 deletions
14
test/Microsoft.OpenApi.Readers.Tests/V31Tests/ReferenceSamples/inlineLocalReference.yaml
This file contains hidden or 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,14 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Example of reference object pointing to a parameter | ||
version: 1.0.0 | ||
paths: | ||
/item: | ||
get: | ||
parameters: | ||
- $ref: '#/components/parameters/size' | ||
components: | ||
parameters: | ||
size: | ||
schema: | ||
type: number |
Oops, something went wrong.
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.
no need for a break after a return
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.
The break is necessary here to provide a clean exit during execution in case the condition in the if statement doesn't pass
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.
sorry, my earlier comment was unclear. Could you not leverage a when in the case? and clean all of this up in the process?
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.
What's wrong with using the current approach?
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.
you can treat that comment as nitpicking. when usually provides better readability IMHO