openapi-generators / openapi-generators/openapi-python-client
Missing import when there is a const in the object
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 2k
- 分支
- 293
- 平均合併
- 34 分鐘
- 30 天內合併 PR
- 1
描述
Describe the bug
Version: 0.21.1
When I try to generate a client it fails with the following error:
Error(s) encountered while generating, client was not created
ruff failed
rivery_scim_client/models/book.py:40:21: F821 Undefined name cast
Found 209 errors (208 fixed, 1 remaining).
As you can see there is an import missing. I publish a PR that should solve it.
https://github.com/openapi-generators/openapi-python-client/pull/1072
OpenAPI Spec File
I created a dummy openapi specification.
{
"openapi": "3.1.0",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/books": {
"post": {
"summary": "Create User",
"operationId": "create_user_books_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Book"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Book": {
"properties": {
"item_type": {
"const": "book",
"title": "Item Type",
"default": "book"
}
},
"type": "object",
"title": "Book"
},
"ErrorResponse": {
"properties": {
"schemas": {
"items": {
"type": "string"
},
"type": "array",
"title": "Schemas",
"default": [
"urn:ietf:params:scim:api:messages:2.0:Error"
]
},
"status": {
"type": "integer",
"title": "Status"
},
"details": {
"type": "string",
"title": "Details"
}
},
"type": "object",
"required": [
"status",
"details"
],
"title": "ErrorResponse"
},
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
}
},
"securitySchemes": {
"HTTPBearer": {
"type": "http",
"scheme": "bearer"
}
}
}
}
Additional context
Add any other context about the problem here.
N/A
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從提供的 OpenAPI 規格開始,檢查產生的 rivery_scim_client/models/book.py,尤其是第 40 行回報的未定義 cast 參照。將其行為與 pull request 1072 進行比較,並確認產生作業能在沒有 F821 錯誤的情況下成功完成,且產生的用戶端通過 Ruff 檢查。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100