Skip to content

Fix DateTime timestamp field OpenAPI schema to use minimum instead of min - #1090

Open
logoplanet wants to merge 1 commit into
marshmallow-code:devfrom
logoplanet:fix/timestamp-openapi-minimum-1064
Open

logoplanet wants to merge 1 commit into
marshmallow-code:devfrom
logoplanet:fix/timestamp-openapi-minimum-1064

Conversation

@logoplanet

Copy link
Copy Markdown

Description

DateTime fields configured with format="timestamp" or format="timestamp_ms" previously emitted "min": "0" in the generated OpenAPI schema. "min" is not a valid OpenAPI numeric constraint keyword, which causes openapi-spec-validator to fail schema validation with OpenAPIValidationError: Property 'min' is not allowed.

Solution

  • Updated datetime2properties in field_converter.py to emit standard "minimum": 0 as an integer.
  • Added explicit type annotation ret: dict[str, typing.Any] = {} to maintain strict typing under mypy.
  • Updated field conversion assertions in tests/test_ext_marshmallow_field.py.
  • Added OpenAPI specification validation tests across OpenAPI versions 2.0, 3.0.0, and 3.1.0 in tests/test_ext_marshmallow_openapi.py.

Fixes #1064

… min

DateTime fields with format="timestamp" and format="timestamp_ms" previously
emitted an invalid schema property "min": "0", causing validation failures
under openapi-spec-validator. This updates both formats to emit standard
"minimum": 0.

Fixes marshmallow-code#1064

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DateTime(format="timestamp") generates invalid OpenAPI schema using min instead of minimum

1 participant