forked from danielgtaylor/apisprout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change checks for cycles when resolving schemas by keeping a cache of each fully built schema object in a given example. If an item is in the cache but not yet completely built, it indicates a cycle, and the example generator bails out. Sometimes, the recursion isn't actually necessary (e.g., for a property that isn't required), in which case we try to intelligently omit recursive schema references. This should resolve danielgtaylor#45, although without a link to the spec they're using it's difficult to be 100% sure.
- Loading branch information
Showing
7 changed files
with
207 additions
and
19 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
components: | ||
schemas: | ||
Front: | ||
type: object | ||
required: | ||
- back | ||
properties: | ||
back: | ||
$ref: '#/components/schemas/Back' | ||
Back: | ||
type: object | ||
required: | ||
- front | ||
properties: | ||
front: | ||
$ref: '#/components/schemas/Front' |
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,9 @@ | ||
components: | ||
schemas: | ||
Test: | ||
type: object | ||
required: | ||
- test | ||
properties: | ||
test: | ||
$ref: '#/components/schemas/Test' |
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,10 @@ | ||
components: | ||
schemas: | ||
Test: | ||
type: object | ||
properties: | ||
something: | ||
type: string | ||
example: Hello | ||
test: | ||
$ref: '#/components/schemas/Test' |
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 @@ | ||
components: | ||
schemas: | ||
Ref: | ||
type: object | ||
properties: | ||
spud: | ||
type: string | ||
example: "potato" | ||
Test: | ||
type: object | ||
required: | ||
- ref_a | ||
- ref_b | ||
properties: | ||
ref_a: | ||
$ref: '#/components/schemas/Ref' | ||
ref_b: | ||
$ref: '#/components/schemas/Ref' |