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

`Input should be a valid string` for integer keys in openapi.yaml

未关闭
#1,333 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

Describe the bug
When generating classes from openapi.yaml with integers as keys (e.g. 200), I get the error:

paths./api/events.get.responses.200.[key]
  Input should be a valid string [type=string_type, input_value=200, input_type=int]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

Is there a chance to ignore those errors and fall back to string for integer keys?

OpenAPI Spec File
Link to an OpenAPI document

Desktop (please complete the following information):

  • OS: macOS 26.0.1
  • Python Version: 13.3
  • openapi-python-client version: 0.26.2

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用关联的 openapi.yaml 和 openapi-python-client 0.26.2 重现该故障,重点关注 paths./api/events.get.responses.200 中的 response key。当 integer keys 在类生成期间被接受并作为 strings 处理,而不是产生 Pydantic validation error 时,工作即完成。

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

评估

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

把新 issue 发到你的邮箱

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