Open
Description
Description
I have below two properties
[Required]
public TimeSpan StartTime { get; set; }
public TimeSpan? EndTime { get; set; }
but since I can't generate SDK with same timespan field from the swagger json I added below line to startup class
c.MapType<TimeSpan>(() => new OpenApiSchema { Type = "string", Format = "time-span", Nullable = false });
c.MapType<TimeSpan?>(() => new OpenApiSchema { Type = "string", Format = "time-span", Nullable = true });
The json generated also looks good
"startTime": {
"type": "string",
"format": "time-span"
},
"endTime": {
"type": "string",
"format": "time-span",
"nullable": true
},
I then pass the below type mapping argument
--type-mappings time-span=TimeSpan
The problem here is that the non nullable fields comes fine in the SDK generated but the nullable field comes as non nullable itself. Below is the C# code that was generated
[DataMember(Name = "startTime", IsRequired = true, EmitDefaultValue = true)]
public TimeSpan StartTime { get; set; }
[DataMember(Name = "endTime", EmitDefaultValue = true)]
public TimeSpan EndTime { get; set; }
openapi-generator version
6.2.1