OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][Client][RestTemplate] '+' in query parameters is not properly URL-encoded
Nobody has claimed this yet.
- 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
- https://github.com/OpenAPITools/openapi-generator/issues/644
- https://github.com/spring-projects/spring-framework/issues/31363
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/pull/16732
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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