Skip to content

[REQ] [typescript-nestjs-server] Add ArrayPipe support #24107

Description

@Reda1000

Is your feature request related to a problem? Please describe.

Using OpenApi-Spec Query-Config as 'type: array, style: form, explode: true' I dont always receive the correct form.

If I call via:

  • BAD | sort=name:asc => transformed to string
  • FINE | sort=name:asc&sort=name:desc => transformed to string[]
  • FINE | <empty> => undefined

Describe the solution you'd like

I would like to have the generator apply the nestjs available Pipe to transform to Arrays:
https://docs.nestjs.com/pipes

PS. Going by the Imports in Controllers only 3 out of 9 Pipe are being implemented - missing ones are ParseBoolPipe, ParseArrayPipe, ParseUUIDPipe, ParseEnumPipe, ParseFilePipe, ParseDatePipe

It appears the missing Pipe should be inside:

  • paramPipe.mustache
  • controller.mustache

Describe alternatives you've considered

  • Adding the missing Pipes by hand - until the next auto-generation is being done
  • Make the Frontend always duplicate fields at least once - to enforce an Array being turned in
  • Moving the Transformation into some sort of Interceptor / Middleware

Additional context

There might be more Config / Setting to consider on the ParseArrayPipe - like for transforming the items properly or other setting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions