Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[BUG][RUST] chrono date-time path/query/header params are not serialized as RFC 3339

Đang mở Phù hợp với người mới
#25,297 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@teovillanueva đang làm issue này rồi.

Từ ngày 17/10/2026.

  • #25298 của @teovillanueva — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
openapi, rust

Hướng nghiên cứu

Bắt đầu với các template Rust tạo ra src/apis/default_api.rs cho trình tạo rust và các thư viện reqwest, reqwest-trait và hyper. Tìm các điểm serialize tham số path, query và header, nơi các giá trị DateTime của chrono hiện dùng Display hoặc .to_string(), đồng thời giữ NaiveDate không thay đổi. Tạo client từ đặc tả được cung cấp và xác minh rằng ba vị trí tham số đó phát ra giá trị RFC 3339; các test hiện có của trình tạo Rust nên bao phủ lỗi hồi quy này.

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

Mô tả

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

With the rust client generator and useChrono=true (the default), format: date-time parameters are typed chrono::DateTime<chrono::FixedOffset>. Path, query and header params of that type are turned into strings with Display (.to_string() / format!), and chrono's Display is not RFC 3339:

GET /orders/2026-01-02%2003:04:05%20+00:00?createdAfter=2026-01-02+03%3A04%3A05+%2B00%3A00
x-request-time: 2026-01-02 03:04:05 +00:00

Expected (RFC 3339, the same format serde uses for these values in bodies):

GET /orders/2026-01-02T03:04:05+00:00?createdAfter=2026-01-02T03%3A04%3A05%2B00%3A00
x-request-time: 2026-01-02T03:04:05+00:00

Servers that strictly parse date-time reject the request. This affects the reqwest, reqwest-trait and hyper libraries. format: date (chrono::NaiveDate) is not affected, because its Display is already YYYY-MM-DD.

openapi-generator version

master (7.27.0-SNAPSHOT). Not a regression: it has been this way since chrono support was added.

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: date-time params
  version: 1.0.0
paths:
  /orders/{since}:
    get:
      operationId: listOrders
      parameters:
        - name: since
          in: path
          required: true
          schema:
            type: string
            format: date-time
        - name: createdAfter
          in: query
          required: true
          schema:
            type: string
            format: date-time
        - name: X-Request-Time
          in: header
          required: false
          schema:
            type: string
            format: date-time
      responses:
        '204':
          description: No content
Generation Details
java -jar openapi-generator-cli.jar generate -g rust --library reqwest -i spec.yaml -o out

The same happens with --library reqwest-trait and --library hyper.

Steps to reproduce
  1. Generate the client from the spec above.
  2. Look at src/apis/default_api.rs: since=p_path_since, &p_query_created_after.to_string(), .header("X-Request-Time", param_value.to_string()).
  3. Call list_orders with DateTime::parse_from_rfc3339("2026-01-02T03:04:05Z") and inspect the request: the values are sent as 2026-01-02 03:04:05 +00:00.
Related issues/PRs

#23451 (added chrono support to the rust client)

Suggest a fix

For chrono DateTime path, query and header params, use .to_rfc3339() instead of Display.

Ngôn ngữ chính
Java
Star
26.8k
Fork
7.7k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
166

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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.

Issue khác của OpenAPITools/openapi-generator

Tất cả issue của OpenAPITools/openapi-generator

Issue tương tự

Thêm issue về Java

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.