Reputation: 1
I am using a datacontract for the model and the datetime datamember is working properly, however swagger ui is showing the datatype as string instead of dateTime.
datamember example:
[DataMember(EmitDefaultValue = false, Order = 6), XmlElement(Namespace = apiNameSpace, Order = 6)]
public DateTime? StartDate { get; set; } = null;
swashbuckle swagger-ui model output:
StartDate (string, optional):
Upvotes: 0
Views: 2720
Reputation: 1250
This is per the Swagger 2.0 spec (see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md).
The spec says that a dateTime should be represented as a string type, with the associated "format" property set to "date-time".
Have a look at http://petstore.swagger.io/#!/store/placeOrder if you want to see an example. "shipDate" there is defined as (string, optional) just like your StartDate field.
Upvotes: 2