OpenAPITools / OpenAPITools/openapi-generator

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

Open
#24,107 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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.

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with paramPipe.mustache and controller.mustache, then compare the existing generated NestJS pipe imports and controller usage. Trace how the TypeScript NestJS server generator handles the current pipes and determine the required ParseArrayPipe configuration for query arrays. Done means generated controllers support the requested array forms without manual edits and existing pipe behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.