#NestJS & NX using Generics, swagger and ApiExtraModels

3 messages · Page 1 of 1 (latest)

bright sand
#

Using NestJS you can use the ExtraModels functionality to have swagger generate documentation for generic classes
Ie
export class PagedResultDto<T>{
rows:T[];
@ancient minnowProperty()
count: number;
}

This works great.
However when we bring NX into the equation, this no longer works if your DTO is contained within a library.

How could i work around this limitation while still keeping my DTO in a reusable Lib?

#

as soon as i reference a generic defined in another library i get a circular reference error.
If i move the definition of that generic to the main nestjs app and not in the lib it works perfectly

stark stratus
#

Even a generic Dto doesn't work in my case