One of my endpoint takes 2 parameters in Java code with data/format type
as Date
. In swagger, the API shows expected input as:
string($date-time)
(query)
When I enter 2020-07-07T01:08:10Z
in both the parameter boxes, I get status code 400 Bad request
in response. I also tried with 2020-07-07T01:08:10.873Z
.
Am I giving wrong Date format?. Please help.
Edit:
@GetMapping("/findAllEventsWithoutLogin")
public Collection<GeneralEvent> getAllEvents(@RequestParam("start_date") Date startDate,
@RequestParam("end_date") Date endDate) {
package com.events.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@Configuration
public class SwaggerConfig {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
}
Edit:
FYI: The same Date format is working fine when I am passing Date in body, but not when I am passing it as a query parameter. Below is working fine.