Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger generates string for DateTime

I have this action method:

[HttpGet]
public async Task<ActionResult<Agent[]>> Get(DateTime? lastModified = null) {}

I can see that the following swagger json is generated using Swashbuckle.AspNetCore v4.0.1:

"parameters":[{"name":"lastModified","in":"query","required":false,"type":"string","format":"date-time"}]

Why is the type string? Shouldn't it be DateTime?

like image 726
David Klempfner Avatar asked Sep 19 '25 22:09

David Klempfner


1 Answers

OpenAPI defines the following basic types: string,number,integer,boolean,array,object.There's no DateTime.

The string type includes dates and files and the date-time format is one of string formats.

Refer to

https://swagger.io/docs/specification/data-models/data-types/

https://swagger.io/specification/#dataTypes

like image 158
Ryan Avatar answered Sep 23 '25 07:09

Ryan