1

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

Thore
  • 1,918
  • 2
  • 25
  • 50

1 Answers1

0

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.

digitalacorn
  • 146
  • 1
  • 5
  • This is coming from the basic `Get started` guide from the TSOA website. `export type UserCreationParams = Pick;` – Thore Jul 17 '23 at 13:20
  • Yes, that does result in the 'ugly' entry in the swagger docs. If you change to an interface instead of a type it will use the interface name in the docs instead – digitalacorn Jul 18 '23 at 12:05