[BUG][DART] API with path parameter named `format` produces incorrect paths.
See original GitHub issueBug 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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
When you touch this please also update it for the
dart-dio
templates.