Hello,
I am trying to figure out if there is a way to dynamically add descriptions to a Nest.js DTO @ApiProperty() decorator property.
Take this example for instance:
import { SomeDataFetchingClass } from '../some-dir/SomeDataFetchingClass';
export class SomeDTO extends AnotherClass {
@SomePropertyOne()
@ApiProperty({ description: 'I am a description set manually.' })
@SomePropertyTwo()
@ApiProperty({ description: SomeDataFetchingClass.fetchPropertyTwoDescription() })
}
The above example shows how I am trying to dynamically set the @ApiProperty() description property for @SomePropertyTwo(). I have created a class that fetches data from a remote api then returns a string to this description property. The problem I'm running into is that when the nest.js project runs it's bootstrapping process I cannot seem to get the application to wait for the data fetching class to resolve with the remote data in order to populate the description prop.
My question to the community would be: Has anyone else successfully documented their swagger api documentation dynamically rather than setting each property's description value manually? Any suggestions would be gratefully appreciated.
Thanks
Top comments (1)
You could try to do the fetching OUTSIDE of the bootstrapping? I haven't tried this though