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
  • #8352
Closed
Open
Issue created Jan 06, 2021 by Administrator@rootContributor

[BUG] [Java Resttemplate] Incorrect handling of free form query parameters

Created by: gspatace

Description: Currently, when using free form query parameters, the URI is not built correctly.

Steps to reproduce: Input spec file:

openapi: 3.0.0
info:
  title: test
  version: 0.0.1
servers: 
  - url: "http://localhost"
paths:
  /some/endpoint: 
    get: 
      parameters: 
        - in: "query"
          name: "fixed"
          schema: 
            type: "string"
        - in: "query"
          name: "free-form"
          schema:
            type: "object"
          style: "form"
      responses: 
        200:
          description: "test"

Command to generate client files: java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i spec.yml -o work -g java --library resttemplate

Client code ( usage of generated API ):

        ApiClient apiClient = new ApiClient();
        DefaultApi defaultApi = new DefaultApi(apiClient);
        Map<String, Object> freeFormQueryParams = new HashMap<>();
        freeFormQueryParams.put("this", "first");
        freeFormQueryParams.put("that", "second");
        freeFormQueryParams.put("other", "third");
        defaultApi.someEndpointGet("fixedValue", freeFormQueryParams);

Expected result of URI built for the endpoint: http://localhost/some/endpoint?fixed=fixedValue&this=first&that=second&other=third

Actual result: http://localhost/some/endpoint?fixed=fixedValue&free-form=%7Bthat%3Dsecond%2C+other%3Dthird%2C+this%3Dfirst%7D

Tested with master as of today.

I've added a patch that addresses this, I'll open a PR soon, too.

free-form-params.txt

Assignee
Assign to
Time tracking