Skip to content

fix: use OpenAPI 'minimum' for timestamp DateTime formats - #1067

Open
Sanjays2402 wants to merge 1 commit into
marshmallow-code:devfrom
Sanjays2402:fix/datetime-timestamp-minimum
Open

fix: use OpenAPI 'minimum' for timestamp DateTime formats#1067
Sanjays2402 wants to merge 1 commit into
marshmallow-code:devfrom
Sanjays2402:fix/datetime-timestamp-minimum

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #1064

DateTime(format="timestamp") / format="timestamp_ms" produced "min": "0", which is not an OpenAPI Schema Object keyword, so the generated spec failed openapi-spec-validator with Property 'min' is not allowed. Emits the standard numeric minimum: 0 instead; the two existing timestamp tests are updated to match.

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

DateTime fields with format="timestamp" or "timestamp_ms" were converted
to a schema containing "min": "0". "min" is not an OpenAPI Schema Object
keyword, so the generated spec failed validation with
openapi-spec-validator ("Property 'min' is not allowed").

Emit the standard "minimum" keyword with a numeric 0 instead.

@lafrech lafrech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

"format": "float",
"example": "1676451245.596",
"min": "0",
"minimum": 0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be

"minimum": "0",

@ULisichkin ULisichkin Aug 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the value "0" is invalid and causes the validator to fail, as I already mentioned in the opened Issue.
See example https://spec.openapis.org/oas/v3.0.2#simple-model

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

3 participants