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
  • #249
Closed
Open
Issue created Jun 07, 2018 by Administrator@rootContributor

[JAVA][RestTemplate]Query parameter is not URL encoded

Created by: simingweng

Description

If an API accept query parameter and parameter contains unsafe symbol, such as "&" sign, in the RestTemplate-based Java client, it is not encoded. When the request is sent as it is to the server side, it prevents the server from parsing the parameter properly.

openapi-generator version

3.0.0

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/v3.0.0/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml

Command line used for generation

https://github.com/OpenAPITools/openapi-generator/blob/v3.0.0/bin/java-petstore-resttemplate.sh

Steps to reproduce

the line of code in question is at https://github.com/OpenAPITools/openapi-generator/blob/9c82520637b9cd4415046e78ddb13dec84e89509/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java#L518

the parameter string are put into UriComponentsBuilder as it is

Suggest a fix/enhancement

It seems other flavour of Java clients, such as "okhttp-gson", is doing "escaping" while building the request, at https://github.com/OpenAPITools/openapi-generator/blob/9c82520637b9cd4415046e78ddb13dec84e89509/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java#L1037

we need to introduce this sanitisation in RestTemplate-based client

Assignee
Assign to
Time tracking