OpenAPITools/openapi-generator

Rust codegen creates incorrectly escaped parameter names

Open

#1,222 创建于 2018年10月11日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Java (7,516 fork)batch import
Client: RustHacktoberfestIssue: BugServer: Rusthelp wanted

仓库指标

Star
 (26,243 star)
PR 合并指标
 (平均合并 9天 1小时) (30 天内合并 123 个 PR)

描述

Description

Generating Rust APIs for Kubernetes or any other API using parameters names which match keywords generates invalid rust since the escaped parameters names are invalid.

The swagger file contains "continue" as a parameter. This gets escaped by the codegen to “_continue”. Unfortunately this fails to compile when used in a format macro:

error: invalid format string: invalid argument name `_continue`
     --> kubernetes/src/client/mod.rs:21864:99
      |
21864 |         let query__continue = param__continue.map_or_else(String::new, |query| format!("continue={_continue}&", _continue=query.to_string()));
      |                                                                                                   ^^^^^^^^^ invalid argument name in format string
      |
      = note: argument names cannot start with an underscore
OpenAPI declaration file content or url

https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.11/api/openapi-spec/swagger.json https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/swagger-spec/v1.json

Suggest a fix/enhancement

Could position, rather than parameter names, be used in the format string?

贡献者指南