Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Added TimeSpan support #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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"},

Expand All @@ -47,6 +48,7 @@ public static class TypeExtensions
[typeof(DateTime?)] = () => new OpenApiSchema {Type = "string", Format = "date-time", Nullable = true},
[typeof(DateTimeOffset?)] = () =>
new OpenApiSchema {Type = "string", Format = "date-time", Nullable = true},
[typeof(TimeSpan?)] = () => new OpenApiSchema { Type = "string", Nullable = true },
[typeof(Guid?)] = () => new OpenApiSchema {Type = "string", Format = "uuid", Nullable = true},
[typeof(char?)] = () => new OpenApiSchema {Type = "string", Nullable = true},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------------------------------------------------------------

using Newtonsoft.Json;
using System;

namespace Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration.Tests.Contracts
{
Expand Down Expand Up @@ -53,5 +54,11 @@ public sealed class SampleObject1
/// </summary>
[JsonProperty(PropertyName = "samplePropertyEnum", Required = Required.Always)]
public SampleEnum1 SamplePropertyEnum { get; set; }

/// <summary>
/// Gets or sets the sample timespan
/// </summary>
[JsonProperty(PropertyName = "samplePropertyTimespan", Required = Required.Always)]
public TimeSpan SamplePropertyTimespan { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -667,6 +668,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -187,6 +188,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -187,6 +188,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -739,6 +740,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -203,6 +204,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -203,6 +204,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -254,6 +255,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -129,6 +130,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -245,6 +246,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
}
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -677,6 +678,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -676,6 +677,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -670,6 +671,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -677,6 +678,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -593,6 +594,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -606,6 +607,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@
"required": [
"samplePropertyString3",
"samplePropertyString4",
"samplePropertyEnum"
"samplePropertyEnum",
"samplePropertyTimespan"
],
"type": "object",
"properties": {
Expand Down Expand Up @@ -651,6 +652,10 @@
],
"type": "string",
"description": "Gets or sets the sample property enum"
},
"samplePropertyTimespan": {
"type": "string",
"description": "Gets or sets the sample timespan"
}
}
},
Expand Down
Loading