Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] std::option::Option<&str> cannot be formatted with the default formatter #20145

Open
3 of 6 tasks
mickvangelderen opened this issue Nov 20, 2024 · 0 comments
Open
3 of 6 tasks

Comments

@mickvangelderen
Copy link

mickvangelderen commented Nov 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant