代码之家  ›  专栏  ›  技术社区  ›  Tanisha Sethi

Swagger中的错误消息“未提供必填字段”

  •  0
  • Tanisha Sethi  · 技术社区  · 2 年前
    public ResponseEntity<Document> fetchRep(
        @Parameter(name = "fromDate", description = "${AbcController.fromDate.ApiParam.value}",
          required = true,
          example = "2023-01-11", schema = @Schema(type = "String"),
          allowEmptyValue = false) @RequestHeader(value = "fromDate", required = true) String fromDate,
        @Parameter(name = "toDate", description = "${AbcController.toDate.ApiParam.value}",
          required = true,
          example = "2023-01-11",
          schema = @Schema(type = "String"), allowEmptyValue = false) @RequestHeader(value = "toDate", required = true) String toDate
    

    image link

    yaml文档-

    AbcController:
     fromDate:
       ApiParam:
        value: 'Holds the date from which the report data is generated. [yyyy-mm-dd]'
     toDate:
       ApiParam:
        value: 'Holds the date till which the report data is generated [yyyy-mm-dd]'
    

    你能告诉我为什么我会出现这个验证错误吗?

    1 回复  |  直到 2 年前
        1
  •  0
  •   Helen    2 年前

    改变

    @Schema(type = "String")
    

    @Schema(type = "string")
    

    注意“string”中的小写“s”。