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

date-time is not formatted correctly

未關閉
#841 4 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

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

描述

Describe the bug
OpenAPI date-time fields are generated using datetime.datetime.isoformat and don't comply with OpenAPI spec / RFC3339

OpenAPI Spec File

/api/example:
    get:
      tags:
        - "example"
      operationId: example-get
      summary: "summary removed"
      description: ""
      parameters:
      - in: query
        name: "start"
        description: "desciption removed"
        required: true
        schema:
          type: string
          format: date-time
          example: '2020-07-21T17:32:28Z'
      - in: query
        name: "end"
        description: "desciption removed"
        required: true
        schema:
          type: string
          format: date-time
          example: '2020-07-21T17:32:28Z'

Desktop:

  • OS: Windows 11
  • Python Version: 3.9.13
  • openapi-python-client version 0.15.1

Additional context
Client code generated using openapi-python-client version 0.15.1 parses datetime.datetime objects and uses .isoformat() function to convert these to strings. This produces timestamp strings non-compliant with OpenAPI spec (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#data-types). According to spec timestamps should look like this:
2023-08-23T13:26:16Z
Instead they look like this:
2023-08-23T12:26:16.979067

I have a server that rejects these as invalid timestamps. I can patch the client manually after generation, but I thought it would be beneficial to submit a bug report.

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

首先定位處理 datetime.datetime 值並呼叫 isoformat() 的產生用戶端請求序列化程式碼。將其輸出與 issue 中的 RFC3339/OpenAPI 範例進行比較,然後執行或補充對 date-time 查詢參數的涵蓋。完成的標準是,產生的時間戳記被回報的伺服器接受為符合規範的 date-time 值。

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

評估

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

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

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