diff --git a/.github/workflows/samples-dotnet.yaml b/.github/workflows/samples-dotnet.yaml
index 5751b7fb725..9d2c9b1bc53 100644
--- a/.github/workflows/samples-dotnet.yaml
+++ b/.github/workflows/samples-dotnet.yaml
@@ -4,6 +4,7 @@ on:
push:
paths:
- 'samples/client/petstore/csharp/**net6.0**/'
+ - 'samples/client/petstore/csharp/**net7.0**/'
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-netcore**/'
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**'
- 'samples/server/petstore/aspnetcore-6.0/**'
@@ -12,6 +13,7 @@ on:
pull_request:
paths:
- 'samples/client/petstore/csharp/**net6.0**/'
+ - 'samples/client/petstore/csharp/**net7.0**/'
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-netcore**/'
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**'
- 'samples/server/petstore/aspnetcore-6.0/**'
@@ -35,6 +37,8 @@ jobs:
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests
+ - samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
+ - samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
- samples/server/petstore/aspnetcore-6.0
- samples/server/petstore/aspnetcore-6.0-pocoModels
- samples/server/petstore/aspnetcore-6.0-project4Models
diff --git a/bin/configs/csharp-generichost-net7.0-useDateTimeForDate.yaml b/bin/configs/csharp-generichost-net7.0-useDateTimeForDate.yaml
new file mode 100644
index 00000000000..c20fcdcd7f7
--- /dev/null
+++ b/bin/configs/csharp-generichost-net7.0-useDateTimeForDate.yaml
@@ -0,0 +1,9 @@
+# for csharp generichost
+generatorName: csharp
+outputDir: samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate
+inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
+library: generichost
+templateDir: modules/openapi-generator/src/main/resources/csharp
+additionalProperties:
+ packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}'
+ useDateTimeForDate: true
diff --git a/bin/configs/csharp-restsharp-net7.0-useDateTimeForDate.yaml b/bin/configs/csharp-restsharp-net7.0-useDateTimeForDate.yaml
new file mode 100644
index 00000000000..e5c65c57d20
--- /dev/null
+++ b/bin/configs/csharp-restsharp-net7.0-useDateTimeForDate.yaml
@@ -0,0 +1,9 @@
+# for .net standard
+generatorName: csharp
+outputDir: samples/client/petstore/csharp/OpenAPIClient-net7.0-useDateTimeForDate
+inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
+templateDir: modules/openapi-generator/src/main/resources/csharp
+additionalProperties:
+ packageGuid: '{D0A67E81-4061-48EB-B4B8-C73BDF8B2D95}'
+ targetFramework: net7.0
+ useDateTimeForDate: true
diff --git a/docs/generators/README.md b/docs/generators/README.md
index adf500bdace..3b624bd8b8f 100644
--- a/docs/generators/README.md
+++ b/docs/generators/README.md
@@ -12,7 +12,7 @@ The following generators are available:
* [cpp-restsdk](cpp-restsdk.md)
* [cpp-tizen](cpp-tizen.md)
* [csharp](csharp.md)
-* [csharp-netcore](csharp-netcore.md)
+* [csharp-functions](csharp-functions.md)
* [dart](dart.md)
* [dart-dio](dart-dio.md)
* [eiffel](eiffel.md)
diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md
index 4937e49beb1..5dbedb169c5 100644
--- a/docs/generators/aspnetcore.md
+++ b/docs/generators/aspnetcore.md
@@ -47,6 +47,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sourceFolder|source folder for generated code| |src|
|swashbuckleVersion|Swashbuckle version: 3.0.0 (deprecated), 4.0.0 (deprecated), 5.0.0 (deprecated), 6.4.0|
- **3.0.0**
- Swashbuckle 3.0.0
- **4.0.0**
- Swashbuckle 4.0.0
- **5.0.0**
- Swashbuckle 5.0.0
- **6.4.0**
- Swashbuckle 6.4.0
|3.0.0|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
+|useDateTimeForDate|Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useDefaultRouting|Use default routing for the ASP.NET Core version.| |true|
|useFrameworkReference|Use frameworkReference for ASP.NET Core 3.0+ and PackageReference ASP.NET Core 2.2 or earlier.| |false|
@@ -74,6 +75,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Boolean
- Collection
+- DateOnly
+- DateOnly?
- DateTime
- DateTime?
- DateTimeOffset
diff --git a/docs/generators/csharp-functions.md b/docs/generators/csharp-functions.md
index 16b6a650816..8e6a6a98726 100644
--- a/docs/generators/csharp-functions.md
+++ b/docs/generators/csharp-functions.md
@@ -44,6 +44,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
+|useDateTimeForDate|Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useNewtonsoft|Uses the Newtonsoft JSON library.| |true|
@@ -67,6 +68,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Boolean
- Collection
+- DateOnly
+- DateOnly?
- DateTime
- DateTime?
- DateTimeOffset
diff --git a/docs/generators/csharp.md b/docs/generators/csharp.md
index 461bfc4c28e..97122c15677 100644
--- a/docs/generators/csharp.md
+++ b/docs/generators/csharp.md
@@ -47,6 +47,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sourceFolder|source folder for generated code| |src|
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|- **netstandard1.3**
- .NET Standard 1.3
- **netstandard1.4**
- .NET Standard 1.4
- **netstandard1.5**
- .NET Standard 1.5
- **netstandard1.6**
- .NET Standard 1.6
- **netstandard2.0**
- .NET Standard 2.0
- **netstandard2.1**
- .NET Standard 2.1
- **net47**
- .NET Framework 4.7
- **net48**
- .NET Framework 4.8
- **net6.0**
- .NET 6.0 (End of Support 12 November 2024)
- **net7.0**
- .NET 7.0
- **net8.0**
- .NET 8.0
|net8.0|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
+|useDateTimeForDate|Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
|useSourceGeneration|Use source generation where available (only `generichost` library supports this option).| |false|
@@ -73,6 +74,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Boolean
- Collection
+- DateOnly
+- DateOnly?
- DateTime
- DateTime?
- DateTimeOffset
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
index 545fea104f4..39a22bb458a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
@@ -156,6 +156,9 @@ public class CodegenConstants {
public static final String USE_DATETIME_OFFSET = "useDateTimeOffset";
public static final String USE_DATETIME_OFFSET_DESC = "Use DateTimeOffset to model date-time properties";
+ public static final String USE_DATETIME_FOR_DATE = "useDateTimeForDate";
+ public static final String USE_DATETIME_FOR_DATE_DESC = "Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)";
+
public static final String ENSURE_UNIQUE_PARAMS = "ensureUniqueParams";
public static final String ENSURE_UNIQUE_PARAMS_DESC = "Whether to ensure parameter names are unique in an operation (rename parameters that are not).";
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 576a254cc3f..59584728003 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
@@ -55,6 +55,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected boolean optionalProjectFileFlag = true;
protected boolean optionalMethodArgumentFlag = true;
protected boolean useDateTimeOffsetFlag = false;
+ protected boolean useDateTimeForDateFlag = false;
protected boolean useCollection = false;
protected boolean returnICollection = false;
protected boolean netCoreProjectFileFlag = false;
@@ -186,6 +187,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
"DateTime",
"DateTimeOffset?",
"DateTimeOffset",
+ "DateOnly?",
+ "DateOnly",
"Boolean",
"Double",
"Decimal",
@@ -234,6 +237,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
this.setTypeMapping();
}
+ public void useDateTimeForDate(boolean flag) {
+ this.useDateTimeForDateFlag = flag;
+ this.setTypeMapping();
+ }
+
@Override
protected void addParentFromContainer(CodegenModel model, Schema schema) {
// we do not want to inherit simply because additionalProperties is true
@@ -354,6 +362,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.USE_DATETIME_OFFSET, useDateTimeOffsetFlag);
}
+ // {{useDateTimeForDate}}
+ if (additionalProperties.containsKey(CodegenConstants.USE_DATETIME_FOR_DATE)) {
+ useDateTimeForDate(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_DATETIME_FOR_DATE));
+ } else {
+ additionalProperties.put(CodegenConstants.USE_DATETIME_FOR_DATE, useDateTimeForDateFlag);
+ }
+
if (additionalProperties.containsKey(CodegenConstants.USE_COLLECTION)) {
setUseCollection(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_COLLECTION));
} else {
@@ -1756,6 +1771,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
return (this.getValueTypes().contains(var.dataType) || var.isEnum);
}
+ protected boolean useNet60OrLater() { return false; }
+
+ protected boolean useDateOnly() {
+ return useNet60OrLater() && !useDateTimeForDateFlag;
+ }
+
@Override
public void setParameterExampleValue(CodegenParameter p) {
String example;
@@ -1820,16 +1841,18 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
example = "System.Text.Encoding.ASCII.GetBytes(\"" + escapeText(example) + "\")";
} else if (p.isDate) {
+ String dateType = typeMapping.get("date");
if (example == null) {
- example = "DateTime.Parse(\"2013-10-20\")";
+ example = dateType + ".Parse(\"2013-10-20\")";
} else {
- example = "DateTime.Parse(\"" + example + "\")";
+ example = dateType + ".Parse(\"" + example + "\")";
}
} else if (p.isDateTime) {
+ String dateType = typeMapping.get("DateTime");
if (example == null) {
- example = "DateTime.Parse(\"2013-10-20T19:20:30+01:00\")";
+ example = dateType + ".Parse(\"2013-10-20T19:20:30+01:00\")";
} else {
- example = "DateTime.Parse(\"" + example + "\")";
+ example = dateType + ".Parse(\"" + example + "\")";
}
} else if (p.isDecimal) {
if (example == null) {
@@ -1993,7 +2016,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
protected Set getValueTypes() {
- return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double", "DateTime", "DateTimeOffset", "Guid"));
+ return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double", "DateTime", "DateOnly", "DateTimeOffset", "Guid"));
}
protected void setTypeMapping() {
@@ -2012,7 +2035,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("decimal", "decimal");
typeMapping.put("BigDecimal", "decimal");
typeMapping.put("DateTime", this.useDateTimeOffsetFlag ? "DateTimeOffset" : "DateTime");
- typeMapping.put("date", "DateTime");
+ typeMapping.put("date", this.useDateOnly() ? "DateOnly" : "DateTime");
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 9afd271def0..4248ad52050 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
@@ -52,6 +52,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen {
public static final String BUILD_TARGET = "buildTarget";
public static final String MODEL_CLASS_MODIFIER = "modelClassModifier";
public static final String TARGET_FRAMEWORK = "targetFramework";
+ public static final String NET_60_OR_LATER = "net60OrLater";
public static final String PROJECT_SDK = "projectSdk";
public static final String SDK_WEB = "Microsoft.NET.Sdk.Web";
@@ -209,6 +210,10 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen {
CodegenConstants.USE_DATETIME_OFFSET_DESC,
useDateTimeOffsetFlag);
+ addSwitch(CodegenConstants.USE_DATETIME_FOR_DATE,
+ CodegenConstants.USE_DATETIME_FOR_DATE_DESC,
+ useDateTimeForDateFlag);
+
addSwitch(CodegenConstants.USE_COLLECTION,
CodegenConstants.USE_COLLECTION_DESC,
useCollection);
@@ -299,7 +304,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen {
@Override
protected Set getNullableTypes() {
return new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double",
- "DateTime", "DateTimeOffset", "Guid"));
+ "DateTime", "DateOnly", "DateTimeOffset", "Guid"));
}
@Override
@@ -462,6 +467,11 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen {
this.setTypeMapping();
}
+ @Override
+ protected boolean useNet60OrLater() {
+ return additionalProperties.containsKey(NET_60_OR_LATER);
+ }
+
public void setPackageGuid(String packageGuid) {
this.packageGuid = packageGuid;
}
@@ -775,6 +785,20 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen {
useFrameworkReference = true;
additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference);
additionalProperties.put(TARGET_FRAMEWORK, "net6.0");
+ } else if (aspnetCoreVersion.getOptValue().startsWith("7.")) {
+ LOGGER.warn(
+ "ASP.NET core version is {} so changing to use frameworkReference instead of packageReference ",
+ aspnetCoreVersion.getOptValue());
+ useFrameworkReference = true;
+ additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference);
+ additionalProperties.put(TARGET_FRAMEWORK, "net7.0");
+ } else if (aspnetCoreVersion.getOptValue().startsWith("8.")) {
+ LOGGER.warn(
+ "ASP.NET core version is {} so changing to use frameworkReference instead of packageReference ",
+ aspnetCoreVersion.getOptValue());
+ useFrameworkReference = true;
+ additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference);
+ additionalProperties.put(TARGET_FRAMEWORK, "net8.0");
} else {
if (additionalProperties.containsKey(USE_FRAMEWORK_REFERENCE)) {
useFrameworkReference = convertPropertyToBooleanAndWriteBack(USE_FRAMEWORK_REFERENCE);
@@ -783,6 +807,17 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen {
}
additionalProperties.put(TARGET_FRAMEWORK, "netcoreapp" + aspnetCoreVersion);
}
+
+ setAddititonalPropertyForFramework();
+ }
+
+ private void setAddititonalPropertyForFramework() {
+ String targetFramework = ((String)additionalProperties.get(TARGET_FRAMEWORK));
+ if (targetFramework.startsWith("net6.0") ||
+ targetFramework.startsWith("net7.0") ||
+ targetFramework.startsWith("net8.0")) {
+ additionalProperties.put(NET_60_OR_LATER, true);
+ }
}
private void setUseNewtonsoft() {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
index 20576ede388..f084de1cc73 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
@@ -114,6 +114,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
protected boolean supportsAsync = Boolean.TRUE;
protected boolean netStandard = Boolean.FALSE;
protected boolean supportsFileParameters = Boolean.TRUE;
+ protected boolean supportsDateOnly = Boolean.FALSE;
protected boolean validatable = Boolean.TRUE;
protected boolean equatable = Boolean.FALSE;
@@ -264,6 +265,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
CodegenConstants.USE_DATETIME_OFFSET_DESC,
this.useDateTimeOffsetFlag);
+ addSwitch(CodegenConstants.USE_DATETIME_FOR_DATE,
+ CodegenConstants.USE_DATETIME_FOR_DATE_DESC,
+ useDateTimeForDateFlag);
+
addSwitch(CodegenConstants.USE_COLLECTION,
CodegenConstants.USE_COLLECTION_DESC,
this.useCollection);
@@ -359,6 +364,11 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
: new HashSet<>(Arrays.asList("decimal", "bool", "int", "uint", "long", "ulong", "float", "double"));
}
+ @Override
+ protected boolean useNet60OrLater() {
+ return additionalProperties.containsKey(NET_60_OR_LATER);
+ }
+
@Override
protected void setTypeMapping() {
super.setTypeMapping();
@@ -782,6 +792,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
syncBooleanProperty(additionalProperties, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, this::setUseOneOfDiscriminatorLookup, this.useOneOfDiscriminatorLookup);
syncBooleanProperty(additionalProperties, "supportsFileParameters", this::setSupportsFileParameters, this.supportsFileParameters);
syncBooleanProperty(additionalProperties, "useSourceGeneration", this::setUseSourceGeneration, this.useSourceGeneration);
+ syncBooleanProperty(additionalProperties, "supportsDateOnly", this::setSupportsDateOnly, this.supportsDateOnly);
final String testPackageName = testPackageName();
String packageFolder = sourceFolder + File.separator + packageName;
@@ -843,6 +854,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
}
}
+ if (useDateOnly()) {
+ setSupportsDateOnly(true);
+ additionalProperties.put("supportsDateOnly", true);
+ }
// include the spec in the output
supportingFiles.add(new SupportingFile("openapi.mustache", "api", "openapi.yaml"));
@@ -988,6 +1003,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("ApiFactory.mustache", clientPackageDir, "ApiFactory.cs"));
supportingFiles.add(new SupportingFile("DateTimeJsonConverter.mustache", clientPackageDir, "DateTimeJsonConverter.cs"));
supportingFiles.add(new SupportingFile("DateTimeNullableJsonConverter.mustache", clientPackageDir, "DateTimeNullableJsonConverter.cs"));
+ if (useDateOnly()) {
+ supportingFiles.add(new SupportingFile("DateOnlyJsonConverter.mustache", clientPackageDir, "DateOnlyJsonConverter.cs"));
+ supportingFiles.add(new SupportingFile("DateOnlyNullableJsonConverter.mustache", clientPackageDir, "DateOnlyNullableJsonConverter.cs"));
+ }
supportingFiles.add(new SupportingFile("ApiResponseEventArgs`1.mustache", clientPackageDir, "ApiResponseEventArgs.cs"));
supportingFiles.add(new SupportingFile("ExceptionEventArgs.mustache", clientPackageDir, "ExceptionEventArgs.cs"));
supportingFiles.add(new SupportingFile("JsonSerializerOptionsProvider.mustache", clientPackageDir, "JsonSerializerOptionsProvider.cs"));
@@ -1092,6 +1111,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
this.supportsFileParameters = supportsFileParameters;
}
+ public void setSupportsDateOnly(Boolean supportsDateOnly) {
+ this.supportsDateOnly = supportsDateOnly;
+ }
+
public void setSupportsRetry(Boolean supportsRetry) {
this.supportsRetry = supportsRetry;
}
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 0052dbb0470..9aaffde2c10 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
@@ -53,6 +53,7 @@ public class CSharpFunctionsServerCodegen extends AbstractCSharpCodegen {
public static final String COMPATIBILITY_VERSION = "compatibilityVersion";
public static final String USE_NEWTONSOFT = "useNewtonsoft";
public static final String NEWTONSOFT_VERSION = "newtonsoftVersion";
+ public static final String NET_60_OR_LATER = "net60OrLater";
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
private String userSecretsGuid = randomUUID().toString();
@@ -188,6 +189,10 @@ public class CSharpFunctionsServerCodegen extends AbstractCSharpCodegen {
CodegenConstants.USE_DATETIME_OFFSET_DESC,
useDateTimeOffsetFlag);
+ addSwitch(CodegenConstants.USE_DATETIME_FOR_DATE,
+ CodegenConstants.USE_DATETIME_FOR_DATE_DESC,
+ useDateTimeForDateFlag);
+
addSwitch(CodegenConstants.USE_COLLECTION,
CodegenConstants.USE_COLLECTION_DESC,
useCollection);
@@ -263,18 +268,8 @@ public class CSharpFunctionsServerCodegen extends AbstractCSharpCodegen {
}
@Override
- protected void setTypeMapping() {
- super.setTypeMapping();
- typeMapping.put("boolean", "bool");
- typeMapping.put("integer", "int");
- typeMapping.put("float", "float");
- typeMapping.put("long", "long");
- typeMapping.put("double", "double");
- typeMapping.put("number", "decimal");
- typeMapping.put("DateTime", "DateTime");
- typeMapping.put("date", "DateTime");
- typeMapping.put("UUID", "Guid");
- typeMapping.put("URI", "string");
+ protected boolean useNet60OrLater() {
+ return additionalProperties.containsKey(NET_60_OR_LATER);
}
@Override
@@ -607,6 +602,13 @@ public class CSharpFunctionsServerCodegen extends AbstractCSharpCodegen {
//set .NET target version
String targetFrameworkVersion = "net" + netCoreVersion.getOptValue();
additionalProperties.put(TARGET_FRAMEWORK, targetFrameworkVersion);
+ setAddititonalPropertyForFramework();
+ }
+
+ private void setAddititonalPropertyForFramework() {
+ if (((String)additionalProperties.get(TARGET_FRAMEWORK)).startsWith("net6.0")) {
+ additionalProperties.put(NET_60_OR_LATER, true);
+ }
}
private void setOperationIsAsync() {
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateFormats.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateFormats.mustache
new file mode 100644
index 00000000000..920ecda88fa
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateFormats.mustache
@@ -0,0 +1,2 @@
+ "yyyy'-'MM'-'dd",
+ "yyyyMMdd"
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateOnlyJsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateOnlyJsonConverter.mustache
new file mode 100644
index 00000000000..209979c8db4
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateOnlyJsonConverter.mustache
@@ -0,0 +1,51 @@
+{{>partial_header}}
+using System;
+using System.Globalization;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace {{packageName}}.{{clientPackage}}
+{
+ ///
+ /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
+ ///
+ {{>visibility}} class DateOnlyJsonConverter : JsonConverter
+ {
+ ///
+ /// The formats used to deserialize the date
+ ///
+ public static string[] Formats { get; } = {
+{{>DateFormats}}
+ };
+
+ ///
+ /// Returns a DateOnly from the Json object
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
+ if (reader.TokenType == JsonTokenType.Null)
+ throw new NotSupportedException();
+
+ string value = reader.GetString(){{nrt!}};
+
+ foreach(string format in Formats)
+ if (DateOnly.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateOnly result))
+ return result;
+
+ throw new NotSupportedException();
+ }
+
+ ///
+ /// Writes the DateOnly to the json writer
+ ///
+ ///
+ ///
+ ///
+ public override void Write(Utf8JsonWriter writer, DateOnly dateOnlyValue, JsonSerializerOptions options) =>
+ writer.WriteStringValue(dateOnlyValue.ToString("{{{dateFormat}}}", CultureInfo.InvariantCulture));
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateOnlyNullableJsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateOnlyNullableJsonConverter.mustache
new file mode 100644
index 00000000000..17c84736536
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateOnlyNullableJsonConverter.mustache
@@ -0,0 +1,56 @@
+{{>partial_header}}
+using System;
+using System.Globalization;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace {{packageName}}.{{clientPackage}}
+{
+ ///
+ /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
+ ///
+ {{>visibility}} class DateOnlyNullableJsonConverter : JsonConverter
+ {
+ ///
+ /// The formats used to deserialize the date
+ ///
+ public static string[] Formats { get; } = {
+{{>DateFormats}}
+ };
+
+ ///
+ /// Returns a DateOnly from the Json object
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override DateOnly? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
+ if (reader.TokenType == JsonTokenType.Null)
+ return null;
+
+ string value = reader.GetString(){{nrt!}};
+
+ foreach(string format in Formats)
+ if (DateOnly.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateOnly result))
+ return result;
+
+ throw new NotSupportedException();
+ }
+
+ ///
+ /// Writes the DateOnly to the json writer
+ ///
+ ///
+ ///
+ ///
+ public override void Write(Utf8JsonWriter writer, DateOnly? dateOnlyValue, JsonSerializerOptions options)
+ {
+ if (dateOnlyValue == null)
+ writer.WriteNullValue();
+ else
+ writer.WriteStringValue(dateOnlyValue.Value.ToString("{{{dateFormat}}}", CultureInfo.InvariantCulture));
+ }
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeFormats.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeFormats.mustache
index c8887e20859..85ed99a2c9e 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeFormats.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeFormats.mustache
@@ -6,7 +6,9 @@
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ssK",
+ {{^supportsDateOnly}}
"yyyy'-'MM'-'dd",
+ {{/supportsDateOnly}}
"yyyyMMddTHHmmss.fffffffK",
"yyyyMMddTHHmmss.ffffffK",
"yyyyMMddTHHmmss.fffffK",
@@ -15,4 +17,6 @@
"yyyyMMddTHHmmss.ffK",
"yyyyMMddTHHmmss.fK",
"yyyyMMddTHHmmssK",
- "yyyyMMdd"
\ No newline at end of file
+ {{^supportsDateOnly}}
+ "yyyyMMdd"
+ {{/supportsDateOnly}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeJsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeJsonConverter.mustache
index 21d35ec2302..c5187f50815 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeJsonConverter.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeJsonConverter.mustache
@@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
namespace {{packageName}}.{{clientPackage}}
{
///
- /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// Formatter for {{#supportsDateOnly}}'date-time'{{/supportsDateOnly}}{{^supportsDateOnly}}'date' and 'date-time'{{/supportsDateOnly}} openapi formats ss defined by full-date - RFC3339
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
///
{{>visibility}} class DateTimeJsonConverter : JsonConverter
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeNullableJsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeNullableJsonConverter.mustache
index 52e2afa0b7a..646c729478d 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeNullableJsonConverter.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DateTimeNullableJsonConverter.mustache
@@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
namespace {{packageName}}.{{clientPackage}}
{
///
- /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// Formatter for {{#supportsDateOnly}}'date-time'{{/supportsDateOnly}}{{^supportsDateOnly}}'date' and 'date-time'{{/supportsDateOnly}} openapi formats ss defined by full-date - RFC3339
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
///
{{>visibility}} class DateTimeNullableJsonConverter : JsonConverter
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
index 1e848862a8b..d7d1e3bf3a8 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/HostConfiguration.mustache
@@ -35,6 +35,10 @@ namespace {{packageName}}.{{clientPackage}}
_jsonOptions.Converters.Add(new JsonStringEnumConverter());
_jsonOptions.Converters.Add(new DateTimeJsonConverter());
_jsonOptions.Converters.Add(new DateTimeNullableJsonConverter());
+ {{#supportsDateOnly}}
+ _jsonOptions.Converters.Add(new DateOnlyJsonConverter());
+ _jsonOptions.Converters.Add(new DateOnlyNullableJsonConverter());
+ {{/supportsDateOnly}}
{{#models}}
{{#model}}
{{#isEnum}}
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 09c544ac52f..e136dd4d5be 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
@@ -208,7 +208,7 @@
{{/isNumeric}}
{{#isDate}}
if (utf8JsonReader.TokenType != JsonTokenType.Null)
- {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
+ {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<{{#supportsDateOnly}}DateOnly{{/supportsDateOnly}}{{^supportsDateOnly}}DateTime{{/supportsDateOnly}}{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions));
{{/isDate}}
{{#isDateTime}}
if (utf8JsonReader.TokenType != JsonTokenType.Null)
diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
new file mode 100644
index 00000000000..34fd6fa65d7
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml
@@ -0,0 +1,25 @@
+openapi: 3.0.0
+info:
+ title: OpenAPI Dates
+ version: 1.0.0
+ description: Thic spec contains endpoints with dates in different formats
+ license:
+ name: Apache-2.0
+ url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
+paths:
+ /now:
+ get:
+ responses:
+ '200':
+ description: now dates
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ today:
+ type: string
+ format: date
+ now:
+ type: string
+ format: date-time
diff --git a/samples/client/echo_api/csharp-restsharp/docs/QueryApi.md b/samples/client/echo_api/csharp-restsharp/docs/QueryApi.md
index 681e00fa5fe..227f3fa7494 100644
--- a/samples/client/echo_api/csharp-restsharp/docs/QueryApi.md
+++ b/samples/client/echo_api/csharp-restsharp/docs/QueryApi.md
@@ -108,7 +108,7 @@ No authorization required
# **TestQueryDatetimeDateString**
-> string TestQueryDatetimeDateString (DateTime? datetimeQuery = null, DateTime? dateQuery = null, string? stringQuery = null)
+> string TestQueryDatetimeDateString (DateTime? datetimeQuery = null, DateOnly? dateQuery = null, string? stringQuery = null)
Test query parameter(s)
@@ -132,7 +132,7 @@ namespace Example
config.BasePath = "http://localhost:3000";
var apiInstance = new QueryApi(config);
var datetimeQuery = DateTime.Parse("2013-10-20T19:20:30+01:00"); // DateTime? | (optional)
- var dateQuery = DateTime.Parse("2013-10-20"); // DateTime? | (optional)
+ var dateQuery = DateOnly.Parse("2013-10-20"); // DateOnly? | (optional)
var stringQuery = "stringQuery_example"; // string? | (optional)
try
@@ -177,7 +177,7 @@ catch (ApiException e)
| Name | Type | Description | Notes |
|------|------|-------------|-------|
| **datetimeQuery** | **DateTime?** | | [optional] |
-| **dateQuery** | **DateTime?** | | [optional] |
+| **dateQuery** | **DateOnly?** | | [optional] |
| **stringQuery** | **string?** | | [optional] |
### Return type
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/QueryApi.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/QueryApi.cs
index a19c0ef303c..9b54b9048f6 100644
--- a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/QueryApi.cs
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/QueryApi.cs
@@ -64,7 +64,7 @@ namespace Org.OpenAPITools.Api
/// (optional)
/// Index associated with the operation.
/// string
- string TestQueryDatetimeDateString(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0);
+ string TestQueryDatetimeDateString(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0);
///
/// Test query parameter(s)
@@ -78,7 +78,7 @@ namespace Org.OpenAPITools.Api
/// (optional)
/// Index associated with the operation.
/// ApiResponse of string
- ApiResponse TestQueryDatetimeDateStringWithHttpInfo(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0);
+ ApiResponse TestQueryDatetimeDateStringWithHttpInfo(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0);
///
/// Test query parameter(s)
///
@@ -270,7 +270,7 @@ namespace Org.OpenAPITools.Api
/// Index associated with the operation.
/// Cancellation Token to cancel the request.
/// Task of string
- System.Threading.Tasks.Task TestQueryDatetimeDateStringAsync(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+ System.Threading.Tasks.Task TestQueryDatetimeDateStringAsync(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
///
/// Test query parameter(s)
@@ -285,7 +285,7 @@ namespace Org.OpenAPITools.Api
/// Index associated with the operation.
/// Cancellation Token to cancel the request.
/// Task of ApiResponse (string)
- System.Threading.Tasks.Task> TestQueryDatetimeDateStringWithHttpInfoAsync(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+ System.Threading.Tasks.Task> TestQueryDatetimeDateStringWithHttpInfoAsync(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
///
/// Test query parameter(s)
///
@@ -719,7 +719,7 @@ namespace Org.OpenAPITools.Api
/// (optional)
/// Index associated with the operation.
/// string
- public string TestQueryDatetimeDateString(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0)
+ public string TestQueryDatetimeDateString(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0)
{
Org.OpenAPITools.Client.ApiResponse localVarResponse = TestQueryDatetimeDateStringWithHttpInfo(datetimeQuery, dateQuery, stringQuery);
return localVarResponse.Data;
@@ -734,7 +734,7 @@ namespace Org.OpenAPITools.Api
/// (optional)
/// Index associated with the operation.
/// ApiResponse of string
- public Org.OpenAPITools.Client.ApiResponse TestQueryDatetimeDateStringWithHttpInfo(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0)
+ public Org.OpenAPITools.Client.ApiResponse TestQueryDatetimeDateStringWithHttpInfo(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0)
{
Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();
@@ -799,7 +799,7 @@ namespace Org.OpenAPITools.Api
/// Index associated with the operation.
/// Cancellation Token to cancel the request.
/// Task of string
- public async System.Threading.Tasks.Task TestQueryDatetimeDateStringAsync(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
+ public async System.Threading.Tasks.Task TestQueryDatetimeDateStringAsync(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
Org.OpenAPITools.Client.ApiResponse localVarResponse = await TestQueryDatetimeDateStringWithHttpInfoAsync(datetimeQuery, dateQuery, stringQuery, operationIndex, cancellationToken).ConfigureAwait(false);
return localVarResponse.Data;
@@ -815,7 +815,7 @@ namespace Org.OpenAPITools.Api
/// Index associated with the operation.
/// Cancellation Token to cancel the request.
/// Task of ApiResponse (string)
- public async System.Threading.Tasks.Task> TestQueryDatetimeDateStringWithHttpInfoAsync(DateTime? datetimeQuery = default(DateTime?), DateTime? dateQuery = default(DateTime?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
+ public async System.Threading.Tasks.Task> TestQueryDatetimeDateStringWithHttpInfoAsync(DateTime? datetimeQuery = default(DateTime?), DateOnly? dateQuery = default(DateOnly?), string? stringQuery = default(string?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/.openapi-generator/FILES
index 96f2ef1bc1c..f26dd3d19b8 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/.openapi-generator/FILES
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/.openapi-generator/FILES
@@ -122,6 +122,8 @@ src/UseSourceGeneration/Client/BasicToken.cs
src/UseSourceGeneration/Client/BearerToken.cs
src/UseSourceGeneration/Client/ClientUtils.cs
src/UseSourceGeneration/Client/CookieContainer.cs
+src/UseSourceGeneration/Client/DateOnlyJsonConverter.cs
+src/UseSourceGeneration/Client/DateOnlyNullableJsonConverter.cs
src/UseSourceGeneration/Client/DateTimeJsonConverter.cs
src/UseSourceGeneration/Client/DateTimeNullableJsonConverter.cs
src/UseSourceGeneration/Client/ExceptionEventArgs.cs
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/apis/FakeApi.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/apis/FakeApi.md
index fdb257f14d2..2549af1e984 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/apis/FakeApi.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/apis/FakeApi.md
@@ -896,7 +896,7 @@ No authorization required
# **TestEndpointParameters**
-> void TestEndpointParameters (byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime date = null, System.IO.Stream binary = null, float varFloat = null, int integer = null, int int32 = null, long int64 = null, string varString = null, string password = null, string callback = null, DateTime dateTime = null)
+> void TestEndpointParameters (byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateOnly date = null, System.IO.Stream binary = null, float varFloat = null, int integer = null, int int32 = null, long int64 = null, string varString = null, string password = null, string callback = null, DateTime dateTime = null)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -927,7 +927,7 @@ namespace Example
var number = 8.14D; // decimal | None
var varDouble = 1.2D; // double | None
var patternWithoutDelimiter = "patternWithoutDelimiter_example"; // string | None
- var date = DateTime.Parse("2013-10-20"); // DateTime | None (optional)
+ var date = DateOnly.Parse("2013-10-20"); // DateOnly | None (optional)
var binary = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | None (optional)
var varFloat = 3.4F; // float | None (optional)
var integer = 56; // int | None (optional)
@@ -979,7 +979,7 @@ catch (ApiException e)
| **number** | **decimal** | None | |
| **varDouble** | **double** | None | |
| **patternWithoutDelimiter** | **string** | None | |
-| **date** | **DateTime** | None | [optional] |
+| **date** | **DateOnly** | None | [optional] |
| **binary** | **System.IO.Stream****System.IO.Stream** | None | [optional] |
| **varFloat** | **float** | None | [optional] |
| **integer** | **int** | None | [optional] |
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/DateOnlyClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/DateOnlyClass.md
index 6a98ffe33b9..1efce906ea2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/DateOnlyClass.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/DateOnlyClass.md
@@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**DateOnlyProperty** | **DateTime** | | [optional]
+**DateOnlyProperty** | **DateOnly** | | [optional]
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/FormatTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/FormatTest.md
index 98fa755fce0..3540ad007d2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/FormatTest.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/FormatTest.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**VarByte** | **byte[]** | |
-**Date** | **DateTime** | |
+**Date** | **DateOnly** | |
**Number** | **decimal** | |
**Password** | **string** | |
**Binary** | **System.IO.Stream** | | [optional]
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/NullableClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/NullableClass.md
index ce95a131e6c..9c5ff428a98 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/NullableClass.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/NullableClass.md
@@ -8,7 +8,7 @@ Name | Type | Description | Notes
**ArrayItemsNullable** | **List<Object>** | | [optional]
**ArrayNullableProp** | **List<Object>** | | [optional]
**BooleanProp** | **bool** | | [optional]
-**DateProp** | **DateTime** | | [optional]
+**DateProp** | **DateOnly** | | [optional]
**DatetimeProp** | **DateTime** | | [optional]
**IntegerProp** | **int** | | [optional]
**NumberProp** | **decimal** | | [optional]
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/RequiredClass.md
index fa83b86d571..27f01c16af1 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/RequiredClass.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/RequiredClass.md
@@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**RequiredNotNullableDateProp** | **DateTime** | |
+**RequiredNotNullableDateProp** | **DateOnly** | |
**RequiredNotnullableArrayOfString** | **List<string>** | |
**RequiredNotnullableBooleanProp** | **bool** | |
**RequiredNotnullableDatetimeProp** | **DateTime** | |
@@ -17,7 +17,7 @@ Name | Type | Description | Notes
**RequiredNotnullableintegerProp** | **int** | |
**RequiredNullableArrayOfString** | **List<string>** | |
**RequiredNullableBooleanProp** | **bool** | |
-**RequiredNullableDateProp** | **DateTime** | |
+**RequiredNullableDateProp** | **DateOnly** | |
**RequiredNullableDatetimeProp** | **DateTime** | |
**RequiredNullableEnumInteger** | **int** | |
**RequiredNullableEnumIntegerOnly** | **int** | |
@@ -26,9 +26,9 @@ Name | Type | Description | Notes
**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | |
**RequiredNullableStringProp** | **string** | |
**RequiredNullableUuid** | **Guid** | |
-**NotRequiredNotnullableDateProp** | **DateTime** | | [optional]
+**NotRequiredNotnullableDateProp** | **DateOnly** | | [optional]
**NotRequiredNotnullableintegerProp** | **int** | | [optional]
-**NotRequiredNullableDateProp** | **DateTime** | | [optional]
+**NotRequiredNullableDateProp** | **DateOnly** | | [optional]
**NotRequiredNullableIntegerProp** | **int** | | [optional]
**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional]
**NotrequiredNotnullableBooleanProp** | **bool** | | [optional]
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs
index d4140341ae8..3d39a5b433d 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs
@@ -288,7 +288,7 @@ namespace UseSourceGeneration.Api
/// None (optional, default to "2010-02-01T10:20:10.111110+01:00")
/// Cancellation Token to cancel the request.
/// <>
- Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default);
+ Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default);
///
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -312,7 +312,7 @@ namespace UseSourceGeneration.Api
/// None (optional, default to "2010-02-01T10:20:10.111110+01:00")
/// Cancellation Token to cancel the request.
/// <?>
- Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default);
+ Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default);
///
/// To test enum parameters
@@ -3243,7 +3243,7 @@ namespace UseSourceGeneration.Api
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
}
- partial void FormatTestEndpointParameters(ref byte[] varByte, ref decimal number, ref double varDouble, ref string patternWithoutDelimiter, ref Option date, ref Option binary, ref Option varFloat, ref Option integer, ref Option int32, ref Option int64, ref Option varString, ref Option password, ref Option callback, ref Option dateTime);
+ partial void FormatTestEndpointParameters(ref byte[] varByte, ref decimal number, ref double varDouble, ref string patternWithoutDelimiter, ref Option date, ref Option binary, ref Option varFloat, ref Option integer, ref Option int32, ref Option int64, ref Option varString, ref Option password, ref Option callback, ref Option dateTime);
///
/// Validates the request parameters
@@ -3294,7 +3294,7 @@ namespace UseSourceGeneration.Api
///
///
///
- private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime)
+ private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime)
{
bool suppressDefaultLog = false;
AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime);
@@ -3321,7 +3321,7 @@ namespace UseSourceGeneration.Api
///
///
///
- partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime);
+ partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime);
///
/// Logs exceptions that occur while retrieving the server response
@@ -3343,7 +3343,7 @@ namespace UseSourceGeneration.Api
///
///
///
- private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime)
+ private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime)
{
bool suppressDefaultLog = false;
OnErrorTestEndpointParameters(ref suppressDefaultLog, exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime);
@@ -3372,7 +3372,7 @@ namespace UseSourceGeneration.Api
///
///
///
- partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime);
+ partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime);
///
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -3393,7 +3393,7 @@ namespace UseSourceGeneration.Api
/// None (optional, default to "2010-02-01T10:20:10.111110+01:00")
/// Cancellation Token to cancel the request.
/// <>
- public async Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default)
+ public async Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default)
{
try
{
@@ -3425,7 +3425,7 @@ namespace UseSourceGeneration.Api
/// None (optional, default to "2010-02-01T10:20:10.111110+01:00")
/// Cancellation Token to cancel the request.
/// <>
- public async Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default)
+ public async Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default)
{
UriBuilder uriBuilderLocalVar = new UriBuilder();
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateOnlyJsonConverter.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateOnlyJsonConverter.cs
new file mode 100644
index 00000000000..7bcb8ec3897
--- /dev/null
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateOnlyJsonConverter.cs
@@ -0,0 +1,61 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.Globalization;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace UseSourceGeneration.Client
+{
+ ///
+ /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
+ ///
+ public class DateOnlyJsonConverter : JsonConverter
+ {
+ ///
+ /// The formats used to deserialize the date
+ ///
+ public static string[] Formats { get; } = {
+ "yyyy'-'MM'-'dd",
+ "yyyyMMdd"
+
+ };
+
+ ///
+ /// Returns a DateOnly from the Json object
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
+ if (reader.TokenType == JsonTokenType.Null)
+ throw new NotSupportedException();
+
+ string value = reader.GetString()!;
+
+ foreach(string format in Formats)
+ if (DateOnly.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateOnly result))
+ return result;
+
+ throw new NotSupportedException();
+ }
+
+ ///
+ /// Writes the DateOnly to the json writer
+ ///
+ ///
+ ///
+ ///
+ public override void Write(Utf8JsonWriter writer, DateOnly dateOnlyValue, JsonSerializerOptions options) =>
+ writer.WriteStringValue(dateOnlyValue.ToString("yyyy'-'MM'-'dd", CultureInfo.InvariantCulture));
+ }
+}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateOnlyNullableJsonConverter.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateOnlyNullableJsonConverter.cs
new file mode 100644
index 00000000000..b12272beb82
--- /dev/null
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateOnlyNullableJsonConverter.cs
@@ -0,0 +1,66 @@
+/*
+ * OpenAPI Petstore
+ *
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.Globalization;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace UseSourceGeneration.Client
+{
+ ///
+ /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
+ ///
+ public class DateOnlyNullableJsonConverter : JsonConverter
+ {
+ ///
+ /// The formats used to deserialize the date
+ ///
+ public static string[] Formats { get; } = {
+ "yyyy'-'MM'-'dd",
+ "yyyyMMdd"
+
+ };
+
+ ///
+ /// Returns a DateOnly from the Json object
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override DateOnly? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
+ if (reader.TokenType == JsonTokenType.Null)
+ return null;
+
+ string value = reader.GetString()!;
+
+ foreach(string format in Formats)
+ if (DateOnly.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateOnly result))
+ return result;
+
+ throw new NotSupportedException();
+ }
+
+ ///
+ /// Writes the DateOnly to the json writer
+ ///
+ ///
+ ///
+ ///
+ public override void Write(Utf8JsonWriter writer, DateOnly? dateOnlyValue, JsonSerializerOptions options)
+ {
+ if (dateOnlyValue == null)
+ writer.WriteNullValue();
+ else
+ writer.WriteStringValue(dateOnlyValue.Value.ToString("yyyy'-'MM'-'dd", CultureInfo.InvariantCulture));
+ }
+ }
+}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeJsonConverter.cs
index 4c66712a3e3..47944cd6613 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeJsonConverter.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeJsonConverter.cs
@@ -15,7 +15,7 @@ using System.Text.Json.Serialization;
namespace UseSourceGeneration.Client
{
///
- /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// Formatter for 'date-time' openapi formats ss defined by full-date - RFC3339
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
///
public class DateTimeJsonConverter : JsonConverter
@@ -32,7 +32,6 @@ namespace UseSourceGeneration.Client
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ssK",
- "yyyy'-'MM'-'dd",
"yyyyMMddTHHmmss.fffffffK",
"yyyyMMddTHHmmss.ffffffK",
"yyyyMMddTHHmmss.fffffK",
@@ -41,7 +40,7 @@ namespace UseSourceGeneration.Client
"yyyyMMddTHHmmss.ffK",
"yyyyMMddTHHmmss.fK",
"yyyyMMddTHHmmssK",
- "yyyyMMdd"
+
};
///
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeNullableJsonConverter.cs
index e341a77d5cd..03e2a747e15 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeNullableJsonConverter.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/DateTimeNullableJsonConverter.cs
@@ -15,7 +15,7 @@ using System.Text.Json.Serialization;
namespace UseSourceGeneration.Client
{
///
- /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
+ /// Formatter for 'date-time' openapi formats ss defined by full-date - RFC3339
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
///
public class DateTimeNullableJsonConverter : JsonConverter
@@ -32,7 +32,6 @@ namespace UseSourceGeneration.Client
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ssK",
- "yyyy'-'MM'-'dd",
"yyyyMMddTHHmmss.fffffffK",
"yyyyMMddTHHmmss.ffffffK",
"yyyyMMddTHHmmss.fffffK",
@@ -41,7 +40,7 @@ namespace UseSourceGeneration.Client
"yyyyMMddTHHmmss.ffK",
"yyyyMMddTHHmmss.fK",
"yyyyMMddTHHmmssK",
- "yyyyMMdd"
+
};
///
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs
index a1bc8ed1289..615be479166 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/HostConfiguration.cs
@@ -41,6 +41,8 @@ namespace UseSourceGeneration.Client
_jsonOptions.Converters.Add(new JsonStringEnumConverter());
_jsonOptions.Converters.Add(new DateTimeJsonConverter());
_jsonOptions.Converters.Add(new DateTimeNullableJsonConverter());
+ _jsonOptions.Converters.Add(new DateOnlyJsonConverter());
+ _jsonOptions.Converters.Add(new DateOnlyNullableJsonConverter());
_jsonOptions.Converters.Add(new ActivityJsonConverter());
_jsonOptions.Converters.Add(new ActivityOutputElementRepresentationJsonConverter());
_jsonOptions.Converters.Add(new AdditionalPropertiesClassJsonConverter());
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DateOnlyClass.cs
index dcfcc06467a..d5cd3f8c074 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DateOnlyClass.cs
@@ -37,7 +37,7 @@ namespace UseSourceGeneration.Model
///
/// dateOnlyProperty
[JsonConstructor]
- public DateOnlyClass(Option dateOnlyProperty = default)
+ public DateOnlyClass(Option dateOnlyProperty = default)
{
DateOnlyPropertyOption = dateOnlyProperty;
OnCreated();
@@ -50,14 +50,14 @@ namespace UseSourceGeneration.Model
///
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
- public Option DateOnlyPropertyOption { get; private set; }
+ public Option DateOnlyPropertyOption { get; private set; }
///
/// Gets or Sets DateOnlyProperty
///
/// Fri Jul 21 00:00:00 UTC 2017
[JsonPropertyName("dateOnlyProperty")]
- public DateTime? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new(value); } }
+ public DateOnly? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new(value); } }
///
/// Gets or Sets additional properties
@@ -117,7 +117,7 @@ namespace UseSourceGeneration.Model
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
- Option dateOnlyProperty = default;
+ Option dateOnlyProperty = default;
while (utf8JsonReader.Read())
{
@@ -136,7 +136,7 @@ namespace UseSourceGeneration.Model
{
case "dateOnlyProperty":
if (utf8JsonReader.TokenType != JsonTokenType.Null)
- dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
+ dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions));
break;
default:
break;
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FormatTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FormatTest.cs
index 43006afbbb0..254504ca937 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FormatTest.cs
@@ -55,7 +55,7 @@ namespace UseSourceGeneration.Model
/// unsignedLong
/// uuid
[JsonConstructor]
- public FormatTest(byte[] varByte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option varDecimal = default, Option varDouble = default, Option varFloat = default, Option int32 = default, Option int64 = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option varString = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default)
+ public FormatTest(byte[] varByte, DateOnly date, decimal number, string password, Option binary = default, Option dateTime = default, Option varDecimal = default, Option varDouble = default, Option varFloat = default, Option int32 = default, Option int64 = default, Option