OpenAPITools / OpenAPITools/openapi-generator
[REQ] Add 'isFormStyle', 'isSpaceDelimited', and 'isPipeDelimited' flags to CodegenParameter similar to 'isDeepObject'
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.
We already have 'isDeepObject' flag but to determine the parameter style (when it's not deepObject), we need to manually check the value of {{style}}. This process results in a significant amount of unnecessary generated code.
For example, in the cpp-qt-client/api-body.mustache file, (399-472), we have redundant code that can be eliminated with a more streamlined approach.
I want to avoid code like this:
else if (QString("pipes").indexOf("csv") == 0) {
....
} else if (QString("pipes").indexOf("pipes") == 0) {
....
} else if (QString("pipes").indexOf("deepObject") == 0) {
Describe the solution you'd like
I suggest adding flags similar to the existing isDeepObject flag for other parameter styles such as: form, spaceDelimited, pipeDelimited.
Using the flags ensures that only the relevant code is generated. So only one block of the above code will be generated.
For example, with these new flags in place, we could write the following in the mustache templates:
{#isFormStyle}}{{#isExplode}} //csv {{/isExplode}}{{^isExplode}} ... //multi {{/isExplode}}{/isFormStyle}}
{{#isSpaceDelimited}} .... //ssv {{/isSpaceDelimited}}
{{#isPipeDelimited}} ... //pipes {{/isPipeDelimited}}
{{#isDeepObject}} ... {{/isDeepObject}}
Describe alternatives you've considered
I'm aware that the existing code relies on collectionFormat values. I'm not sure if it's necessary to preserve support for collectionFormat or if it's okay to focus only on the OpenAPI 3.x+ approach using style and explode.
If that's not the case, we can also add flags similar to the existing isCollectionFormatMulti:
isCollectionFormatCsvisCollectionFormatSsvisCollectionFormatPipes
Additional context
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 locating CodegenParameter and the existing isDeepObject flag, then inspect cpp-qt-client/api-body.mustache around lines 399-472 to understand the redundant style checks. Decide whether the new flags cover OpenAPI 3 style/explode values only or also preserve collectionFormat behavior. Done means the requested form, spaceDelimited, and pipeDelimited flags are available for templates and eliminate the relevant manual checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100