POST /api/todo-lists/{listId}/todos
控制器和用夸张属性处理帖子的方法看起来像:
@Controller('api/todo-lists')
export class TodosController {
@Post('/:listId/todos')
@ApiQuery({
name: 'listId',
description: "The ID of the list associated with this todo",
required: true,
type: String,
})
async create(@AuthUser() user, @CurrentToDoList() todoList, @Body() todo: TodoCreateDto):
<removed for brevity>
}
}
这是创建Follwing Swagger Doc:
paths:
/api/todo-lists/{listId}/todos:
post:
operationId: TodosController_create
parameters:
- name: listId
required: true
in: query
description: The ID of the list associated with this todo
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TodoCreateDto'
这引起验证错误:
Semantic error at paths./api/todo-lists/{listId}/todos
Declared path parameter "listId" needs to be defined as a path parameter at either the path or operation level
我没有在对控制器本身的呼叫中使用
listId
,我的中间件正在抓取
listID
并实例化列表,然后将其传递给每个控制器方法。任何想法?我想在控制器级别上添加
listID
文档,但无法弄清楚如何做到这一点。
/:listId/todos
这是一个段fora url参数,而不是查询参数。使用
@ApiParam()
而不是@ApiQuery()