OpenAPITools / OpenAPITools/openapi-generator
[REQ] Form parameters with additionalProperties
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I have a POST route in my openapi specification with a form-urlencoded body. The schema of this body is composed of some known properties that are defined, but also should accept other arbitrary properties as a Map that will be passed to the service without prior validation. To do this, I have an object type with the additionalProperties property to true.
Currently, it generates this error :
Form parameters with additionalProperties are not supported by OpenAPI Generator. Please report the issue to https://github.com/openapitools/openapi-generator if you need help.
Describe the solution you'd like
I would like the generator to generate a method signature with the known parameters as classic parameters, with an additional parameter with a Map<String, Object> or Map<String, String> type
public ResponseEntity<ResponseDTO> postRoute(Boolean param1, String param2,
@RequestParam Map<String, Object> additionalParameters) {
...
}
Describe alternatives you've considered
I have not thought of a better way to do this. Currently, I need to remove the @Override modifier because I need this Map.
I can't change the content type or define all the parameters, because I don't control the client that will call this route (a webhook).
Additional context
Here is my openapi specification for the requestBody I need :
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
param1:
type: boolean
default: false
param2:
type: string
additionalProperties: true
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 tracing how Java server generation handles application/x-www-form-urlencoded request bodies and where the “Form parameters with additionalProperties” error is emitted. Compare the generated method signature with the requestBody schema in the issue. Done means known properties remain typed parameters and arbitrary form fields are accepted through a Map parameter without the current error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100