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

"model_type" error when encountering "items": false

未關閉
#1,229 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
2k
分支
293
平均合併
34 分鐘
30 天內合併 PR
1

描述

Describe the bug
According to the openapi 3.1 specification, tuples should be modeled using the "prefixItems" field with the "items" field being set to false (spec).

However this causes a "model_type" error as the generator expects the "items" field to be a dictionary.

OpenAPI Spec File

{
    "openapi": "3.1.0",
    "info": {
        "title": "foobar",
        "description": "",
        "license": {
            "name": ""
        },
        "version": "0.1.0"
    },
    "paths": {
        "/my/path": {
            "get": {
                "description": "foo",
                "operationId": "bar",
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "type": "array",
                                        "items": false,
                                        "prefixItems": [
                                            {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            {}
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Removing the "items": false causes the file to parse successfully.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.5 LTS
  • Python Version: 3.10.12
  • openapi-python-client version 0.24.1

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先使用 issue 中包含的 OpenAPI 3.1 規格重現 model_type 錯誤,重點關注 items 為 false 且存在 prefixItems 的巢狀陣列 schema。追蹤假設 items 是字典的 schema 解析或驗證路徑。完成的標準是:提供的規格能夠成功解析,且回歸測試涵蓋這種 tuple 形式。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
openapi, python
領域
backend-api-design, tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。