Skip to content

[Bug]: "null" + format #557

Closed
Closed
@zupo

Description

@zupo

Actual Behavior

I want to declare a formatted string, that can be null, as such:

today:
  type: [string, "null"]
  format: date

As per OAI/OpenAPI-Specification#3148, I believe the above is a valid v3.1 spec. I could be wrong.

However, when I validate a response {'today': None} I get the following error:

Unable to unmarshal value None for format date: strptime() argument 1 must be str, not None

Expected Behavior

Response {'today': None} should pass validaiton.

Steps to Reproduce

I made a self-contained single-file example with a test that fails: https://github.com/Pylons/pyramid_openapi3/blob/example/null/examples/singlefile/app.py

  1. Run the test with python -m unittest app.py and it fails.
  2. Comment out line 35 (to remove format: date) and the test passes.

OpenAPI Core Version

Latest master

OpenAPI Core Integration

pyramid_openapi3

Affected Area(s)

validation

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions