From 8a00ec2121dc3a3beafd874c1ca0eb775802a384 Mon Sep 17 00:00:00 2001 From: Sophie Dasinger Date: Tue, 4 Feb 2020 21:07:30 -0800 Subject: [PATCH 1/2] Add TimeSpan handling --- .../Extensions/TypeExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs b/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs index 42173e0..7568abd 100644 --- a/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs +++ b/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs @@ -31,6 +31,7 @@ public static class TypeExtensions [typeof(decimal)] = () => new OpenApiSchema {Type = "number", Format = "double"}, [typeof(DateTime)] = () => new OpenApiSchema {Type = "string", Format = "date-time"}, [typeof(DateTimeOffset)] = () => new OpenApiSchema {Type = "string", Format = "date-time"}, + [typeof(TimeSpan)] = () => new OpenApiSchema {Type = "string"}, [typeof(Guid)] = () => new OpenApiSchema {Type = "string", Format = "uuid"}, [typeof(char)] = () => new OpenApiSchema {Type = "string"}, @@ -45,6 +46,7 @@ public static class TypeExtensions [typeof(double?)] = () => new OpenApiSchema {Type = "number", Format = "double", Nullable = true}, [typeof(decimal?)] = () => new OpenApiSchema {Type = "number", Format = "double", Nullable = true}, [typeof(DateTime?)] = () => new OpenApiSchema {Type = "string", Format = "date-time", Nullable = true}, + [typeof(TimeSpan?)] = () => new OpenApiSchema {Type = "string"}, [typeof(DateTimeOffset?)] = () => new OpenApiSchema {Type = "string", Format = "date-time", Nullable = true}, [typeof(Guid?)] = () => new OpenApiSchema {Type = "string", Format = "uuid", Nullable = true}, From 5b2e46222a0ddcb2faac062b7ad2a3672106abb5 Mon Sep 17 00:00:00 2001 From: Sophie Dasinger Date: Tue, 4 Feb 2020 21:13:55 -0800 Subject: [PATCH 2/2] Add nullable=true --- .../Extensions/TypeExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs b/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs index 7568abd..3141143 100644 --- a/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs +++ b/src/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration/Extensions/TypeExtensions.cs @@ -46,7 +46,7 @@ public static class TypeExtensions [typeof(double?)] = () => new OpenApiSchema {Type = "number", Format = "double", Nullable = true}, [typeof(decimal?)] = () => new OpenApiSchema {Type = "number", Format = "double", Nullable = true}, [typeof(DateTime?)] = () => new OpenApiSchema {Type = "string", Format = "date-time", Nullable = true}, - [typeof(TimeSpan?)] = () => new OpenApiSchema {Type = "string"}, + [typeof(TimeSpan?)] = () => new OpenApiSchema {Type = "string", Nullable = true}, [typeof(DateTimeOffset?)] = () => new OpenApiSchema {Type = "string", Format = "date-time", Nullable = true}, [typeof(Guid?)] = () => new OpenApiSchema {Type = "string", Format = "uuid", Nullable = true},