我想为 API 接口启用 Swagger,在 Nx monorepo 中的 NestJS 和 Angular 应用程序之间共享。是否有一致的而不是变通的方式?
这些是我没有成功的方法:
@nestjs/swagger
装饰器应用于共享 DTO 类npx create-nx-workspace@latest
angular-nest
工作区蓝图Message
中app.component.ts
(没有意义,只是为了测试):export class AppComponent {
@Input() message: Message;
hello$ = this.http.get<Message>('/api/hello');
constructor(private http: HttpClient) {}
}
Run Code Online (Sandbox Code Playgroud)
message
用ApiProperty()
in装饰属性api-interfaces.ts
:import { ApiProperty } from '@nestjs/swagger';
export class Message {
@ApiProperty()
message: string;
}
Run Code Online (Sandbox Code Playgroud)