Reputation: 21
export interface ProjectInterface {
id: string;
@ApiProperty
title: string;
description: string;
How to use swagger docs implementation while using interface instead of class AS DTO? At API Property annotation error is showing because of the interface that I used. But if I don't want to use class. How can I implement this?
Upvotes: 2
Views: 2545
Reputation: 70111
It's not possible to use interfaces for Nest's swagger module. Nest's swagger module works by reading class metadata that Typescript reflects at compile time. As interfaces are existed from the runtime code, there's no metadata to be reflected and read, so you can't use interfaces, it must be a class.
Upvotes: 3