Skip to content

[REQ] Add 'isFormStyle', 'isSpaceDelimited', and 'isPipeDelimited' flags to CodegenParameter similar to 'isDeepObject' #21239

Open
@Rym-qt

Description

@Rym-qt

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:

  • isCollectionFormatCsv
  • isCollectionFormatSsv
  • isCollectionFormatPipes

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions