[BUG][DART] API with path parameter named `format` produces incorrect paths.
Created by: tombowers
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