openapi-generators / openapi-generators/openapi-python-client

Union[Unset, datetime.date] is not allowed in header

未关闭
#881 3 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

🐞bug
主要语言
Python
星标
2k
派生
293
平均合并
34 分钟
30 天内合并 PR
1

描述

Describe the bug
The parameter name='IF-MODIFIED-SINCE' produces an error 'Union[Unset, datetime.date] is not allowed in header', which prevents the endpoint from being generated.

OpenAPI Spec File
https://docs.developers.clio.com/openapi.json

Desktop (please complete the following information):

  • OS: macOS 13.4.1
  • Python Version: 3.12
  • openapi-python-client version: 0.15.2

Additional context
The parameter schema is:
"schema": {
"type": "string", (the format in "YYYY-MM-DD")
"format": "date" (the format defined by full-date in RFC3339)
}
The client generator is attempting to map this schema to a Python Union type, the union of Unset and datetime.date, which is not allowed or fitting in a HTTP header. Maybe string dates need to be transformed to datetime objects and vice versa? Or the date could be converted to a string before setting the header? At least that's my limited understanding of the situation.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

未指定 repository 文件或测试。首先使用链接的 OpenAPI 规范重现生成过程,并跟踪 IF-MODIFIED-SINCE header 参数的处理;检查字符串日期在生成的 header 中是如何表示的。当 endpoint 能够成功生成且不再出现 Union[Unset, datetime.date] 错误,并且日期 header 的表示形式已有测试时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。