OpenAPITools / OpenAPITools/openapi-generator
[BUG] `std::option::Option<&str>` cannot be formatted with the default formatter
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- 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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm using the rust generator to generate a client for our kubernetes API server.
The generated client code fails to compile with:
error[E0277]: `std::option::Option<&str>` doesn't implement `std::fmt::Display`
--> kubernetes-client/src/apis/core_v1_api.rs:3872:67
|
3872 | let local_var_uri_str = format!("{}/api/v1/nodes/{name}/proxy/{path}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
| ^^^^^^ `std::option::Option<&str>` cannot be formatted with the default formatter
The generated code:
/// connect POST requests to proxy of Node
pub async fn connect_core_v1_post_node_proxy_with_path(configuration: &configuration::Configuration, name: &str, path: Option<&str>) -> Result<String, Error<ConnectCoreV1PostNodeProxyWithPathError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v1/nodes/{name}/proxy/{path}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
// ...
}
openapi-generator version
Happens on:
- 7.10.0
- 7.11.0-SNAPSHOT
OpenAPI declaration file content or url
Can't share but it is a Kubernetes OpenAPI V2 spec.
Generation Details
docker run --rm --network=host -v ${PWD}:/local openapitools/openapi-generator-cli \
generate \
-i https://apiserver/openapi/v2 \
-g rust \
-o /local \
--additional-properties=packageName=kubernetes-client,packageVersion=0.1.0
Steps to reproduce
Related issues/PRs
Suggest a fix
Perhaps the last part of the URL /{path} or just {path} (not the slash) should be left off if path is None.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported failure with the Rust generator and inspect the generated URI formatting for the optional path parameter, particularly the generated core_v1_api.rs example. Done means the generated Rust client handles path: None correctly and compiles without the Option<&str> formatting error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, rust
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100