Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8676
Closed
Open
Issue created Feb 11, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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

Assignee
Assign to
Time tracking