This repository has been archived by the owner on May 5, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MugeSo/support-external-schemas
Support external schemas
- Loading branch information
Showing
9 changed files
with
318 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
test/data-driven/accept-external-references-through-local-ref.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,34 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: '#/definitions/foo' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: { | ||
foo: { | ||
$ref: 'http://example.com/schema' | ||
} | ||
}, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 'asdf'}, | ||
|
||
expectedValidationError: '' | ||
}; | ||
|
38 changes: 38 additions & 0 deletions
38
test/data-driven/accept-external-references-with-path-through-local-ref.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,38 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: '#/definitions/foo' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: { | ||
foo: { | ||
$ref: 'http://example.com/schema#/definitions/foo' | ||
} | ||
}, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
definitions: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 'asdf'}, | ||
|
||
expectedValidationError: '' | ||
}; | ||
|
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,34 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: 'http://example.com/schema#/definitions/foo' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: null, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
definitions: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 'asdf'}, | ||
|
||
expectedValidationError: '' | ||
}; | ||
|
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,30 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: 'http://example.com/schema' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: null, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 'asdf'}, | ||
|
||
expectedValidationError: '' | ||
}; | ||
|
44 changes: 44 additions & 0 deletions
44
test/data-driven/fail-with-external-references-through-local-ref.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,44 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: '#/definitions/foo' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: { | ||
foo: { | ||
$ref: 'http://example.com/schema' | ||
} | ||
}, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 2345}, | ||
|
||
expectedValidationError: { | ||
status: 500, | ||
message: 'The response was not valid.', | ||
errors: [ | ||
{ | ||
path: 'foo', | ||
errorCode: 'type.openapi.responseValidation', | ||
message: 'foo is not of a type(s) string' | ||
} | ||
] | ||
} | ||
}; | ||
|
48 changes: 48 additions & 0 deletions
48
test/data-driven/fail-with-external-references-with-path-through-local-ref.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,48 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: '#/definitions/foo' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: { | ||
foo: { | ||
$ref: 'http://example.com/schema#/definitions/foo' | ||
} | ||
}, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
definitions: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 2345}, | ||
|
||
expectedValidationError: { | ||
status: 500, | ||
message: 'The response was not valid.', | ||
errors: [ | ||
{ | ||
path: 'foo', | ||
errorCode: 'type.openapi.responseValidation', | ||
message: 'foo is not of a type(s) string' | ||
} | ||
] | ||
} | ||
}; | ||
|
44 changes: 44 additions & 0 deletions
44
test/data-driven/fail-with-external-references-with-path.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,44 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: 'http://example.com/schema#/definitions/foo' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: null, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
definitions: { | ||
foo: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 2345}, | ||
|
||
expectedValidationError: { | ||
status: 500, | ||
message: 'The response was not valid.', | ||
errors: [ | ||
{ | ||
path: 'foo', | ||
errorCode: 'type.openapi.responseValidation', | ||
message: 'foo is not of a type(s) string' | ||
} | ||
] | ||
} | ||
}; | ||
|
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,40 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
$ref: 'http://example.com/schema' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
definitions: null, | ||
|
||
externalSchemas: { | ||
'http://example.com/schema': { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: {foo: 2345}, | ||
|
||
expectedValidationError: { | ||
status: 500, | ||
message: 'The response was not valid.', | ||
errors: [ | ||
{ | ||
path: 'foo', | ||
errorCode: 'type.openapi.responseValidation', | ||
message: 'foo is not of a type(s) string' | ||
} | ||
] | ||
} | ||
}; | ||
|