[BUG][RUST] chrono date-time path/query/header params are not serialized as RFC 3339
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
- Lĩnh vực
- developer-experience, tooling
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
- Generate the client from the spec above.
- 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()). - Call
list_orderswithDateTime::parse_from_rfc3339("2026-01-02T03:04:05Z")and inspect the request: the values are sent as2026-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
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.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenAPITools/openapi-generator
-
Enhancement: Feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25364 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][RUST] Reqwest - encoding of spaces in path parametersCó thể đã có người làm @GlenWright đã nhận 10 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenAPITools/openapi-generator#25257 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25237 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] OpenApiEvaluator reports "default value not in enum" for numerically equal values with different scale (e.g. 1.5 and 1.50)Có thể đã có người làm @mohitduhan19 đã nhận 12 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25233 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] OpenApiEvaluator emits "Unused model" warnings even when recommendations are disabledCó thể đã có người làm @mohitduhan19 đã nhận 12 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25232 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenAPITools/openapi-generator
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
AllTheMods/AllTheModium#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/stormcrawler#2264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
commons-app/apps-android-commons#7115 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
objectionary/lints#1596 ·
Maintainer thường phản hồi trong vòng 2 ngày