Skip to content

Commit 17d81ef

Browse files
author
bllassit
committed
sample code for TimeSpan
1 parent 814fca1 commit 17d81ef

File tree

72 files changed

+726
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+726
-37
lines changed

samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,10 @@ components:
16421642
example: 2007-12-03T10:15:30+01:00
16431643
format: date-time
16441644
type: string
1645+
duration:
1646+
example: 1.03:14:56.1667
1647+
format: duration
1648+
type: string
16451649
uuid:
16461650
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
16471651
format: uuid
@@ -1668,6 +1672,7 @@ components:
16681672
required:
16691673
- byte
16701674
- date
1675+
- duration
16711676
- number
16721677
- password
16731678
type: object

samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Byte** | **byte[]** | |
88
**Date** | **DateTime** | |
9+
**Duration** | **TimeSpan** | |
910
**Number** | **decimal** | |
1011
**Password** | **string** | |
1112
**Binary** | **System.IO.Stream** | | [optional]

samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
3434
/// </summary>
3535
/// <param name="byte">byte</param>
3636
/// <param name="date">date</param>
37+
/// <param name="duration">duration</param>
3738
/// <param name="number">number</param>
3839
/// <param name="password">password</param>
3940
/// <param name="binary">binary</param>
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
5758
/// <param name="unsignedLong">unsignedLong</param>
5859
/// <param name="uuid">uuid</param>
5960
[JsonConstructor]
60-
public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option<System.IO.Stream> binary = default, Option<DateTime?> dateTime = default, Option<decimal?> @decimal = default, Option<double?> @double = default, Option<float?> @float = default, Option<int?> int32 = default, Option<int?> int32Range = default, Option<long?> int64 = default, Option<long?> int64Negative = default, Option<long?> int64NegativeExclusive = default, Option<long?> int64Positive = default, Option<long?> int64PositiveExclusive = default, Option<int?> integer = default, Option<string> patternWithBackslash = default, Option<string> patternWithDigits = default, Option<string> patternWithDigitsAndDelimiter = default, Option<string> @string = default, Option<uint?> unsignedInteger = default, Option<ulong?> unsignedLong = default, Option<Guid?> uuid = default)
61+
public FormatTest(byte[] @byte, DateTime date, TimeSpan duration, decimal number, string password, Option<System.IO.Stream> binary = default, Option<DateTime?> dateTime = default, Option<decimal?> @decimal = default, Option<double?> @double = default, Option<float?> @float = default, Option<int?> int32 = default, Option<int?> int32Range = default, Option<long?> int64 = default, Option<long?> int64Negative = default, Option<long?> int64NegativeExclusive = default, Option<long?> int64Positive = default, Option<long?> int64PositiveExclusive = default, Option<int?> integer = default, Option<string> patternWithBackslash = default, Option<string> patternWithDigits = default, Option<string> patternWithDigitsAndDelimiter = default, Option<string> @string = default, Option<uint?> unsignedInteger = default, Option<ulong?> unsignedLong = default, Option<Guid?> uuid = default)
6162
{
6263
Byte = @byte;
6364
Date = date;
65+
Duration = duration;
6466
Number = number;
6567
Password = password;
6668
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateTime date, decimal number, string password,
101103
[JsonPropertyName("date")]
102104
public DateTime Date { get; set; }
103105

106+
/// <summary>
107+
/// Gets or Sets Duration
108+
/// </summary>
109+
/* <example>1.03:14:56.1667</example> */
110+
[JsonPropertyName("duration")]
111+
public TimeSpan Duration { get; set; }
112+
104113
/// <summary>
105114
/// Gets or Sets Number
106115
/// </summary>
@@ -394,6 +403,7 @@ public override string ToString()
394403
sb.Append("class FormatTest {\n");
395404
sb.Append(" Byte: ").Append(Byte).Append("\n");
396405
sb.Append(" Date: ").Append(Date).Append("\n");
406+
sb.Append(" Duration: ").Append(Duration).Append("\n");
397407
sb.Append(" Number: ").Append(Number).Append("\n");
398408
sb.Append(" Password: ").Append(Password).Append("\n");
399409
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
626636

627637
Option<byte[]> varByte = default;
628638
Option<DateTime?> date = default;
639+
Option<TimeSpan?> duration = default;
629640
Option<decimal?> number = default;
630641
Option<string> password = default;
631642
Option<System.IO.Stream> binary = default;
@@ -672,6 +683,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
672683
if (utf8JsonReader.TokenType != JsonTokenType.Null)
673684
date = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions));
674685
break;
686+
case "duration":
687+
duration = new Option<TimeSpan?>(utf8JsonReader.GetString());
688+
break;
675689
case "number":
676690
if (utf8JsonReader.TokenType != JsonTokenType.Null)
677691
number = new Option<decimal?>(utf8JsonReader.GetDecimal());
@@ -767,6 +781,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
767781
if (!date.IsSet)
768782
throw new ArgumentException("Property is required for class FormatTest.", nameof(date));
769783

