From 279677af50f92bc8c2647d1f2a82c375e211741f Mon Sep 17 00:00:00 2001 From: Bjarne Callewaert Date: Mon, 14 Feb 2022 10:18:30 +0100 Subject: [PATCH] IsDateTime should return true when using Moment (see NjsonSchema) #1613 --- src/NSwag.CodeGeneration/Models/ParameterModelBase.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs b/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs index 26a2635caa..b4d4ed9bdc 100644 --- a/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs +++ b/src/NSwag.CodeGeneration/Models/ParameterModelBase.cs @@ -156,7 +156,8 @@ public IEnumerable CollectionPropertyNames /// Gets a value indicating whether the parameter is of type date-time public bool IsDateTime => - Schema.Format == JsonFormatStrings.DateTime && _generator.GetTypeName(Schema, IsNullable, null) != "string"; + Schema.Format is JsonFormatStrings.DateTime or JsonFormatStrings.TimeSpan && + _generator.GetTypeName(Schema, IsNullable, null) != "string"; /// Gets a value indicating whether the parameter is of type date-time or date public bool IsDateOrDateTime => IsDate || IsDateTime; @@ -182,7 +183,7 @@ public IEnumerable CollectionPropertyNames /// Gets a value indicating whether the parameter is of type date-time array. public bool IsDateTimeArray => IsArray && - Schema.Item?.ActualSchema.Format == JsonFormatStrings.DateTime && + Schema.Item?.ActualSchema.Format is JsonFormatStrings.DateTime or JsonFormatStrings.TimeSpan && _generator.GetTypeName(Schema.Item.ActualSchema, IsNullable, null) != "string"; /// Gets a value indicating whether the parameter is of type date-time or date array.