openapi-generators / openapi-generators/openapi-python-client
Generator fails on type: array without items even though it's valid in JSON Schema 2020-12 / OpenAPI 3.1
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 2k
- 分支
- 293
- 平均合併
- 34 分鐘
- 30 天內合併 PR
- 1
描述
Describe the bug
When a schema has "type": "array" without an "items" field, the generator fails to produce a property for it. In JSON Schema 2020-12 (used by OpenAPI 3.1), omitting items is valid and means "array of any type". The generator should treat it as equivalent to "items": {} (i.e., generate a List[Any] property) rather than silently failing.
OpenAPI Spec File
We encountered this in two forms:
Case 1 — bare array with no constraints:
{
"type": "array",
"description": "Array of objects representing a row of metrics data - can be any format."
}
Case 2 — array with maxItems but no items:
{
"anyOf": [
{ "type": "array", "maxItems": 0 },
{ "type": "object", "properties": { "tag": { "type": "array", "items": { "type": "string" } } } }
]
}
In both cases the generator silently skips the schema (or the anyOf branch) without an error. Adding ["items": {}] to each fixes the generation.
Expected behaviour: {"type": "array"} (with or without other constraints like maxItems) should generate a List[Any] property, consistent with how JSON Schema 2020-12 defines it.
Desktop (please complete the following information):
- OS: Ubuntu 24.04.3 LTS
- Python Version: 3.12.3
- openapi-python-client 0.28.1
- OpenAPI version: 3.1.1 (JSON Schema 2020-12)
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先使用 issue 中的兩個 schema 作為輸入,追蹤 generator 在缺少 items 時如何處理 array schema 和 anyOf 分支。為裸 array 以及帶有 maxItems 的 array 新增回歸覆蓋,然後執行 generator 並確認兩者都會產生 List[Any] 屬性,而不是被跳過。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- openapi, python
- 領域
- api, tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 64/100