Add proper support of "x-nullable"
Issue #84
resolved
I have the following swagger schema:
name: body
in: body
required: true
schema:
type: object
required:
- myfield
properties:
myfield:
type: string
format: uuid
x-nullable: true
Which actually means that I expect "myfield" to be uuid or null, but it's required to pass this field. However, within this configuration when I send 'myfield: "null"' I recieve: {"error":{"id":"8b6e8fc9-013e-4e02-91c3-3bb8054b3214","message":"Object has missing required properties (["myfield"])"}}
I believe that this is wrong and should be fixed. Validator should accept this in this case.
Comments (3)
-
-
I have tested and confirmed that this is working in v2.0.0-rc3 (the swagger-parser maps
x-nullable
into the new OpenAPI v3nullable
, which is supported on thev2.0
branch). -
- changed status to resolved
Available in v2.0.0-rc3
- Log in to comment
Ive not come across this use case before, but having a look at https://github.com/OAI/OpenAPI-Specification/issues/229 it does appear that
x-nullable
is a common solution to this problem. I have no problem adding support for it - just need to find the time.Thanks for raising it!