Last active
March 15, 2024 10:08
-
-
Save sdesalas/5c9db8f60e1ff5081a6ea7fd693676a8 to your computer and use it in GitHub Desktop.
Bug report use type `nullable` and `anyOf` in express-openapi-validator
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
**Describe the bug** | |
A clear and concise description of what happens. | |
Hiya. Thanks for putting together this awesome library. | |
We're trying to validate a response schema as follows: | |
``` | |
properties: | |
name: | |
type: string | |
value: | |
# type: string # <--- validator needs this here to use `nullable`, however it still ignores it | |
nullable: true | |
anyOf: | |
- type: string | |
- type: boolean | |
- type: integer | |
- type: object | |
- type: array | |
``` | |
**To Reproduce** | |
Steps to reproduce the behavior. | |
Use the openAPI schema above, validator with `validateResponses: true` and return a response as follows: | |
``` | |
{ | |
"name": "some key", | |
"value": null | |
} | |
``` | |
**Actual behavior** | |
``` | |
Error: /response/value must be string, /response/value must be boolean, /response/value must be integer, /response/value must be object, /response/value must be array, /response/value must match a schema in anyOf | |
``` | |
A clear and concise description of what happens. | |
**Expected behavior** | |
A clear and concise description of what you expected to happen. | |
**Examples and context** | |
An example or relevant context e.g. an OpenAPI snippet, an Express handler function snippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment