I'm using autoRest to generate a new client from a swagger schema. I have list of DateTime in a model
public class DateRange
{
public IList<DateTime> Dates{ get; set; }
}
This the Json swagger schema it is generated from that property
{ ...
"Dates": {
"type": "array",
"items": {
"format": "date-time",
"type": "string"
}
}
...
}
This is the result I am getting after I run autoRest
public class DateRange
{
[JsonProperty(PropertyName = "Dates")]
public IList<System.DateTime?> Dates{ get; set; }
}
I would like to get a non nullable dateTime property something like this
public IList<System.DateTime> Dates{ get; set; }
Update your Swagger schema so that your property would look like:
dates:
type: "array"
items:
format: "date-time"
type: "string"
x-nullable: false
Then generated the client using AutoRest
in the command line:
autorest --input-file="swagger.json" --output-folder="output" --csharp
Resulting in:
/// <summary>
/// </summary>
[JsonProperty(PropertyName = "dates")]
public IList<System.DateTime> Dates { get; set; }