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

date-time is not formatted correctly

Đang mở
#841 4 bình luận 3 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
2k
Fork
293
Merge trung bình
34 phút
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách xác định phần tuần tự hóa request của client được sinh ra, phần xử lý các giá trị datetime.datetime và gọi isoformat(). So sánh đầu ra của nó với các ví dụ RFC3339/OpenAPI trong issue, sau đó chạy hoặc bổ sung coverage cho các tham số query date-time. Hoàn tất khi các timestamp được sinh ra được server được nêu chấp nhận là các giá trị date-time tuân thủ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
openapi, python
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.