python-openapi/openapi-schema-validator

Nullable Strings are not recognized, incorrect check for None if type is string

tuxmania87 opened this issue · 1 comments

I was digging through the code and it seems for string type None validation there is no check for nullable. It is in the code but validate from shortcuts pulls directly the jsonschema type validator which ignores nullables alltoghether.

I am looking for a possibility for it wo work.
Can be easily replicated by adding to the examle on README a nullable string and put it in the content.

This project currently defaults to OpenAPI 3.1.0, but nullable was only supported until the OpenAPI 3.0.* spec.

You can either:

  • fix your spec by swapping nullable for type arrays or
  • fix your code by supplying the cls=OAS30Validator argument to the validate function.

See https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0