OpenAPITools / OpenAPITools/openapi-generator
[BUG] Order of parameter in form data is not garantee according the description file
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4 define that form data must be send in the order of the declaration
"The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream. "
openapi-generator version
bug exist in all version. I tries maven plugin 4.3.1 and 5.0
OpenAPI declaration file content or url
"multipart/form-data": {
"schema": {
"type": "object",
"title": "CreatedMessage",
"required": [
"subject",
"comment",
],
"properties": {
"subject": {
"type": "string",
"example": "Very important files"
},
"comment": {
"type": "string",
"example": "Please review this document ASAP"
},
Generation Details
The main problem is related to sendXCall where X is the method. There is in generated code
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
Steps to reproduce
generate an openapi file with formdata
Related issues/PRs
Suggest a fix
As localVarFormParams is an HashMap, order of retrieving according to the order of insertion is not garantee.
My correction was to create localVarFormParams as a LinkedHashMap
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 at the generated sendXCall method and inspect where localVarFormParams is initialized and iterated. Reproduce a multipart/form-data client from the provided declaration, then verify that subject and comment are sent in declaration order across the relevant generated client output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100