Search code examples
javaspring-bootswagger-ui

Error message "Required field is not provided" in Swagger


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 doc -

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]'

Can you please tell me why i am getting this validation error?


Solution

  • Change

    @Schema(type = "String")
    

    to

    @Schema(type = "string")
    

    Note lowercase "s" in "string".