-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle multi-file spec circular reference edge case (#333)
The validator chokes on a specific scenario - when a multi-file spec has schemas that reference each other in a ciruclar manner across files. The bundler we use to put together mutli-file specs doesn't store the reference in a helpful way, so there's not really a way to report the location of the circular reference the way we do for other scenarios. All we can really do is avoid crashing completely and send the user the fully resolved path to the problematic schema that they will need to trace manually. A test is added to capture the behavior. This test case would exhibit the crash without the fix.
- Loading branch information
Showing
6 changed files
with
87 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
schema: | ||
properties: | ||
name: | ||
type: string | ||
primary_team: | ||
type: object | ||
$ref: ./sports-team.yaml#/schema |
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
7 changes: 7 additions & 0 deletions
7
test/cli-validator/mockFiles/multi-file-spec/sports-team.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,7 @@ | ||
schema: | ||
properties: | ||
name: | ||
type: string | ||
location: | ||
type: object | ||
$ref: ./city.yaml#/schema |
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