我定义了这个 DTO 类。
import { ApiProperty } from "@nestjs/swagger"
export class FormDTO {
@ApiProperty()
id: string
@ApiProperty()
type: string
@ApiProperty()
fieldValues?: Record<string, unknown>
@ApiProperty()
parentFormId?: string
}
Run Code Online (Sandbox Code Playgroud)
我预计生成的 OpenAPI 规范会表明这一点fieldValues并且parentFormId是可选的,但它们是必需的。
根据此处文档中的示例,它们应该是可选的。我缺少什么?
使用该 DTO 的唯一方法如下所示,但我认为这并不重要:
@Post(":id")
createForm(@Body() createFormDto: FormDTO) {
if (this.formService.hasForm(createFormDto.id)) {
throw new ConflictException(
undefined,
`A form with the id ${createFormDto.id} already exists.`
)
}
return this.formService.createOrUpdateForm(createFormDto)
}
Run Code Online (Sandbox Code Playgroud)
如果重要的话,这里是代码DocumentBuilder
const config = new DocumentBuilder()
.setTitle("API")
.setDescription(
"description."
)
.setVersion("1.0")
.addBearerAuth(
{
type: "http",
scheme: "bearer",
bearerFormat: "JWT",
description: "Paste a valid access token here."
},
JWTGuard.name
)
.build()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1875 次 |
| 最近记录: |