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 摘要。