Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsDateTime should return true when using Moment (see NjsonSchema) #1613 #4916

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/NSwag.CodeGeneration/Models/ParameterModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public IEnumerable<PropertyModel> CollectionPropertyNames

/// <summary>Gets a value indicating whether the parameter is of type date-time</summary>
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";

/// <summary>Gets a value indicating whether the parameter is of type date-time or date</summary>
public bool IsDateOrDateTime => IsDate || IsDateTime;
Expand All @@ -182,7 +183,7 @@ public IEnumerable<PropertyModel> CollectionPropertyNames
/// <summary>Gets a value indicating whether the parameter is of type date-time array.</summary>
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";

/// <summary>Gets a value indicating whether the parameter is of type date-time or date array.</summary>
Expand Down
Loading