Swagger 为 DateTime 生成字符串
Swagger generates string for DateTime
我有这个操作方法:
[HttpGet]
public async Task<ActionResult<Agent[]>> Get(DateTime? lastModified = null) {}
我可以看到下面的 swagger json 是使用 Swashbuckle.AspNetCore v4.0.1 生成的:
"parameters":[{"name":"lastModified","in":"query","required":false,"type":"string","format":"date-time"}]
为什么类型是string
?
不应该是DateTime
吗?
OpenAPI定义了以下基本类型:string,number,integer,boolean,array,object.There没有DateTime.
string
类型包括日期和文件,date-time
格式是字符串格式之一。
参考
https://swagger.io/docs/specification/data-models/data-types/
我有这个操作方法:
[HttpGet]
public async Task<ActionResult<Agent[]>> Get(DateTime? lastModified = null) {}
我可以看到下面的 swagger json 是使用 Swashbuckle.AspNetCore v4.0.1 生成的:
"parameters":[{"name":"lastModified","in":"query","required":false,"type":"string","format":"date-time"}]
为什么类型是string
?
不应该是DateTime
吗?
OpenAPI定义了以下基本类型:string,number,integer,boolean,array,object.There没有DateTime.
string
类型包括日期和文件,date-time
格式是字符串格式之一。
参考
https://swagger.io/docs/specification/data-models/data-types/