OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA][Client][RestTemplate] '+' in query parameters is not properly URL-encoded

Open
#16,733 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

This is a re-occurrence of the below issue, where date-time field is not properly encoded on the + character.
https://github.com/OpenAPITools/openapi-generator/issues/644

In my humble opinion, this is actually an issue with Spring Framework, so I opened a ticket there, but it doesn't seem to be accepted as an issue on that side, so I can only think of fixing it here instead.
https://github.com/spring-projects/spring-framework/issues/31363

openapi-generator version

I've managed to reproduce it with 6.x and 7.x.
This is technically a regression, and I believe it started to happen again once Spring Framework 5.x was adopted here, since that is where they made their change to the processing of + character in particular.

OpenAPI declaration file content or url
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: soldAfter
          in: query
          description: If specified, only pets sold after the given date and time will be returned.
          required: false
          schema:
            type: string
            format: date-time

(copied over from original ticket)

Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

https://github.com/OpenAPITools/openapi-generator/pull/16732

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the RestTemplate client generation path and the supplied /pets query parameter with date-time format. Compare the behavior described here with issues #644 and Spring Framework issue #31363, and inspect the suggested fix in pull request #16732. Done means '+' in the generated client's query parameter is encoded as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.