OpenAPITools / OpenAPITools/openapi-generator

[BUG] Default Python datetimeFormat is not RFC3339 compliant

Open
#20,961 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

OpenAPI documentation suggests that both date and date-time formats should be RFC3339 compliant, but the default for Python is not, as it is missing a colon in the timezone offset field. (%Y-%m-%dT%H:%M:%S%z).

openapi-generator version

7.11.0

OpenAPI declaration file content or url
timestamp:
    type: string
    format: date-time
Generation Details
Steps to reproduce

Add a date-time formatted string field as a parameter, the generated python code will send timestamps in the format (%Y-%m-%dT%H:%M:%S%z) e.g. 2025-03-25T12:32:00+0900

Related issues/PRs
Suggest a fix

In Python 3.12+, changing the %z directive to %:z will add a colon to the timezone offset, making the timestamp RFC3339 compliant.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python generator behavior described in the issue and reproduce it using the supplied OpenAPI schema with a date-time field. Trace where the default datetime format is selected; the work is done when generated timestamps include the colon required by RFC3339 and the reproduction no longer produces an offset such as +0900.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.