Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 488
Thore Avatar asked Sep 14 '25 21:09

Thore


1 Answers

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.

like image 119
digitalacorn Avatar answered Sep 16 '25 17:09

digitalacorn