-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resolver): collect errors in ExampleElement visitor hook
This change in specific to OpenAPI 3.1.0 resolution strategy. Errors are now collected, instead of thrown and visitor tranversal is not interrupted. Refs #2798
- Loading branch information
Showing
7 changed files
with
140 additions
and
15 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
17 changes: 17 additions & 0 deletions
17
...pidom/reference/dereference/strategies/openapi-3-1-swagger-client/utils/get-root-cause.js
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,17 @@ | ||
/** | ||
* Retrieves the root cause of ApiDOM error hierarchy. | ||
* ApiDOM error hierarchies are modeled similar to Java. | ||
* Every error can have cause attribute which references | ||
* cause of this error. | ||
*/ | ||
const getRootCause = (error) => { | ||
if (!Object.hasOwn(error, 'cause')) return error; | ||
|
||
let { cause } = error; | ||
while (Object.hasOwn(cause, 'cause')) { | ||
cause = cause.cause; | ||
} | ||
return cause; | ||
}; | ||
|
||
export default getRootCause; |
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
...-swagger-client/example-object/__fixtures__/external-value-unresolvable/dereferenced.json
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 @@ | ||
[ | ||
{ | ||
"openapi": "3.1.0", | ||
"components": { | ||
"examples": { | ||
"example1": { | ||
"description": "example1 description", | ||
"externalValue": "./ex.json" | ||
} | ||
} | ||
} | ||
} | ||
] |
14 changes: 14 additions & 0 deletions
14
...er-client/example-object/__fixtures__/external-value-value-both-defined/dereferenced.json
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,14 @@ | ||
[ | ||
{ | ||
"openapi": "3.1.0", | ||
"components": { | ||
"examples": { | ||
"example1": { | ||
"description": "example1 description", | ||
"value": "sample value", | ||
"externalValue": "./ex.json" | ||
} | ||
} | ||
} | ||
} | ||
] |
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