seems "nullable" is not understood by validator
See original GitHub issuetrying to use for OpenAPI3, validator wont understand
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
So I have to bring “schema” up
oav = require('openapi-response-validator')
v = new oav.default({
summary: "Sum",
description: "Desc",
parameters: [],
responses: {
"200": {
description: "Ok",
schema: {
"type": "object",
"properties": {
"msisdn": {
"type": "string"
},
"countryId": {
"type": "string",
"nullable": true
}
},
"required": [
"msisdn"
]
}
}
}
})
console.log(JSON.stringify(v.validateResponse('200', {"msisdn":"790000000000","countryId":null}), null, ' '))
output
{
"message": "The response was not valid.",
"errors": [
{
"path": "countryId",
"errorCode": "type.openapi.responseValidation",
"message": "countryId should be string"
}
]
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Validation error when field is nullable and consumer sends in ...
When an OpenAPI specification declares an enum, and specifies it as being nullable, the consumer can send the values: {... field: null ....
Read more >Why is Express Validator not allowing null values in optional ...
On a hunch I tried reversing the method calls. This validator worked for me: body("date_field").isDate().optional({ nullable: true }),.
Read more >Understanding JSON Schema
JSON Schema is a powerful tool for validating the structure of JSON data. However, learning to use it by reading its.
Read more >Validation — oracle-tech
Hi all, I wish to add a validation to check on all items(text fields, select list, checkbox) and display that at least one...
Read more >Validating form input - Angular
Async validators, Asynchronous functions that take a control instance and return a Promise or Observable that later emits a set of validation errors...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
just fixed it, will push to my fork soon. Just did what @jsdevel proposed
@jsdevel do you know if anything was ever pulled into the response validator to deal with nullable?
Edit: nevermind, I found it: https://github.com/kogosoftwarellc/open-api/blob/master/packages/openapi-response-validator/index.ts#L215-L218