我收到以下错误:
声明的路径参数“ imageId”需要定义为路径 路径或操作级别的参数
这是我张扬的定义的快照
'/api/v1/images/{unitnumber}/{type}/{imageId}':
delete:
tags:
- Images
summary: 'Summary'
description: "Description"
operationId: DeleteImage
consumes: []
produces:
- application/json
parameters:
- name: unitnumber
in: path
required: true
type: string
- name: type
in: path
required: true
type: string
- name: imageId
in: query
required: false
type: string
responses:
'400':
description: Bad Request
schema:
$ref: '#/definitions/ErrorResponse'
'401':
description: Unauthorized
schema:
type: string
'500':
description: Server Error
schema:
$ref: '#/definitions/ErrorResponse'
仅当我采用imageId
并改成path
而不是query
时,我才能摆脱错误
- name: imageId
in: path
required: true
type: string
对我需要更改以使其正常工作的任何想法吗?
答案 0 :(得分:1)
路径字符串/api/v1/images/{unitnumber}/{type}/{imageId}
表示imageId
是路径参数,因此它必须为in: path
。
如果像imageId
那样将/api/v1/images/{unitnumber}/{type}?imageId=...
作为查询参数,则需要将路径字符串更改为/api/v1/images/{unitnumber}/{type}
。查询参数should not be mentioned in paths,它们仅在parameters
部分中定义。