OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Dart] Dollar sign in parameter names generated invalid code

Open
#9,864 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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:
    expected vs actual
  • [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 $
afbeelding

Related issues/PRs

None

Suggest a fix

Make sure dollar signs are escaped in string literals

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.