using @nestjs/swagger
and @nestjs/typeorm
, how to properly display a relationship field in swagger UI.
for example:
@Entity()
class MyEntity{
@ManyToOne(() => StoreEntity, (store) => store.checkouts)
@ApiProperty({ type: 'string', format: 'uuid', name: 'storeId' })
store: StoreEntity;
}
I want that field to be displayed in swagger as a string to enter only the store's id, but in typeORM to be s storeEntity
object.
so, req.body.store
can be just a string, but response.store
is the full object
without separating them like that ...
@ManyToOne(() => StoreEntity, (store) => store.checkouts)
@ApiHideProperty()
store: StoreEntity;
@ApiProperty({ type: 'string', format: 'uuid' })
storeId: string;