[BUG][Rust] reqwest client does not compile for required nullable params, free-form object query params, inline object form fields and a param named configuration
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start by generating the client from the supplied spec.yaml with the shown OpenAPI Generator command, then run cargo check and inspect src/apis/default_api.rs. Trace the Rust generator templates for query parameters, multipart fields, model qualification, and parameter naming. Done means the four reduced cases generate compiling Rust without the reported errors.
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
The rust generator (default reqwest library) emits code that doesn't compile for four parameter shapes. They came up generating a client for GitLab's description (doc/api/openapi/openapi_v3.yaml, 19.5), where they account for 214 of the 219 compile errors. Four more come from path parameters GitLab uses without declaring, and one from .to_string() on an array-of-objects form field, which I haven't reduced. The spec below reduces the four to three operations.
- A parameter that is required and
nullable: truegets anOptiontype, but the template takes the required branch and uses it as a plain value. For a query array it iterates theOptionand calls.to_string()on the wholeVec<String>; for a multipart file it passesOption<PathBuf>toTokioFile::open. This is 158 of GitLab's errors. - A free-form object query parameter (
type: object, no properties) is typedmodels::serde_json::Value. - An inline object form field is typed
models::models::CreateImportRequestConfiguration. Together with 2, that's 48 errors on GitLab. - A form field named
configurationbecomes a second parameter namedconfiguration, next to the&configuration::Configurationargument, and the rest of the function then fails to type-check (8 errors on GitLab).
openapi-generator version
7.25.0.
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: rust reqwest compile errors
version: "1"
paths:
/variables:
delete:
operationId: deleteVariables
parameters:
- name: filter
in: query
schema:
type: object
nullable: true
- name: paths
in: query
required: true
schema:
type: array
nullable: true
items:
type: string
responses:
"204":
description: deleted
/imports:
post:
operationId: createImport
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
configuration:
type: object
properties:
url:
type: string
responses:
"201":
description: created
/uploads:
post:
operationId: upload
requestBody:
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
format: binary
nullable: true
responses:
"201":
description: created
Generation Details
java -jar openapi-generator-cli-7.25.0.jar generate -g rust -i spec.yaml -o out --additional-properties=packageName=repro
cd out && cargo check --message-format=short
Steps to reproduce
src/apis/default_api.rs:42:74 error[E0415]: identifier `configuration` is bound more than once in this parameter list
src/apis/default_api.rs:42:104 error[E0433]: cannot find `models` in `models`
src/apis/default_api.rs:72:128 error[E0433]: cannot find `serde_json` in `models`
src/apis/default_api.rs:84:96 error[E0599]: `Vec<std::string::String>` doesn't implement `std::fmt::Display`
src/apis/default_api.rs:116:16 error[E0277]: the trait bound `std::option::Option<PathBuf>: AsRef<Path>` is not satisfied
src/apis/default_api.rs:118:33 error[E0599]: no method named `file_name` found for enum `std::option::Option<T>`
(plus follow-on errors from the duplicate configuration). The generated lines:
pub async fn create_import(configuration: &configuration::Configuration, configuration: Option<models::models::CreateImportRequestConfiguration>) -> Result<(), Error<CreateImportError>> {
pub async fn delete_variables(configuration: &configuration::Configuration, paths: Option<Vec<String>>, filter: Option<models::serde_json::Value>) -> Result<(), Error<DeleteVariablesError>> {
"multi" => req_builder.query(&p_query_paths.into_iter().map(|p| ("paths".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
let file = TokioFile::open(&p_form_file).await?;
Suggest a fix
Treat required nullable parameters like optional ones in the query and multipart templates, keep serde_json::Value and already-qualified model types free of the extra models:: prefix, and escape a parameter named configuration the way other colliding names are escaped.
- Ngôn ngữ chính
- Java
- Star
- 26.9k
- Fork
- 7.8k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 180
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
-
Issue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
OpenAPITools/openapi-generator#25643 · 1 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 82/100
OpenAPITools/openapi-generator#25640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Có thể đã có người làm @Inf1mum đã nhận 2 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#25567 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceCó thể đã có người làm @Inf1mum đã nhận 9 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 62/100
OpenAPITools/openapi-generator#25524 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở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
Tất cả issue của OpenAPITools/openapi-generator
Issue tương tự
-
bug emitter:client:csharp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/typespec#12572 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationCó thể đã có người làm @amalsaidov đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ 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 2 ngày
-
area/ai area/backend component/zeebe kind/task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày