TSOA generates Typescript Pick, Partial and Omit schemas in swagger.json file

491 Views Asked by At

I have been following the 'Getting started' guide from TSOA to setup a new express project with typescript, add a nodemon configuration and swagger documentation. After finishing step three "Live reloading" the result should be a GET and POST route in swagger and two schemas: User and UserCreationParams.

I'm getting the same result except that it generated a third schema Pick_User.email-or-name-or-phoneNumbers_. If I create more routes and interfaces and create extra types using Pick, Partial or Omit they are all getting picked up and added to the schema.

I'm looking for a way to ignore these 'dirty' schemas

enter image description here

1

There are 1 best solutions below

2
On

It would be useful to see how you declared these interfaces.

I'm working around this by declaring nicely named empty interfaces as aliases for the swagger documents, as follows...

/* eslint-disable-next-line @typescript-eslint/no-empty-interface */
export interface UserCreationParams extends Pick<User, 'email'|'name'|'phoneNumbers'> {}

A definition for UserCreationParams appears in the docs rather than the ugly auto-generated one from the Pick/Omit generic.

Our default linter setup complains about empty interfaces - so I have disabled that rule for all files defining the interfaces exposed to the swagger docs.