OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Dart] Dollar sign in parameter names generated invalid code
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? swagger.json
- Have you validated the input using an OpenAPI validator (example)? Yes, it's valid.
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs? Yes, no related issues for dart exist.
- What's the actual output vs expected output? Incorrect string literals get generated:

- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Parameters with a dollar sign ($) in their names cause a syntax error in generated code. This is because a dollar sign is used for string interpolation in dart.
openapi-generator version
5.1.1
OpenAPI declaration file content or url
The following swagger.json contains an operation with a couple of parameters with a $ prefix, such as $top and $search.
Generation Details
Dart language/generator. I think it also applies to other dart variants. Default config.
Steps to reproduce
Generate a dart client with the openapi spec linked above. Config specifics seems to be irrelevant for this issue. Notice how there's a couple of syntax errors for any parameter starting with a $

Related issues/PRs
None
Suggest a fix
Make sure dollar signs are escaped in string literals
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 with the linked swagger.json and generate a Dart client using the Dart language/generator with the default configuration. Inspect the generated code for parameters such as $top and $search, then verify that dollar signs are escaped in string literals and the generated client no longer has syntax errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100