open-api
open-api copied to clipboard
Not validating extra parameters in responses
When validating both a request and response. Extra parameters are ignored even if they are not defined in the spec.
Ej:
{
validateArgs: {
parameters: [],
requestBody: {
description: 'a test body',
content: {
'application/json': {
schema: {
$ref: '#/definitions/Test1',
},
},
},
},
schemas: {
Test1: {
properties: {
foo: {
type: 'string',
},
bar: {
type: 'string',
}
},
},
},
},
request: {
body: {
baz: 'asdf',
},
headers: {
'content-type': 'application/json',
},
}
}
This should throw an error because baz is not part of the spec
I think there is something wrong with the tests, that is why it is not throwing.
If you want it to throw an error when using the module, you can add additionalProperties: false to the schema definition.
By default additionalProperties is set to true, that is why it is allowed.