How to define an operation with both body and header parameters in OpenAPI 2.0?
OpenAPI 2.0 (Swagger 2.0) 定义如何在同一个操作中同时包含正文和标头参数?我尝试了以下方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /image-correction: post: operationId: image-correction_create tags: - image-corrections consumes: - application/json produces: - application/json parameters: - in: body name: requestBody description: imageCorrection schema: $ref: '#/definitions/ImageCorrection' - in: header name: X-Request-ID schema: type: string format: uuid required: true |
但 Swagger 编辑器显示错误:
should NOT have additional properties additionalProperty: schema
在 OpenAPI 2.0 中,标头、查询和路径参数不使用
1 2 3 4 5 | - in: header name: X-Request-ID type: string # <---- format: uuid # <---- required: true |
这在 OpenAPI 3.0 (