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
  • #909
Closed
Open
Issue created Aug 27, 2018 by Administrator@rootContributor

[Java][Webclient] Authentication queryParams double encoded

Created by: marcoreni

Description

A querystring authentication param is double encoded during request.

openapi-generator version

3.2.3-SNAPSHOT

OpenAPI declaration file content or url
security:
  - apiKey: []
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: query
      name: apiKey
[...]
Steps to reproduce
  1. Generate a client with authentication
  2. Set 1234= as auth value
  3. Request should be sent as apiKey=1234%3D, but instead is sent as apiKey=1234%253D
Suggest a fix/enhancement

I'm assuming that this behavior happens for all query params, since there is no special handling for authentication query params once these are added to the list in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache#L529 .

I checked the generated code and debugged a request.

  1. During prepareRequest() all queryParams are encoded.
  2. During builder.build().toUri() (specifically during toUri()) the params are encoded once again, since build() is called without encoded param (see https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html#build-- / https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html#build-boolean- ).

I think the best solution would be to leave the encoding to toUri(), thus removing the loop in prepareRequest() (https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache#L534).

Assignee
Assign to
Time tracking