OpenAPITools / OpenAPITools/openapi-generator
[BUG][Rust] format! syntax error for path parameters with dashes in them
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The Rust generator generates syntax errors when URI templates have parameter names with - dashes in them.
openapi-generator version
0e05cf2
OpenAPI declaration file content or url
openapi: '3.0.0'
info:
version: 1.0.0
title: test
paths:
/test/{uwu-owo}:
get:
summary: sample
parameters:
- name: uwu-owo
in: path
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
hello:
type: string
Generation Details
java -jar /home/val/.m2/repository/org/openapitools/openapi-generator-cli/7.6.0-SNAPSHOT/openapi-generator-cli-7.6.0-SNAPSHOT.jar generate -i dash.yaml -o rsbug/ -g rust
Steps to reproduce
generate the above, try to build, get syntax error:
error: invalid format string: expected `'}'`, found `'-'`
--> src/apis/default_api.rs:31:50
|
31 | let local_var_uri_str = format!("{}/test/{uwu-owo}", local_var_configuration.base_path, uwu-owo=crate::api...
| - ^ expected `'}'` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
Related issues/PRs
🤷♀️
Suggest a fix
Add dash replacement for format! key names
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 running the documented Java generator command with the provided dash.yaml and inspect the generated src/apis/default_api.rs. Compare the generated format! call with the reported Rust compiler error and trace it back to the Rust generator templates or code that handles path parameter names. Done means the same specification generates Rust code that builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100