我在使用 spring boot 应用程序创建的 swagger 定义时遇到了问题。该错误导致 kubernetes 部署出现问题,并且与尝试以 swagger 方式显示示例 requestBody 有关。这是我从 https://editor.swagger.io/.
得到的错误application/json
should not have both `example` and `examples`, as they are mutually exclusive
Jump to line 31
错误来自配置的末尾 -> 示例:null
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PromotionsRequestBody'
examples:
promotionsRequestBody:
description: promotionsRequestBody
value:
ncrc: '12345678'
divisionCd: 24
promoReq:
- unitType: 1
cics:
- 52030001
- 47150124
- 13400023
startDate: '2023-01-01'
endDate: '2023-12-21'
stores:
- 3427
- 3439
rogs: SHGN
storeGroup: 101
example: null
required: true
这是用于显示示例 requestBody 的 swagger 注释的代码片段。
public ResponseEntity<PromotionsDTO> getPromotions(
@Parameter(name = "requestBody", description = "requestBody") @Valid
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = @Content(
examples = { @ExampleObject(name = "promotionsRequestBody", value = Constants.PROMOTIONS_REQUEST_EXAMPLE) })) @RequestBody PromotionsRequestBody requestBody)
{
有人知道如何解决这个问题吗? swagger3中没有示例选项。