diff --git a/docs/generators/aspnet-fastendpoints.md b/docs/generators/aspnet-fastendpoints.md
index 75a31639bdba..426314b2e5b5 100644
--- a/docs/generators/aspnet-fastendpoints.md
+++ b/docs/generators/aspnet-fastendpoints.md
@@ -77,6 +77,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
Object
String
System.IO.Stream
+TimeSpan
+TimeSpan?
bool
bool?
byte[]
diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md
index 5d0ca08085dc..ce3c0d08c86c 100644
--- a/docs/generators/aspnetcore.md
+++ b/docs/generators/aspnetcore.md
@@ -95,6 +95,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
Object
String
System.IO.Stream
+TimeSpan
+TimeSpan?
bool
bool?
byte[]
diff --git a/docs/generators/csharp-functions.md b/docs/generators/csharp-functions.md
index 8e6a6a98726a..48b4a492ef02 100644
--- a/docs/generators/csharp-functions.md
+++ b/docs/generators/csharp-functions.md
@@ -87,6 +87,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
Object
String
System.IO.Stream
+TimeSpan
+TimeSpan?
bool
bool?
byte[]
diff --git a/docs/generators/csharp.md b/docs/generators/csharp.md
index ef482820cef6..4b4b601be3fe 100644
--- a/docs/generators/csharp.md
+++ b/docs/generators/csharp.md
@@ -96,6 +96,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
Object
String
System.IO.Stream
+TimeSpan
+TimeSpan?
bool
bool?
byte[]
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
index 5303598ed7a6..ca63ccab4e64 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
@@ -125,7 +125,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public String arrayModelType;
public boolean isAlias; // Is this effectively an alias of another simple type
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime,
- isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean, isFreeFormObject;
+ isDuration, isDecimal, isShort, isUnboundedInteger, isPrimitiveType, isBoolean, isFreeFormObject;
private boolean additionalPropertiesIsAnyType;
public List vars = new ArrayList<>(); // all properties (without parent's properties)
@Getter @Setter
@@ -544,6 +544,16 @@ public void setIsDateTime(boolean isDateTime) {
this.isDateTime = isDateTime;
}
+ @Override
+ public boolean getIsDuration() {
+ return isDuration;
+ }
+
+ @Override
+ public void setIsDuration(boolean isDuration) {
+ this.isDuration = isDuration;
+ }
+
@Override
public boolean getIsMap() {
return isMap;
@@ -878,6 +888,7 @@ public boolean equals(Object o) {
isDouble == that.isDouble &&
isDate == that.isDate &&
isDateTime == that.isDateTime &&
+ isDuration == that.isDuration &&
hasVars == that.hasVars &&
emptyVars == that.emptyVars &&
hasMoreModels == that.hasMoreModels &&
@@ -979,7 +990,7 @@ public int hashCode() {
getDescription(), getClassVarName(), getModelJson(), getDataType(), getXmlPrefix(), getXmlNamespace(),
getXmlName(), getClassFilename(), getUnescapedDescription(), getDiscriminator(), getDefaultValue(),
getArrayModelType(), isAlias, isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble,
- isDate, isDateTime, isNull, hasValidation, isShort, isUnboundedInteger, isBoolean,
+ isDate, isDateTime, isDuration, isNull, hasValidation, isShort, isUnboundedInteger, isBoolean,
getVars(), getAllVars(), getNonNullableVars(), getRequiredVars(), getOptionalVars(), getReadOnlyVars(), getReadWriteVars(),
getParentVars(), getAllowableValues(), getMandatory(), getAllMandatory(), getImports(), hasVars,
isEmptyVars(), hasMoreModels, hasEnums, isEnum, isNullable, hasRequired, hasOptional, isArray,
@@ -1035,6 +1046,7 @@ public String toString() {
sb.append(", isDouble=").append(isDouble);
sb.append(", isDate=").append(isDate);
sb.append(", isDateTime=").append(isDateTime);
+ sb.append(", isDuration=").append(isDuration);
sb.append(", vars=").append(vars);
sb.append(", allVars=").append(allVars);
sb.append(", nonNullableVars=").append(nonNullableVars);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
index 0497bf49c55b..ed75caea9ae9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
@@ -48,7 +48,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public Map examples;
public String jsonSchema;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
- isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
+ isBoolean, isDate, isDateTime, isDuration, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
public boolean isArray, isMap;
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
public boolean isOptional;
@@ -259,6 +259,7 @@ public CodegenParameter copy() {
output.isBoolean = this.isBoolean;
output.isDate = this.isDate;
output.isDateTime = this.isDateTime;
+ output.isDuration = this.isDuration;
output.isUuid = this.isUuid;
output.isUri = this.isUri;
output.isEmail = this.isEmail;
@@ -286,7 +287,7 @@ public int hashCode() {
unescapedDescription, baseType, containerType, containerTypeMapped, defaultValue,
enumDefaultValue, enumName, style, isDeepObject, isMatrix, isAllowEmptyValue, example, examples,
jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal,
- isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword,
+ isByteArray, isBinary, isBoolean, isDate, isDateTime, isDuration, isUuid, isUri, isEmail, isPassword,
isFreeFormObject, isAnyType, isArray, isMap, isOptional, isFile, isEnum, isEnumRef, _enum, allowableValues,
items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation,
getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(),
@@ -329,6 +330,7 @@ public boolean equals(Object o) {
isBoolean == that.isBoolean &&
isDate == that.isDate &&
isDateTime == that.isDateTime &&
+ isDuration == that.isDuration &&
isUuid == that.isUuid &&
isUri == that.isUri &&
isEmail == that.isEmail &&
@@ -463,6 +465,7 @@ public String toString() {
sb.append(", isBoolean=").append(isBoolean);
sb.append(", isDate=").append(isDate);
sb.append(", isDateTime=").append(isDateTime);
+ sb.append(", isDuration=").append(isDuration);
sb.append(", isUuid=").append(isUuid);
sb.append(", isUri=").append(isUri);
sb.append(", isEmail=").append(isEmail);
@@ -754,6 +757,16 @@ public void setIsDateTime(boolean isDateTime) {
this.isDateTime = isDateTime;
}
+ @Override
+ public boolean getIsDuration() {
+ return isDuration;
+ }
+
+ @Override
+ public void setIsDuration(boolean isDuration) {
+ this.isDuration = isDuration;
+ }
+
@Override
public boolean getIsMap() {
return isMap;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
index dddec1c620c6..e6538091693f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
@@ -159,6 +159,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean isBoolean;
public boolean isDate; // full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21
public boolean isDateTime; // the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z
+ public boolean isDuration;
public boolean isUuid;
public boolean isUri;
public boolean isEmail;
@@ -488,6 +489,16 @@ public void setIsDateTime(boolean isDateTime) {
this.isDateTime = isDateTime;
}
+ @Override
+ public boolean getIsDuration() {
+ return isDuration;
+ }
+
+ @Override
+ public void setIsDuration(boolean isDuration) {
+ this.isDuration = isDuration;
+ }
+
@Override
public boolean getIsMap() {
return isMap;
@@ -1014,6 +1025,7 @@ public String toString() {
sb.append(", isBoolean=").append(isBoolean);
sb.append(", isDate=").append(isDate);
sb.append(", isDateTime=").append(isDateTime);
+ sb.append(", isDuration=").append(isDuration);
sb.append(", isUuid=").append(isUuid);
sb.append(", isUri=").append(isUri);
sb.append(", isEmail=").append(isEmail);
@@ -1111,6 +1123,7 @@ public boolean equals(Object o) {
isBoolean == that.isBoolean &&
isDate == that.isDate &&
isDateTime == that.isDateTime &&
+ isDuration == that.isDuration &&
isUuid == that.isUuid &&
isUri == that.isUri &&
isEmail == that.isEmail &&
@@ -1210,7 +1223,7 @@ public int hashCode() {
exclusiveMinimum, exclusiveMaximum, required, deprecated,
hasMoreNonReadOnly, isPrimitiveType, isModel, isContainer, isString, isNumeric,
isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isFile,
- isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
+ isBoolean, isDate, isDateTime, isDuration, isUuid, isUri, isEmail, isPassword, isFreeFormObject,
isArray, isMap, isOptional, isEnum, isInnerEnum, isEnumRef, isAnyType, isReadOnly, isWriteOnly, isNullable, isShort,
isUnboundedInteger, isSelfReference, isCircularReference, isDiscriminator, isNew, isOverridden, _enum,
allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars,
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
index 9c8dc08aaa5f..37dc51c3f58b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
@@ -53,6 +53,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public boolean isBoolean;
public boolean isDate;
public boolean isDateTime;
+ public boolean isDuration;
public boolean isUuid;
public boolean isEmail;
public boolean isPassword;
@@ -109,7 +110,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public int hashCode() {
return Objects.hash(headers, code, message, examples, dataType, baseType, containerType, containerTypeMapped, hasHeaders,
isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBoolean, isDate,
- isDateTime, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
+ isDateTime, isDuration, isUuid, isEmail, isPassword, isModel, isFreeFormObject, isAnyType, isDefault, simpleType, primitiveType,
isMap, isOptional, isArray, isBinary, isFile, schema, jsonSchema, vendorExtensions, items, additionalProperties,
vars, requiredVars, isNull, isVoid, hasValidation, isShort, isUnboundedInteger,
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
@@ -139,6 +140,7 @@ public boolean equals(Object o) {
isBoolean == that.isBoolean &&
isDate == that.isDate &&
isDateTime == that.isDateTime &&
+ isDuration == that.isDuration &&
isUuid == that.isUuid &&
isEmail == that.isEmail &&
isPassword == that.isPassword &&
@@ -485,6 +487,16 @@ public void setIsDateTime(boolean isDateTime) {
this.isDateTime = isDateTime;
}
+ @Override
+ public boolean getIsDuration() {
+ return isDuration;
+ }
+
+ @Override
+ public void setIsDuration(boolean isDuration) {
+ this.isDuration = isDuration;
+ }
+
@Override
public boolean getIsMap() {
return isMap;
@@ -586,6 +598,7 @@ public String toString() {
sb.append(", isBoolean=").append(isBoolean);
sb.append(", isDate=").append(isDate);
sb.append(", isDateTime=").append(isDateTime);
+ sb.append(", isDuration=").append(isDuration);
sb.append(", isUuid=").append(isUuid);
sb.append(", isEmail=").append(isEmail);
sb.append(", isPassword=").append(isPassword);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
index 47fef0eddf5f..5852deae62e5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
@@ -101,6 +101,10 @@ public interface IJsonSchemaValidationProperties {
void setIsDateTime(boolean isDateTime);
+ boolean getIsDuration();
+
+ void setIsDuration(boolean isDuration);
+
// true when the schema type is object
boolean getIsMap();
@@ -312,6 +316,8 @@ default void setTypeProperties(Schema p, OpenAPI openAPI) {
;
} else if (ModelUtils.isDateTimeSchema(p)) {
;
+ } else if (ModelUtils.isDurationSchema(p)) {
+ ;
} else if (ModelUtils.isDecimalSchema(p)) { // type: string, format: number
;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
index 02043c013d9a..73ee05931cf8 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
@@ -195,6 +195,8 @@ public AbstractCSharpCodegen() {
"DateTimeOffset",
"DateOnly?",
"DateOnly",
+ "TimeSpan?",
+ "TimeSpan",
"Boolean",
"Double",
"Decimal",
@@ -1427,6 +1429,10 @@ public String toDefaultValue(Schema p) {
if (p.getDefault() != null) {
return "\"" + p.getDefault().toString() + "\"";
}
+ } else if (ModelUtils.isDurationSchema(p)) {
+ if (p.getDefault() != null) {
+ return "\"" + p.getDefault().toString() + "\"";
+ }
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
if (ModelUtils.isFloatSchema(p)) { // float
@@ -1986,7 +1992,7 @@ protected Set getNullableTypes() {
}
protected Set getValueTypes() {
- return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double", "DateTime", "DateOnly", "DateTimeOffset", "Guid"));
+ return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double", "DateTime", "DateOnly", "DateTimeOffset", "TimeSpan", "Guid"));
}
protected void setTypeMapping() {
@@ -2006,6 +2012,7 @@ protected void setTypeMapping() {
typeMapping.put("BigDecimal", "decimal");
typeMapping.put("DateTime", this.useDateTimeOffsetFlag ? "DateTimeOffset" : "DateTime");
typeMapping.put("date", this.useDateOnly() ? "DateOnly" : "DateTime");
+ typeMapping.put("duration", "TimeSpan");
typeMapping.put("file", "System.IO.Stream");
typeMapping.put("array", "List");
typeMapping.put("list", "List");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java
index 60e8fb231011..d60c4b8bbb1b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java
@@ -327,7 +327,7 @@ private void addCentralizedPackageManagementOption(){
@Override
protected Set getNullableTypes() {
return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double",
- "DateTime", "DateOnly", "DateTimeOffset", "Guid"));
+ "DateTime", "DateOnly", "DateTimeOffset", "TimeSpan", "Guid"));
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpFunctionsServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpFunctionsServerCodegen.java
index 61f4ef6bae87..bab191cea1fc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpFunctionsServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpFunctionsServerCodegen.java
@@ -260,7 +260,7 @@ public CSharpFunctionsServerCodegen() {
@Override
protected Set getNullableTypes() {
return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double",
- "DateTime", "DateTimeOffset", "Guid"));
+ "DateTime", "DateTimeOffset", "TimeSpan", "Guid"));
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpReducedClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpReducedClientCodegen.java
index f0706780a2ec..dd158497513b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpReducedClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpReducedClientCodegen.java
@@ -306,7 +306,7 @@ public CSharpReducedClientCodegen() {
@Override
protected Set getNullableTypes() {
return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double",
- "DateTime", "DateTimeOffset", "Guid"));
+ "DateTime", "DateTimeOffset", "TimeSpan", "Guid"));
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
index d9f77b3f5731..a2047b0e5a4e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
@@ -692,6 +692,12 @@ public static boolean isDateTimeSchema(Schema schema) {
&& SchemaTypeUtil.DATE_TIME_FORMAT.equals(schema.getFormat()));
}
+ public static boolean isDurationSchema(Schema schema) {
+ // format: duration (todo: swagger parser does not support duration)
+ return (SchemaTypeUtil.STRING_TYPE.equals(getType(schema))
+ && "duration".equals(schema.getFormat()));
+ }
+
public static boolean isPasswordSchema(Schema schema) {
return (schema instanceof PasswordSchema) ||
// double
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache
index 1405dd77c79d..77609e770f78 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache
@@ -226,6 +226,10 @@
if (utf8JsonReader.TokenType != JsonTokenType.Null)
{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} = {{>OptionProperty}}JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
{{/isDateTime}}
+ {{#isDuration}}
+ if (utf8JsonReader.TokenType != JsonTokenType.Null)
+ {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} = {{>OptionProperty}}JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
+ {{/isDuration}}
{{#isEnum}}
{{^isMap}}
{{#isNumeric}}
diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index 48b55285aa4b..4b69f27d3a71 100644
--- a/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/csharp-netcore/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -1592,6 +1592,10 @@ components:
type: string
format: date-time
example: '2007-12-03T10:15:30+01:00'
+ duration:
+ type: string
+ format: duration
+ example: '1.03:14:56.1667'
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
index 8828ce072268..b551c197ce06 100644
--- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml
@@ -1658,6 +1658,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -1718,6 +1719,10 @@ components:
type: string
format: date-time
example: '2007-12-03T10:15:30+01:00'
+ duration:
+ type: string
+ format: duration
+ example: '1.03:14:56.1667'
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index 5b726d69b9f6..bd5b4f8640c0 100644
--- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -1672,6 +1672,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -1750,6 +1751,10 @@ components:
type: string
format: date-time
example: '2007-12-03T10:15:30+01:00'
+ duration:
+ type: string
+ format: duration
+ example: '1.03:14:56.1667'
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-echo.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-echo.yaml
index dea319154236..31df8f2c504b 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-echo.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-echo.yaml
@@ -1549,6 +1549,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -1595,6 +1596,9 @@ components:
dateTime:
type: string
format: date-time
+ duration:
+ type: string
+ format: duration
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
index b3727634f1bb..553d87336e7b 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
@@ -1520,6 +1520,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -1563,6 +1564,9 @@ components:
dateTime:
type: string
format: date-time
+ duration:
+ type: string
+ format: duration
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
index e4957b4e19d1..189a0eeb007d 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -1598,6 +1598,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -1644,6 +1645,9 @@ components:
dateTime:
type: string
format: date-time
+ duration:
+ type: string
+ format: duration
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml b/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml
index cc4f62fa3972..0447cb5d8e56 100644
--- a/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml
@@ -1525,6 +1525,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -1571,6 +1572,9 @@ components:
dateTime:
type: string
format: date-time
+ duration:
+ type: string
+ format: duration
uuid:
type: string
format: uuid
diff --git a/modules/openapi-generator/src/test/resources/3_0/unsigned-test.yaml b/modules/openapi-generator/src/test/resources/3_0/unsigned-test.yaml
index 2c7073528db4..d2e806ddfd12 100644
--- a/modules/openapi-generator/src/test/resources/3_0/unsigned-test.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/unsigned-test.yaml
@@ -97,6 +97,7 @@ components:
- number
- byte
- date
+ - duration
- password
properties:
integer:
@@ -157,6 +158,10 @@ components:
type: string
format: date-time
example: '2007-12-03T10:15:30+01:00'
+ duration:
+ type: string
+ format: duration
+ example: '1.03:14:56.1667'
uuid:
type: string
format: uuid
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml
index 3c7d8aa3954b..ab68fdb093f5 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml
@@ -1642,6 +1642,10 @@ components:
example: 2007-12-03T10:15:30+01:00
format: date-time
type: string
+ duration:
+ example: 1.03:14:56.1667
+ format: duration
+ type: string
uuid:
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
format: uuid
@@ -1668,6 +1672,7 @@ components:
required:
- byte
- date
+ - duration
- number
- password
type: object
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md
index 5983bc096900..6cdfcb9a6a07 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Byte** | **byte[]** | |
**Date** | **DateTime** | |
+**Duration** | **TimeSpan** | |
**Number** | **decimal** | |
**Password** | **string** | |
**Binary** | **System.IO.Stream** | | [optional]
diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 86d63c7ac5f6..4c8452c219e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
///
/// byte
/// date
+ /// duration
/// number
/// password
/// binary
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
/// unsignedLong
/// uuid
[JsonConstructor]
- public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
+ public FormatTest(byte[] @byte, DateTime date, TimeSpan duration, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
{
Byte = @byte;
Date = date;
+ Duration = duration;
Number = number;
Password = password;
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateTime date, decimal number, string password,
[JsonPropertyName("date")]
public DateTime Date { get; set; }
+ ///
+ /// Gets or Sets Duration
+ ///
+ /* 1.03:14:56.1667 */
+ [JsonPropertyName("duration")]
+ public TimeSpan Duration { get; set; }
+
///
/// Gets or Sets Number
///
@@ -394,6 +403,7 @@ public override string ToString()
sb.Append("class FormatTest {\n");
sb.Append(" Byte: ").Append(Byte).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
+ sb.Append(" Duration: ").Append(Duration).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
Option varByte = default;
Option date = default;
+ Option duration = default;
Option number = default;
Option password = default;
Option binary = default;
@@ -672,6 +683,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (utf8JsonReader.TokenType != JsonTokenType.Null)
date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
break;
+ case "duration":
+ duration = new Option(utf8JsonReader.GetString());
+ break;
case "number":
if (utf8JsonReader.TokenType != JsonTokenType.Null)
number = new Option(utf8JsonReader.GetDecimal());
@@ -767,6 +781,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (!date.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(date));
+ if (!duration.IsSet)
+ throw new ArgumentException("Property is required for class FormatTest.", nameof(duration));
+
if (!number.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(number));
@@ -779,6 +796,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (date.IsSet && date.Value == null)
throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest.");
+ if (duration.IsSet && duration.Value == null)
+ throw new ArgumentNullException(nameof(duration), "Property is not nullable for class FormatTest.");
+
if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest.");
@@ -845,7 +865,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (uuid.IsSet && uuid.Value == null)
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
- 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);
+ 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);
}
///
@@ -897,6 +917,8 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
+ writer.WriteString("duration", formatTest.Duration);
+
writer.WriteNumber("number", formatTest.Number);
writer.WriteString("password", formatTest.Password);
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml
index 6a83f7a1e484..7bcb600e8e83 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml
@@ -1683,6 +1683,10 @@ components:
example: 2007-12-03T10:15:30+01:00
format: date-time
type: string
+ duration:
+ example: 1.03:14:56.1667
+ format: duration
+ type: string
uuid:
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
format: uuid
@@ -1709,6 +1713,7 @@ components:
required:
- byte
- date
+ - duration
- number
- password
type: object
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md
index 5983bc096900..6cdfcb9a6a07 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Byte** | **byte[]** | |
**Date** | **DateTime** | |
+**Duration** | **TimeSpan** | |
**Number** | **decimal** | |
**Password** | **string** | |
**Binary** | **System.IO.Stream** | | [optional]
diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 86d63c7ac5f6..4c8452c219e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
///
/// byte
/// date
+ /// duration
/// number
/// password
/// binary
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
/// unsignedLong
/// uuid
[JsonConstructor]
- public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
+ public FormatTest(byte[] @byte, DateTime date, TimeSpan duration, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
{
Byte = @byte;
Date = date;
+ Duration = duration;
Number = number;
Password = password;
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateTime date, decimal number, string password,
[JsonPropertyName("date")]
public DateTime Date { get; set; }
+ ///
+ /// Gets or Sets Duration
+ ///
+ /* 1.03:14:56.1667 */
+ [JsonPropertyName("duration")]
+ public TimeSpan Duration { get; set; }
+
///
/// Gets or Sets Number
///
@@ -394,6 +403,7 @@ public override string ToString()
sb.Append("class FormatTest {\n");
sb.Append(" Byte: ").Append(Byte).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
+ sb.Append(" Duration: ").Append(Duration).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
Option varByte = default;
Option date = default;
+ Option duration = default;
Option number = default;
Option password = default;
Option binary = default;
@@ -672,6 +683,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (utf8JsonReader.TokenType != JsonTokenType.Null)
date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
break;
+ case "duration":
+ duration = new Option(utf8JsonReader.GetString());
+ break;
case "number":
if (utf8JsonReader.TokenType != JsonTokenType.Null)
number = new Option(utf8JsonReader.GetDecimal());
@@ -767,6 +781,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (!date.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(date));
+ if (!duration.IsSet)
+ throw new ArgumentException("Property is required for class FormatTest.", nameof(duration));
+
if (!number.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(number));
@@ -779,6 +796,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (date.IsSet && date.Value == null)
throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest.");
+ if (duration.IsSet && duration.Value == null)
+ throw new ArgumentNullException(nameof(duration), "Property is not nullable for class FormatTest.");
+
if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest.");
@@ -845,7 +865,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (uuid.IsSet && uuid.Value == null)
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
- 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);
+ 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);
}
///
@@ -897,6 +917,8 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
+ writer.WriteString("duration", formatTest.Duration);
+
writer.WriteNumber("number", formatTest.Number);
writer.WriteString("password", formatTest.Password);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml
index 3c7d8aa3954b..ab68fdb093f5 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml
@@ -1642,6 +1642,10 @@ components:
example: 2007-12-03T10:15:30+01:00
format: date-time
type: string
+ duration:
+ example: 1.03:14:56.1667
+ format: duration
+ type: string
uuid:
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
format: uuid
@@ -1668,6 +1672,7 @@ components:
required:
- byte
- date
+ - duration
- number
- password
type: object
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/FormatTest.md
index 5983bc096900..6cdfcb9a6a07 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/FormatTest.md
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/FormatTest.md
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Byte** | **byte[]** | |
**Date** | **DateTime** | |
+**Duration** | **TimeSpan** | |
**Number** | **decimal** | |
**Password** | **string** | |
**Binary** | **System.IO.Stream** | | [optional]
diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 86d63c7ac5f6..4c8452c219e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
///
/// byte
/// date
+ /// duration
/// number
/// password
/// binary
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
/// unsignedLong
/// uuid
[JsonConstructor]
- public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
+ public FormatTest(byte[] @byte, DateTime date, TimeSpan duration, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
{
Byte = @byte;
Date = date;
+ Duration = duration;
Number = number;
Password = password;
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateTime date, decimal number, string password,
[JsonPropertyName("date")]
public DateTime Date { get; set; }
+ ///
+ /// Gets or Sets Duration
+ ///
+ /* 1.03:14:56.1667 */
+ [JsonPropertyName("duration")]
+ public TimeSpan Duration { get; set; }
+
///
/// Gets or Sets Number
///
@@ -394,6 +403,7 @@ public override string ToString()
sb.Append("class FormatTest {\n");
sb.Append(" Byte: ").Append(Byte).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
+ sb.Append(" Duration: ").Append(Duration).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
Option varByte = default;
Option date = default;
+ Option duration = default;
Option number = default;
Option password = default;
Option binary = default;
@@ -672,6 +683,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (utf8JsonReader.TokenType != JsonTokenType.Null)
date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
break;
+ case "duration":
+ duration = new Option(utf8JsonReader.GetString());
+ break;
case "number":
if (utf8JsonReader.TokenType != JsonTokenType.Null)
number = new Option(utf8JsonReader.GetDecimal());
@@ -767,6 +781,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (!date.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(date));
+ if (!duration.IsSet)
+ throw new ArgumentException("Property is required for class FormatTest.", nameof(duration));
+
if (!number.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(number));
@@ -779,6 +796,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (date.IsSet && date.Value == null)
throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest.");
+ if (duration.IsSet && duration.Value == null)
+ throw new ArgumentNullException(nameof(duration), "Property is not nullable for class FormatTest.");
+
if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest.");
@@ -845,7 +865,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (uuid.IsSet && uuid.Value == null)
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
- 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);
+ 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);
}
///
@@ -897,6 +917,8 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
+ writer.WriteString("duration", formatTest.Duration);
+
writer.WriteNumber("number", formatTest.Number);
writer.WriteString("password", formatTest.Password);
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml
index 6a83f7a1e484..7bcb600e8e83 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml
@@ -1683,6 +1683,10 @@ components:
example: 2007-12-03T10:15:30+01:00
format: date-time
type: string
+ duration:
+ example: 1.03:14:56.1667
+ format: duration
+ type: string
uuid:
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
format: uuid
@@ -1709,6 +1713,7 @@ components:
required:
- byte
- date
+ - duration
- number
- password
type: object
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/FormatTest.md
index 5983bc096900..6cdfcb9a6a07 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/FormatTest.md
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/FormatTest.md
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Byte** | **byte[]** | |
**Date** | **DateTime** | |
+**Duration** | **TimeSpan** | |
**Number** | **decimal** | |
**Password** | **string** | |
**Binary** | **System.IO.Stream** | | [optional]
diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
index 86d63c7ac5f6..4c8452c219e0 100644
--- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
///
/// byte
/// date
+ /// duration
/// number
/// password
/// binary
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
/// unsignedLong
/// uuid
[JsonConstructor]
- public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
+ public FormatTest(byte[] @byte, DateTime date, TimeSpan duration, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
{
Byte = @byte;
Date = date;
+ Duration = duration;
Number = number;
Password = password;
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateTime date, decimal number, string password,
[JsonPropertyName("date")]
public DateTime Date { get; set; }
+ ///
+ /// Gets or Sets Duration
+ ///
+ /* 1.03:14:56.1667 */
+ [JsonPropertyName("duration")]
+ public TimeSpan Duration { get; set; }
+
///
/// Gets or Sets Number
///
@@ -394,6 +403,7 @@ public override string ToString()
sb.Append("class FormatTest {\n");
sb.Append(" Byte: ").Append(Byte).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
+ sb.Append(" Duration: ").Append(Duration).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
Option varByte = default;
Option date = default;
+ Option duration = default;
Option number = default;
Option password = default;
Option binary = default;
@@ -672,6 +683,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (utf8JsonReader.TokenType != JsonTokenType.Null)
date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
break;
+ case "duration":
+ duration = new Option(utf8JsonReader.GetString());
+ break;
case "number":
if (utf8JsonReader.TokenType != JsonTokenType.Null)
number = new Option(utf8JsonReader.GetDecimal());
@@ -767,6 +781,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (!date.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(date));
+ if (!duration.IsSet)
+ throw new ArgumentException("Property is required for class FormatTest.", nameof(duration));
+
if (!number.IsSet)
throw new ArgumentException("Property is required for class FormatTest.", nameof(number));
@@ -779,6 +796,9 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (date.IsSet && date.Value == null)
throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest.");
+ if (duration.IsSet && duration.Value == null)
+ throw new ArgumentNullException(nameof(duration), "Property is not nullable for class FormatTest.");
+
if (number.IsSet && number.Value == null)
throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest.");
@@ -845,7 +865,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (uuid.IsSet && uuid.Value == null)
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
- 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);
+ 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);
}
///
@@ -897,6 +917,8 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
+ writer.WriteString("duration", formatTest.Duration);
+
writer.WriteNumber("number", formatTest.Number);
writer.WriteString("password", formatTest.Password);
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml
index 3c7d8aa3954b..ab68fdb093f5 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml
@@ -1642,6 +1642,10 @@ components:
example: 2007-12-03T10:15:30+01:00
format: date-time
type: string
+ duration:
+ example: 1.03:14:56.1667
+ format: duration
+ type: string
uuid:
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
format: uuid
@@ -1668,6 +1672,7 @@ components:
required:
- byte
- date
+ - duration
- number
- password
type: object
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/FormatTest.md
index 1009f35198fb..4a79dbcf92d3 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/FormatTest.md
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/FormatTest.md
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Byte** | **byte[]** | |
**Date** | **DateOnly** | |
+**Duration** | **TimeSpan** | |
**Number** | **decimal** | |
**Password** | **string** | |
**Binary** | **System.IO.Stream** | | [optional]
diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
index 96902abd13a6..2da3d5078e2e 100644
--- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -34,6 +34,7 @@ public partial class FormatTest : IValidatableObject
///
/// byte
/// date
+ /// duration
/// number
/// password
/// binary
@@ -57,10 +58,11 @@ public partial class FormatTest : IValidatableObject
/// unsignedLong
/// uuid
[JsonConstructor]
- public FormatTest(byte[] @byte, DateOnly date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
+ public FormatTest(byte[] @byte, DateOnly date, TimeSpan duration, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int32Range = default, Option int64 = default, Option int64Negative = default, Option int64NegativeExclusive = default, Option int64Positive = default, Option int64PositiveExclusive = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
{
Byte = @byte;
Date = date;
+ Duration = duration;
Number = number;
Password = password;
BinaryOption = binary;
@@ -101,6 +103,13 @@ public FormatTest(byte[] @byte, DateOnly date, decimal number, string password,
[JsonPropertyName("date")]
public DateOnly Date { get; set; }
+ ///
+ /// Gets or Sets Duration
+ ///
+ /* 1.03:14:56.1667 */
+ [JsonPropertyName("duration")]
+ public TimeSpan Duration { get; set; }
+
///
/// Gets or Sets Number
///
@@ -394,6 +403,7 @@ public override string ToString()
sb.Append("class FormatTest {\n");
sb.Append(" Byte: ").Append(Byte).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
+ sb.Append(" Duration: ").Append(Duration).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
@@ -626,6 +636,7 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
Option varByte = default;
Option date = default;
+ Option duration = default;
Option number = default;
Option