784+
if (!duration.IsSet)
785+
throw new ArgumentException("Property is required for class FormatTest.", nameof(duration));
786+
770787
if (!number.IsSet)
771788
throw new ArgumentException("Property is required for class FormatTest.", nameof(number));
772789

@@ -779,6 +796,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
779796
if (date.IsSet && date.Value == null)
780797
throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest.");
781798

799+
if (duration.IsSet && duration.Value == null)
800+
throw new ArgumentNullException(nameof(duration), "Property is not nullable for class FormatTest.");
801+
782802
if (number.IsSet && number.Value == null)
783803
throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest.");
784804

@@ -845,7 +865,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
845865
if (uuid.IsSet && uuid.Value == null)
846866
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
847867

848-
return new FormatTest(varByte.Value, date.Value.Value, number.Value.Value, password.Value, binary, dateTime, varDecimal, varDouble, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid);
868+
return new FormatTest(varByte.Value, date.Value.Value, duration.Value.Value, number.Value.Value, password.Value, binary, dateTime, varDecimal, varDouble, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid);
849869
}
850870

851871
/// <summary>
@@ -897,6 +917,8 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
897917
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
898918
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
899919

920+
writer.WriteString("duration", formatTest.Duration);
921+
900922
writer.WriteNumber("number", formatTest.Number);
901923

902924
writer.WriteString("password", formatTest.Password);

samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,10 @@ components:
16831683
example: 2007-12-03T10:15:30+01:00
16841684
format: date-time
16851685
type: string
1686+
duration:
1687+
example: 1.03:14:56.1667
1688+
format: duration
1689+
type: string
16861690
uuid:
16871691
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
16881692
format: uuid
@@ -1709,6 +1713,7 @@ components:
17091713
required:
17101714
- byte
17111715
- date
1716+
- duration
17121717
- number
17131718
- password
17141719
type: object

samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Byte** | **byte[]** | |
88
**Date** | **DateTime** | |
9+
**Duration** | **TimeSpan** | |
910
**Number** | **decimal** | |
1011
**Password** | **string** | |
1112
**Binary** | **System.IO.Stream** | | [optional]

samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
3434
/// </summary>
3535
/// <param name="byte">byte</param>
3636
/// <param name="date">date</param>
37+
/// <param name="duration">duration</param>
3738
/// <param name="number">number</param>
3839
/// <param name="password">password</param>
3940
/// <param name="binary">binary</param>
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
5758
/// <param name="unsignedLong">unsignedLong</param>
5859
/// <param name="uuid">uuid</param>
5960
[JsonConstructor]
60-
public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option<System.IO.Stream> binary = default, Option<DateTime?> dateTime = default, Option<decimal?> @decimal = default, Option<double?> @double = default, Option<float?> @float = default, Option<int?> int32 = default, Option<int?> int32Range = default, Option<long?> int64 = default, Option<long?> int64Negative = default, Option<long?> int64NegativeExclusive = default, Option<long?> int64Positive = default, Option<long?> int64PositiveExclusive = default, Option<int?> integer = default, Option<string> patternWithBackslash = default, Option<string> patternWithDigits = default, Option<string> patternWithDigitsAndDelimiter = default, Option<string> @string = default, Option<uint?> unsignedInteger = default, Option<ulong?> unsignedLong = default, Option<Guid?> uuid = default)
61+
public FormatTest(byte[] @byte, DateTime date, TimeSpan duration, decimal number, string password, Option<System.IO.Stream> binary = default, Option<DateTime?> dateTime = default, Option<decimal?> @decimal = default, Option<double?> @double = default, Option<float?> @float = default, Option<int?> int32 = default, Option<int?> int32Range = default, Option<long?> int64 = default, Option<long?> int64Negative = default, Option<long?> int64NegativeExclusive = default, Option<long?> int64Positive = default, Option<long?> int64PositiveExclusive = default, Option<int?> integer = default, Option<string> patternWithBackslash = default, Option<string> patternWithDigits = default, Option<string> patternWithDigitsAndDelimiter = default, Option<string> @string = default, Option<uint?> unsignedInteger = default, Option<ulong?> unsignedLong = default, Option<Guid?> uuid = default)
6162
{
6263
Byte = @byte;
6364
Date = date;
65+
Duration = duration;
6466
Number = number;
6567
Password = password;
6668
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateTime date, decimal number, string password,
101103
[JsonPropertyName("date")]
102104
public DateTime Date { get; set; }
103105

106+
/// <summary>
107+
/// Gets or Sets Duration
108+
/// </summary>
109+
/* <example>1.03:14:56.1667</example> */
110+
[JsonPropertyName("duration")]
111+
public TimeSpan Duration { get; set; }
112+
104113
/// <summary>
105114
/// Gets or Sets Number
106115
/// </summary>
@@ -394,6 +403,7 @@ public override string ToString()
394403
sb.Append("class FormatTest {\n");
395404
sb.Append(" Byte: ").Append(Byte).Append("\n");
396405
sb.Append(" Date: ").Append(Date).Append("\n");
406+
sb.Append(" Duration: ").Append(Duration).Append("\n");
397407
sb.Append(" Number: ").Append(Number).Append("\n");
398408
sb.Append(" Password: ").Append(Password).Append("\n");
399409
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
626636

627637
Option<byte[]> varByte = default;
628638
Option<DateTime?> date = default;
639+
Option<TimeSpan?> duration = default;
629640
Option<decimal?> number = default;
630641
Option<string> password = default;
631642
Option<System.IO.Stream> binary = default;
@@ -672,6 +683,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
672683
if (utf8JsonReader.TokenType != JsonTokenType.Null)
673684
date = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions));
674685
break;
686+
case "duration":
687+
duration = new Option<TimeSpan?>(utf8JsonReader.GetString());
688+
break;
675689
case "number":
676690
if (utf8JsonReader.TokenType != JsonTokenType.Null)
677691
number = new Option<decimal?>(utf8JsonReader.GetDecimal());
@@ -767,6 +781,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
767781
if (!date.IsSet)
768782
throw new ArgumentException("Property is required for class FormatTest.", nameof(date));
769783

784+
if (!duration.IsSet)
785+
throw new ArgumentException("Property is required for class FormatTest.", nameof(duration));
786+
770787
if (!number.IsSet)
771788
throw new ArgumentException("Property is required for class FormatTest.", nameof(number));
772789

@@ -779,6 +796,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
779796
if (date.IsSet && date.Value == null)
780797
throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest.");
781798

799+
if (duration.IsSet && duration.Value == null)
800+
throw new ArgumentNullException(nameof(duration), "Property is not nullable for class FormatTest.");
801+
782802
if (number.IsSet && number.Value == null)
783803
throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest.");
784804

@@ -845,7 +865,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
845865
if (uuid.IsSet && uuid.Value == null)
846866
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
847867

848-
return new FormatTest(varByte.Value, date.Value.Value, number.Value.Value, password.Value, binary, dateTime, varDecimal, varDouble, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid);
868+
return new FormatTest(varByte.Value, date.Value.Value, duration.Value.Value, number.Value.Value, password.Value, binary, dateTime, varDecimal, varDouble, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid);
849869
}
850870

851871
/// <summary>
@@ -897,6 +917,8 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
897917
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
898918
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
899919

920+
writer.WriteString("duration", formatTest.Duration);
921+
900922
writer.WriteNumber("number", formatTest.Number);
901923

902924
writer.WriteString("password", formatTest.Password);

samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,10 @@ components:
16421642
example: 2007-12-03T10:15:30+01:00
16431643
format: date-time
16441644
type: string
1645+
duration:
1646+
example: 1.03:14:56.1667
1647+
format: duration
1648+
type: string
16451649
uuid:
16461650
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
16471651
format: uuid
@@ -1668,6 +1672,7 @@ components:
16681672
required:
16691673
- byte
16701674
- date
1675+
- duration
16711676
- number
16721677
- password
16731678
type: object

samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/FormatTest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Byte** | **byte[]** | |
88
**Date** | **DateTime** | |
9+
**Duration** | **TimeSpan** | |
910
**Number** | **decimal** | |
1011
**Password** | **string** | |
1112
**Binary** | **System.IO.Stream** | | [optional]

0 commit comments

Comments
 (0)