question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG][DART] API with path parameter named `format` produces incorrect paths.

See original GitHub issue

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

If a resource contains a path parameter named format, the generated library replaces the parameter with the word json prior to normal parameter substitution, breaking the API.

Here is an example of the code produced.

final path = '/things/{format}'.replaceAll('{format}', 'json')
    .replaceAll('{' + 'format' + '}', format.toString());
openapi-generator version

5.0.0 (also tested with 5.0.1-20210206.073348-97)

OpenAPI declaration file content or url
openapi: 3.0.4
info:
  title: Sample API
  version: 0.1.1
paths:
  /things/{format}:
    get:
      summary: Returns a list of things.
      parameters:
        - in: path
          name: format
          schema:
            type: string
          required: true
      responses:
        '200':
          description: A JSON array of things
Generation Details

Generated using compiled jar. e.g.

java -cp openapi-generator-cli-5.0.1-20210206.073348-97.jar org.openapitools.codegen.OpenAPIGenerator generate -i "format-issue.yml" -g dart -o formatissue
Suggest a fix

I am unfamiliar with the codebase, but it appears to be happening here. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/dart/api.mustache#L28

And it seems to be present in many languages, for example. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/android/api.mustache#L63

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
wing328commented, Feb 16, 2021

That’s an old behaviour. I remember first seeing it in the Ruby client generator when I started. We’ve since removed it to address issues similar to this one.

Please feel free to remove this old behaviour from the Dart generators.

1reaction
kuhnroyalcommented, Feb 17, 2021

When you touch this please also update it for the dart-dio templates.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger:Issue with Path parameter - apigee - Stack Overflow
I am try to create a swagger file with the following path: paths: /v1/customers/{id}/ ...
Read more >
Rest Assured Tutorial - Query Parameter vs. Path ... - YouTube
Learn what is the difference between Query, Path Parameters and how to handle them in Rest Assured. Found this video interesting - Please ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found