openapi-generators / openapi-generators/openapi-python-client
Missing import when there is a const in the object
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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