Skip to content

Commit

Permalink
feat(resolver): collect errors in SchemaElement visitor hook
Browse files Browse the repository at this point in the history
This change is specific to OpenAPI 3.1.0 resolution
strategy. Errors are now collected, instead of
thrown and visitor traversal is not interrupted.

Refs #2806
  • Loading branch information
char0n committed Feb 1, 2023
1 parent fba4bbc commit 70cbd60
Show file tree
Hide file tree
Showing 16 changed files with 781 additions and 318 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import createError from '../../../../../../../specmap/lib/create-error.js';

// eslint-disable-next-line import/prefer-default-export
export const SchemaRefError = createError('SchemaRefError', function cb(message, extra, oriError) {
this.originalError = oriError;
Object.assign(this, extra || {});
});

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"login": {
"type": "string"
},
"password": {
"type": "string"
},
"profile": {
"$ref": "#user-profile"
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"$id": "./schemas/",
"type": "object",
"properties": {
"login": {
"type": "string"
},
"password": {
"type": "string"
},
"profile": {
"$id": "./nested/",
"$ref": "./ex.json"
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"login": {
"type": "string"
},
"password": {
"type": "string"
},
"profile": {
"$ref": "./ex.json"
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"login": {
"type": "string"
},
"password": {
"type": "string"
},
"profile": {
"$ref": "urn:uuid:3"
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"$ref": "#/components/schemas/User"
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {},
"Indirection1": {},
"Indirection2": {},
"Indirection3": {}
}
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"Indirection1": {
"$ref": "#/components/schemas/Indirection2"
},
"Indirection3": {
"Indirection2": {
"$ref": "#/components/schemas/Indirection3"
},
"Indirection4": {
"Indirection3": {
"$ref": "#/components/schemas/User"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"type": "object"
},
"UserProfile": {
"type": "object"
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"type": "object",
"$ref": "#/components/schemas/invalid-pointer"
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"type": "object"
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"openapi": "3.1.0",
"components": {
"schemas": {
"User": {
"properties": {
"profile": {
"$ref": "#/components/schemas/UserProfile"
}
}
}
}
}
}
]
Loading

0 comments on commit 70cbd60

Please sign in to comment.