express-openapi-validator
express-openapi-validator copied to clipboard
string `YES` or `NO` is being converted to boolean `true` or `false`
Describe the bug
A clear and concise description of what the bug is.
If you write the string YES or NO in the example, it will be automatically converted to boolean true or false
You can find that in the request.openapi.schema.responses[code]["content"]["application/vnd.api+json"]["examples"]
To Reproduce Steps to reproduce the behavior.
this.app.use(
OpenApiValidator.middleware({
apiSpec: this.openApiPath,
operationHandlers: path.join(__dirname),
fileUploader: { dest: config.FILE_UPLOAD_PATH },
$refParser: {
mode: 'dereference',
}
})
)
Actual behavior
A clear and concise description of what happens.
string YES or NO is being converted to boolean true or false
Expected behavior A clear and concise description of what you expected to happen. They should not be converted since I didn't tell the package to convert it for me...
Examples and context An example or relevant context e.g. an OpenAPI snippet, an Express handler function snippet "express-openapi-validator": "^4.12.14"
paths:
/answers:
get:
operationId: getAnswers
x-eov-operation-handler: controllers/answersController
summary: Get answers
responses:
'200':
description: OK
content:
application/vnd.api+json:
examples:
answer:
$ref: '#/components/examples/answer'
components:
examples:
answer:
value:
data:
type: answers
attributes:
valid: YES
clear: NO
relationships:
Field:
data:
type: fields
id: u785
If I put it as 'YES' or 'NO' then it works
In YAML, YES and NO are boolean values, per spec: https://yaml.org/type/bool.html
So you'd have to quote those values as strings: "YES" and "NO"
This should not be the case in newer YAML versions