Skip to content

Commit

Permalink
Merge pull request #2480 from captainsafia/fix-dateonly
Browse files Browse the repository at this point in the history
Set DateOnly as string type with date format in schema
  • Loading branch information
domaindrivendev authored Nov 14, 2022
2 parents 4a28652 + d9f2017 commit a97df7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ [ typeof(DateTime) ] = Tuple.Create(DataType.String, "date-time"),
[ typeof(DateTimeOffset) ] = Tuple.Create(DataType.String, "date-time"),
[ typeof(Guid) ] = Tuple.Create(DataType.String, "uuid"),
[ typeof(Uri) ] = Tuple.Create(DataType.String, "uri"),
[ typeof(TimeSpan) ] = Tuple.Create(DataType.String, "date-span")
[ typeof(TimeSpan) ] = Tuple.Create(DataType.String, "date-span"),
#if NET6_0_OR_GREATER
[ typeof(DateOnly) ] = Tuple.Create(DataType.String, "date"),
[ typeof(TimeOnly) ] = Tuple.Create(DataType.String, "time")
#endif
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ [ typeof(char) ] = Tuple.Create(DataType.String, (string)null),
[ typeof(DateTime) ] = Tuple.Create(DataType.String, "date-time"),
[ typeof(DateTimeOffset) ] = Tuple.Create(DataType.String, "date-time"),
[ typeof(Guid) ] = Tuple.Create(DataType.String, "uuid"),
[ typeof(Uri) ] = Tuple.Create(DataType.String, "uri")
[ typeof(Uri) ] = Tuple.Create(DataType.String, "uri"),
#if NET6_0_OR_GREATER
[ typeof(DateOnly) ] = Tuple.Create(DataType.String, "date"),
[ typeof(TimeOnly) ] = Tuple.Create(DataType.String, "time")
#endif
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ public void GenerateSchema_GeneratesFileSchema_IfFormFileOrFileResultType(Type t
[InlineData(typeof(DateTimeOffset), "string", "date-time")]
[InlineData(typeof(Guid), "string", "uuid")]
[InlineData(typeof(Uri), "string", "uri")]
[InlineData(typeof(DateOnly), "string", "date")]
[InlineData(typeof(TimeOnly), "string", "time")]
[InlineData(typeof(bool?), "boolean", null)]
[InlineData(typeof(int?), "integer", "int32")]
[InlineData(typeof(DateTime?), "string", "date-time")]
[InlineData(typeof(Guid?), "string", "uuid")]
[InlineData(typeof(DateOnly?), "string", "date")]
[InlineData(typeof(TimeOnly?), "string", "time")]
public void GenerateSchema_GeneratesPrimitiveSchema_IfPrimitiveOrNullablePrimitiveType(
Type type,
string expectedSchemaType,
Expand Down

0 comments on commit a97df7d

Please sign in to comment.