Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: "null" + format #557

Closed
zupo opened this issue Apr 13, 2023 · 2 comments · Fixed by #562
Closed

[Bug]: "null" + format #557

zupo opened this issue Apr 13, 2023 · 2 comments · Fixed by #562
Labels

Comments

@zupo
Copy link
Contributor

zupo commented Apr 13, 2023

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

@zupo zupo added the kind/bug Indicates an issue label Apr 13, 2023
@zupo
Copy link
Contributor Author

zupo commented Apr 13, 2023

What else can I try? Any additional info that I can provide?

@zupo zupo changed the title [Bug]: nullable + format [Bug]: "null" + format Apr 13, 2023
@SethThoburn
Copy link

+1

This is definitely valid OAS 3.1

The best workaround I have found is to go back to OAS 3.0 and add a nullable attribute until this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants