code generated for `date-time` fromat can not parse null response data
まだ誰も着手していません。
評価
調査の方向性
まず、date-time形式のOpenAPIフィールドに対するモデルのデシリアライゼーションを生成するジェネレーターのロジックを特定し、次に提供されたnullableなupdateTimeスキーマとレスポンスデータを使って問題を再現します。nullのdate-time値に対する回帰テストを追加し、生成されたクライアントがTypeErrorを発生させずにレスポンスを受け入れることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
code generated for date-time fromat in models file like this for now:
_update_time = d.pop("updateTime", UNSET)
update_time: Union[Unset, datetime.datetime]
if isinstance(_update_time, Unset):
update_time = UNSET
else:
update_time = isoparse(_update_time)
if response data of updateTime field is null, the _update_time variable will be set to None, so isoparse function will rasie TypeError except.
self = <dateutil.parser.isoparser.isoparser object at 0x7f94bf7ae950>, dt_str = None
def _parse_isodate_common(self, dt_str):
> len_str = len(dt_str)
E TypeError: object of type 'NoneType' has no len()
../../../../.local/lib/python3.10/site-packages/dateutil/parser/isoparser.py:213: TypeError
OpenAPI Spec File
{
"updateTime": {
"type": "string",
"description": "updateTime",
"format": "date-time"
}
}
Desktop (please complete the following information):
- OS: windows wsl ubuntu 22.0
- Python Version: 3.10.0
- openapi-python-client version 0.17.2
Additional context
my suggestion is, adding branch check value is None before call isoparse function, generate code like this:
_update_time = d.pop("updateTime", UNSET)
update_time: Union[Unset, datetime.datetime]
if isinstance(_update_time, Unset):
update_time = UNSET
elif _update_time is None:
update_time = None
else:
update_time = isoparse(_update_time)
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openapi-generators/openapi-python-client のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
openapi-generators/openapi-python-client#1451 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
openapi-generators/openapi-python-client#1435 · コメント 1 件 ·
openapi-generators/openapi-python-client の issue をすべて見る
似ている issue
-
link-check link-check:sphinx-theme
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
CSCfi/sd-search-api#39 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100