openapi-generators / openapi-generators/openapi-python-client
date-time is not formatted correctly
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 2k
- 派生
- 293
- 平均合并
- 34 分钟
- 30 天内合并 PR
- 1
描述
Describe the bug
OpenAPI date-time fields are generated using datetime.datetime.isoformat and don't comply with OpenAPI spec / RFC3339
OpenAPI Spec File
/api/example:
get:
tags:
- "example"
operationId: example-get
summary: "summary removed"
description: ""
parameters:
- in: query
name: "start"
description: "desciption removed"
required: true
schema:
type: string
format: date-time
example: '2020-07-21T17:32:28Z'
- in: query
name: "end"
description: "desciption removed"
required: true
schema:
type: string
format: date-time
example: '2020-07-21T17:32:28Z'
Desktop:
- OS: Windows 11
- Python Version: 3.9.13
- openapi-python-client version 0.15.1
Additional context
Client code generated using openapi-python-client version 0.15.1 parses datetime.datetime objects and uses .isoformat() function to convert these to strings. This produces timestamp strings non-compliant with OpenAPI spec (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#data-types). According to spec timestamps should look like this:
2023-08-23T13:26:16Z
Instead they look like this:
2023-08-23T12:26:16.979067
I have a server that rejects these as invalid timestamps. I can patch the client manually after generation, but I thought it would be beneficial to submit a bug report.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位处理 datetime.datetime 值并调用 isoformat() 的生成客户端请求序列化代码。将其输出与 issue 中的 RFC3339/OpenAPI 示例进行比较,然后运行或补充对 date-time 查询参数的覆盖。完成的标准是,生成的时间戳被报告中的服务器接受为符合规范的 date-time 值。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- openapi, python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100