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 b458f6aeba6..0c7c3f27c16 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 @@ -418,11 +418,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co @Override protected ImmutableMap.Builder addMustacheLambdas() { + CopyLambda copyLambda = new CopyLambda(); + return super.addMustacheLambdas() .put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true)) .put("required", new RequiredParameterLambda()) .put("optional", new OptionalParameterLambda().generator(this)) .put("joinWithComma", new JoinWithCommaLambda()) + .put("joinWithAmpersand", new JoinWithCommaLambda(true, " ", " && ")) .put("joinLinesWithComma", new JoinWithCommaLambda(false, "\n", ",\n")) .put("joinConditions", new JoinWithCommaLambda(true, " ", " && ")) .put("trimLineBreaks", new TrimLineBreaksLambda()) @@ -430,9 +433,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co .put("trimTrailing", new TrimTrailingWhiteSpaceLambda(false)) .put("first", new FirstLambda(" ")) .put("firstDot", new FirstLambda("\\.")) + .put("indent1", new IndentedLambda(4, " ", false, true)) .put("indent3", new IndentedLambda(12, " ", false, true)) .put("indent4", new IndentedLambda(16, " ", false, true)) - .put("uniqueLinesWithNewLine", new UniqueLambda("\n", true)); + .put("copy", copyLambda) + .put("paste", new PasteLambda(copyLambda, true, true, true, false)) + .put("pasteOnce", new PasteLambda(copyLambda, true, true, true, true)) + .put("pasteLine", new PasteLambda(copyLambda, true, true, false, false)); } @Override 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 bb27fe20f64..fa33ee56c64 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 @@ -454,14 +454,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { Collections.sort(codegenModel.readWriteVars, propertyComparatorByName); Collections.sort(codegenModel.parentVars, propertyComparatorByName); - Comparator comparator = propertyComparatorByNullable.thenComparing(propertyComparatorByDefaultValue); - Collections.sort(codegenModel.vars, comparator); - Collections.sort(codegenModel.allVars, comparator); - Collections.sort(codegenModel.requiredVars, comparator); - Collections.sort(codegenModel.optionalVars, comparator); - Collections.sort(codegenModel.readOnlyVars, comparator); - Collections.sort(codegenModel.readWriteVars, comparator); - Collections.sort(codegenModel.parentVars, comparator); + Collections.sort(codegenModel.vars, propertyComparatorByNotNullableRequiredNoDefault); + Collections.sort(codegenModel.allVars, propertyComparatorByNotNullableRequiredNoDefault); + Collections.sort(codegenModel.requiredVars, propertyComparatorByNotNullableRequiredNoDefault); + Collections.sort(codegenModel.optionalVars, propertyComparatorByNotNullableRequiredNoDefault); + Collections.sort(codegenModel.readOnlyVars, propertyComparatorByNotNullableRequiredNoDefault); + Collections.sort(codegenModel.readWriteVars, propertyComparatorByNotNullableRequiredNoDefault); + Collections.sort(codegenModel.parentVars, propertyComparatorByNotNullableRequiredNoDefault); } return codegenModel; @@ -474,24 +473,12 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { } }; - public static Comparator propertyComparatorByDefaultValue = new Comparator() { + public static Comparator propertyComparatorByNotNullableRequiredNoDefault = new Comparator() { @Override public int compare(CodegenProperty one, CodegenProperty another) { - if ((one.defaultValue == null) == (another.defaultValue == null)) + if (one.isNullable == another.isNullable && one.required == another.required && (one.defaultValue == null) == (another.defaultValue == null)) return 0; - else if (one.defaultValue == null) - return -1; - else - return 1; - } - }; - - public static Comparator propertyComparatorByNullable = new Comparator() { - @Override - public int compare(CodegenProperty one, CodegenProperty another) { - if (one.isNullable == another.isNullable) - return 0; - else if (Boolean.FALSE.equals(one.isNullable)) + else if (!one.isNullable && one.required && one.defaultValue == null) return -1; else return 1; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CopyLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CopyLambda.java new file mode 100644 index 00000000000..f1e4868c59b --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CopyLambda.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.templating.mustache; + +import java.io.IOException; +import java.io.Writer; + +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template.Fragment; + +/** + * Saves template text to be used later. + * + * Register: + *
+ * additionalProperties.put("copy", new CopyLambda());
+ * 
+ * + * Use: + *
+ * {{#copy}}{{name}}{{/copy}}
+ * 
+ */ +public class CopyLambda implements Mustache.Lambda { + public String savedContent; + + public CopyLambda() { + } + + @Override + public void execute(Fragment fragment, Writer writer) throws IOException { + savedContent = fragment.execute().stripTrailing(); + } +} diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/PasteLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/PasteLambda.java new file mode 100644 index 00000000000..ea798d9dc3c --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/PasteLambda.java @@ -0,0 +1,76 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.templating.mustache; + +import java.io.IOException; +import java.io.Writer; + +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template.Fragment; + +/** + * Writes text that was previously saved. + * + * Register: + *
+ * additionalProperties.put("paste", new PasteLambda(copyLambda, true, true, true, false));
+ * 
+ * + * Use: + *
+ * {{#paste}}{{/paste}}
+ * 
+ */ +public class PasteLambda implements Mustache.Lambda { + private final CopyLambda copyLambda; + private final Boolean stripLeading; + private final Boolean stripTrailing; + private final Boolean endWithLineBreak; + private final Boolean clear; + + public PasteLambda(CopyLambda copyLambda, Boolean stripLeading, Boolean stripTrailing, Boolean endWithLineBreak, boolean clear) { + this.copyLambda = copyLambda; + this.stripLeading = stripLeading; + this.stripTrailing = stripTrailing; + this.endWithLineBreak = endWithLineBreak; + this.clear = clear; + } + + @Override + public void execute(Fragment fragment, Writer writer) throws IOException { + String content = this.copyLambda.savedContent; + + if (content == null) { + return; + } + + if (this.stripTrailing){ + content = content.stripTrailing(); + } + if (this.stripLeading) { + content = content.stripLeading(); + } + if (this.endWithLineBreak && !content.endsWith("\n")){ + content = content + "\n"; + } + writer.write(content); + + if (this.clear) { + this.copyLambda.savedContent = null; + } + } +} diff --git a/modules/openapi-generator/src/main/resources/csharp/NullConditionalProperty.mustache b/modules/openapi-generator/src/main/resources/csharp/NullConditionalProperty.mustache index d8ad9266699..7dcafa8033e 100644 --- a/modules/openapi-generator/src/main/resources/csharp/NullConditionalProperty.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/NullConditionalProperty.mustache @@ -1 +1 @@ -{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}} \ No newline at end of file +{{#lambda.first}}{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} \ No newline at end of file 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 e2aa6a74d6a..9967867ac01 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 @@ -38,7 +38,7 @@ JsonTokenType startingTokenType = utf8JsonReader.TokenType; {{#allVars}} - {{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default; + Option<{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}> {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default; {{#-last}} {{/-last}} @@ -167,39 +167,39 @@ {{^isMap}} {{^isEnum}} {{^isUuid}} - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetString(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetString(){{^isNullable}}{{nrt!}}{{/isNullable}}); {{/isUuid}} {{/isEnum}} {{/isMap}} {{/isString}} {{#isBoolean}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetBoolean(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetBoolean()); {{/isBoolean}} {{#isNumeric}} {{^isEnum}} {{#isDouble}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetDouble(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetDouble()); {{/isDouble}} {{#isDecimal}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetDecimal(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetDecimal()); {{/isDecimal}} {{#isFloat}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = (float)utf8JsonReader.GetDouble(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}(float)utf8JsonReader.GetDouble()); {{/isFloat}} {{#isLong}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int64(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int64()); {{/isLong}} {{^isLong}} {{^isFloat}} {{^isDecimal}} {{^isDouble}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32()); {{/isDouble}} {{/isDecimal}} {{/isFloat}} @@ -208,36 +208,34 @@ {{/isNumeric}} {{#isDate}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); {{/isDate}} {{#isDateTime}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); {{/isDateTime}} {{#isEnum}} {{^isMap}} {{#isNumeric}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = ({{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}})utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}({{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}})utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32()); {{/isNumeric}} {{^isNumeric}} string{{nrt?}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = utf8JsonReader.GetString(); {{^isInnerEnum}} - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue == null - ? null - : {{{datatypeWithEnum}}}ValueConverter.FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue); + if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null) + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}{{{datatypeWithEnum}}}ValueConverter.FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue)); {{/isInnerEnum}} {{#isInnerEnum}} - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue == null - ? null - : {{classname}}.{{{datatypeWithEnum}}}FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue); + if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null) + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}{{classname}}.{{{datatypeWithEnum}}}FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue)); {{/isInnerEnum}} {{/isNumeric}} {{/isMap}} {{/isEnum}} {{#isUuid}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetGuid(); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetGuid()); {{/isUuid}} {{^isUuid}} {{^isEnum}} @@ -247,7 +245,7 @@ {{^isDate}} {{^isDateTime}} if (utf8JsonReader.TokenType != JsonTokenType.Null) - {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<{{{datatypeWithEnum}}}>(ref utf8JsonReader, jsonSerializerOptions); + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<{{{datatypeWithEnum}}}>(ref utf8JsonReader, jsonSerializerOptions){{^isNullable}}{{nrt!}}{{/isNullable}}); {{/isDateTime}} {{/isDate}} {{/isNumeric}} @@ -263,10 +261,17 @@ } } + {{#allVars}} + {{#required}} + if (!{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.IsSet) + throw new ArgumentException("Property is required for class {{classname}}.", nameof({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}})); + + {{/required}} + {{/allVars}} {{#allVars}} {{^isNullable}} - if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) - throw new ArgumentNullException(nameof({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}), "Property is required for class {{classname}}."); + if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.IsSet && {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.Value == null) + throw new ArgumentNullException(nameof({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}), "Property is not nullable for class {{classname}}."); {{/isNullable}} {{/allVars}} @@ -275,7 +280,7 @@ {{#model.hasDiscriminatorWithNonEmptyMapping}} {{#mappedModels}} if ({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}} != null) - return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}}); + return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}}); {{#-last}} throw new JsonException(); @@ -284,13 +289,23 @@ {{/model.hasDiscriminatorWithNonEmptyMapping}} {{/model.discriminator}} {{^composedSchemas.oneOf}} - return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}}); + {{^required}} + {{#model.composedSchemas.anyOf}} + Option<{{baseType}}{{>NullConditionalProperty}}> {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}ParsedValue = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} == null + ? default + : new Option<{{baseType}}{{>NullConditionalProperty}}>({{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}); + {{/model.composedSchemas.anyOf}} + {{#-last}} + + {{/-last}} + {{/required}} + return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}ParsedValue{{#required}}.Value{{^isNullable}}{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}}); {{/composedSchemas.oneOf}} {{^model.discriminator}} {{#composedSchemas}} {{#oneOf}} if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} != null) - return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}}); + return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#required}}ParsedValue{{/required}} {{/allVars}}{{/lambda.joinWithComma}}); {{#-last}} throw new JsonException(); @@ -328,10 +343,10 @@ {{^model.discriminator}} {{#composedSchemas}} {{#anyOf}} - if ({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}} != null) + if ({{#lambda.joinWithAmpersand}}{{^required}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}Option.IsSet {{/required}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}{{^required}}Option.Value{{/required}} != null{{/lambda.joinWithAmpersand}}) { - {{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}.GetType())); - {{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}, jsonSerializerOptions); + {{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}{{^required}}Option.Value{{/required}}.GetType())); + {{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions); } {{/anyOf}} @@ -354,78 +369,76 @@ {{#lambda.trimTrailingWithNewLine}} {{#lambda.trimLineBreaks}} {{#allVars}} + {{^isNullable}} + {{#vendorExtensions.x-is-reference-type}} + if ({{^required}}{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet && {{/required}}{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null) + throw new ArgumentNullException(nameof({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}), "Property is required for class {{classname}}."); + + {{/vendorExtensions.x-is-reference-type}} + {{/isNullable}} + {{/allVars}} + {{#allVars}} {{#isString}} {{^isMap}} {{^isEnum}} {{^isUuid}} + {{#lambda.copy}} writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isUuid}} {{/isEnum}} {{/isMap}} {{/isString}} {{#isBoolean}} - {{#isNullable}} - - if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null) - writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value); - else - writer.WriteNull("{{baseName}}"); - - {{/isNullable}} - {{^isNullable}} - writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}); - {{/isNullable}} + {{#lambda.copy}} + writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isBoolean}} {{^isEnum}} {{#isNumeric}} - {{#isNullable}} - - if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null) - writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value); - else - writer.WriteNull("{{baseName}}"); - - {{/isNullable}} - {{^isNullable}} - writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}); - {{/isNullable}} + {{#lambda.copy}} + writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isNumeric}} {{/isEnum}} {{#isDate}} - {{#isNullable}} - - if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null) - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value.ToString({{name}}Format)); - else - writer.WriteNull("{{baseName}}"); - - {{/isNullable}} - {{^isNullable}} - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.ToString({{name}}Format)); - {{/isNullable}} + {{#lambda.copy}} + writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}.ToString({{name}}Format)); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isDate}} {{#isDateTime}} - {{#isNullable}} - - if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null) - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value.ToString({{name}}Format)); - else - writer.WriteNull("{{baseName}}"); - - {{/isNullable}} - {{^isNullable}} - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.ToString({{name}}Format)); - {{/isNullable}} + {{#lambda.copy}} + writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}.ToString({{name}}Format)); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isDateTime}} {{#isEnum}} {{#isNumeric}} - writer.WriteNumber("{{baseName}}", {{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}})); + {{#lambda.copy}} + writer.WriteNumber("{{baseName}}", {{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}})); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isNumeric}} {{^isMap}} {{^isNumeric}} {{#isInnerEnum}} - - var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}); + var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}{{nrt!}}.Value{{/isNullable}}{{/required}}); if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null) writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue); else @@ -433,18 +446,21 @@ {{/isInnerEnum}} {{^isInnerEnum}} + {{#lambda.copy}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue + {{/lambda.copy}} + {{#required}} {{#isNullable}} - if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null) writer.WriteNull("{{baseName}}"); else { - var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{#isNullable}}.Value{{/isNullable}}); + var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value); {{#allowableValues}} {{#enumVars}} {{#-first}} {{#isString}} - if ({{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue != null){{! we cant use name here because enumVar also has a name property, so use the camel case variant only as a work around }} + if ({{#lambda.pasteLine}}{{/lambda.pasteLine}} != null){{! we cant use name here because enumVar also has a name property, so use the paste lambda instead }} writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue); else writer.WriteNull("{{baseName}}"); @@ -456,44 +472,53 @@ {{/enumVars}} {{/allowableValues}} } - {{/isNullable}} {{^isNullable}} - var {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{#isNullable}}.Value{{/isNullable}}); + var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}); {{#allowableValues}} {{#enumVars}} {{#-first}} {{#isString}} - - if ({{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue != null) - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue); - else - writer.WriteNull("{{baseName}}"); - + writer.WriteString("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}); {{/isString}} {{^isString}} - writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue); + writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/lambda.camelcase_param}}RawValue); {{/isString}} {{/-first}} {{/enumVars}} {{/allowableValues}} {{/isNullable}} + + {{/required}} + {{^required}} + if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet) + {{#isNullable}} + if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option{{nrt!}}.Value != null) + { + var {{#lambda.pasteLine}}{{/lambda.pasteLine}} = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.Value{{nrt!}}.Value); + writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{#isString}}WriteString {{/isString}}{{^isString}}WriteNumber {{/isString}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}); + } + else + writer.WriteNull("{{baseName}}"); + {{/isNullable}} + {{^isNullable}} + { + var {{#lambda.pasteLine}}{{/lambda.pasteLine}} = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{nrt!}}.Value); + writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{#isString}}WriteString {{/isString}}{{^isString}}WriteNumber {{/isString}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}}); + } + {{/isNullable}} + {{/required}} {{/isInnerEnum}} {{/isNumeric}} {{/isMap}} {{/isEnum}} {{#isUuid}} - {{^isNullable}} - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}); - {{/isNullable}} - {{#isNullable}} - - if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null) - writer.WriteNull("{{baseName}}"); - else - writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value); - - {{/isNullable}} + {{#lambda.copy}} + writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}); + {{/lambda.copy}} + {{#lambda.indent3}} + {{>WriteProperty}} + {{/lambda.indent3}} {{/isUuid}} {{^isUuid}} {{^isEnum}} @@ -502,8 +527,39 @@ {{^isNumeric}} {{^isDate}} {{^isDateTime}} + {{#required}} + {{#isNullable}} + if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null) + { + writer.WritePropertyName("{{baseName}}"); + JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions); + } + else + writer.WriteNull("{{baseName}}"); + {{/isNullable}} + {{^isNullable}} writer.WritePropertyName("{{baseName}}"); JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions); + {{/isNullable}} + {{/required}} + {{^required}} + if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet) + {{#isNullable}} + if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.Value != null) + { + writer.WritePropertyName("{{baseName}}"); + JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions); + } + else + writer.WriteNull("{{baseName}}"); + {{/isNullable}} + {{^isNullable}} + { + writer.WritePropertyName("{{baseName}}"); + JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions); + } + {{/isNullable}} + {{/required}} {{/isDateTime}} {{/isDate}} {{/isNumeric}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache index 3a1e7c35d69..b5a2c08ac29 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache @@ -1 +1 @@ -{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}} \ No newline at end of file +{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache index 0e7bbc90e6b..faa8273bf2b 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache @@ -1 +1 @@ -{{#model.allVars}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^defaultValue}}{{#isNullable}} = default{{/isNullable}}{{/defaultValue}} {{/model.allVars}} \ No newline at end of file +{{#model.allVars}}{{^required}}Option<{{/required}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^required}}default{{/required}}{{#required}}{{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{.}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/required}}{{/defaultValue}}{{^defaultValue}}{{#lambda.first}}{{#isNullable}} = default {{/isNullable}}{{^required}} = default {{/required}}{{/lambda.first}}{{/defaultValue}} {{/model.allVars}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/Option.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/Option.mustache index 8e0d888a224..eed49143e41 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/Option.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/Option.mustache @@ -31,5 +31,17 @@ namespace {{packageName}}.{{clientPackage}} IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OptionProperty.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OptionProperty.mustache new file mode 100644 index 00000000000..d7504188775 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OptionProperty.mustache @@ -0,0 +1 @@ +new Option<{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}>( \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ValidateRegex.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ValidateRegex.mustache new file mode 100644 index 00000000000..78aba8fb345 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ValidateRegex.mustache @@ -0,0 +1,7 @@ +// {{{name}}} ({{{dataType}}}) pattern +Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}); +{{#lambda.copy}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null && {{/lambda.copy}} +if ({{#lambda.first}}{{^required}}{{#lambda.pasteLine}}{{/lambda.pasteLine}} {{/required}}{{#isNullable}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/isNullable}}{{/lambda.first}}!regex{{{name}}}.Match(this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}}{{#isUuid}}.ToString(){{#lambda.first}}{{^required}}{{nrt!}} {{/required}}{{#isNullable}}! {{/isNullable}}{{/lambda.first}}{{/isUuid}}).Success) +{ + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" }); +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WriteProperty.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WriteProperty.mustache new file mode 100644 index 00000000000..6c9192d8597 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WriteProperty.mustache @@ -0,0 +1,9 @@ +{{#required}} +{{>WritePropertyHelper}} +{{/required}} +{{^required}} +if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet) + {{#lambda.indent1}} + {{>WritePropertyHelper}} + {{/lambda.indent1}} +{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache new file mode 100644 index 00000000000..8c8e7b4a704 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache @@ -0,0 +1,9 @@ +{{#isNullable}} +if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{/required}} != null) + {{#lambda.pasteLine}}{{/lambda.pasteLine}} +else + writer.WriteNull("{{baseName}}"); +{{/isNullable}} +{{^isNullable}} +{{#lambda.pasteLine}}{{/lambda.pasteLine}} +{{/isNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/model.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/model.mustache index f11dd9ba2b0..f9931574dcf 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/model.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/model.mustache @@ -26,8 +26,8 @@ using OpenAPIClientUtils = {{packageName}}.Client.ClientUtils; {{#useGenericHost}} {{#useSourceGeneration}} using System.Text.Json.Serialization.Metadata; -using {{packageName}}.{{clientPackage}}; {{/useSourceGeneration}} +using {{packageName}}.{{clientPackage}}; {{/useGenericHost}} {{#models}} {{#lambda.trimTrailingWithNewLine}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache index 5667892c0b1..62ed3f172ab 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache @@ -15,19 +15,19 @@ {{#allVars}} /// {{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}} {{/allVars}} - {{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{{dataType}}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{#model.composedSchemas.anyOf}}{{{dataType}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/model.composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#parentModel.composedSchemas.oneOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.oneOf}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}} + {{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{{dataType}}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{#model.composedSchemas.anyOf}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/model.composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#parentModel.composedSchemas.oneOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.oneOf}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}} { {{#composedSchemas.anyOf}} - {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}; + {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}; {{/composedSchemas.anyOf}} {{name}} = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}; {{#allVars}} {{^isInherited}} - {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; {{/isInherited}} {{#isInherited}} {{#isNew}} - {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; {{/isNew}} {{/isInherited}} {{/allVars}} @@ -49,18 +49,18 @@ {{^composedSchemas.anyOf}} [JsonConstructor] {{/composedSchemas.anyOf}} - {{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{#composedSchemas.anyOf}}{{{name}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}} + {{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{#composedSchemas.anyOf}}{{^required}}Option<{{/required}}{{{name}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}} { {{#composedSchemas.anyOf}} - {{#lambda.titlecase}}{{name}}{{/lambda.titlecase}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; {{/composedSchemas.anyOf}} {{#allVars}} {{^isInherited}} - {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; {{/isInherited}} {{#isInherited}} {{#isNew}} - {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; {{/isNew}} {{/isInherited}} {{/allVars}} @@ -84,6 +84,15 @@ {{/complexType}} {{/isEnum}} {{#isEnum}} + {{^required}} + /// + /// Used to track the state of {{{name}}} + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public {{#isNew}}new {{/isNew}}Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}} + + {{/required}} /// /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} /// @@ -97,12 +106,21 @@ {{#deprecated}} [Obsolete] {{/deprecated}} - public {{#isNew}}new {{/isNew}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{name}} { get; {{^isReadOnly}}set; {{/isReadOnly}}} + public {{#isNew}}new {{/isNew}}{{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{name}}Option; } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}} {{/isEnum}} {{/vars}} {{#composedSchemas.anyOf}} {{^vendorExtensions.x-duplicated-data-type}} + {{^required}} + /// + /// Used to track the state of {{{name}}} + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public {{#isNew}}new {{/isNew}}Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}} + + {{/required}} /// /// {{description}}{{^description}}Gets or Sets {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}{{/description}} /// {{#description}} @@ -113,7 +131,7 @@ {{#deprecated}} [Obsolete] {{/deprecated}} - public {{{dataType}}}{{>NullConditionalProperty}} {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} { get; {{^isReadOnly}}set; {{/isReadOnly}}} + public {{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}Option; } {{^isReadOnly}}set { this.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}} {{/vendorExtensions.x-duplicated-data-type}} {{/composedSchemas.anyOf}} @@ -137,6 +155,15 @@ {{^isEnum}} {{#isInherited}} {{#isNew}} + {{^required}} + /// + /// Used to track the state of {{{name}}} + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}} + + {{/required}} /// /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} /// {{#description}} @@ -148,11 +175,20 @@ {{#deprecated}} [Obsolete] {{/deprecated}} - public new {{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{name}} { get; {{^isReadOnly}}set; {{/isReadOnly}}} + public new {{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{name}}Option } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}} {{/isNew}} {{/isInherited}} {{^isInherited}} + {{^required}} + /// + /// Used to track the state of {{{name}}} + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}} + + {{/required}} /// /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} /// {{#description}} @@ -164,7 +200,7 @@ {{#deprecated}} [Obsolete] {{/deprecated}} - public {{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{name}} { get; {{^isReadOnly}}set; {{/isReadOnly}}} + public {{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this. {{name}}Option; } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}} {{/isInherited}} {{/isEnum}} @@ -274,16 +310,24 @@ int hashCode = 41; {{/parent}} {{#readOnlyVars}} + {{#required}} {{^isNullable}} hashCode = (hashCode * 59) + {{name}}.GetHashCode(); {{/isNullable}} + {{/required}} {{/readOnlyVars}} {{#readOnlyVars}} - {{#isNullable}} + {{#lambda.copy}} if ({{name}} != null) hashCode = (hashCode * 59) + {{name}}.GetHashCode(); + {{/lambda.copy}} + {{#isNullable}} + {{#lambda.pasteOnce}}{{/lambda.pasteOnce}} {{/isNullable}} + {{^required}} + {{#lambda.pasteOnce}}{{/lambda.pasteOnce}} + {{/required}} {{/readOnlyVars}} {{#isAdditionalPropertiesTrue}} {{^parentModel}} diff --git a/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache index 2c78e1cb660..0f484b0552e 100644 --- a/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache @@ -74,7 +74,7 @@ {{#isString}} /// {{/isString}} - public static {{>EnumValueDataType}}{{>NullConditionalProperty}} {{datatypeWithEnum}}ToJsonValue({{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{>NullConditionalProperty}} value) + public static {{>EnumValueDataType}}{{#nrt}}{{#isString}}{{#isNullable}}{{nrt?}} {{^nrt}}{{#vendorExtensions.x-is-value-type}}? {{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}}{{/isString}}{{/nrt}} {{datatypeWithEnum}}ToJsonValue({{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#isString}}{{>NullConditionalProperty}}{{/isString}} value) { {{^isString}} return ({{>EnumValueDataType}}) value; @@ -83,8 +83,8 @@ {{#isNullable}} if (value == null) return null; - {{/isNullable}} + {{/isNullable}} {{#allowableValues}} {{#enumVars}} if (value == {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.{{name}}) diff --git a/modules/openapi-generator/src/main/resources/csharp/validatable.mustache b/modules/openapi-generator/src/main/resources/csharp/validatable.mustache index 2352d0d5517..b06b98fc636 100644 --- a/modules/openapi-generator/src/main/resources/csharp/validatable.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/validatable.mustache @@ -78,7 +78,7 @@ {{/minLength}} {{#maximum}} // {{{name}}} ({{{dataType}}}) maximum - if (this.{{{name}}} > ({{{dataType}}}){{maximum}}) + if ({{#useGenericHost}}{{^required}}this.{{{name}}}Option.IsSet && {{/required}}{{/useGenericHost}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} > ({{{dataType}}}){{maximum}}) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" }); } @@ -86,7 +86,7 @@ {{/maximum}} {{#minimum}} // {{{name}}} ({{{dataType}}}) minimum - if (this.{{{name}}} < ({{{dataType}}}){{minimum}}) + if ({{#useGenericHost}}{{^required}}this.{{{name}}}Option.IsSet && {{/required}}{{/useGenericHost}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} < ({{{dataType}}}){{minimum}}) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" }); } @@ -96,7 +96,7 @@ {{^isByteArray}} {{#vendorExtensions.x-is-value-type}} {{#isNullable}} - if (this.{{{name}}} != null){ + if (this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null){ {{#lambda.trimTrailingWithNewLine}} {{#lambda.indent4}} {{>ValidateRegex}} @@ -116,7 +116,7 @@ {{/isNullable}} {{/vendorExtensions.x-is-value-type}} {{^vendorExtensions.x-is-value-type}} - if (this.{{{name}}} != null) { + if (this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null) { {{#lambda.trimTrailingWithNewLine}} {{#lambda.indent4}} {{>ValidateRegex}} 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 2fab0cbf594..0ebc00da632 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 @@ -1983,6 +1983,266 @@ components: nullable: true type: string description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + RequiredClass: + type: object + properties: + required_nullable_integer_prop: + type: integer + nullable: true + required_notnullableinteger_prop: + type: integer + nullable: false + not_required_nullable_integer_prop: + type: integer + nullable: true + not_required_notnullableinteger_prop: + type: integer + nullable: false + + required_nullable_string_prop: + type: string + nullable: true + required_notnullable_string_prop: + type: string + nullable: false + notrequired_nullable_string_prop: + type: string + nullable: true + notrequired_notnullable_string_prop: + type: string + nullable: false + + required_nullable_boolean_prop: + type: boolean + nullable: true + required_notnullable_boolean_prop: + type: boolean + nullable: false + notrequired_nullable_boolean_prop: + type: boolean + nullable: true + notrequired_notnullable_boolean_prop: + type: boolean + nullable: false + + required_nullable_date_prop: + type: string + format: date + nullable: true + required_not_nullable_date_prop: + type: string + format: date + nullable: false + not_required_nullable_date_prop: + type: string + format: date + nullable: true + not_required_notnullable_date_prop: + type: string + format: date + nullable: false + + required_notnullable_datetime_prop: + type: string + format: date-time + nullable: false + required_nullable_datetime_prop: + type: string + format: date-time + nullable: true + notrequired_nullable_datetime_prop: + type: string + format: date-time + nullable: true + notrequired_notnullable_datetime_prop: + type: string + format: date-time + nullable: false + + required_nullable_enum_integer: + type: integer + format: int32 + nullable: true + enum: + - 1 + - -1 + required_notnullable_enum_integer: + type: integer + format: int32 + nullable: false + enum: + - 1 + - -1 + notrequired_nullable_enum_integer: + type: integer + format: int32 + nullable: true + enum: + - 1 + - -1 + notrequired_notnullable_enum_integer: + type: integer + format: int32 + nullable: false + enum: + - 1 + - -1 + + required_nullable_enum_integer_only: + type: integer + nullable: true + enum: + - 2 + - -2 + required_notnullable_enum_integer_only: + type: integer + nullable: false + enum: + - 2 + - -2 + notrequired_nullable_enum_integer_only: + type: integer + nullable: true + enum: + - 2 + - -2 + notrequired_notnullable_enum_integer_only: + type: integer + nullable: false + enum: + - 2 + - -2 + + required_notnullable_enum_string: + type: string + nullable: false + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + required_nullable_enum_string: + type: string + nullable: true + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + notrequired_nullable_enum_string: + type: string + nullable: true + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + notrequired_notnullable_enum_string: + type: string + nullable: false + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + + required_nullable_outerEnumDefaultValue: + nullable: true + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + required_notnullable_outerEnumDefaultValue: + nullable: false + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + notrequired_nullable_outerEnumDefaultValue: + nullable: true + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + notrequired_notnullable_outerEnumDefaultValue: + nullable: false + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + + required_nullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: true + required_notnullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: false + notrequired_nullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: true + notrequired_notnullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: false + + required_nullable_array_of_string: + type: array + nullable: true + items: + type: string + required_notnullable_array_of_string: + type: array + nullable: false + items: + type: string + notrequired_nullable_array_of_string: + type: array + nullable: true + items: + type: string + notrequired_notnullable_array_of_string: + type: array + nullable: false + items: + type: string + required: + - required_nullable_boolean_prop + - required_notnullable_boolean_prop + - required_nullable_string_prop + - required_notnullable_string_prop + - required_nullable_integer_prop + - required_notnullableinteger_prop + - required_nullable_date_prop + - required_not_nullable_date_prop + - required_notnullable_datetime_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_notnullable_enum_integer + - required_nullable_enum_integer_only + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_nullable_enum_string + - required_nullable_outerEnumDefaultValue + - required_notnullable_outerEnumDefaultValue + - required_nullable_uuid + - required_notnullable_uuid + - required_nullable_array_of_string + - required_notnullable_array_of_string NullableClass: type: object properties: diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES index ddeca89d213..1e54de3472d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -198,6 +199,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/README.md b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/README.md index af827f28641..c2d5ddeb353 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/README.md @@ -221,6 +221,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..a3bfdf70206 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1954 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger + { + get{ return _RequiredNullableEnumInteger;} + set + { + _RequiredNullableEnumInteger = value; + _flagRequiredNullableEnumInteger = true; + } + } + private RequiredNullableEnumIntegerEnum _RequiredNullableEnumInteger; + private bool _flagRequiredNullableEnumInteger; + + /// + /// Returns false as RequiredNullableEnumInteger should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableEnumInteger() + { + return _flagRequiredNullableEnumInteger; + } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger + { + get{ return _RequiredNotnullableEnumInteger;} + set + { + _RequiredNotnullableEnumInteger = value; + _flagRequiredNotnullableEnumInteger = true; + } + } + private RequiredNotnullableEnumIntegerEnum _RequiredNotnullableEnumInteger; + private bool _flagRequiredNotnullableEnumInteger; + + /// + /// Returns false as RequiredNotnullableEnumInteger should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableEnumInteger() + { + return _flagRequiredNotnullableEnumInteger; + } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger + { + get{ return _NotrequiredNullableEnumInteger;} + set + { + _NotrequiredNullableEnumInteger = value; + _flagNotrequiredNullableEnumInteger = true; + } + } + private NotrequiredNullableEnumIntegerEnum? _NotrequiredNullableEnumInteger; + private bool _flagNotrequiredNullableEnumInteger; + + /// + /// Returns false as NotrequiredNullableEnumInteger should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableEnumInteger() + { + return _flagNotrequiredNullableEnumInteger; + } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger + { + get{ return _NotrequiredNotnullableEnumInteger;} + set + { + _NotrequiredNotnullableEnumInteger = value; + _flagNotrequiredNotnullableEnumInteger = true; + } + } + private NotrequiredNotnullableEnumIntegerEnum? _NotrequiredNotnullableEnumInteger; + private bool _flagNotrequiredNotnullableEnumInteger; + + /// + /// Returns false as NotrequiredNotnullableEnumInteger should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableEnumInteger() + { + return _flagNotrequiredNotnullableEnumInteger; + } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly + { + get{ return _RequiredNullableEnumIntegerOnly;} + set + { + _RequiredNullableEnumIntegerOnly = value; + _flagRequiredNullableEnumIntegerOnly = true; + } + } + private RequiredNullableEnumIntegerOnlyEnum _RequiredNullableEnumIntegerOnly; + private bool _flagRequiredNullableEnumIntegerOnly; + + /// + /// Returns false as RequiredNullableEnumIntegerOnly should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableEnumIntegerOnly() + { + return _flagRequiredNullableEnumIntegerOnly; + } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly + { + get{ return _RequiredNotnullableEnumIntegerOnly;} + set + { + _RequiredNotnullableEnumIntegerOnly = value; + _flagRequiredNotnullableEnumIntegerOnly = true; + } + } + private RequiredNotnullableEnumIntegerOnlyEnum _RequiredNotnullableEnumIntegerOnly; + private bool _flagRequiredNotnullableEnumIntegerOnly; + + /// + /// Returns false as RequiredNotnullableEnumIntegerOnly should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableEnumIntegerOnly() + { + return _flagRequiredNotnullableEnumIntegerOnly; + } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly + { + get{ return _NotrequiredNullableEnumIntegerOnly;} + set + { + _NotrequiredNullableEnumIntegerOnly = value; + _flagNotrequiredNullableEnumIntegerOnly = true; + } + } + private NotrequiredNullableEnumIntegerOnlyEnum? _NotrequiredNullableEnumIntegerOnly; + private bool _flagNotrequiredNullableEnumIntegerOnly; + + /// + /// Returns false as NotrequiredNullableEnumIntegerOnly should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableEnumIntegerOnly() + { + return _flagNotrequiredNullableEnumIntegerOnly; + } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly + { + get{ return _NotrequiredNotnullableEnumIntegerOnly;} + set + { + _NotrequiredNotnullableEnumIntegerOnly = value; + _flagNotrequiredNotnullableEnumIntegerOnly = true; + } + } + private NotrequiredNotnullableEnumIntegerOnlyEnum? _NotrequiredNotnullableEnumIntegerOnly; + private bool _flagNotrequiredNotnullableEnumIntegerOnly; + + /// + /// Returns false as NotrequiredNotnullableEnumIntegerOnly should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableEnumIntegerOnly() + { + return _flagNotrequiredNotnullableEnumIntegerOnly; + } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString + { + get{ return _RequiredNotnullableEnumString;} + set + { + _RequiredNotnullableEnumString = value; + _flagRequiredNotnullableEnumString = true; + } + } + private RequiredNotnullableEnumStringEnum _RequiredNotnullableEnumString; + private bool _flagRequiredNotnullableEnumString; + + /// + /// Returns false as RequiredNotnullableEnumString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableEnumString() + { + return _flagRequiredNotnullableEnumString; + } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString + { + get{ return _RequiredNullableEnumString;} + set + { + _RequiredNullableEnumString = value; + _flagRequiredNullableEnumString = true; + } + } + private RequiredNullableEnumStringEnum _RequiredNullableEnumString; + private bool _flagRequiredNullableEnumString; + + /// + /// Returns false as RequiredNullableEnumString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableEnumString() + { + return _flagRequiredNullableEnumString; + } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString + { + get{ return _NotrequiredNullableEnumString;} + set + { + _NotrequiredNullableEnumString = value; + _flagNotrequiredNullableEnumString = true; + } + } + private NotrequiredNullableEnumStringEnum? _NotrequiredNullableEnumString; + private bool _flagNotrequiredNullableEnumString; + + /// + /// Returns false as NotrequiredNullableEnumString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableEnumString() + { + return _flagNotrequiredNullableEnumString; + } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString + { + get{ return _NotrequiredNotnullableEnumString;} + set + { + _NotrequiredNotnullableEnumString = value; + _flagNotrequiredNotnullableEnumString = true; + } + } + private NotrequiredNotnullableEnumStringEnum? _NotrequiredNotnullableEnumString; + private bool _flagNotrequiredNotnullableEnumString; + + /// + /// Returns false as NotrequiredNotnullableEnumString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableEnumString() + { + return _flagNotrequiredNotnullableEnumString; + } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue + { + get{ return _RequiredNullableOuterEnumDefaultValue;} + set + { + _RequiredNullableOuterEnumDefaultValue = value; + _flagRequiredNullableOuterEnumDefaultValue = true; + } + } + private OuterEnumDefaultValue _RequiredNullableOuterEnumDefaultValue; + private bool _flagRequiredNullableOuterEnumDefaultValue; + + /// + /// Returns false as RequiredNullableOuterEnumDefaultValue should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableOuterEnumDefaultValue() + { + return _flagRequiredNullableOuterEnumDefaultValue; + } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue + { + get{ return _RequiredNotnullableOuterEnumDefaultValue;} + set + { + _RequiredNotnullableOuterEnumDefaultValue = value; + _flagRequiredNotnullableOuterEnumDefaultValue = true; + } + } + private OuterEnumDefaultValue _RequiredNotnullableOuterEnumDefaultValue; + private bool _flagRequiredNotnullableOuterEnumDefaultValue; + + /// + /// Returns false as RequiredNotnullableOuterEnumDefaultValue should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableOuterEnumDefaultValue() + { + return _flagRequiredNotnullableOuterEnumDefaultValue; + } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue + { + get{ return _NotrequiredNullableOuterEnumDefaultValue;} + set + { + _NotrequiredNullableOuterEnumDefaultValue = value; + _flagNotrequiredNullableOuterEnumDefaultValue = true; + } + } + private OuterEnumDefaultValue? _NotrequiredNullableOuterEnumDefaultValue; + private bool _flagNotrequiredNullableOuterEnumDefaultValue; + + /// + /// Returns false as NotrequiredNullableOuterEnumDefaultValue should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableOuterEnumDefaultValue() + { + return _flagNotrequiredNullableOuterEnumDefaultValue; + } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue + { + get{ return _NotrequiredNotnullableOuterEnumDefaultValue;} + set + { + _NotrequiredNotnullableOuterEnumDefaultValue = value; + _flagNotrequiredNotnullableOuterEnumDefaultValue = true; + } + } + private OuterEnumDefaultValue? _NotrequiredNotnullableOuterEnumDefaultValue; + private bool _flagNotrequiredNotnullableOuterEnumDefaultValue; + + /// + /// Returns false as NotrequiredNotnullableOuterEnumDefaultValue should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableOuterEnumDefaultValue() + { + return _flagNotrequiredNotnullableOuterEnumDefaultValue; + } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableIntegerProp = requiredNullableIntegerProp; + this._RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this._RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableBooleanProp = requiredNullableBooleanProp; + this._RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableDateProp = requiredNullableDateProp; + this._RequiredNotNullableDateProp = requiredNotNullableDateProp; + this._RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this._RequiredNullableEnumInteger = requiredNullableEnumInteger; + this._RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this._RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this._RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this._RequiredNotnullableEnumString = requiredNotnullableEnumString; + this._RequiredNullableEnumString = requiredNullableEnumString; + this._RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this._RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableUuid = requiredNullableUuid; + this._RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this._RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this._RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this._NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + if (this.NotRequiredNullableIntegerProp != null) + { + this._flagNotRequiredNullableIntegerProp = true; + } + this._NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + if (this.NotRequiredNotnullableintegerProp != null) + { + this._flagNotRequiredNotnullableintegerProp = true; + } + this._NotrequiredNullableStringProp = notrequiredNullableStringProp; + if (this.NotrequiredNullableStringProp != null) + { + this._flagNotrequiredNullableStringProp = true; + } + this._NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + if (this.NotrequiredNotnullableStringProp != null) + { + this._flagNotrequiredNotnullableStringProp = true; + } + this._NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + if (this.NotrequiredNullableBooleanProp != null) + { + this._flagNotrequiredNullableBooleanProp = true; + } + this._NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + if (this.NotrequiredNotnullableBooleanProp != null) + { + this._flagNotrequiredNotnullableBooleanProp = true; + } + this._NotRequiredNullableDateProp = notRequiredNullableDateProp; + if (this.NotRequiredNullableDateProp != null) + { + this._flagNotRequiredNullableDateProp = true; + } + this._NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + if (this.NotRequiredNotnullableDateProp != null) + { + this._flagNotRequiredNotnullableDateProp = true; + } + this._NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + if (this.NotrequiredNullableDatetimeProp != null) + { + this._flagNotrequiredNullableDatetimeProp = true; + } + this._NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + if (this.NotrequiredNotnullableDatetimeProp != null) + { + this._flagNotrequiredNotnullableDatetimeProp = true; + } + this._NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + if (this.NotrequiredNullableEnumInteger != null) + { + this._flagNotrequiredNullableEnumInteger = true; + } + this._NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + if (this.NotrequiredNotnullableEnumInteger != null) + { + this._flagNotrequiredNotnullableEnumInteger = true; + } + this._NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + if (this.NotrequiredNullableEnumIntegerOnly != null) + { + this._flagNotrequiredNullableEnumIntegerOnly = true; + } + this._NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + if (this.NotrequiredNotnullableEnumIntegerOnly != null) + { + this._flagNotrequiredNotnullableEnumIntegerOnly = true; + } + this._NotrequiredNullableEnumString = notrequiredNullableEnumString; + if (this.NotrequiredNullableEnumString != null) + { + this._flagNotrequiredNullableEnumString = true; + } + this._NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + if (this.NotrequiredNotnullableEnumString != null) + { + this._flagNotrequiredNotnullableEnumString = true; + } + this._NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + if (this.NotrequiredNullableOuterEnumDefaultValue != null) + { + this._flagNotrequiredNullableOuterEnumDefaultValue = true; + } + this._NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + if (this.NotrequiredNotnullableOuterEnumDefaultValue != null) + { + this._flagNotrequiredNotnullableOuterEnumDefaultValue = true; + } + this._NotrequiredNullableUuid = notrequiredNullableUuid; + if (this.NotrequiredNullableUuid != null) + { + this._flagNotrequiredNullableUuid = true; + } + this._NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + if (this.NotrequiredNotnullableUuid != null) + { + this._flagNotrequiredNotnullableUuid = true; + } + this._NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + if (this.NotrequiredNullableArrayOfString != null) + { + this._flagNotrequiredNullableArrayOfString = true; + } + this._NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + if (this.NotrequiredNotnullableArrayOfString != null) + { + this._flagNotrequiredNotnullableArrayOfString = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp + { + get{ return _RequiredNullableIntegerProp;} + set + { + _RequiredNullableIntegerProp = value; + _flagRequiredNullableIntegerProp = true; + } + } + private int? _RequiredNullableIntegerProp; + private bool _flagRequiredNullableIntegerProp; + + /// + /// Returns false as RequiredNullableIntegerProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableIntegerProp() + { + return _flagRequiredNullableIntegerProp; + } + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp + { + get{ return _RequiredNotnullableintegerProp;} + set + { + _RequiredNotnullableintegerProp = value; + _flagRequiredNotnullableintegerProp = true; + } + } + private int _RequiredNotnullableintegerProp; + private bool _flagRequiredNotnullableintegerProp; + + /// + /// Returns false as RequiredNotnullableintegerProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableintegerProp() + { + return _flagRequiredNotnullableintegerProp; + } + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp + { + get{ return _NotRequiredNullableIntegerProp;} + set + { + _NotRequiredNullableIntegerProp = value; + _flagNotRequiredNullableIntegerProp = true; + } + } + private int? _NotRequiredNullableIntegerProp; + private bool _flagNotRequiredNullableIntegerProp; + + /// + /// Returns false as NotRequiredNullableIntegerProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotRequiredNullableIntegerProp() + { + return _flagNotRequiredNullableIntegerProp; + } + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp + { + get{ return _NotRequiredNotnullableintegerProp;} + set + { + _NotRequiredNotnullableintegerProp = value; + _flagNotRequiredNotnullableintegerProp = true; + } + } + private int _NotRequiredNotnullableintegerProp; + private bool _flagNotRequiredNotnullableintegerProp; + + /// + /// Returns false as NotRequiredNotnullableintegerProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotRequiredNotnullableintegerProp() + { + return _flagNotRequiredNotnullableintegerProp; + } + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp + { + get{ return _RequiredNullableStringProp;} + set + { + _RequiredNullableStringProp = value; + _flagRequiredNullableStringProp = true; + } + } + private string _RequiredNullableStringProp; + private bool _flagRequiredNullableStringProp; + + /// + /// Returns false as RequiredNullableStringProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableStringProp() + { + return _flagRequiredNullableStringProp; + } + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp + { + get{ return _RequiredNotnullableStringProp;} + set + { + _RequiredNotnullableStringProp = value; + _flagRequiredNotnullableStringProp = true; + } + } + private string _RequiredNotnullableStringProp; + private bool _flagRequiredNotnullableStringProp; + + /// + /// Returns false as RequiredNotnullableStringProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableStringProp() + { + return _flagRequiredNotnullableStringProp; + } + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp + { + get{ return _NotrequiredNullableStringProp;} + set + { + _NotrequiredNullableStringProp = value; + _flagNotrequiredNullableStringProp = true; + } + } + private string _NotrequiredNullableStringProp; + private bool _flagNotrequiredNullableStringProp; + + /// + /// Returns false as NotrequiredNullableStringProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableStringProp() + { + return _flagNotrequiredNullableStringProp; + } + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp + { + get{ return _NotrequiredNotnullableStringProp;} + set + { + _NotrequiredNotnullableStringProp = value; + _flagNotrequiredNotnullableStringProp = true; + } + } + private string _NotrequiredNotnullableStringProp; + private bool _flagNotrequiredNotnullableStringProp; + + /// + /// Returns false as NotrequiredNotnullableStringProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableStringProp() + { + return _flagNotrequiredNotnullableStringProp; + } + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp + { + get{ return _RequiredNullableBooleanProp;} + set + { + _RequiredNullableBooleanProp = value; + _flagRequiredNullableBooleanProp = true; + } + } + private bool? _RequiredNullableBooleanProp; + private bool _flagRequiredNullableBooleanProp; + + /// + /// Returns false as RequiredNullableBooleanProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableBooleanProp() + { + return _flagRequiredNullableBooleanProp; + } + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp + { + get{ return _RequiredNotnullableBooleanProp;} + set + { + _RequiredNotnullableBooleanProp = value; + _flagRequiredNotnullableBooleanProp = true; + } + } + private bool _RequiredNotnullableBooleanProp; + private bool _flagRequiredNotnullableBooleanProp; + + /// + /// Returns false as RequiredNotnullableBooleanProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableBooleanProp() + { + return _flagRequiredNotnullableBooleanProp; + } + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp + { + get{ return _NotrequiredNullableBooleanProp;} + set + { + _NotrequiredNullableBooleanProp = value; + _flagNotrequiredNullableBooleanProp = true; + } + } + private bool? _NotrequiredNullableBooleanProp; + private bool _flagNotrequiredNullableBooleanProp; + + /// + /// Returns false as NotrequiredNullableBooleanProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableBooleanProp() + { + return _flagNotrequiredNullableBooleanProp; + } + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp + { + get{ return _NotrequiredNotnullableBooleanProp;} + set + { + _NotrequiredNotnullableBooleanProp = value; + _flagNotrequiredNotnullableBooleanProp = true; + } + } + private bool _NotrequiredNotnullableBooleanProp; + private bool _flagNotrequiredNotnullableBooleanProp; + + /// + /// Returns false as NotrequiredNotnullableBooleanProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableBooleanProp() + { + return _flagNotrequiredNotnullableBooleanProp; + } + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonConverter(typeof(OpenAPIDateConverter))] + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDateProp + { + get{ return _RequiredNullableDateProp;} + set + { + _RequiredNullableDateProp = value; + _flagRequiredNullableDateProp = true; + } + } + private DateTime? _RequiredNullableDateProp; + private bool _flagRequiredNullableDateProp; + + /// + /// Returns false as RequiredNullableDateProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableDateProp() + { + return _flagRequiredNullableDateProp; + } + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonConverter(typeof(OpenAPIDateConverter))] + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotNullableDateProp + { + get{ return _RequiredNotNullableDateProp;} + set + { + _RequiredNotNullableDateProp = value; + _flagRequiredNotNullableDateProp = true; + } + } + private DateTime _RequiredNotNullableDateProp; + private bool _flagRequiredNotNullableDateProp; + + /// + /// Returns false as RequiredNotNullableDateProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotNullableDateProp() + { + return _flagRequiredNotNullableDateProp; + } + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonConverter(typeof(OpenAPIDateConverter))] + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + public DateTime? NotRequiredNullableDateProp + { + get{ return _NotRequiredNullableDateProp;} + set + { + _NotRequiredNullableDateProp = value; + _flagNotRequiredNullableDateProp = true; + } + } + private DateTime? _NotRequiredNullableDateProp; + private bool _flagNotRequiredNullableDateProp; + + /// + /// Returns false as NotRequiredNullableDateProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotRequiredNullableDateProp() + { + return _flagNotRequiredNullableDateProp; + } + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonConverter(typeof(OpenAPIDateConverter))] + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + public DateTime NotRequiredNotnullableDateProp + { + get{ return _NotRequiredNotnullableDateProp;} + set + { + _NotRequiredNotnullableDateProp = value; + _flagNotRequiredNotnullableDateProp = true; + } + } + private DateTime _NotRequiredNotnullableDateProp; + private bool _flagNotRequiredNotnullableDateProp; + + /// + /// Returns false as NotRequiredNotnullableDateProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotRequiredNotnullableDateProp() + { + return _flagNotRequiredNotnullableDateProp; + } + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp + { + get{ return _RequiredNotnullableDatetimeProp;} + set + { + _RequiredNotnullableDatetimeProp = value; + _flagRequiredNotnullableDatetimeProp = true; + } + } + private DateTime _RequiredNotnullableDatetimeProp; + private bool _flagRequiredNotnullableDatetimeProp; + + /// + /// Returns false as RequiredNotnullableDatetimeProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableDatetimeProp() + { + return _flagRequiredNotnullableDatetimeProp; + } + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp + { + get{ return _RequiredNullableDatetimeProp;} + set + { + _RequiredNullableDatetimeProp = value; + _flagRequiredNullableDatetimeProp = true; + } + } + private DateTime? _RequiredNullableDatetimeProp; + private bool _flagRequiredNullableDatetimeProp; + + /// + /// Returns false as RequiredNullableDatetimeProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableDatetimeProp() + { + return _flagRequiredNullableDatetimeProp; + } + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp + { + get{ return _NotrequiredNullableDatetimeProp;} + set + { + _NotrequiredNullableDatetimeProp = value; + _flagNotrequiredNullableDatetimeProp = true; + } + } + private DateTime? _NotrequiredNullableDatetimeProp; + private bool _flagNotrequiredNullableDatetimeProp; + + /// + /// Returns false as NotrequiredNullableDatetimeProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableDatetimeProp() + { + return _flagNotrequiredNullableDatetimeProp; + } + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp + { + get{ return _NotrequiredNotnullableDatetimeProp;} + set + { + _NotrequiredNotnullableDatetimeProp = value; + _flagNotrequiredNotnullableDatetimeProp = true; + } + } + private DateTime _NotrequiredNotnullableDatetimeProp; + private bool _flagNotrequiredNotnullableDatetimeProp; + + /// + /// Returns false as NotrequiredNotnullableDatetimeProp should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableDatetimeProp() + { + return _flagNotrequiredNotnullableDatetimeProp; + } + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid + { + get{ return _RequiredNullableUuid;} + set + { + _RequiredNullableUuid = value; + _flagRequiredNullableUuid = true; + } + } + private Guid? _RequiredNullableUuid; + private bool _flagRequiredNullableUuid; + + /// + /// Returns false as RequiredNullableUuid should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableUuid() + { + return _flagRequiredNullableUuid; + } + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid + { + get{ return _RequiredNotnullableUuid;} + set + { + _RequiredNotnullableUuid = value; + _flagRequiredNotnullableUuid = true; + } + } + private Guid _RequiredNotnullableUuid; + private bool _flagRequiredNotnullableUuid; + + /// + /// Returns false as RequiredNotnullableUuid should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableUuid() + { + return _flagRequiredNotnullableUuid; + } + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid + { + get{ return _NotrequiredNullableUuid;} + set + { + _NotrequiredNullableUuid = value; + _flagNotrequiredNullableUuid = true; + } + } + private Guid? _NotrequiredNullableUuid; + private bool _flagNotrequiredNullableUuid; + + /// + /// Returns false as NotrequiredNullableUuid should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableUuid() + { + return _flagNotrequiredNullableUuid; + } + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid + { + get{ return _NotrequiredNotnullableUuid;} + set + { + _NotrequiredNotnullableUuid = value; + _flagNotrequiredNotnullableUuid = true; + } + } + private Guid _NotrequiredNotnullableUuid; + private bool _flagNotrequiredNotnullableUuid; + + /// + /// Returns false as NotrequiredNotnullableUuid should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableUuid() + { + return _flagNotrequiredNotnullableUuid; + } + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString + { + get{ return _RequiredNullableArrayOfString;} + set + { + _RequiredNullableArrayOfString = value; + _flagRequiredNullableArrayOfString = true; + } + } + private List _RequiredNullableArrayOfString; + private bool _flagRequiredNullableArrayOfString; + + /// + /// Returns false as RequiredNullableArrayOfString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNullableArrayOfString() + { + return _flagRequiredNullableArrayOfString; + } + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString + { + get{ return _RequiredNotnullableArrayOfString;} + set + { + _RequiredNotnullableArrayOfString = value; + _flagRequiredNotnullableArrayOfString = true; + } + } + private List _RequiredNotnullableArrayOfString; + private bool _flagRequiredNotnullableArrayOfString; + + /// + /// Returns false as RequiredNotnullableArrayOfString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeRequiredNotnullableArrayOfString() + { + return _flagRequiredNotnullableArrayOfString; + } + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString + { + get{ return _NotrequiredNullableArrayOfString;} + set + { + _NotrequiredNullableArrayOfString = value; + _flagNotrequiredNullableArrayOfString = true; + } + } + private List _NotrequiredNullableArrayOfString; + private bool _flagNotrequiredNullableArrayOfString; + + /// + /// Returns false as NotrequiredNullableArrayOfString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNullableArrayOfString() + { + return _flagNotrequiredNullableArrayOfString; + } + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString + { + get{ return _NotrequiredNotnullableArrayOfString;} + set + { + _NotrequiredNotnullableArrayOfString = value; + _flagNotrequiredNotnullableArrayOfString = true; + } + } + private List _NotrequiredNotnullableArrayOfString; + private bool _flagNotrequiredNotnullableArrayOfString; + + /// + /// Returns false as NotrequiredNotnullableArrayOfString should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeNotrequiredNotnullableArrayOfString() + { + return _flagNotrequiredNotnullableArrayOfString; + } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs index 4e25bc4a95c..24989ea90db 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs @@ -64,7 +64,7 @@ public class UnitTest1 Apple apple = new("#000000", "cultivar", "origin"); string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions); Apple? apple2 = JsonSerializer.Deserialize(appleJson, _jsonSerializerOptions); - Assert.IsTrue(apple2 != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin.Equals(apple2.Origin)); + Assert.IsTrue(apple2 != null && apple.Cultivar != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin != null && apple.Origin.Equals(apple2.Origin)); } [TestMethod] @@ -106,12 +106,12 @@ public class UnitTest1 gmFruit2 != null && gmFruit2.Apple != null && gmFruit2.Banana != null && + gmFruit2.Apple.Cultivar != null && gmFruit2.Apple.Cultivar.Equals(gmFruit.Apple.Cultivar) && + gmFruit2.Apple.Origin != null && gmFruit2.Apple.Origin.Equals(gmFruit.Apple.Origin) && gmFruit2.Banana.LengthCm.Equals(gmFruit.Banana.LengthCm)); - Apple? apple2 = JsonSerializer.Deserialize(gmFruitJson); - Assert.IsTrue(apple2 != null && apple.Cultivar == apple2.Cultivar && apple.Origin == apple2.Origin); // TODO: assert the the properties from Banana and GmFruit are in additionalProperties } @@ -146,16 +146,16 @@ public class UnitTest1 ChildCat childCat = new("some name", ChildCat.PetTypeEnum.ChildCat); string childCatJson = JsonSerializer.Serialize(childCat, _jsonSerializerOptions); ChildCat? childCat2 = JsonSerializer.Deserialize(childCatJson, _jsonSerializerOptions); - Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name.Equals(childCat2.Name)); + Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name != null && childCat.Name.Equals(childCat2.Name)); } [TestMethod] public void Cat() { - Cat cat = new("cat", false, "black"); // TODO: where is the address property? + Cat cat = new("cat", "black", false); // TODO: where is the address property? string catJson = JsonSerializer.Serialize(cat, _jsonSerializerOptions); Cat? cat2 = JsonSerializer.Deserialize(catJson, _jsonSerializerOptions); - Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color.Equals(cat2.Color)); // TODO: add the address property + Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color != null && cat.Color.Equals(cat2.Color)); // TODO: add the address property } } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs index 1dc4e1bcbd0..60f9abd940b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs @@ -50,7 +50,7 @@ namespace OpenAPIClient_generichost_manual_tests Apple apple = new("#000000", "cultivar", "origin"); string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions); Apple? apple2 = JsonSerializer.Deserialize(appleJson, _jsonSerializerOptions); - Assert.IsTrue(apple2 != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin.Equals(apple2.Origin)); + Assert.IsTrue(apple2 != null && apple.Cultivar != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin != null && apple.Origin.Equals(apple2.Origin)); } [TestMethod] @@ -92,12 +92,12 @@ namespace OpenAPIClient_generichost_manual_tests gmFruit2 != null && gmFruit2.Apple != null && gmFruit2.Banana != null && + gmFruit2.Apple.Cultivar != null && gmFruit2.Apple.Cultivar.Equals(gmFruit.Apple.Cultivar) && + gmFruit2.Apple.Origin != null && gmFruit2.Apple.Origin.Equals(gmFruit.Apple.Origin) && gmFruit2.Banana.LengthCm.Equals(gmFruit.Banana.LengthCm)); - Apple? apple2 = JsonSerializer.Deserialize(gmFruitJson); - Assert.IsTrue(apple2 != null && apple.Cultivar == apple2.Cultivar && apple.Origin == apple2.Origin); // TODO: assert the the properties from Banana and GmFruit are in additionalProperties } @@ -132,16 +132,16 @@ namespace OpenAPIClient_generichost_manual_tests ChildCat childCat = new("some name", Org.OpenAPITools.Model.ChildCat.PetTypeEnum.ChildCat); string childCatJson = JsonSerializer.Serialize(childCat, _jsonSerializerOptions); ChildCat? childCat2 = JsonSerializer.Deserialize(childCatJson, _jsonSerializerOptions); - Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name.Equals(childCat2.Name)); + Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name != null && childCat.Name.Equals(childCat2.Name)); } [TestMethod] public void Cat() { - Cat cat = new("cat", false, "black"); // TODO: where is the address property? + Cat cat = new("cat", "black", false); // TODO: where is the address property? string catJson = JsonSerializer.Serialize(cat, _jsonSerializerOptions); Cat? cat2 = JsonSerializer.Deserialize(catJson, _jsonSerializerOptions); - Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color.Equals(cat2.Color)); // TODO: add the address property + Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color != null && cat.Color.Equals(cat2.Color)); // TODO: add the address property } } } \ No newline at end of file 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 03f61d17360..96f2ef1bc1c 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 @@ -79,6 +79,7 @@ docs/models/PolymorphicProperty.md docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md +docs/models/RequiredClass.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -206,6 +207,7 @@ src/UseSourceGeneration/Model/PolymorphicProperty.cs src/UseSourceGeneration/Model/Quadrilateral.cs src/UseSourceGeneration/Model/QuadrilateralInterface.cs src/UseSourceGeneration/Model/ReadOnlyFirst.cs +src/UseSourceGeneration/Model/RequiredClass.cs src/UseSourceGeneration/Model/Return.cs src/UseSourceGeneration/Model/RolesReportsHash.cs src/UseSourceGeneration/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/AdditionalPropertiesClass.md index 0cd0716de5f..60851b8b7ba 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/AdditionalPropertiesClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/AdditionalPropertiesClass.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Anytype1** | **Object** | | [optional] **EmptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] **MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] **MapProperty** | **Dictionary<string, string>** | | [optional] @@ -11,7 +12,6 @@ Name | Type | Description | Notes **MapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional] **MapWithUndeclaredPropertiesAnytype3** | **Dictionary<string, Object>** | | [optional] **MapWithUndeclaredPropertiesString** | **Dictionary<string, string>** | | [optional] -**Anytype1** | **Object** | | [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/Drawing.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Drawing.md index a9a319fd6bb..00ab29d641d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Drawing.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Drawing.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **MainShape** | [**Shape**](Shape.md) | | [optional] -**Shapes** | [**List<Shape>**](Shape.md) | | [optional] **NullableShape** | [**NullableShape**](NullableShape.md) | | [optional] **ShapeOrNull** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] +**Shapes** | [**List<Shape>**](Shape.md) | | [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/EnumTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/EnumTest.md index 49836874e08..b1e5ad4bc42 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/EnumTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/EnumTest.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] **EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **EnumString** | **string** | | [optional] -**EnumStringRequired** | **string** | | +**OuterEnum** | **OuterEnum** | | [optional] **OuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] **OuterEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional] -**OuterEnum** | **OuterEnum** | | [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 33be89a5331..98fa755fce0 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 @@ -4,9 +4,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Binary** | **System.IO.Stream** | | [optional] **VarByte** | **byte[]** | | **Date** | **DateTime** | | +**Number** | **decimal** | | +**Password** | **string** | | +**Binary** | **System.IO.Stream** | | [optional] **DateTime** | **DateTime** | | [optional] **VarDecimal** | **decimal** | | [optional] **VarDouble** | **double** | | [optional] @@ -14,8 +16,6 @@ Name | Type | Description | Notes **Int32** | **int** | | [optional] **Int64** | **long** | | [optional] **Integer** | **int** | | [optional] -**Number** | **decimal** | | -**Password** | **string** | | **PatternWithBackslash** | **string** | None | [optional] **PatternWithDigits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional] **PatternWithDigitsAndDelimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [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 3bc480afe03..ce95a131e6c 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 @@ -4,9 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ArrayItemsNullable** | **List<Object>** | | [optional] -**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ArrayAndItemsNullableProp** | **List<Object>** | | [optional] +**ArrayItemsNullable** | **List<Object>** | | [optional] **ArrayNullableProp** | **List<Object>** | | [optional] **BooleanProp** | **bool** | | [optional] **DateProp** | **DateTime** | | [optional] @@ -14,6 +13,7 @@ Name | Type | Description | Notes **IntegerProp** | **int** | | [optional] **NumberProp** | **decimal** | | [optional] **ObjectAndItemsNullableProp** | **Dictionary<string, Object>** | | [optional] +**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ObjectNullableProp** | **Dictionary<string, Object>** | | [optional] **StringProp** | **string** | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Order.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Order.md index 3ec4ab0e9ad..e1399706ef9 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Order.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Order.md @@ -4,12 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Complete** | **bool** | | [optional] [default to false] **Id** | **long** | | [optional] **PetId** | **long** | | [optional] **Quantity** | **int** | | [optional] **ShipDate** | **DateTime** | | [optional] **Status** | **string** | Order Status | [optional] -**Complete** | **bool** | | [optional] [default to false] [[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/Pet.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Pet.md index 0c5ac31d799..ea37536068a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Pet.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/Pet.md @@ -4,10 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Category** | [**Category**](Category.md) | | [optional] -**Id** | **long** | | [optional] **Name** | **string** | | **PhotoUrls** | **List<string>** | | +**Category** | [**Category**](Category.md) | | [optional] +**Id** | **long** | | [optional] **Status** | **string** | pet status in the store | [optional] **Tags** | [**List<Tag>**](Tag.md) | | [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 new file mode 100644 index 00000000000..fa83b86d571 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/RequiredClass.md @@ -0,0 +1,53 @@ +# UseSourceGeneration.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNotNullableDateProp** | **DateTime** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNotnullableEnumInteger** | **int** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**RequiredNotnullableEnumString** | **string** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableStringProp** | **string** | | +**RequiredNotnullableUuid** | **Guid** | | +**RequiredNotnullableintegerProp** | **int** | | +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNullableBooleanProp** | **bool** | | +**RequiredNullableDateProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime** | | +**RequiredNullableEnumInteger** | **int** | | +**RequiredNullableEnumIntegerOnly** | **int** | | +**RequiredNullableEnumString** | **string** | | +**RequiredNullableIntegerProp** | **int** | | +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNullableStringProp** | **string** | | +**RequiredNullableUuid** | **Guid** | | +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**NotRequiredNullableDateProp** | **DateTime** | | [optional] +**NotRequiredNullableIntegerProp** | **int** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNullableBooleanProp** | **bool** | | [optional] +**NotrequiredNullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNullableEnumInteger** | **int** | | [optional] +**NotrequiredNullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNullableUuid** | **Guid** | | [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/User.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/User.md index 9c3095927a6..4b5d0d81b71 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/User.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/User.md @@ -4,18 +4,18 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] +**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] **Email** | **string** | | [optional] **FirstName** | **string** | | [optional] **Id** | **long** | | [optional] **LastName** | **string** | | [optional] **ObjectWithNoDeclaredProps** | **Object** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional] +**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] **Password** | **string** | | [optional] **Phone** | **string** | | [optional] **UserStatus** | **int** | User Status | [optional] **Username** | **string** | | [optional] -**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] -**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] -**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [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/src/UseSourceGeneration.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..535d720a770 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/RequiredClassTests.cs @@ -0,0 +1,452 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using UseSourceGeneration.Model; +using UseSourceGeneration.Client; +using System.Reflection; + +namespace UseSourceGeneration.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ClientUtils.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ClientUtils.cs index ed4c7f582c6..3b9dc7cfc15 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/ClientUtils.cs @@ -143,6 +143,8 @@ namespace UseSourceGeneration.Client return EnumArrays.JustSymbolEnumToJsonValue(enumArraysJustSymbolEnum); if (obj is EnumClass enumClass) return EnumClassValueConverter.ToJsonValue(enumClass); + if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) + return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is EnumTest.EnumIntegerEnum enumTestEnumIntegerEnum) return EnumTest.EnumIntegerEnumToJsonValue(enumTestEnumIntegerEnum).ToString(); if (obj is EnumTest.EnumIntegerOnlyEnum enumTestEnumIntegerOnlyEnum) @@ -151,8 +153,6 @@ namespace UseSourceGeneration.Client return EnumTest.EnumNumberEnumToJsonValue(enumTestEnumNumberEnum).ToString(); if (obj is EnumTest.EnumStringEnum enumTestEnumStringEnum) return EnumTest.EnumStringEnumToJsonValue(enumTestEnumStringEnum); - if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) - return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is MapTest.InnerEnum mapTestInnerEnum) return MapTest.InnerEnumToJsonValue(mapTestInnerEnum); if (obj is Order.StatusEnum orderStatusEnum) @@ -169,6 +169,30 @@ namespace UseSourceGeneration.Client return OuterEnumTestValueConverter.ToJsonValue(outerEnumTest); if (obj is Pet.StatusEnum petStatusEnum) return Pet.StatusEnumToJsonValue(petStatusEnum); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerEnum requiredClassRequiredNotnullableEnumIntegerEnum) + return RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum requiredClassRequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumStringEnum requiredClassRequiredNotnullableEnumStringEnum) + return RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClassRequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.RequiredNullableEnumIntegerEnum requiredClassRequiredNullableEnumIntegerEnum) + return RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClassRequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumIntegerOnlyEnum requiredClassRequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) + return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerEnum requiredClassNotrequiredNotnullableEnumIntegerEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumStringEnum requiredClassNotrequiredNotnullableEnumStringEnum) + return RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClassNotrequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerEnum requiredClassNotrequiredNullableEnumIntegerEnum) + return RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum requiredClassNotrequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumStringEnum requiredClassNotrequiredNullableEnumStringEnum) + return RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClassNotrequiredNullableEnumStringEnum); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 7a8056ab4da..a1bc8ed1289 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 @@ -116,6 +116,7 @@ namespace UseSourceGeneration.Client _jsonOptions.Converters.Add(new QuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -210,6 +211,7 @@ namespace UseSourceGeneration.Client new QuadrilateralSerializationContext(), new QuadrilateralInterfaceSerializationContext(), new ReadOnlyFirstSerializationContext(), + new RequiredClassSerializationContext(), new ReturnSerializationContext(), new RolesReportsHashSerializationContext(), new RolesReportsHashRoleSerializationContext(), diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/Option.cs index 93f54baec74..2c6fe01fa6e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Client/Option.cs @@ -37,5 +37,17 @@ namespace UseSourceGeneration.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Activity.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Activity.cs index 21b946eba14..d86feea2f50 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Activity.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Activity.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// activityOutputs [JsonConstructor] - public Activity(Dictionary> activityOutputs) + public Activity(Option>?> activityOutputs = default) { - ActivityOutputs = activityOutputs; + ActivityOutputsOption = activityOutputs; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ActivityOutputs + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ActivityOutputsOption { get; private set; } + /// /// Gets or Sets ActivityOutputs /// [JsonPropertyName("activity_outputs")] - public Dictionary> ActivityOutputs { get; set; } + public Dictionary>? ActivityOutputs { get { return this. ActivityOutputsOption; } set { this.ActivityOutputsOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary>? activityOutputs = default; + Option>?> activityOutputs = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "activity_outputs": if (utf8JsonReader.TokenType != JsonTokenType.Null) - activityOutputs = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + activityOutputs = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -131,8 +138,8 @@ namespace UseSourceGeneration.Model } } - if (activityOutputs == null) - throw new ArgumentNullException(nameof(activityOutputs), "Property is required for class Activity."); + if (activityOutputs.IsSet && activityOutputs.Value == null) + throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity."); return new Activity(activityOutputs); } @@ -161,8 +168,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("activity_outputs"); - JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null) + throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity."); + + if (activity.ActivityOutputsOption.IsSet) + { + writer.WritePropertyName("activity_outputs"); + JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ActivityOutputElementRepresentation.cs index 7d7042c48e5..3e94618e5cf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ActivityOutputElementRepresentation.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// prop1 /// prop2 [JsonConstructor] - public ActivityOutputElementRepresentation(string prop1, Object prop2) + public ActivityOutputElementRepresentation(Option prop1 = default, Option prop2 = default) { - Prop1 = prop1; - Prop2 = prop2; + Prop1Option = prop1; + Prop2Option = prop2; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Prop1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop1Option { get; private set; } + /// /// Gets or Sets Prop1 /// [JsonPropertyName("prop1")] - public string Prop1 { get; set; } + public string? Prop1 { get { return this. Prop1Option; } set { this.Prop1Option = new(value); } } + + /// + /// Used to track the state of Prop2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop2Option { get; private set; } /// /// Gets or Sets Prop2 /// [JsonPropertyName("prop2")] - public Object Prop2 { get; set; } + public Object? Prop2 { get { return this. Prop2Option; } set { this.Prop2Option = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? prop1 = default; - Object? prop2 = default; + Option prop1 = default; + Option prop2 = default; while (utf8JsonReader.Read()) { @@ -132,11 +146,11 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "prop1": - prop1 = utf8JsonReader.GetString(); + prop1 = new Option(utf8JsonReader.GetString()!); break; case "prop2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - prop2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + prop2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -144,11 +158,11 @@ namespace UseSourceGeneration.Model } } - if (prop1 == null) - throw new ArgumentNullException(nameof(prop1), "Property is required for class ActivityOutputElementRepresentation."); + if (prop1.IsSet && prop1.Value == null) + throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation."); - if (prop2 == null) - throw new ArgumentNullException(nameof(prop2), "Property is required for class ActivityOutputElementRepresentation."); + if (prop2.IsSet && prop2.Value == null) + throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation."); return new ActivityOutputElementRepresentation(prop1, prop2); } @@ -177,9 +191,20 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); - writer.WritePropertyName("prop2"); - JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop1Option.IsSet) + writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); + + if (activityOutputElementRepresentation.Prop2Option.IsSet) + { + writer.WritePropertyName("prop2"); + JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AdditionalPropertiesClass.cs index 09b3dd1d261..b0310944a82 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AdditionalPropertiesClass.cs @@ -35,6 +35,7 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// + /// anytype1 /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// mapOfMapProperty /// mapProperty @@ -42,71 +43,126 @@ namespace UseSourceGeneration.Model /// mapWithUndeclaredPropertiesAnytype2 /// mapWithUndeclaredPropertiesAnytype3 /// mapWithUndeclaredPropertiesString - /// anytype1 [JsonConstructor] - public AdditionalPropertiesClass(Object emptyMap, Dictionary> mapOfMapProperty, Dictionary mapProperty, Object mapWithUndeclaredPropertiesAnytype1, Object mapWithUndeclaredPropertiesAnytype2, Dictionary mapWithUndeclaredPropertiesAnytype3, Dictionary mapWithUndeclaredPropertiesString, Object? anytype1 = default) + public AdditionalPropertiesClass(Option anytype1 = default, Option emptyMap = default, Option>?> mapOfMapProperty = default, Option?> mapProperty = default, Option mapWithUndeclaredPropertiesAnytype1 = default, Option mapWithUndeclaredPropertiesAnytype2 = default, Option?> mapWithUndeclaredPropertiesAnytype3 = default, Option?> mapWithUndeclaredPropertiesString = default) { - EmptyMap = emptyMap; - MapOfMapProperty = mapOfMapProperty; - MapProperty = mapProperty; - MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - Anytype1 = anytype1; + Anytype1Option = anytype1; + EmptyMapOption = emptyMap; + MapOfMapPropertyOption = mapOfMapProperty; + MapPropertyOption = mapProperty; + MapWithUndeclaredPropertiesAnytype1Option = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2Option = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3Option = mapWithUndeclaredPropertiesAnytype3; + MapWithUndeclaredPropertiesStringOption = mapWithUndeclaredPropertiesString; OnCreated(); } partial void OnCreated(); /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// Used to track the state of Anytype1 /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [JsonPropertyName("empty_map")] - public Object EmptyMap { get; set; } - - /// - /// Gets or Sets MapOfMapProperty - /// - [JsonPropertyName("map_of_map_property")] - public Dictionary> MapOfMapProperty { get; set; } - - /// - /// Gets or Sets MapProperty - /// - [JsonPropertyName("map_property")] - public Dictionary MapProperty { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_1")] - public Object MapWithUndeclaredPropertiesAnytype1 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_2")] - public Object MapWithUndeclaredPropertiesAnytype2 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_3")] - public Dictionary MapWithUndeclaredPropertiesAnytype3 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesString - /// - [JsonPropertyName("map_with_undeclared_properties_string")] - public Dictionary MapWithUndeclaredPropertiesString { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Anytype1Option { get; private set; } /// /// Gets or Sets Anytype1 /// [JsonPropertyName("anytype_1")] - public Object? Anytype1 { get; set; } + public Object? Anytype1 { get { return this. Anytype1Option; } set { this.Anytype1Option = new(value); } } + + /// + /// Used to track the state of EmptyMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmptyMapOption { get; private set; } + + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + [JsonPropertyName("empty_map")] + public Object? EmptyMap { get { return this. EmptyMapOption; } set { this.EmptyMapOption = new(value); } } + + /// + /// Used to track the state of MapOfMapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> MapOfMapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [JsonPropertyName("map_of_map_property")] + public Dictionary>? MapOfMapProperty { get { return this. MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new(value); } } + + /// + /// Used to track the state of MapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapProperty + /// + [JsonPropertyName("map_property")] + public Dictionary? MapProperty { get { return this. MapPropertyOption; } set { this.MapPropertyOption = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype1Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] + public Object? MapWithUndeclaredPropertiesAnytype1 { get { return this. MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype2Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] + public Object? MapWithUndeclaredPropertiesAnytype2 { get { return this. MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype3 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapWithUndeclaredPropertiesAnytype3Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] + public Dictionary? MapWithUndeclaredPropertiesAnytype3 { get { return this. MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapWithUndeclaredPropertiesStringOption { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesString + /// + [JsonPropertyName("map_with_undeclared_properties_string")] + public Dictionary? MapWithUndeclaredPropertiesString { get { return this. MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -122,6 +178,7 @@ namespace UseSourceGeneration.Model { StringBuilder sb = new StringBuilder(); sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); @@ -129,7 +186,6 @@ namespace UseSourceGeneration.Model sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); - sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -168,14 +224,14 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Object? emptyMap = default; - Dictionary>? mapOfMapProperty = default; - Dictionary? mapProperty = default; - Object? mapWithUndeclaredPropertiesAnytype1 = default; - Object? mapWithUndeclaredPropertiesAnytype2 = default; - Dictionary? mapWithUndeclaredPropertiesAnytype3 = default; - Dictionary? mapWithUndeclaredPropertiesString = default; - Object? anytype1 = default; + Option anytype1 = default; + Option emptyMap = default; + Option>?> mapOfMapProperty = default; + Option?> mapProperty = default; + Option mapWithUndeclaredPropertiesAnytype1 = default; + Option mapWithUndeclaredPropertiesAnytype2 = default; + Option?> mapWithUndeclaredPropertiesAnytype3 = default; + Option?> mapWithUndeclaredPropertiesString = default; while (utf8JsonReader.Read()) { @@ -192,37 +248,37 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { + case "anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; case "empty_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - emptyMap = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + emptyMap = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_of_map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfMapProperty = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapOfMapProperty = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapProperty = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapProperty = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_anytype_1": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_anytype_2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_anytype_3": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype3 = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype3 = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "anytype_1": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - anytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -230,28 +286,28 @@ namespace UseSourceGeneration.Model } } - if (emptyMap == null) - throw new ArgumentNullException(nameof(emptyMap), "Property is required for class AdditionalPropertiesClass."); + if (emptyMap.IsSet && emptyMap.Value == null) + throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapOfMapProperty == null) - throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null) + throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapProperty == null) - throw new ArgumentNullException(nameof(mapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapProperty.IsSet && mapProperty.Value == null) + throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype1 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype2 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype3 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesString == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass."); - return new AdditionalPropertiesClass(emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString, anytype1); + return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString); } /// @@ -278,22 +334,70 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("empty_map"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); - writer.WritePropertyName("map_of_map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_string"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); - writer.WritePropertyName("anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.Anytype1Option.IsSet) + if (additionalPropertiesClass.Anytype1Option.Value != null) + { + writer.WritePropertyName("anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + } + else + writer.WriteNull("anytype_1"); + if (additionalPropertiesClass.EmptyMapOption.IsSet) + { + writer.WritePropertyName("empty_map"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet) + { + writer.WritePropertyName("map_of_map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapPropertyOption.IsSet) + { + writer.WritePropertyName("map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_string"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Animal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Animal.cs index 6beaaf3e97c..d07daedca7f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Animal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Animal.cs @@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, string color = @"red") + public Animal(string className, Option color = default) { ClassName = className; - Color = color; + ColorOption = color; OnCreated(); } @@ -53,11 +53,18 @@ namespace UseSourceGeneration.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Gets or Sets additional properties @@ -123,8 +130,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - string? color = default; + Option className = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -142,10 +149,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -153,13 +160,16 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Animal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Animal.", nameof(className)); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Animal."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal."); - return new Animal(className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); + + return new Animal(className.Value!, color); } /// @@ -186,8 +196,16 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { + if (animal.ClassName == null) + throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); + + if (animal.ColorOption.IsSet && animal.Color == null) + throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); + writer.WriteString("className", animal.ClassName); - writer.WriteString("color", animal.Color); + + if (animal.ColorOption.IsSet) + writer.WriteString("color", animal.Color); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ApiResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ApiResponse.cs index 44f22494b30..32f43734f0a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ApiResponse.cs @@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model /// message /// type [JsonConstructor] - public ApiResponse(int code, string message, string type) + public ApiResponse(Option code = default, Option message = default, Option type = default) { - Code = code; - Message = message; - Type = type; + CodeOption = code; + MessageOption = message; + TypeOption = type; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + /// /// Gets or Sets Code /// [JsonPropertyName("code")] - public int Code { get; set; } + public int? Code { get { return this. CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Message + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MessageOption { get; private set; } /// /// Gets or Sets Message /// [JsonPropertyName("message")] - public string Message { get; set; } + public string? Message { get { return this. MessageOption; } set { this.MessageOption = new(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public string Type { get; set; } + public string? Type { get { return this. TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets additional properties @@ -122,9 +143,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? code = default; - string? message = default; - string? type = default; + Option code = default; + Option message = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -143,13 +164,13 @@ namespace UseSourceGeneration.Model { case "code": if (utf8JsonReader.TokenType != JsonTokenType.Null) - code = utf8JsonReader.GetInt32(); + code = new Option(utf8JsonReader.GetInt32()); break; case "message": - message = utf8JsonReader.GetString(); + message = new Option(utf8JsonReader.GetString()!); break; case "type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -157,16 +178,16 @@ namespace UseSourceGeneration.Model } } - if (code == null) - throw new ArgumentNullException(nameof(code), "Property is required for class ApiResponse."); + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse."); - if (message == null) - throw new ArgumentNullException(nameof(message), "Property is required for class ApiResponse."); + if (message.IsSet && message.Value == null) + throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class ApiResponse."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse."); - return new ApiResponse(code.Value, message, type); + return new ApiResponse(code, message, type); } /// @@ -193,9 +214,20 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("code", apiResponse.Code); - writer.WriteString("message", apiResponse.Message); - writer.WriteString("type", apiResponse.Type); + if (apiResponse.MessageOption.IsSet && apiResponse.Message == null) + throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse."); + + if (apiResponse.TypeOption.IsSet && apiResponse.Type == null) + throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse."); + + if (apiResponse.CodeOption.IsSet) + writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value); + + if (apiResponse.MessageOption.IsSet) + writer.WriteString("message", apiResponse.Message); + + if (apiResponse.TypeOption.IsSet) + writer.WriteString("type", apiResponse.Type); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Apple.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Apple.cs index f163ab1d0ba..83db95beaff 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Apple.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Apple.cs @@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model /// cultivar /// origin [JsonConstructor] - public Apple(string colorCode, string cultivar, string origin) + public Apple(Option colorCode = default, Option cultivar = default, Option origin = default) { - ColorCode = colorCode; - Cultivar = cultivar; - Origin = origin; + ColorCodeOption = colorCode; + CultivarOption = cultivar; + OriginOption = origin; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ColorCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorCodeOption { get; private set; } + /// /// Gets or Sets ColorCode /// [JsonPropertyName("color_code")] - public string ColorCode { get; set; } + public string? ColorCode { get { return this. ColorCodeOption; } set { this.ColorCodeOption = new(value); } } + + /// + /// Used to track the state of Cultivar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CultivarOption { get; private set; } /// /// Gets or Sets Cultivar /// [JsonPropertyName("cultivar")] - public string Cultivar { get; set; } + public string? Cultivar { get { return this. CultivarOption; } set { this.CultivarOption = new(value); } } + + /// + /// Used to track the state of Origin + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OriginOption { get; private set; } /// /// Gets or Sets Origin /// [JsonPropertyName("origin")] - public string Origin { get; set; } + public string? Origin { get { return this. OriginOption; } set { this.OriginOption = new(value); } } /// /// Gets or Sets additional properties @@ -96,28 +117,31 @@ namespace UseSourceGeneration.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - if (this.ColorCode != null) { + if (this.ColorCodeOption.Value != null) { // ColorCode (string) pattern Regex regexColorCode = new Regex(@"^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$", RegexOptions.CultureInvariant); - if (!regexColorCode.Match(this.ColorCode).Success) + + if (this.ColorCodeOption.Value != null &&!regexColorCode.Match(this.ColorCodeOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ColorCode, must match a pattern of " + regexColorCode, new [] { "ColorCode" }); } } - if (this.Cultivar != null) { + if (this.CultivarOption.Value != null) { // Cultivar (string) pattern Regex regexCultivar = new Regex(@"^[a-zA-Z\s]*$", RegexOptions.CultureInvariant); - if (!regexCultivar.Match(this.Cultivar).Success) + + if (this.CultivarOption.Value != null &&!regexCultivar.Match(this.CultivarOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Cultivar, must match a pattern of " + regexCultivar, new [] { "Cultivar" }); } } - if (this.Origin != null) { + if (this.OriginOption.Value != null) { // Origin (string) pattern Regex regexOrigin = new Regex(@"^[A-Z\s]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexOrigin.Match(this.Origin).Success) + + if (this.OriginOption.Value != null &&!regexOrigin.Match(this.OriginOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Origin, must match a pattern of " + regexOrigin, new [] { "Origin" }); } @@ -149,9 +173,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? colorCode = default; - string? cultivar = default; - string? origin = default; + Option colorCode = default; + Option cultivar = default; + Option origin = default; while (utf8JsonReader.Read()) { @@ -169,13 +193,13 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "color_code": - colorCode = utf8JsonReader.GetString(); + colorCode = new Option(utf8JsonReader.GetString()!); break; case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()!); break; case "origin": - origin = utf8JsonReader.GetString(); + origin = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -183,14 +207,14 @@ namespace UseSourceGeneration.Model } } - if (colorCode == null) - throw new ArgumentNullException(nameof(colorCode), "Property is required for class Apple."); + if (colorCode.IsSet && colorCode.Value == null) + throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple."); - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class Apple."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple."); - if (origin == null) - throw new ArgumentNullException(nameof(origin), "Property is required for class Apple."); + if (origin.IsSet && origin.Value == null) + throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple."); return new Apple(colorCode, cultivar, origin); } @@ -219,9 +243,23 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color_code", apple.ColorCode); - writer.WriteString("cultivar", apple.Cultivar); - writer.WriteString("origin", apple.Origin); + if (apple.ColorCodeOption.IsSet && apple.ColorCode == null) + throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple."); + + if (apple.CultivarOption.IsSet && apple.Cultivar == null) + throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple."); + + if (apple.OriginOption.IsSet && apple.Origin == null) + throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple."); + + if (apple.ColorCodeOption.IsSet) + writer.WriteString("color_code", apple.ColorCode); + + if (apple.CultivarOption.IsSet) + writer.WriteString("cultivar", apple.Cultivar); + + if (apple.OriginOption.IsSet) + writer.WriteString("origin", apple.Origin); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AppleReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AppleReq.cs index 52d9af2f361..33a606d744a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/AppleReq.cs @@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model /// cultivar /// mealy [JsonConstructor] - public AppleReq(string cultivar, bool mealy) + public AppleReq(string cultivar, Option mealy = default) { Cultivar = cultivar; - Mealy = mealy; + MealyOption = mealy; OnCreated(); } @@ -53,11 +53,18 @@ namespace UseSourceGeneration.Model [JsonPropertyName("cultivar")] public string Cultivar { get; set; } + /// + /// Used to track the state of Mealy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MealyOption { get; private set; } + /// /// Gets or Sets Mealy /// [JsonPropertyName("mealy")] - public bool Mealy { get; set; } + public bool? Mealy { get { return this. MealyOption; } set { this.MealyOption = new(value); } } /// /// Returns the string presentation of the object @@ -106,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? cultivar = default; - bool? mealy = default; + Option cultivar = default; + Option mealy = default; while (utf8JsonReader.Read()) { @@ -125,11 +132,11 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()!); break; case "mealy": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mealy = utf8JsonReader.GetBoolean(); + mealy = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -137,13 +144,16 @@ namespace UseSourceGeneration.Model } } - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class AppleReq."); + if (!cultivar.IsSet) + throw new ArgumentException("Property is required for class AppleReq.", nameof(cultivar)); - if (mealy == null) - throw new ArgumentNullException(nameof(mealy), "Property is required for class AppleReq."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq."); - return new AppleReq(cultivar, mealy.Value); + if (mealy.IsSet && mealy.Value == null) + throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq."); + + return new AppleReq(cultivar.Value!, mealy); } /// @@ -170,8 +180,13 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) { + if (appleReq.Cultivar == null) + throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq."); + writer.WriteString("cultivar", appleReq.Cultivar); - writer.WriteBoolean("mealy", appleReq.Mealy); + + if (appleReq.MealyOption.IsSet) + writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfArrayOfNumberOnly.cs index 96905a9ad00..852333df6a5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfArrayOfNumberOnly.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// arrayArrayNumber [JsonConstructor] - public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber) + public ArrayOfArrayOfNumberOnly(Option>?> arrayArrayNumber = default) { - ArrayArrayNumber = arrayArrayNumber; + ArrayArrayNumberOption = arrayArrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ArrayArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayArrayNumber /// [JsonPropertyName("ArrayArrayNumber")] - public List> ArrayArrayNumber { get; set; } + public List>? ArrayArrayNumber { get { return this. ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List>? arrayArrayNumber = default; + Option>?> arrayArrayNumber = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "ArrayArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayNumber = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayNumber = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -131,8 +138,8 @@ namespace UseSourceGeneration.Model } } - if (arrayArrayNumber == null) - throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly."); return new ArrayOfArrayOfNumberOnly(arrayArrayNumber); } @@ -161,8 +168,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfNumberOnly.cs index 2fc3f9aa15b..3366dbdb1a5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayOfNumberOnly.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// arrayNumber [JsonConstructor] - public ArrayOfNumberOnly(List arrayNumber) + public ArrayOfNumberOnly(Option?> arrayNumber = default) { - ArrayNumber = arrayNumber; + ArrayNumberOption = arrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayNumber /// [JsonPropertyName("ArrayNumber")] - public List ArrayNumber { get; set; } + public List? ArrayNumber { get { return this. ArrayNumberOption; } set { this.ArrayNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? arrayNumber = default; + Option?> arrayNumber = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "ArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNumber = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNumber = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -131,8 +138,8 @@ namespace UseSourceGeneration.Model } } - if (arrayNumber == null) - throw new ArgumentNullException(nameof(arrayNumber), "Property is required for class ArrayOfNumberOnly."); + if (arrayNumber.IsSet && arrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly."); return new ArrayOfNumberOnly(arrayNumber); } @@ -161,8 +168,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly."); + + if (arrayOfNumberOnly.ArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayTest.cs index 5923398e2ca..6b6ce17d389 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ArrayTest.cs @@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model /// arrayArrayOfModel /// arrayOfString [JsonConstructor] - public ArrayTest(List> arrayArrayOfInteger, List> arrayArrayOfModel, List arrayOfString) + public ArrayTest(Option>?> arrayArrayOfInteger = default, Option>?> arrayArrayOfModel = default, Option?> arrayOfString = default) { - ArrayArrayOfInteger = arrayArrayOfInteger; - ArrayArrayOfModel = arrayArrayOfModel; - ArrayOfString = arrayOfString; + ArrayArrayOfIntegerOption = arrayArrayOfInteger; + ArrayArrayOfModelOption = arrayArrayOfModel; + ArrayOfStringOption = arrayOfString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayOfInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ArrayArrayOfIntegerOption { get; private set; } + /// /// Gets or Sets ArrayArrayOfInteger /// [JsonPropertyName("array_array_of_integer")] - public List> ArrayArrayOfInteger { get; set; } + public List>? ArrayArrayOfInteger { get { return this. ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new(value); } } + + /// + /// Used to track the state of ArrayArrayOfModel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ArrayArrayOfModelOption { get; private set; } /// /// Gets or Sets ArrayArrayOfModel /// [JsonPropertyName("array_array_of_model")] - public List> ArrayArrayOfModel { get; set; } + public List>? ArrayArrayOfModel { get { return this. ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new(value); } } + + /// + /// Used to track the state of ArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayOfStringOption { get; private set; } /// /// Gets or Sets ArrayOfString /// [JsonPropertyName("array_of_string")] - public List ArrayOfString { get; set; } + public List? ArrayOfString { get { return this. ArrayOfStringOption; } set { this.ArrayOfStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -122,9 +143,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List>? arrayArrayOfInteger = default; - List>? arrayArrayOfModel = default; - List? arrayOfString = default; + Option>?> arrayArrayOfInteger = default; + Option>?> arrayArrayOfModel = default; + Option?> arrayOfString = default; while (utf8JsonReader.Read()) { @@ -143,15 +164,15 @@ namespace UseSourceGeneration.Model { case "array_array_of_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfInteger = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfInteger = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "array_array_of_model": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfModel = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfModel = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "array_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayOfString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -159,14 +180,14 @@ namespace UseSourceGeneration.Model } } - if (arrayArrayOfInteger == null) - throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is required for class ArrayTest."); + if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest."); - if (arrayArrayOfModel == null) - throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is required for class ArrayTest."); + if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest."); - if (arrayOfString == null) - throw new ArgumentNullException(nameof(arrayOfString), "Property is required for class ArrayTest."); + if (arrayOfString.IsSet && arrayOfString.Value == null) + throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest."); return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString); } @@ -195,12 +216,30 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_array_of_integer"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); - writer.WritePropertyName("array_array_of_model"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); - writer.WritePropertyName("array_of_string"); - JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfIntegerOption.IsSet) + { + writer.WritePropertyName("array_array_of_integer"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); + } + if (arrayTest.ArrayArrayOfModelOption.IsSet) + { + writer.WritePropertyName("array_array_of_model"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); + } + if (arrayTest.ArrayOfStringOption.IsSet) + { + writer.WritePropertyName("array_of_string"); + JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Banana.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Banana.cs index 5528e531ea8..3daafe3df5b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Banana.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Banana.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// lengthCm [JsonConstructor] - public Banana(decimal lengthCm) + public Banana(Option lengthCm = default) { - LengthCm = lengthCm; + LengthCmOption = lengthCm; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of LengthCm + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LengthCmOption { get; private set; } + /// /// Gets or Sets LengthCm /// [JsonPropertyName("lengthCm")] - public decimal LengthCm { get; set; } + public decimal? LengthCm { get { return this. LengthCmOption; } set { this.LengthCmOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; + Option lengthCm = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -131,10 +138,10 @@ namespace UseSourceGeneration.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class Banana."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana."); - return new Banana(lengthCm.Value); + return new Banana(lengthCm); } /// @@ -161,7 +168,8 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("lengthCm", banana.LengthCm); + if (banana.LengthCmOption.IsSet) + writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BananaReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BananaReq.cs index 7b518611405..87bb604c63a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BananaReq.cs @@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model /// lengthCm /// sweet [JsonConstructor] - public BananaReq(decimal lengthCm, bool sweet) + public BananaReq(decimal lengthCm, Option sweet = default) { LengthCm = lengthCm; - Sweet = sweet; + SweetOption = sweet; OnCreated(); } @@ -53,11 +53,18 @@ namespace UseSourceGeneration.Model [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } + /// + /// Used to track the state of Sweet + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SweetOption { get; private set; } + /// /// Gets or Sets Sweet /// [JsonPropertyName("sweet")] - public bool Sweet { get; set; } + public bool? Sweet { get { return this. SweetOption; } set { this.SweetOption = new(value); } } /// /// Returns the string presentation of the object @@ -106,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; - bool? sweet = default; + Option lengthCm = default; + Option sweet = default; while (utf8JsonReader.Read()) { @@ -126,11 +133,11 @@ namespace UseSourceGeneration.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; case "sweet": if (utf8JsonReader.TokenType != JsonTokenType.Null) - sweet = utf8JsonReader.GetBoolean(); + sweet = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -138,13 +145,16 @@ namespace UseSourceGeneration.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class BananaReq."); + if (!lengthCm.IsSet) + throw new ArgumentException("Property is required for class BananaReq.", nameof(lengthCm)); - if (sweet == null) - throw new ArgumentNullException(nameof(sweet), "Property is required for class BananaReq."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq."); - return new BananaReq(lengthCm.Value, sweet.Value); + if (sweet.IsSet && sweet.Value == null) + throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq."); + + return new BananaReq(lengthCm.Value!.Value!, sweet); } /// @@ -172,7 +182,9 @@ namespace UseSourceGeneration.Model public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); - writer.WriteBoolean("sweet", bananaReq.Sweet); + + if (bananaReq.SweetOption.IsSet) + writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BasquePig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BasquePig.cs index 4721383c896..f97e5880885 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/BasquePig.cs @@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,10 +130,13 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class BasquePig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class BasquePig.", nameof(className)); - return new BasquePig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class BasquePig."); + + return new BasquePig(className.Value!); } /// @@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) { + if (basquePig.ClassName == null) + throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig."); + writer.WriteString("className", basquePig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Capitalization.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Capitalization.cs index b0cc3ec0d59..9394170cc39 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Capitalization.cs @@ -42,55 +42,97 @@ namespace UseSourceGeneration.Model /// smallCamel /// smallSnake [JsonConstructor] - public Capitalization(string aTTNAME, string capitalCamel, string capitalSnake, string sCAETHFlowPoints, string smallCamel, string smallSnake) + public Capitalization(Option aTTNAME = default, Option capitalCamel = default, Option capitalSnake = default, Option sCAETHFlowPoints = default, Option smallCamel = default, Option smallSnake = default) { - ATT_NAME = aTTNAME; - CapitalCamel = capitalCamel; - CapitalSnake = capitalSnake; - SCAETHFlowPoints = sCAETHFlowPoints; - SmallCamel = smallCamel; - SmallSnake = smallSnake; + ATT_NAMEOption = aTTNAME; + CapitalCamelOption = capitalCamel; + CapitalSnakeOption = capitalSnake; + SCAETHFlowPointsOption = sCAETHFlowPoints; + SmallCamelOption = smallCamel; + SmallSnakeOption = smallSnake; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ATT_NAME + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ATT_NAMEOption { get; private set; } + /// /// Name of the pet /// /// Name of the pet [JsonPropertyName("ATT_NAME")] - public string ATT_NAME { get; set; } + public string? ATT_NAME { get { return this. ATT_NAMEOption; } set { this.ATT_NAMEOption = new(value); } } + + /// + /// Used to track the state of CapitalCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalCamelOption { get; private set; } /// /// Gets or Sets CapitalCamel /// [JsonPropertyName("CapitalCamel")] - public string CapitalCamel { get; set; } + public string? CapitalCamel { get { return this. CapitalCamelOption; } set { this.CapitalCamelOption = new(value); } } + + /// + /// Used to track the state of CapitalSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalSnakeOption { get; private set; } /// /// Gets or Sets CapitalSnake /// [JsonPropertyName("Capital_Snake")] - public string CapitalSnake { get; set; } + public string? CapitalSnake { get { return this. CapitalSnakeOption; } set { this.CapitalSnakeOption = new(value); } } + + /// + /// Used to track the state of SCAETHFlowPoints + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SCAETHFlowPointsOption { get; private set; } /// /// Gets or Sets SCAETHFlowPoints /// [JsonPropertyName("SCA_ETH_Flow_Points")] - public string SCAETHFlowPoints { get; set; } + public string? SCAETHFlowPoints { get { return this. SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new(value); } } + + /// + /// Used to track the state of SmallCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallCamelOption { get; private set; } /// /// Gets or Sets SmallCamel /// [JsonPropertyName("smallCamel")] - public string SmallCamel { get; set; } + public string? SmallCamel { get { return this. SmallCamelOption; } set { this.SmallCamelOption = new(value); } } + + /// + /// Used to track the state of SmallSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallSnakeOption { get; private set; } /// /// Gets or Sets SmallSnake /// [JsonPropertyName("small_Snake")] - public string SmallSnake { get; set; } + public string? SmallSnake { get { return this. SmallSnakeOption; } set { this.SmallSnakeOption = new(value); } } /// /// Gets or Sets additional properties @@ -150,12 +192,12 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? aTTNAME = default; - string? capitalCamel = default; - string? capitalSnake = default; - string? sCAETHFlowPoints = default; - string? smallCamel = default; - string? smallSnake = default; + Option aTTNAME = default; + Option capitalCamel = default; + Option capitalSnake = default; + Option sCAETHFlowPoints = default; + Option smallCamel = default; + Option smallSnake = default; while (utf8JsonReader.Read()) { @@ -173,22 +215,22 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "ATT_NAME": - aTTNAME = utf8JsonReader.GetString(); + aTTNAME = new Option(utf8JsonReader.GetString()!); break; case "CapitalCamel": - capitalCamel = utf8JsonReader.GetString(); + capitalCamel = new Option(utf8JsonReader.GetString()!); break; case "Capital_Snake": - capitalSnake = utf8JsonReader.GetString(); + capitalSnake = new Option(utf8JsonReader.GetString()!); break; case "SCA_ETH_Flow_Points": - sCAETHFlowPoints = utf8JsonReader.GetString(); + sCAETHFlowPoints = new Option(utf8JsonReader.GetString()!); break; case "smallCamel": - smallCamel = utf8JsonReader.GetString(); + smallCamel = new Option(utf8JsonReader.GetString()!); break; case "small_Snake": - smallSnake = utf8JsonReader.GetString(); + smallSnake = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -196,23 +238,23 @@ namespace UseSourceGeneration.Model } } - if (aTTNAME == null) - throw new ArgumentNullException(nameof(aTTNAME), "Property is required for class Capitalization."); + if (aTTNAME.IsSet && aTTNAME.Value == null) + throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization."); - if (capitalCamel == null) - throw new ArgumentNullException(nameof(capitalCamel), "Property is required for class Capitalization."); + if (capitalCamel.IsSet && capitalCamel.Value == null) + throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization."); - if (capitalSnake == null) - throw new ArgumentNullException(nameof(capitalSnake), "Property is required for class Capitalization."); + if (capitalSnake.IsSet && capitalSnake.Value == null) + throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization."); - if (sCAETHFlowPoints == null) - throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is required for class Capitalization."); + if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null) + throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization."); - if (smallCamel == null) - throw new ArgumentNullException(nameof(smallCamel), "Property is required for class Capitalization."); + if (smallCamel.IsSet && smallCamel.Value == null) + throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization."); - if (smallSnake == null) - throw new ArgumentNullException(nameof(smallSnake), "Property is required for class Capitalization."); + if (smallSnake.IsSet && smallSnake.Value == null) + throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization."); return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake); } @@ -241,12 +283,41 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("ATT_NAME", capitalization.ATT_NAME); - writer.WriteString("CapitalCamel", capitalization.CapitalCamel); - writer.WriteString("Capital_Snake", capitalization.CapitalSnake); - writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); - writer.WriteString("smallCamel", capitalization.SmallCamel); - writer.WriteString("small_Snake", capitalization.SmallSnake); + if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null) + throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization."); + + if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null) + throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization."); + + if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null) + throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization."); + + if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null) + throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization."); + + if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null) + throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization."); + + if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null) + throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization."); + + if (capitalization.ATT_NAMEOption.IsSet) + writer.WriteString("ATT_NAME", capitalization.ATT_NAME); + + if (capitalization.CapitalCamelOption.IsSet) + writer.WriteString("CapitalCamel", capitalization.CapitalCamel); + + if (capitalization.CapitalSnakeOption.IsSet) + writer.WriteString("Capital_Snake", capitalization.CapitalSnake); + + if (capitalization.SCAETHFlowPointsOption.IsSet) + writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); + + if (capitalization.SmallCamelOption.IsSet) + writer.WriteString("smallCamel", capitalization.SmallCamel); + + if (capitalization.SmallSnakeOption.IsSet) + writer.WriteString("small_Snake", capitalization.SmallSnake); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Cat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Cat.cs index 9535772c506..dd9ac1cb6a3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Cat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Cat.cs @@ -36,22 +36,29 @@ namespace UseSourceGeneration.Model /// Initializes a new instance of the class. /// /// className - /// declawed /// color (default to "red") + /// declawed [JsonConstructor] - public Cat(string className, bool declawed, string color = @"red") : base(className, color) + public Cat(string className, Option color = default, Option declawed = default) : base(className, color) { - Declawed = declawed; + DeclawedOption = declawed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Declawed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeclawedOption { get; private set; } + /// /// Gets or Sets Declawed /// [JsonPropertyName("declawed")] - public bool Declawed { get; set; } + public bool? Declawed { get { return this. DeclawedOption; } set { this.DeclawedOption = new(value); } } /// /// Returns the string presentation of the object @@ -90,9 +97,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - bool? declawed = default; - string? color = default; + Option className = default; + Option color = default; + Option declawed = default; while (utf8JsonReader.Read()) { @@ -110,14 +117,14 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); + break; + case "color": + color = new Option(utf8JsonReader.GetString()!); break; case "declawed": if (utf8JsonReader.TokenType != JsonTokenType.Null) - declawed = utf8JsonReader.GetBoolean(); - break; - case "color": - color = utf8JsonReader.GetString(); + declawed = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -125,16 +132,19 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Cat."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Cat.", nameof(className)); - if (declawed == null) - throw new ArgumentNullException(nameof(declawed), "Property is required for class Cat."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Cat."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat."); - return new Cat(className, declawed.Value, color); + if (declawed.IsSet && declawed.Value == null) + throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); + + return new Cat(className.Value!, color, declawed); } /// @@ -161,9 +171,19 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { + if (cat.ClassName == null) + throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); + + if (cat.ColorOption.IsSet && cat.Color == null) + throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); + writer.WriteString("className", cat.ClassName); - writer.WriteBoolean("declawed", cat.Declawed); - writer.WriteString("color", cat.Color); + + if (cat.ColorOption.IsSet) + writer.WriteString("color", cat.Color); + + if (cat.DeclawedOption.IsSet) + writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Category.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Category.cs index 1c1133055c7..b2ecc92d82a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Category.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Category.cs @@ -38,20 +38,27 @@ namespace UseSourceGeneration.Model /// id /// name (default to "default-name") [JsonConstructor] - public Category(long id, string name = @"default-name") + public Category(Option id = default, string name = @"default-name") { - Id = id; + IdOption = id; Name = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } /// /// Gets or Sets Name @@ -113,8 +120,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string? name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -133,10 +140,10 @@ namespace UseSourceGeneration.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -144,13 +151,16 @@ namespace UseSourceGeneration.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Category."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Category.", nameof(name)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Category."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category."); - return new Category(id.Value, name); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category."); + + return new Category(id, name.Value!); } /// @@ -177,7 +187,12 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", category.Id); + if (category.Name == null) + throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category."); + + if (category.IdOption.IsSet) + writer.WriteNumber("id", category.IdOption.Value!.Value); + writer.WriteString("name", category.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs index 7a1c4d8042d..ca3b07960c8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs @@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model /// name /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(string name, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value)) { - Name = name; - PetType = petType; + NameOption = name; + PetTypeOption = petType; OnCreated(); } @@ -91,26 +91,39 @@ namespace UseSourceGeneration.Model /// /// /// - public static string PetTypeEnumToJsonValue(PetTypeEnum value) + public static string PetTypeEnumToJsonValue(PetTypeEnum? value) { - if (value == PetTypeEnum.ChildCat) return "ChildCat"; throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of PetType + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new Option PetTypeOption { get; private set; } + /// /// Gets or Sets PetType /// [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } + public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Returns the string presentation of the object @@ -150,8 +163,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? name = default; - ChildCat.PetTypeEnum? petType = default; + Option name = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -169,13 +182,12 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; case "pet_type": string? petTypeRawValue = utf8JsonReader.GetString(); - petType = petTypeRawValue == null - ? null - : ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue); + if (petTypeRawValue != null) + petType = new Option(ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue)); break; default: break; @@ -183,13 +195,13 @@ namespace UseSourceGeneration.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class ChildCat."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ChildCat."); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value); + return new ChildCat(name, petType); } /// @@ -216,9 +228,13 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", childCat.Name); + if (childCat.NameOption.IsSet && childCat.Name == null) + throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat."); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); + if (childCat.NameOption.IsSet) + writer.WriteString("name", childCat.Name); + + var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value!.Value); if (petTypeRawValue != null) writer.WriteString("pet_type", petTypeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ClassModel.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ClassModel.cs index af9e0c3d1c5..3577fc7c3ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ClassModel.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// varClass [JsonConstructor] - public ClassModel(string varClass) + public ClassModel(Option varClass = default) { - VarClass = varClass; + VarClassOption = varClass; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("_class")] - public string VarClass { get; set; } + public string? VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varClass = default; + Option varClass = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "_class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class ClassModel."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel."); return new ClassModel(varClass); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_class", classModel.VarClass); + if (classModel.VarClassOption.IsSet && classModel.VarClass == null) + throw new ArgumentNullException(nameof(classModel.VarClass), "Property is required for class ClassModel."); + + if (classModel.VarClassOption.IsSet) + writer.WriteString("_class", classModel.VarClass); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ComplexQuadrilateral.cs index 3d57316efa8..7aac7ba9240 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ComplexQuadrilateral.cs @@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; - string? shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -132,10 +132,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -143,13 +143,19 @@ namespace UseSourceGeneration.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class ComplexQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ComplexQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(shapeType)); - return new ComplexQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class ComplexQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ComplexQuadrilateral."); + + return new ComplexQuadrilateral(quadrilateralType.Value!, shapeType.Value!); } /// @@ -176,7 +182,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (complexQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral."); + + if (complexQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral."); + writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", complexQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DanishPig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DanishPig.cs index 8734f04bad7..312da5259bf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DanishPig.cs @@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,10 +130,13 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class DanishPig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class DanishPig.", nameof(className)); - return new DanishPig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class DanishPig."); + + return new DanishPig(className.Value!); } /// @@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) { + if (danishPig.ClassName == null) + throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig."); + writer.WriteString("className", danishPig.ClassName); } } 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 bd4801d771c..dcfcc06467a 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,20 +37,27 @@ namespace UseSourceGeneration.Model /// /// dateOnlyProperty [JsonConstructor] - public DateOnlyClass(DateTime dateOnlyProperty) + public DateOnlyClass(Option dateOnlyProperty = default) { - DateOnlyProperty = dateOnlyProperty; + DateOnlyPropertyOption = dateOnlyProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateOnlyProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateOnlyPropertyOption { get; private set; } + /// /// Gets or Sets DateOnlyProperty /// /// Fri Jul 21 00:00:00 UTC 2017 [JsonPropertyName("dateOnlyProperty")] - public DateTime DateOnlyProperty { get; set; } + public DateTime? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new(value); } } /// /// Gets or Sets additional properties @@ -110,7 +117,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateOnlyProperty = default; + Option dateOnlyProperty = default; while (utf8JsonReader.Read()) { @@ -129,7 +136,7 @@ namespace UseSourceGeneration.Model { case "dateOnlyProperty": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -137,10 +144,10 @@ namespace UseSourceGeneration.Model } } - if (dateOnlyProperty == null) - throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is required for class DateOnlyClass."); + if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null) + throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass."); - return new DateOnlyClass(dateOnlyProperty.Value); + return new DateOnlyClass(dateOnlyProperty); } /// @@ -167,7 +174,8 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(DateOnlyPropertyFormat)); + if (dateOnlyClass.DateOnlyPropertyOption.IsSet) + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat)); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DeprecatedObject.cs index 1783c3add71..20f34678e8a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/DeprecatedObject.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// name [JsonConstructor] - public DeprecatedObject(string name) + public DeprecatedObject(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class DeprecatedObject."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject."); return new DeprecatedObject(name); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", deprecatedObject.Name); + if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null) + throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject."); + + if (deprecatedObject.NameOption.IsSet) + writer.WriteString("name", deprecatedObject.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Dog.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Dog.cs index 70beb60686b..3b5881a4711 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Dog.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Dog.cs @@ -35,23 +35,30 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// - /// breed /// className + /// breed /// color (default to "red") [JsonConstructor] - public Dog(string breed, string className, string color = @"red") : base(className, color) + public Dog(string className, Option breed = default, Option color = default) : base(className, color) { - Breed = breed; + BreedOption = breed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Breed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BreedOption { get; private set; } + /// /// Gets or Sets Breed /// [JsonPropertyName("breed")] - public string Breed { get; set; } + public string? Breed { get { return this. BreedOption; } set { this.BreedOption = new(value); } } /// /// Returns the string presentation of the object @@ -90,9 +97,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? breed = default; - string? className = default; - string? color = default; + Option className = default; + Option breed = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -109,14 +116,14 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { - case "breed": - breed = utf8JsonReader.GetString(); - break; case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); + break; + case "breed": + breed = new Option(utf8JsonReader.GetString()!); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -124,16 +131,19 @@ namespace UseSourceGeneration.Model } } - if (breed == null) - throw new ArgumentNullException(nameof(breed), "Property is required for class Dog."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Dog.", nameof(className)); - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Dog."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Dog."); + if (breed.IsSet && breed.Value == null) + throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog."); - return new Dog(breed, className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); + + return new Dog(className.Value!, breed, color); } /// @@ -160,9 +170,22 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("breed", dog.Breed); + if (dog.ClassName == null) + throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); + + if (dog.BreedOption.IsSet && dog.Breed == null) + throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); + + if (dog.ColorOption.IsSet && dog.Color == null) + throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog."); + writer.WriteString("className", dog.ClassName); - writer.WriteString("color", dog.Color); + + if (dog.BreedOption.IsSet) + writer.WriteString("breed", dog.Breed); + + if (dog.ColorOption.IsSet) + writer.WriteString("color", dog.Color); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Drawing.cs index 955f0571e1d..872db7c6266 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Drawing.cs @@ -36,44 +36,72 @@ namespace UseSourceGeneration.Model /// Initializes a new instance of the class. /// /// mainShape - /// shapes /// nullableShape /// shapeOrNull + /// shapes [JsonConstructor] - public Drawing(Shape mainShape, List shapes, NullableShape? nullableShape = default, ShapeOrNull? shapeOrNull = default) : base() + public Drawing(Option mainShape = default, Option nullableShape = default, Option shapeOrNull = default, Option?> shapes = default) : base() { - MainShape = mainShape; - Shapes = shapes; - NullableShape = nullableShape; - ShapeOrNull = shapeOrNull; + MainShapeOption = mainShape; + NullableShapeOption = nullableShape; + ShapeOrNullOption = shapeOrNull; + ShapesOption = shapes; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MainShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MainShapeOption { get; private set; } + /// /// Gets or Sets MainShape /// [JsonPropertyName("mainShape")] - public Shape MainShape { get; set; } + public Shape? MainShape { get { return this. MainShapeOption; } set { this.MainShapeOption = new(value); } } /// - /// Gets or Sets Shapes + /// Used to track the state of NullableShape /// - [JsonPropertyName("shapes")] - public List Shapes { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableShapeOption { get; private set; } /// /// Gets or Sets NullableShape /// [JsonPropertyName("nullableShape")] - public NullableShape? NullableShape { get; set; } + public NullableShape? NullableShape { get { return this. NullableShapeOption; } set { this.NullableShapeOption = new(value); } } + + /// + /// Used to track the state of ShapeOrNull + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShapeOrNullOption { get; private set; } /// /// Gets or Sets ShapeOrNull /// [JsonPropertyName("shapeOrNull")] - public ShapeOrNull? ShapeOrNull { get; set; } + public ShapeOrNull? ShapeOrNull { get { return this. ShapeOrNullOption; } set { this.ShapeOrNullOption = new(value); } } + + /// + /// Used to track the state of Shapes + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ShapesOption { get; private set; } + + /// + /// Gets or Sets Shapes + /// + [JsonPropertyName("shapes")] + public List? Shapes { get { return this. ShapesOption; } set { this.ShapesOption = new(value); } } /// /// Gets or Sets additional properties @@ -91,9 +119,9 @@ namespace UseSourceGeneration.Model sb.Append("class Drawing {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" MainShape: ").Append(MainShape).Append("\n"); - sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -142,10 +170,10 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Shape? mainShape = default; - List? shapes = default; - NullableShape? nullableShape = default; - ShapeOrNull? shapeOrNull = default; + Option mainShape = default; + Option nullableShape = default; + Option shapeOrNull = default; + Option?> shapes = default; while (utf8JsonReader.Read()) { @@ -164,19 +192,19 @@ namespace UseSourceGeneration.Model { case "mainShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mainShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "shapes": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapes = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mainShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "nullableShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - nullableShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapeOrNull = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapes": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -184,13 +212,13 @@ namespace UseSourceGeneration.Model } } - if (mainShape == null) - throw new ArgumentNullException(nameof(mainShape), "Property is required for class Drawing."); + if (mainShape.IsSet && mainShape.Value == null) + throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapes == null) - throw new ArgumentNullException(nameof(shapes), "Property is required for class Drawing."); + if (shapes.IsSet && shapes.Value == null) + throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); - return new Drawing(mainShape, shapes, nullableShape, shapeOrNull); + return new Drawing(mainShape, nullableShape, shapeOrNull, shapes); } /// @@ -217,14 +245,38 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("mainShape"); - JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); - writer.WritePropertyName("shapes"); - JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); - writer.WritePropertyName("nullableShape"); - JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) + throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) + throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); + + if (drawing.MainShapeOption.IsSet) + { + writer.WritePropertyName("mainShape"); + JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); + } + if (drawing.NullableShapeOption.IsSet) + if (drawing.NullableShapeOption.Value != null) + { + writer.WritePropertyName("nullableShape"); + JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); + } + else + writer.WriteNull("nullableShape"); + if (drawing.ShapeOrNullOption.IsSet) + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); + if (drawing.ShapesOption.IsSet) + { + writer.WritePropertyName("shapes"); + JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs index d6194ce8255..664242702ce 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs @@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model /// arrayEnum /// justSymbol [JsonConstructor] - public EnumArrays(List arrayEnum, JustSymbolEnum justSymbol) + public EnumArrays(Option?> arrayEnum = default, Option justSymbol = default) { - ArrayEnum = arrayEnum; - JustSymbol = justSymbol; + ArrayEnumOption = arrayEnum; + JustSymbolOption = justSymbol; OnCreated(); } @@ -102,9 +102,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum value) + public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum? value) { - if (value == ArrayEnumEnum.Fish) return "fish"; @@ -169,9 +168,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string JustSymbolEnumToJsonValue(JustSymbolEnum value) + public static string JustSymbolEnumToJsonValue(JustSymbolEnum? value) { - if (value == JustSymbolEnum.GreaterThanOrEqualTo) return ">="; @@ -181,17 +179,31 @@ namespace UseSourceGeneration.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of JustSymbol + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustSymbolOption { get; private set; } + /// /// Gets or Sets JustSymbol /// [JsonPropertyName("just_symbol")] - public JustSymbolEnum JustSymbol { get; set; } + public JustSymbolEnum? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new(value); } } + + /// + /// Used to track the state of ArrayEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayEnumOption { get; private set; } /// /// Gets or Sets ArrayEnum /// [JsonPropertyName("array_enum")] - public List ArrayEnum { get; set; } + public List? ArrayEnum { get { return this. ArrayEnumOption; } set { this.ArrayEnumOption = new(value); } } /// /// Gets or Sets additional properties @@ -247,8 +259,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? arrayEnum = default; - EnumArrays.JustSymbolEnum? justSymbol = default; + Option?> arrayEnum = default; + Option justSymbol = default; while (utf8JsonReader.Read()) { @@ -267,13 +279,12 @@ namespace UseSourceGeneration.Model { case "array_enum": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayEnum = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayEnum = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "just_symbol": string? justSymbolRawValue = utf8JsonReader.GetString(); - justSymbol = justSymbolRawValue == null - ? null - : EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue); + if (justSymbolRawValue != null) + justSymbol = new Option(EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue)); break; default: break; @@ -281,13 +292,13 @@ namespace UseSourceGeneration.Model } } - if (arrayEnum == null) - throw new ArgumentNullException(nameof(arrayEnum), "Property is required for class EnumArrays."); + if (arrayEnum.IsSet && arrayEnum.Value == null) + throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays."); - if (justSymbol == null) - throw new ArgumentNullException(nameof(justSymbol), "Property is required for class EnumArrays."); + if (justSymbol.IsSet && justSymbol.Value == null) + throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays."); - return new EnumArrays(arrayEnum, justSymbol.Value); + return new EnumArrays(arrayEnum, justSymbol); } /// @@ -314,10 +325,15 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_enum"); - JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null) + throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays."); - var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbol); + if (enumArrays.ArrayEnumOption.IsSet) + { + writer.WritePropertyName("array_enum"); + JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + } + var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value!.Value); if (justSymbolRawValue != null) writer.WriteString("just_symbol", justSymbolRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs index c267bb49c12..e0248de04b9 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs @@ -35,392 +35,32 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// + /// enumStringRequired /// enumInteger /// enumIntegerOnly /// enumNumber /// enumString - /// enumStringRequired + /// outerEnum /// outerEnumDefaultValue /// outerEnumInteger /// outerEnumIntegerDefaultValue - /// outerEnum [JsonConstructor] - public EnumTest(EnumIntegerEnum enumInteger, EnumIntegerOnlyEnum enumIntegerOnly, EnumNumberEnum enumNumber, EnumStringEnum enumString, EnumStringRequiredEnum enumStringRequired, OuterEnumDefaultValue outerEnumDefaultValue, OuterEnumInteger outerEnumInteger, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue, OuterEnum? outerEnum = default) + public EnumTest(EnumStringRequiredEnum enumStringRequired, Option enumInteger = default, Option enumIntegerOnly = default, Option enumNumber = default, Option enumString = default, Option outerEnum = default, Option outerEnumDefaultValue = default, Option outerEnumInteger = default, Option outerEnumIntegerDefaultValue = default) { - EnumInteger = enumInteger; - EnumIntegerOnly = enumIntegerOnly; - EnumNumber = enumNumber; - EnumString = enumString; EnumStringRequired = enumStringRequired; - OuterEnumDefaultValue = outerEnumDefaultValue; - OuterEnumInteger = outerEnumInteger; - OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - OuterEnum = outerEnum; + EnumIntegerOption = enumInteger; + EnumIntegerOnlyOption = enumIntegerOnly; + EnumNumberOption = enumNumber; + EnumStringOption = enumString; + OuterEnumOption = outerEnum; + OuterEnumDefaultValueOption = outerEnumDefaultValue; + OuterEnumIntegerOption = outerEnumInteger; + OuterEnumIntegerDefaultValueOption = outerEnumIntegerDefaultValue; OnCreated(); } partial void OnCreated(); - /// - /// Defines EnumInteger - /// - public enum EnumIntegerEnum - { - /// - /// Enum NUMBER_1 for value: 1 - /// - NUMBER_1 = 1, - - /// - /// Enum NUMBER_MINUS_1 for value: -1 - /// - NUMBER_MINUS_1 = -1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerEnum EnumIntegerEnumFromString(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumInteger - /// - [JsonPropertyName("enum_integer")] - public EnumIntegerEnum EnumInteger { get; set; } - - /// - /// Defines EnumIntegerOnly - /// - public enum EnumIntegerOnlyEnum - { - /// - /// Enum NUMBER_2 for value: 2 - /// - NUMBER_2 = 2, - - /// - /// Enum NUMBER_MINUS_2 for value: -2 - /// - NUMBER_MINUS_2 = -2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumIntegerOnly - /// - [JsonPropertyName("enum_integer_only")] - public EnumIntegerOnlyEnum EnumIntegerOnly { get; set; } - - /// - /// Defines EnumNumber - /// - public enum EnumNumberEnum - { - /// - /// Enum NUMBER_1_DOT_1 for value: 1.1 - /// - NUMBER_1_DOT_1 = 1, - - /// - /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 - /// - NUMBER_MINUS_1_DOT_2 = 2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumNumberEnum EnumNumberEnumFromString(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static double EnumNumberEnumToJsonValue(EnumNumberEnum value) - { - - if (value == EnumNumberEnum.NUMBER_1_DOT_1) - return 1.1; - - if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) - return -1.2; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumNumber - /// - [JsonPropertyName("enum_number")] - public EnumNumberEnum EnumNumber { get; set; } - - /// - /// Defines EnumString - /// - public enum EnumStringEnum - { - /// - /// Enum UPPER for value: UPPER - /// - UPPER = 1, - - /// - /// Enum Lower for value: lower - /// - Lower = 2, - - /// - /// Enum Empty for value: - /// - Empty = 3, - - /// - /// Enum ValuewithTab for value: Value\twith tab - /// - ValuewithTab = 4, - - /// - /// Enum ValueWithQuote for value: Value with \" quote - /// - ValueWithQuote = 5, - - /// - /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote - /// - ValueWithEscapedQuote = 6, - - /// - /// Enum Duplicatevalue for value: Duplicate\nvalue - /// - Duplicatevalue = 7, - - /// - /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue - /// - Duplicatevalue2 = 8 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumStringEnum EnumStringEnumFromString(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static string EnumStringEnumToJsonValue(EnumStringEnum value) - { - - if (value == EnumStringEnum.UPPER) - return "UPPER"; - - if (value == EnumStringEnum.Lower) - return "lower"; - - if (value == EnumStringEnum.Empty) - return ""; - - if (value == EnumStringEnum.ValuewithTab) - return "Value\twith tab"; - - if (value == EnumStringEnum.ValueWithQuote) - return "Value with \" quote"; - - if (value == EnumStringEnum.ValueWithEscapedQuote) - return "Value with escaped \" quote"; - - if (value == EnumStringEnum.Duplicatevalue) - return "Duplicate\nvalue"; - - if (value == EnumStringEnum.Duplicatevalue2) - return "Duplicate\r\nvalue"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumString - /// - [JsonPropertyName("enum_string")] - public EnumStringEnum EnumString { get; set; } - /// /// Defines EnumStringRequired /// @@ -544,7 +184,6 @@ namespace UseSourceGeneration.Model /// public static string EnumStringRequiredEnumToJsonValue(EnumStringRequiredEnum value) { - if (value == EnumStringRequiredEnum.UPPER) return "UPPER"; @@ -579,28 +218,442 @@ namespace UseSourceGeneration.Model public EnumStringRequiredEnum EnumStringRequired { get; set; } /// - /// Gets or Sets OuterEnumDefaultValue + /// Defines EnumInteger /// - [JsonPropertyName("outerEnumDefaultValue")] - public OuterEnumDefaultValue OuterEnumDefaultValue { get; set; } + public enum EnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } /// - /// Gets or Sets OuterEnumInteger + /// Returns a /// - [JsonPropertyName("outerEnumInteger")] - public OuterEnumInteger OuterEnumInteger { get; set; } + /// + /// + /// + public static EnumIntegerEnum EnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); + } /// - /// Gets or Sets OuterEnumIntegerDefaultValue + /// Returns a /// - [JsonPropertyName("outerEnumIntegerDefaultValue")] - public OuterEnumIntegerDefaultValue OuterEnumIntegerDefaultValue { get; set; } + /// + /// + public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOption { get; private set; } + + /// + /// Gets or Sets EnumInteger + /// + [JsonPropertyName("enum_integer")] + public EnumIntegerEnum? EnumInteger { get { return this.EnumIntegerOption; } set { this.EnumIntegerOption = new(value); } } + + /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets EnumIntegerOnly + /// + [JsonPropertyName("enum_integer_only")] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get { return this.EnumIntegerOnlyOption; } set { this.EnumIntegerOnlyOption = new(value); } } + + /// + /// Defines EnumNumber + /// + public enum EnumNumberEnum + { + /// + /// Enum NUMBER_1_DOT_1 for value: 1.1 + /// + NUMBER_1_DOT_1 = 1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 + /// + NUMBER_MINUS_1_DOT_2 = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumNumberEnum EnumNumberEnumFromString(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static double EnumNumberEnumToJsonValue(EnumNumberEnum? value) + { + if (value == EnumNumberEnum.NUMBER_1_DOT_1) + return 1.1; + + if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) + return -1.2; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumNumberOption { get; private set; } + + /// + /// Gets or Sets EnumNumber + /// + [JsonPropertyName("enum_number")] + public EnumNumberEnum? EnumNumber { get { return this.EnumNumberOption; } set { this.EnumNumberOption = new(value); } } + + /// + /// Defines EnumString + /// + public enum EnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumStringEnum EnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string EnumStringEnumToJsonValue(EnumStringEnum? value) + { + if (value == EnumStringEnum.UPPER) + return "UPPER"; + + if (value == EnumStringEnum.Lower) + return "lower"; + + if (value == EnumStringEnum.Empty) + return ""; + + if (value == EnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumStringOption { get; private set; } + + /// + /// Gets or Sets EnumString + /// + [JsonPropertyName("enum_string")] + public EnumStringEnum? EnumString { get { return this.EnumStringOption; } set { this.EnumStringOption = new(value); } } + + /// + /// Used to track the state of OuterEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumOption { get; private set; } /// /// Gets or Sets OuterEnum /// [JsonPropertyName("outerEnum")] - public OuterEnum? OuterEnum { get; set; } + public OuterEnum? OuterEnum { get { return this.OuterEnumOption; } set { this.OuterEnumOption = new(value); } } + + /// + /// Used to track the state of OuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumDefaultValue + /// + [JsonPropertyName("outerEnumDefaultValue")] + public OuterEnumDefaultValue? OuterEnumDefaultValue { get { return this.OuterEnumDefaultValueOption; } set { this.OuterEnumDefaultValueOption = new(value); } } + + /// + /// Used to track the state of OuterEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets OuterEnumInteger + /// + [JsonPropertyName("outerEnumInteger")] + public OuterEnumInteger? OuterEnumInteger { get { return this.OuterEnumIntegerOption; } set { this.OuterEnumIntegerOption = new(value); } } + + /// + /// Used to track the state of OuterEnumIntegerDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumIntegerDefaultValue + /// + [JsonPropertyName("outerEnumIntegerDefaultValue")] + public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get { return this.OuterEnumIntegerDefaultValueOption; } set { this.OuterEnumIntegerDefaultValueOption = new(value); } } /// /// Gets or Sets additional properties @@ -616,15 +669,15 @@ namespace UseSourceGeneration.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EnumTest {\n"); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" EnumString: ").Append(EnumString).Append("\n"); - sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); - sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -663,15 +716,15 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - EnumTest.EnumIntegerEnum? enumInteger = default; - EnumTest.EnumIntegerOnlyEnum? enumIntegerOnly = default; - EnumTest.EnumNumberEnum? enumNumber = default; - EnumTest.EnumStringEnum? enumString = default; - EnumTest.EnumStringRequiredEnum? enumStringRequired = default; - OuterEnumDefaultValue? outerEnumDefaultValue = default; - OuterEnumInteger? outerEnumInteger = default; - OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default; - OuterEnum? outerEnum = default; + Option enumStringRequired = default; + Option enumInteger = default; + Option enumIntegerOnly = default; + Option enumNumber = default; + Option enumString = default; + Option outerEnum = default; + Option outerEnumDefaultValue = default; + Option outerEnumInteger = default; + Option outerEnumIntegerDefaultValue = default; while (utf8JsonReader.Read()) { @@ -688,53 +741,47 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { + case "enum_string_required": + string? enumStringRequiredRawValue = utf8JsonReader.GetString(); + if (enumStringRequiredRawValue != null) + enumStringRequired = new Option(EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue)); + break; case "enum_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumInteger = (EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32(); + enumInteger = new Option((EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32()); break; case "enum_integer_only": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumIntegerOnly = (EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32(); + enumIntegerOnly = new Option((EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); break; case "enum_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumNumber = (EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32(); + enumNumber = new Option((EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32()); break; case "enum_string": string? enumStringRawValue = utf8JsonReader.GetString(); - enumString = enumStringRawValue == null - ? null - : EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue); - break; - case "enum_string_required": - string? enumStringRequiredRawValue = utf8JsonReader.GetString(); - enumStringRequired = enumStringRequiredRawValue == null - ? null - : EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue); - break; - case "outerEnumDefaultValue": - string? outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumDefaultValue = outerEnumDefaultValueRawValue == null - ? null - : OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue); - break; - case "outerEnumInteger": - string? outerEnumIntegerRawValue = utf8JsonReader.GetString(); - outerEnumInteger = outerEnumIntegerRawValue == null - ? null - : OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue); - break; - case "outerEnumIntegerDefaultValue": - string? outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumIntegerDefaultValue = outerEnumIntegerDefaultValueRawValue == null - ? null - : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue); + if (enumStringRawValue != null) + enumString = new Option(EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue)); break; case "outerEnum": string? outerEnumRawValue = utf8JsonReader.GetString(); - outerEnum = outerEnumRawValue == null - ? null - : OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue); + if (outerEnumRawValue != null) + outerEnum = new Option(OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue)); + break; + case "outerEnumDefaultValue": + string? outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumDefaultValueRawValue != null) + outerEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue)); + break; + case "outerEnumInteger": + string? outerEnumIntegerRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerRawValue != null) + outerEnumInteger = new Option(OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue)); + break; + case "outerEnumIntegerDefaultValue": + string? outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerDefaultValueRawValue != null) + outerEnumIntegerDefaultValue = new Option(OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue)); break; default: break; @@ -742,31 +789,34 @@ namespace UseSourceGeneration.Model } } - if (enumInteger == null) - throw new ArgumentNullException(nameof(enumInteger), "Property is required for class EnumTest."); + if (!enumStringRequired.IsSet) + throw new ArgumentException("Property is required for class EnumTest.", nameof(enumStringRequired)); - if (enumIntegerOnly == null) - throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is required for class EnumTest."); + if (enumStringRequired.IsSet && enumStringRequired.Value == null) + throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest."); - if (enumNumber == null) - throw new ArgumentNullException(nameof(enumNumber), "Property is required for class EnumTest."); + if (enumInteger.IsSet && enumInteger.Value == null) + throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest."); - if (enumString == null) - throw new ArgumentNullException(nameof(enumString), "Property is required for class EnumTest."); + if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest."); - if (enumStringRequired == null) - throw new ArgumentNullException(nameof(enumStringRequired), "Property is required for class EnumTest."); + if (enumNumber.IsSet && enumNumber.Value == null) + throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest."); - if (outerEnumDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is required for class EnumTest."); + if (enumString.IsSet && enumString.Value == null) + throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest."); - if (outerEnumInteger == null) - throw new ArgumentNullException(nameof(outerEnumInteger), "Property is required for class EnumTest."); + if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest."); - if (outerEnumIntegerDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is required for class EnumTest."); + if (outerEnumInteger.IsSet && outerEnumInteger.Value == null) + throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest."); - return new EnumTest(enumInteger.Value, enumIntegerOnly.Value, enumNumber.Value, enumString.Value, enumStringRequired.Value, outerEnumDefaultValue.Value, outerEnumInteger.Value, outerEnumIntegerDefaultValue.Value, outerEnum); + if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest."); + + return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue); } /// @@ -793,43 +843,49 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumInteger)); - writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnly)); - writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumber)); - - var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumString); - if (enumStringRawValue != null) - writer.WriteString("enum_string", enumStringRawValue); - else - writer.WriteNull("enum_string"); - var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); if (enumStringRequiredRawValue != null) writer.WriteString("enum_string_required", enumStringRequiredRawValue); else writer.WriteNull("enum_string_required"); - var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue); + if (enumTest.EnumIntegerOption.IsSet) + writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value)); - if (outerEnumDefaultValueRawValue != null) - writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + if (enumTest.EnumIntegerOnlyOption.IsSet) + writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value)); + + if (enumTest.EnumNumberOption.IsSet) + writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value)); + + var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value); + if (enumStringRawValue != null) + writer.WriteString("enum_string", enumStringRawValue); else - writer.WriteNull("outerEnumDefaultValue"); + writer.WriteNull("enum_string"); - var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger); - writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); - var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue); - writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); - - if (enumTest.OuterEnum == null) - writer.WriteNull("outerEnum"); - else - { - var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnum.Value); - if (outerEnumRawValue != null) + if (enumTest.OuterEnumOption.IsSet) + if (enumTest.OuterEnumOption!.Value != null) + { + var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnumOption.Value!.Value); writer.WriteString("outerEnum", outerEnumRawValue); + } else writer.WriteNull("outerEnum"); + if (enumTest.OuterEnumDefaultValueOption.IsSet) + { + var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue!.Value); + writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + } + if (enumTest.OuterEnumIntegerOption.IsSet) + { + var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger!.Value); + writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); + } + if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet) + { + var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue!.Value); + writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EquilateralTriangle.cs index b161cd58e18..ef87cf48dfd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EquilateralTriangle.cs @@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; - string? triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -132,10 +132,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -143,13 +143,19 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class EquilateralTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class EquilateralTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(triangleType)); - return new EquilateralTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class EquilateralTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class EquilateralTriangle."); + + return new EquilateralTriangle(shapeType.Value!, triangleType.Value!); } /// @@ -176,7 +182,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (equilateralTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle."); + + if (equilateralTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle."); + writer.WriteString("shapeType", equilateralTriangle.ShapeType); + writer.WriteString("triangleType", equilateralTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/File.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/File.cs index bc7f05fae9e..7a650ad95b0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/File.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/File.cs @@ -37,20 +37,27 @@ namespace UseSourceGeneration.Model /// /// Test capitalization [JsonConstructor] - public File(string sourceURI) + public File(Option sourceURI = default) { - SourceURI = sourceURI; + SourceURIOption = sourceURI; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SourceURI + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SourceURIOption { get; private set; } + /// /// Test capitalization /// /// Test capitalization [JsonPropertyName("sourceURI")] - public string SourceURI { get; set; } + public string? SourceURI { get { return this. SourceURIOption; } set { this.SourceURIOption = new(value); } } /// /// Gets or Sets additional properties @@ -105,7 +112,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? sourceURI = default; + Option sourceURI = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "sourceURI": - sourceURI = utf8JsonReader.GetString(); + sourceURI = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -131,8 +138,8 @@ namespace UseSourceGeneration.Model } } - if (sourceURI == null) - throw new ArgumentNullException(nameof(sourceURI), "Property is required for class File."); + if (sourceURI.IsSet && sourceURI.Value == null) + throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File."); return new File(sourceURI); } @@ -161,7 +168,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("sourceURI", file.SourceURI); + if (file.SourceURIOption.IsSet && file.SourceURI == null) + throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File."); + + if (file.SourceURIOption.IsSet) + writer.WriteString("sourceURI", file.SourceURI); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FileSchemaTestClass.cs index 68d2af61dbc..b061b4c87fa 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FileSchemaTestClass.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// file /// files [JsonConstructor] - public FileSchemaTestClass(File file, List files) + public FileSchemaTestClass(Option file = default, Option?> files = default) { - File = file; - Files = files; + FileOption = file; + FilesOption = files; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of File + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FileOption { get; private set; } + /// /// Gets or Sets File /// [JsonPropertyName("file")] - public File File { get; set; } + public File? File { get { return this. FileOption; } set { this.FileOption = new(value); } } + + /// + /// Used to track the state of Files + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> FilesOption { get; private set; } /// /// Gets or Sets Files /// [JsonPropertyName("files")] - public List Files { get; set; } + public List? Files { get { return this. FilesOption; } set { this.FilesOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - File? file = default; - List? files = default; + Option file = default; + Option?> files = default; while (utf8JsonReader.Read()) { @@ -133,11 +147,11 @@ namespace UseSourceGeneration.Model { case "file": if (utf8JsonReader.TokenType != JsonTokenType.Null) - file = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + file = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "files": if (utf8JsonReader.TokenType != JsonTokenType.Null) - files = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + files = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -145,11 +159,11 @@ namespace UseSourceGeneration.Model } } - if (file == null) - throw new ArgumentNullException(nameof(file), "Property is required for class FileSchemaTestClass."); + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass."); - if (files == null) - throw new ArgumentNullException(nameof(files), "Property is required for class FileSchemaTestClass."); + if (files.IsSet && files.Value == null) + throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass."); return new FileSchemaTestClass(file, files); } @@ -178,10 +192,22 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("file"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); - writer.WritePropertyName("files"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FileOption.IsSet) + { + writer.WritePropertyName("file"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); + } + if (fileSchemaTestClass.FilesOption.IsSet) + { + writer.WritePropertyName("files"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Foo.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Foo.cs index dbedd34f861..39566c13eaf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Foo.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Foo.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// bar (default to "bar") [JsonConstructor] - public Foo(string bar = @"bar") + public Foo(Option bar = default) { - Bar = bar; + BarOption = bar; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; private set; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; set; } + public string? Bar { get { return this. BarOption; } set { this.BarOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? bar = default; + Option bar = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class Foo."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo."); return new Foo(bar); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", foo.Bar); + if (foo.BarOption.IsSet && foo.Bar == null) + throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo."); + + if (foo.BarOption.IsSet) + writer.WriteString("bar", foo.Bar); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FooGetDefaultResponse.cs index dabc1bd83db..1bbe0ddf0fe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FooGetDefaultResponse.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// varString [JsonConstructor] - public FooGetDefaultResponse(Foo varString) + public FooGetDefaultResponse(Option varString = default) { - VarString = varString; + VarStringOption = varString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } + /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public Foo VarString { get; set; } + public Foo? VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Foo? varString = default; + Option varString = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varString = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varString = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -131,8 +138,8 @@ namespace UseSourceGeneration.Model } } - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FooGetDefaultResponse."); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse."); return new FooGetDefaultResponse(varString); } @@ -161,8 +168,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("string"); - JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + if (fooGetDefaultResponse.VarStringOption.IsSet && fooGetDefaultResponse.VarString == null) + throw new ArgumentNullException(nameof(fooGetDefaultResponse.VarString), "Property is required for class FooGetDefaultResponse."); + + if (fooGetDefaultResponse.VarStringOption.IsSet) + { + writer.WritePropertyName("string"); + JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + } } } 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 d45a83b0f1d..43006afbbb0 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 @@ -35,9 +35,11 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// - /// binary /// varByte /// date + /// number + /// password + /// binary /// dateTime /// varDecimal /// varDouble @@ -45,8 +47,6 @@ namespace UseSourceGeneration.Model /// int32 /// int64 /// integer - /// number - /// password /// None /// A string that is a 10 digit number. Can have leading zeros. /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. @@ -55,38 +55,32 @@ namespace UseSourceGeneration.Model /// unsignedLong /// uuid [JsonConstructor] - public FormatTest(System.IO.Stream binary, byte[] varByte, DateTime date, DateTime dateTime, decimal varDecimal, double varDouble, float varFloat, int int32, long int64, int integer, decimal number, string password, string patternWithBackslash, string patternWithDigits, string patternWithDigitsAndDelimiter, string varString, uint unsignedInteger, ulong unsignedLong, Guid uuid) + 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) { - Binary = binary; VarByte = varByte; Date = date; - DateTime = dateTime; - VarDecimal = varDecimal; - VarDouble = varDouble; - VarFloat = varFloat; - Int32 = int32; - Int64 = int64; - Integer = integer; Number = number; Password = password; - PatternWithBackslash = patternWithBackslash; - PatternWithDigits = patternWithDigits; - PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - VarString = varString; - UnsignedInteger = unsignedInteger; - UnsignedLong = unsignedLong; - Uuid = uuid; + BinaryOption = binary; + DateTimeOption = dateTime; + VarDecimalOption = varDecimal; + VarDoubleOption = varDouble; + VarFloatOption = varFloat; + Int32Option = int32; + Int64Option = int64; + IntegerOption = integer; + PatternWithBackslashOption = patternWithBackslash; + PatternWithDigitsOption = patternWithDigits; + PatternWithDigitsAndDelimiterOption = patternWithDigitsAndDelimiter; + VarStringOption = varString; + UnsignedIntegerOption = unsignedInteger; + UnsignedLongOption = unsignedLong; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); - /// - /// Gets or Sets Binary - /// - [JsonPropertyName("binary")] - public System.IO.Stream Binary { get; set; } - /// /// Gets or Sets VarByte /// @@ -100,49 +94,6 @@ namespace UseSourceGeneration.Model [JsonPropertyName("date")] public DateTime Date { get; set; } - /// - /// Gets or Sets DateTime - /// - /// 2007-12-03T10:15:30+01:00 - [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } - - /// - /// Gets or Sets VarDecimal - /// - [JsonPropertyName("decimal")] - public decimal VarDecimal { get; set; } - - /// - /// Gets or Sets VarDouble - /// - [JsonPropertyName("double")] - public double VarDouble { get; set; } - - /// - /// Gets or Sets VarFloat - /// - [JsonPropertyName("float")] - public float VarFloat { get; set; } - - /// - /// Gets or Sets Int32 - /// - [JsonPropertyName("int32")] - public int Int32 { get; set; } - - /// - /// Gets or Sets Int64 - /// - [JsonPropertyName("int64")] - public long Int64 { get; set; } - - /// - /// Gets or Sets Integer - /// - [JsonPropertyName("integer")] - public int Integer { get; set; } - /// /// Gets or Sets Number /// @@ -155,51 +106,205 @@ namespace UseSourceGeneration.Model [JsonPropertyName("password")] public string Password { get; set; } + /// + /// Used to track the state of Binary + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BinaryOption { get; private set; } + + /// + /// Gets or Sets Binary + /// + [JsonPropertyName("binary")] + public System.IO.Stream? Binary { get { return this. BinaryOption; } set { this.BinaryOption = new(value); } } + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + /// 2007-12-03T10:15:30+01:00 + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } } + + /// + /// Used to track the state of VarDecimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDecimalOption { get; private set; } + + /// + /// Gets or Sets VarDecimal + /// + [JsonPropertyName("decimal")] + public decimal? VarDecimal { get { return this. VarDecimalOption; } set { this.VarDecimalOption = new(value); } } + + /// + /// Used to track the state of VarDouble + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDoubleOption { get; private set; } + + /// + /// Gets or Sets VarDouble + /// + [JsonPropertyName("double")] + public double? VarDouble { get { return this. VarDoubleOption; } set { this.VarDoubleOption = new(value); } } + + /// + /// Used to track the state of VarFloat + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarFloatOption { get; private set; } + + /// + /// Gets or Sets VarFloat + /// + [JsonPropertyName("float")] + public float? VarFloat { get { return this. VarFloatOption; } set { this.VarFloatOption = new(value); } } + + /// + /// Used to track the state of Int32 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int32Option { get; private set; } + + /// + /// Gets or Sets Int32 + /// + [JsonPropertyName("int32")] + public int? Int32 { get { return this. Int32Option; } set { this.Int32Option = new(value); } } + + /// + /// Used to track the state of Int64 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int64Option { get; private set; } + + /// + /// Gets or Sets Int64 + /// + [JsonPropertyName("int64")] + public long? Int64 { get { return this. Int64Option; } set { this.Int64Option = new(value); } } + + /// + /// Used to track the state of Integer + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerOption { get; private set; } + + /// + /// Gets or Sets Integer + /// + [JsonPropertyName("integer")] + public int? Integer { get { return this. IntegerOption; } set { this.IntegerOption = new(value); } } + + /// + /// Used to track the state of PatternWithBackslash + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithBackslashOption { get; private set; } + /// /// None /// /// None [JsonPropertyName("pattern_with_backslash")] - public string PatternWithBackslash { get; set; } + public string? PatternWithBackslash { get { return this. PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new(value); } } + + /// + /// Used to track the state of PatternWithDigits + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsOption { get; private set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. [JsonPropertyName("pattern_with_digits")] - public string PatternWithDigits { get; set; } + public string? PatternWithDigits { get { return this. PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new(value); } } + + /// + /// Used to track the state of PatternWithDigitsAndDelimiter + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsAndDelimiterOption { get; private set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. [JsonPropertyName("pattern_with_digits_and_delimiter")] - public string PatternWithDigitsAndDelimiter { get; set; } + public string? PatternWithDigitsAndDelimiter { get { return this. PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new(value); } } + + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public string VarString { get; set; } + public string? VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } } + + /// + /// Used to track the state of UnsignedInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedIntegerOption { get; private set; } /// /// Gets or Sets UnsignedInteger /// [JsonPropertyName("unsigned_integer")] - public uint UnsignedInteger { get; set; } + public uint? UnsignedInteger { get { return this. UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new(value); } } + + /// + /// Used to track the state of UnsignedLong + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedLongOption { get; private set; } /// /// Gets or Sets UnsignedLong /// [JsonPropertyName("unsigned_long")] - public ulong UnsignedLong { get; set; } + public ulong? UnsignedLong { get { return this. UnsignedLongOption; } set { this.UnsignedLongOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -215,9 +320,11 @@ namespace UseSourceGeneration.Model { StringBuilder sb = new StringBuilder(); sb.Append("class FormatTest {\n"); - sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" VarByte: ").Append(VarByte).Append("\n"); sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" DateTime: ").Append(DateTime).Append("\n"); sb.Append(" VarDecimal: ").Append(VarDecimal).Append("\n"); sb.Append(" VarDouble: ").Append(VarDouble).Append("\n"); @@ -225,8 +332,6 @@ namespace UseSourceGeneration.Model sb.Append(" Int32: ").Append(Int32).Append("\n"); sb.Append(" Int64: ").Append(Int64).Append("\n"); sb.Append(" Integer: ").Append(Integer).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" PatternWithBackslash: ").Append(PatternWithBackslash).Append("\n"); sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); @@ -246,54 +351,6 @@ namespace UseSourceGeneration.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - // VarDouble (double) maximum - if (this.VarDouble > (double)123.4) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); - } - - // VarDouble (double) minimum - if (this.VarDouble < (double)67.8) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); - } - - // VarFloat (float) maximum - if (this.VarFloat > (float)987.6) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); - } - - // VarFloat (float) minimum - if (this.VarFloat < (float)54.3) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); - } - - // Int32 (int) maximum - if (this.Int32 > (int)200) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); - } - - // Int32 (int) minimum - if (this.Int32 < (int)20) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); - } - - // Integer (int) maximum - if (this.Integer > (int)100) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); - } - - // Integer (int) minimum - if (this.Integer < (int)10) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); - } - // Number (decimal) maximum if (this.Number > (decimal)543.2) { @@ -318,50 +375,102 @@ namespace UseSourceGeneration.Model yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); } - if (this.PatternWithBackslash != null) { + // VarDouble (double) maximum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value > (double)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); + } + + // VarDouble (double) minimum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value < (double)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); + } + + // VarFloat (float) maximum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value > (float)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); + } + + // VarFloat (float) minimum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value < (float)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); + } + + // Int32 (int) maximum + if (this.Int32Option.IsSet && this.Int32Option.Value > (int)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int) minimum + if (this.Int32Option.IsSet && this.Int32Option.Value < (int)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Integer (int) maximum + if (this.IntegerOption.IsSet && this.IntegerOption.Value > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int) minimum + if (this.IntegerOption.IsSet && this.IntegerOption.Value < (int)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + if (this.PatternWithBackslashOption.Value != null) { // PatternWithBackslash (string) pattern Regex regexPatternWithBackslash = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$", RegexOptions.CultureInvariant); - if (!regexPatternWithBackslash.Match(this.PatternWithBackslash).Success) + + if (this.PatternWithBackslashOption.Value != null &&!regexPatternWithBackslash.Match(this.PatternWithBackslashOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithBackslash, must match a pattern of " + regexPatternWithBackslash, new [] { "PatternWithBackslash" }); } } - if (this.PatternWithDigits != null) { + if (this.PatternWithDigitsOption.Value != null) { // PatternWithDigits (string) pattern Regex regexPatternWithDigits = new Regex(@"^\d{10}$", RegexOptions.CultureInvariant); - if (!regexPatternWithDigits.Match(this.PatternWithDigits).Success) + + if (this.PatternWithDigitsOption.Value != null &&!regexPatternWithDigits.Match(this.PatternWithDigitsOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigits, must match a pattern of " + regexPatternWithDigits, new [] { "PatternWithDigits" }); } } - if (this.PatternWithDigitsAndDelimiter != null) { + if (this.PatternWithDigitsAndDelimiterOption.Value != null) { // PatternWithDigitsAndDelimiter (string) pattern Regex regexPatternWithDigitsAndDelimiter = new Regex(@"^image_\d{1,3}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiter).Success) + + if (this.PatternWithDigitsAndDelimiterOption.Value != null &&!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiterOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigitsAndDelimiter, must match a pattern of " + regexPatternWithDigitsAndDelimiter, new [] { "PatternWithDigitsAndDelimiter" }); } } - if (this.VarString != null) { + if (this.VarStringOption.Value != null) { // VarString (string) pattern Regex regexVarString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexVarString.Match(this.VarString).Success) + + if (this.VarStringOption.Value != null &&!regexVarString.Match(this.VarStringOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarString, must match a pattern of " + regexVarString, new [] { "VarString" }); } } // UnsignedInteger (uint) maximum - if (this.UnsignedInteger > (uint)200) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value > (uint)200) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value less than or equal to 200.", new [] { "UnsignedInteger" }); } // UnsignedInteger (uint) minimum - if (this.UnsignedInteger < (uint)20) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value < (uint)20) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value greater than or equal to 20.", new [] { "UnsignedInteger" }); } @@ -402,25 +511,25 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - System.IO.Stream? binary = default; - byte[]? varByte = default; - DateTime? date = default; - DateTime? dateTime = default; - decimal? varDecimal = default; - double? varDouble = default; - float? varFloat = default; - int? int32 = default; - long? int64 = default; - int? integer = default; - decimal? number = default; - string? password = default; - string? patternWithBackslash = default; - string? patternWithDigits = default; - string? patternWithDigitsAndDelimiter = default; - string? varString = default; - uint? unsignedInteger = default; - ulong? unsignedLong = default; - Guid? uuid = default; + Option varByte = default; + Option date = default; + Option number = default; + Option password = default; + 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; while (utf8JsonReader.Read()) { @@ -437,76 +546,76 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { - case "binary": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - binary = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; case "byte": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varByte = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varByte = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "date": if (utf8JsonReader.TokenType != JsonTokenType.Null) - date = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "dateTime": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "decimal": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDecimal = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "double": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDouble = utf8JsonReader.GetDouble(); - break; - case "float": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varFloat = (float)utf8JsonReader.GetDouble(); - break; - case "int32": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int32 = utf8JsonReader.GetInt32(); - break; - case "int64": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int64 = utf8JsonReader.GetInt64(); - break; - case "integer": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - integer = utf8JsonReader.GetInt32(); + date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - number = utf8JsonReader.GetDecimal(); + number = new Option(utf8JsonReader.GetDecimal()); break; case "password": - password = utf8JsonReader.GetString(); + password = new Option(utf8JsonReader.GetString()!); + break; + case "binary": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + binary = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "decimal": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDecimal = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "double": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDouble = new Option(utf8JsonReader.GetDouble()); + break; + case "float": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varFloat = new Option((float)utf8JsonReader.GetDouble()); + break; + case "int32": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int32 = new Option(utf8JsonReader.GetInt32()); + break; + case "int64": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int64 = new Option(utf8JsonReader.GetInt64()); + break; + case "integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integer = new Option(utf8JsonReader.GetInt32()); break; case "pattern_with_backslash": - patternWithBackslash = utf8JsonReader.GetString(); + patternWithBackslash = new Option(utf8JsonReader.GetString()!); break; case "pattern_with_digits": - patternWithDigits = utf8JsonReader.GetString(); + patternWithDigits = new Option(utf8JsonReader.GetString()!); break; case "pattern_with_digits_and_delimiter": - patternWithDigitsAndDelimiter = utf8JsonReader.GetString(); + patternWithDigitsAndDelimiter = new Option(utf8JsonReader.GetString()!); break; case "string": - varString = utf8JsonReader.GetString(); + varString = new Option(utf8JsonReader.GetString()!); break; case "unsigned_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedInteger = utf8JsonReader.GetUInt32(); + unsignedInteger = new Option(utf8JsonReader.GetUInt32()); break; case "unsigned_long": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedLong = utf8JsonReader.GetUInt64(); + unsignedLong = new Option(utf8JsonReader.GetUInt64()); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -514,64 +623,76 @@ namespace UseSourceGeneration.Model } } - if (binary == null) - throw new ArgumentNullException(nameof(binary), "Property is required for class FormatTest."); + if (!varByte.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(varByte)); - if (varByte == null) - throw new ArgumentNullException(nameof(varByte), "Property is required for class FormatTest."); + if (!date.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(date)); - if (date == null) - throw new ArgumentNullException(nameof(date), "Property is required for class FormatTest."); + if (!number.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(number)); - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class FormatTest."); + if (!password.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(password)); - if (varDecimal == null) - throw new ArgumentNullException(nameof(varDecimal), "Property is required for class FormatTest."); + if (varByte.IsSet && varByte.Value == null) + throw new ArgumentNullException(nameof(varByte), "Property is not nullable for class FormatTest."); - if (varDouble == null) - throw new ArgumentNullException(nameof(varDouble), "Property is required for class FormatTest."); + if (date.IsSet && date.Value == null) + throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest."); - if (varFloat == null) - throw new ArgumentNullException(nameof(varFloat), "Property is required for class FormatTest."); + if (number.IsSet && number.Value == null) + throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest."); - if (int32 == null) - throw new ArgumentNullException(nameof(int32), "Property is required for class FormatTest."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class FormatTest."); - if (int64 == null) - throw new ArgumentNullException(nameof(int64), "Property is required for class FormatTest."); + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest."); - if (integer == null) - throw new ArgumentNullException(nameof(integer), "Property is required for class FormatTest."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest."); - if (number == null) - throw new ArgumentNullException(nameof(number), "Property is required for class FormatTest."); + if (varDecimal.IsSet && varDecimal.Value == null) + throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class FormatTest."); + if (varDouble.IsSet && varDouble.Value == null) + throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest."); - if (patternWithBackslash == null) - throw new ArgumentNullException(nameof(patternWithBackslash), "Property is required for class FormatTest."); + if (varFloat.IsSet && varFloat.Value == null) + throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest."); - if (patternWithDigits == null) - throw new ArgumentNullException(nameof(patternWithDigits), "Property is required for class FormatTest."); + if (int32.IsSet && int32.Value == null) + throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest."); - if (patternWithDigitsAndDelimiter == null) - throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + if (int64.IsSet && int64.Value == null) + throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest."); - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FormatTest."); + if (integer.IsSet && integer.Value == null) + throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest."); - if (unsignedInteger == null) - throw new ArgumentNullException(nameof(unsignedInteger), "Property is required for class FormatTest."); + if (patternWithBackslash.IsSet && patternWithBackslash.Value == null) + throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest."); - if (unsignedLong == null) - throw new ArgumentNullException(nameof(unsignedLong), "Property is required for class FormatTest."); + if (patternWithDigits.IsSet && patternWithDigits.Value == null) + throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class FormatTest."); + if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null) + throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest."); - return new FormatTest(binary, varByte, date.Value, dateTime.Value, varDecimal.Value, varDouble.Value, varFloat.Value, int32.Value, int64.Value, integer.Value, number.Value, password, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger.Value, unsignedLong.Value, uuid.Value); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest."); + + if (unsignedInteger.IsSet && unsignedInteger.Value == null) + throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest."); + + if (unsignedLong.IsSet && unsignedLong.Value == null) + throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest."); + + 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, int64, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid); } /// @@ -598,28 +719,83 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("binary"); - JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + if (formatTest.VarByte == null) + throw new ArgumentNullException(nameof(formatTest.VarByte), "Property is required for class FormatTest."); + + if (formatTest.Password == null) + throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest."); + + if (formatTest.BinaryOption.IsSet && formatTest.Binary == null) + throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest."); + + if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + + if (formatTest.VarStringOption.IsSet && formatTest.VarString == null) + throw new ArgumentNullException(nameof(formatTest.VarString), "Property is required for class FormatTest."); + writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.VarByte, jsonSerializerOptions); writer.WriteString("date", formatTest.Date.ToString(DateFormat)); - writer.WriteString("dateTime", formatTest.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("decimal"); - JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); - writer.WriteNumber("double", formatTest.VarDouble); - writer.WriteNumber("float", formatTest.VarFloat); - writer.WriteNumber("int32", formatTest.Int32); - writer.WriteNumber("int64", formatTest.Int64); - writer.WriteNumber("integer", formatTest.Integer); + writer.WriteNumber("number", formatTest.Number); + writer.WriteString("password", formatTest.Password); - writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); - writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); - writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); - writer.WriteString("string", formatTest.VarString); - writer.WriteNumber("unsigned_integer", formatTest.UnsignedInteger); - writer.WriteNumber("unsigned_long", formatTest.UnsignedLong); - writer.WriteString("uuid", formatTest.Uuid); + + if (formatTest.BinaryOption.IsSet) + { + writer.WritePropertyName("binary"); + JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + } + if (formatTest.DateTimeOption.IsSet) + writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat)); + + if (formatTest.VarDecimalOption.IsSet) + { + writer.WritePropertyName("decimal"); + JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); + } + if (formatTest.VarDoubleOption.IsSet) + writer.WriteNumber("double", formatTest.VarDoubleOption.Value!.Value); + + if (formatTest.VarFloatOption.IsSet) + writer.WriteNumber("float", formatTest.VarFloatOption.Value!.Value); + + if (formatTest.Int32Option.IsSet) + writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value); + + if (formatTest.Int64Option.IsSet) + writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value); + + if (formatTest.IntegerOption.IsSet) + writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value); + + if (formatTest.PatternWithBackslashOption.IsSet) + writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); + + if (formatTest.PatternWithDigitsOption.IsSet) + writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet) + writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); + + if (formatTest.VarStringOption.IsSet) + writer.WriteString("string", formatTest.VarString); + + if (formatTest.UnsignedIntegerOption.IsSet) + writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value); + + if (formatTest.UnsignedLongOption.IsSet) + writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value); + + if (formatTest.UuidOption.IsSet) + writer.WriteString("uuid", formatTest.UuidOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Fruit.cs index be945563eba..066324fd8ac 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Fruit.cs @@ -37,10 +37,10 @@ namespace UseSourceGeneration.Model /// /// /// color - public Fruit(Apple apple, string color) + public Fruit(Apple apple, Option color = default) { Apple = apple; - Color = color; + ColorOption = color; OnCreated(); } @@ -49,10 +49,10 @@ namespace UseSourceGeneration.Model /// /// /// color - public Fruit(Banana banana, string color) + public Fruit(Banana banana, Option color = default) { Banana = banana; - Color = color; + ColorOption = color; OnCreated(); } @@ -68,11 +68,18 @@ namespace UseSourceGeneration.Model /// public Banana? Banana { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Returns the string presentation of the object @@ -120,7 +127,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? color = default; + Option color = default; Apple? apple = default; Banana? banana = default; @@ -160,7 +167,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -168,8 +175,8 @@ namespace UseSourceGeneration.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Fruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); if (apple != null) return new Fruit(apple, color); @@ -204,7 +211,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", fruit.Color); + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GmFruit.cs index fea0b966137..ce3104ed326 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GmFruit.cs @@ -38,31 +38,52 @@ namespace UseSourceGeneration.Model /// /// /// color - public GmFruit(Apple? apple, Banana? banana, string color) + public GmFruit(Option apple, Option banana, Option color = default) { - Apple = apple; - Banana = banana; - Color = color; + AppleOption = apple; + BananaOption = banana; + ColorOption = color; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + /// /// Gets or Sets Apple /// - public Apple? Apple { get; set; } + public Apple? Apple { get { return this.AppleOption; } set { this.AppleOption = new(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } /// /// Gets or Sets Banana /// - public Banana? Banana { get; set; } + public Banana? Banana { get { return this.BananaOption; } set { this.BananaOption = new(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Returns the string presentation of the object @@ -110,7 +131,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? color = default; + Option color = default; Apple? apple = default; Banana? banana = default; @@ -150,7 +171,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -158,10 +179,17 @@ namespace UseSourceGeneration.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class GmFruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit."); - return new GmFruit(apple, banana, color); + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new GmFruit(appleParsedValue, bananaParsedValue, color); } /// @@ -175,16 +203,16 @@ namespace UseSourceGeneration.Model { writer.WriteStartObject(); - if (gmFruit.Apple != null) + if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { - AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Apple.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.Apple, jsonSerializerOptions); + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); } - if (gmFruit.Banana != null) + if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null) { - BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Banana.GetType())); - BananaJsonConverter.WriteProperties(ref writer, gmFruit.Banana, jsonSerializerOptions); + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } WriteProperties(ref writer, gmFruit, jsonSerializerOptions); @@ -200,7 +228,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", gmFruit.Color); + if (gmFruit.ColorOption.IsSet && gmFruit.Color == null) + throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit."); + + if (gmFruit.ColorOption.IsSet) + writer.WriteString("color", gmFruit.Color); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GrandparentAnimal.cs index d4a0752699b..ff6399cd2fe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/GrandparentAnimal.cs @@ -114,7 +114,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -132,7 +132,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -140,10 +140,13 @@ namespace UseSourceGeneration.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class GrandparentAnimal."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class GrandparentAnimal.", nameof(petType)); - return new GrandparentAnimal(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); + + return new GrandparentAnimal(petType.Value!); } /// @@ -170,6 +173,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { + if (grandparentAnimal.PetType == null) + throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); + writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HasOnlyReadOnly.cs index 0ba58633d83..75e57fcf4fe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HasOnlyReadOnly.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// bar /// foo [JsonConstructor] - internal HasOnlyReadOnly(string bar, string foo) + internal HasOnlyReadOnly(Option bar = default, Option foo = default) { - Bar = bar; - Foo = foo; + BarOption = bar; + FooOption = foo; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string? Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Foo + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FooOption { get; } /// /// Gets or Sets Foo /// [JsonPropertyName("foo")] - public string Foo { get; } + public string? Foo { get { return this. FooOption; } } /// /// Gets or Sets additional properties @@ -109,8 +123,12 @@ namespace UseSourceGeneration.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); - hashCode = (hashCode * 59) + Foo.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + if (Foo != null) + hashCode = (hashCode * 59) + Foo.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -150,8 +168,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? bar = default; - string? foo = default; + Option bar = default; + Option foo = default; while (utf8JsonReader.Read()) { @@ -169,10 +187,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()!); break; case "foo": - foo = utf8JsonReader.GetString(); + foo = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -180,11 +198,11 @@ namespace UseSourceGeneration.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class HasOnlyReadOnly."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly."); - if (foo == null) - throw new ArgumentNullException(nameof(foo), "Property is required for class HasOnlyReadOnly."); + if (foo.IsSet && foo.Value == null) + throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly."); return new HasOnlyReadOnly(bar, foo); } @@ -213,8 +231,17 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", hasOnlyReadOnly.Bar); - writer.WriteString("foo", hasOnlyReadOnly.Foo); + if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.BarOption.IsSet) + writer.WriteString("bar", hasOnlyReadOnly.Bar); + + if (hasOnlyReadOnly.FooOption.IsSet) + writer.WriteString("foo", hasOnlyReadOnly.Foo); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HealthCheckResult.cs index b0753cea2a4..44988806cfb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/HealthCheckResult.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// nullableMessage [JsonConstructor] - public HealthCheckResult(string? nullableMessage = default) + public HealthCheckResult(Option nullableMessage = default) { - NullableMessage = nullableMessage; + NullableMessageOption = nullableMessage; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of NullableMessage + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableMessageOption { get; private set; } + /// /// Gets or Sets NullableMessage /// [JsonPropertyName("NullableMessage")] - public string? NullableMessage { get; set; } + public string? NullableMessage { get { return this. NullableMessageOption; } set { this.NullableMessageOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? nullableMessage = default; + Option nullableMessage = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "NullableMessage": - nullableMessage = utf8JsonReader.GetString(); + nullableMessage = new Option(utf8JsonReader.GetString()); break; default: break; @@ -157,7 +164,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + if (healthCheckResult.NullableMessageOption.IsSet) + if (healthCheckResult.NullableMessageOption.Value != null) + writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + else + writer.WriteNull("NullableMessage"); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/IsoscelesTriangle.cs index e54fa76f066..90f931a85c5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/IsoscelesTriangle.cs @@ -106,8 +106,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; - string? triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -125,10 +125,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -136,13 +136,19 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class IsoscelesTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class IsoscelesTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(triangleType)); - return new IsoscelesTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class IsoscelesTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class IsoscelesTriangle."); + + return new IsoscelesTriangle(shapeType.Value!, triangleType.Value!); } /// @@ -169,7 +175,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (isoscelesTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle."); + + if (isoscelesTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle."); + writer.WriteString("shapeType", isoscelesTriangle.ShapeType); + writer.WriteString("triangleType", isoscelesTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/List.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/List.cs index 031e16c39a5..2f75d0bb148 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/List.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/List.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// var123List [JsonConstructor] - public List(string var123List) + public List(Option var123List = default) { - Var123List = var123List; + Var123ListOption = var123List; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Var123List + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123ListOption { get; private set; } + /// /// Gets or Sets Var123List /// [JsonPropertyName("123-list")] - public string Var123List { get; set; } + public string? Var123List { get { return this. Var123ListOption; } set { this.Var123ListOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? var123List = default; + Option var123List = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "123-list": - var123List = utf8JsonReader.GetString(); + var123List = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (var123List == null) - throw new ArgumentNullException(nameof(var123List), "Property is required for class List."); + if (var123List.IsSet && var123List.Value == null) + throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List."); return new List(var123List); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("123-list", list.Var123List); + if (list.Var123ListOption.IsSet && list.Var123List == null) + throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List."); + + if (list.Var123ListOption.IsSet) + writer.WriteString("123-list", list.Var123List); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/LiteralStringClass.cs index 46ae1dc05ae..67cd536b7ba 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/LiteralStringClass.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// escapedLiteralString (default to "C:\\Users\\username") /// unescapedLiteralString (default to "C:\Users\username") [JsonConstructor] - public LiteralStringClass(string escapedLiteralString = @"C:\\Users\\username", string unescapedLiteralString = @"C:\Users\username") + public LiteralStringClass(Option escapedLiteralString = default, Option unescapedLiteralString = default) { - EscapedLiteralString = escapedLiteralString; - UnescapedLiteralString = unescapedLiteralString; + EscapedLiteralStringOption = escapedLiteralString; + UnescapedLiteralStringOption = unescapedLiteralString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of EscapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EscapedLiteralStringOption { get; private set; } + /// /// Gets or Sets EscapedLiteralString /// [JsonPropertyName("escapedLiteralString")] - public string EscapedLiteralString { get; set; } + public string? EscapedLiteralString { get { return this. EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new(value); } } + + /// + /// Used to track the state of UnescapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnescapedLiteralStringOption { get; private set; } /// /// Gets or Sets UnescapedLiteralString /// [JsonPropertyName("unescapedLiteralString")] - public string UnescapedLiteralString { get; set; } + public string? UnescapedLiteralString { get { return this. UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? escapedLiteralString = default; - string? unescapedLiteralString = default; + Option escapedLiteralString = default; + Option unescapedLiteralString = default; while (utf8JsonReader.Read()) { @@ -132,10 +146,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "escapedLiteralString": - escapedLiteralString = utf8JsonReader.GetString(); + escapedLiteralString = new Option(utf8JsonReader.GetString()!); break; case "unescapedLiteralString": - unescapedLiteralString = utf8JsonReader.GetString(); + unescapedLiteralString = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -143,11 +157,11 @@ namespace UseSourceGeneration.Model } } - if (escapedLiteralString == null) - throw new ArgumentNullException(nameof(escapedLiteralString), "Property is required for class LiteralStringClass."); + if (escapedLiteralString.IsSet && escapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass."); - if (unescapedLiteralString == null) - throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is required for class LiteralStringClass."); + if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass."); return new LiteralStringClass(escapedLiteralString, unescapedLiteralString); } @@ -176,8 +190,17 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); - writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); + if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.EscapedLiteralStringOption.IsSet) + writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet) + writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Mammal.cs index fcc1424f2c1..676b1d08c13 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Mammal.cs @@ -154,7 +154,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; Pig? pig = null; Whale? whale = null; @@ -211,7 +211,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -219,17 +219,20 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Mammal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Mammal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className); + return new Mammal(pig, className.Value!); if (whale != null) - return new Mammal(whale, className); + return new Mammal(whale, className.Value!); if (zebra != null) - return new Mammal(zebra, className); + return new Mammal(zebra, className.Value!); throw new JsonException(); } @@ -273,6 +276,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { + if (mammal.ClassName == null) + throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); + writer.WriteString("className", mammal.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MapTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MapTest.cs index e3deeb54016..9e9b2b725f5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MapTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MapTest.cs @@ -40,12 +40,12 @@ namespace UseSourceGeneration.Model /// mapMapOfString /// mapOfEnumString [JsonConstructor] - public MapTest(Dictionary directMap, Dictionary indirectMap, Dictionary> mapMapOfString, Dictionary mapOfEnumString) + public MapTest(Option?> directMap = default, Option?> indirectMap = default, Option>?> mapMapOfString = default, Option?> mapOfEnumString = default) { - DirectMap = directMap; - IndirectMap = indirectMap; - MapMapOfString = mapMapOfString; - MapOfEnumString = mapOfEnumString; + DirectMapOption = directMap; + IndirectMapOption = indirectMap; + MapMapOfStringOption = mapMapOfString; + MapOfEnumStringOption = mapOfEnumString; OnCreated(); } @@ -106,9 +106,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string InnerEnumToJsonValue(InnerEnum value) + public static string InnerEnumToJsonValue(InnerEnum? value) { - if (value == InnerEnum.UPPER) return "UPPER"; @@ -118,29 +117,57 @@ namespace UseSourceGeneration.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of DirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DirectMapOption { get; private set; } + /// /// Gets or Sets DirectMap /// [JsonPropertyName("direct_map")] - public Dictionary DirectMap { get; set; } + public Dictionary? DirectMap { get { return this. DirectMapOption; } set { this.DirectMapOption = new(value); } } + + /// + /// Used to track the state of IndirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> IndirectMapOption { get; private set; } /// /// Gets or Sets IndirectMap /// [JsonPropertyName("indirect_map")] - public Dictionary IndirectMap { get; set; } + public Dictionary? IndirectMap { get { return this. IndirectMapOption; } set { this.IndirectMapOption = new(value); } } + + /// + /// Used to track the state of MapMapOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> MapMapOfStringOption { get; private set; } /// /// Gets or Sets MapMapOfString /// [JsonPropertyName("map_map_of_string")] - public Dictionary> MapMapOfString { get; set; } + public Dictionary>? MapMapOfString { get { return this. MapMapOfStringOption; } set { this.MapMapOfStringOption = new(value); } } + + /// + /// Used to track the state of MapOfEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapOfEnumStringOption { get; private set; } /// /// Gets or Sets MapOfEnumString /// [JsonPropertyName("map_of_enum_string")] - public Dictionary MapOfEnumString { get; set; } + public Dictionary? MapOfEnumString { get { return this. MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -198,10 +225,10 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary? directMap = default; - Dictionary? indirectMap = default; - Dictionary>? mapMapOfString = default; - Dictionary? mapOfEnumString = default; + Option?> directMap = default; + Option?> indirectMap = default; + Option>?> mapMapOfString = default; + Option?> mapOfEnumString = default; while (utf8JsonReader.Read()) { @@ -220,19 +247,19 @@ namespace UseSourceGeneration.Model { case "direct_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - directMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + directMap = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "indirect_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - indirectMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + indirectMap = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_map_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapMapOfString = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapMapOfString = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_of_enum_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfEnumString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapOfEnumString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -240,17 +267,17 @@ namespace UseSourceGeneration.Model } } - if (directMap == null) - throw new ArgumentNullException(nameof(directMap), "Property is required for class MapTest."); + if (directMap.IsSet && directMap.Value == null) + throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest."); - if (indirectMap == null) - throw new ArgumentNullException(nameof(indirectMap), "Property is required for class MapTest."); + if (indirectMap.IsSet && indirectMap.Value == null) + throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest."); - if (mapMapOfString == null) - throw new ArgumentNullException(nameof(mapMapOfString), "Property is required for class MapTest."); + if (mapMapOfString.IsSet && mapMapOfString.Value == null) + throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest."); - if (mapOfEnumString == null) - throw new ArgumentNullException(nameof(mapOfEnumString), "Property is required for class MapTest."); + if (mapOfEnumString.IsSet && mapOfEnumString.Value == null) + throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest."); return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString); } @@ -279,14 +306,38 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("direct_map"); - JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); - writer.WritePropertyName("indirect_map"); - JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); - writer.WritePropertyName("map_map_of_string"); - JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); - writer.WritePropertyName("map_of_enum_string"); - JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null) + throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest."); + + if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null) + throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest."); + + if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null) + throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest."); + + if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null) + throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest."); + + if (mapTest.DirectMapOption.IsSet) + { + writer.WritePropertyName("direct_map"); + JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); + } + if (mapTest.IndirectMapOption.IsSet) + { + writer.WritePropertyName("indirect_map"); + JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); + } + if (mapTest.MapMapOfStringOption.IsSet) + { + writer.WritePropertyName("map_map_of_string"); + JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); + } + if (mapTest.MapOfEnumStringOption.IsSet) + { + writer.WritePropertyName("map_of_enum_string"); + JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 25ea1076cd5..0bc78f42ede 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -40,40 +40,68 @@ namespace UseSourceGeneration.Model /// uuid /// uuidWithPattern [JsonConstructor] - public MixedPropertiesAndAdditionalPropertiesClass(DateTime dateTime, Dictionary map, Guid uuid, Guid uuidWithPattern) + public MixedPropertiesAndAdditionalPropertiesClass(Option dateTime = default, Option?> map = default, Option uuid = default, Option uuidWithPattern = default) { - DateTime = dateTime; - Map = map; - Uuid = uuid; - UuidWithPattern = uuidWithPattern; + DateTimeOption = dateTime; + MapOption = map; + UuidOption = uuid; + UuidWithPatternOption = uuidWithPattern; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + /// /// Gets or Sets DateTime /// [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } } + + /// + /// Used to track the state of Map + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapOption { get; private set; } /// /// Gets or Sets Map /// [JsonPropertyName("map")] - public Dictionary Map { get; set; } + public Dictionary? Map { get { return this. MapOption; } set { this.MapOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// Used to track the state of UuidWithPattern + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidWithPatternOption { get; private set; } /// /// Gets or Sets UuidWithPattern /// [JsonPropertyName("uuid_with_pattern")] - public Guid UuidWithPattern { get; set; } + public Guid? UuidWithPattern { get { return this. UuidWithPatternOption; } set { this.UuidWithPatternOption = new(value); } } /// /// Gets or Sets additional properties @@ -107,7 +135,8 @@ namespace UseSourceGeneration.Model { // UuidWithPattern (Guid) pattern Regex regexUuidWithPattern = new Regex(@"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", RegexOptions.CultureInvariant); - if (!regexUuidWithPattern.Match(this.UuidWithPattern.ToString()).Success) + + if (this.UuidWithPatternOption.Value != null &&!regexUuidWithPattern.Match(this.UuidWithPatternOption.Value.ToString()!).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UuidWithPattern, must match a pattern of " + regexUuidWithPattern, new [] { "UuidWithPattern" }); } @@ -142,10 +171,10 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateTime = default; - Dictionary? map = default; - Guid? uuid = default; - Guid? uuidWithPattern = default; + Option dateTime = default; + Option?> map = default; + Option uuid = default; + Option uuidWithPattern = default; while (utf8JsonReader.Read()) { @@ -164,19 +193,19 @@ namespace UseSourceGeneration.Model { case "dateTime": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - map = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + map = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; case "uuid_with_pattern": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuidWithPattern = utf8JsonReader.GetGuid(); + uuidWithPattern = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -184,19 +213,19 @@ namespace UseSourceGeneration.Model } } - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (map == null) - throw new ArgumentNullException(nameof(map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (map.IsSet && map.Value == null) + throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuidWithPattern == null) - throw new ArgumentNullException(nameof(uuidWithPattern), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuidWithPattern.IsSet && uuidWithPattern.Value == null) + throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - return new MixedPropertiesAndAdditionalPropertiesClass(dateTime.Value, map, uuid.Value, uuidWithPattern.Value); + return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern); } /// @@ -223,11 +252,22 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("map"); - JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); - writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.Uuid); - writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern); + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null) + throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet) + writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat)); + + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet) + { + writer.WritePropertyName("map"); + JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); + } + if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet) + writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value); + + if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet) + writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Model200Response.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Model200Response.cs index 74f7acb1e82..6d738cf1d6a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Model200Response.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// varClass /// name [JsonConstructor] - public Model200Response(string varClass, int name) + public Model200Response(Option varClass = default, Option name = default) { - VarClass = varClass; - Name = name; + VarClassOption = varClass; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("class")] - public string VarClass { get; set; } + public string? VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public int Name { get; set; } + public int? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varClass = default; - int? name = default; + Option varClass = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -132,11 +146,11 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()!); break; case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - name = utf8JsonReader.GetInt32(); + name = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -144,13 +158,13 @@ namespace UseSourceGeneration.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class Model200Response."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Model200Response."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response."); - return new Model200Response(varClass, name.Value); + return new Model200Response(varClass, name); } /// @@ -177,8 +191,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("class", model200Response.VarClass); - writer.WriteNumber("name", model200Response.Name); + if (model200Response.VarClassOption.IsSet && model200Response.VarClass == null) + throw new ArgumentNullException(nameof(model200Response.VarClass), "Property is required for class Model200Response."); + + if (model200Response.VarClassOption.IsSet) + writer.WriteString("class", model200Response.VarClass); + + if (model200Response.NameOption.IsSet) + writer.WriteNumber("name", model200Response.NameOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ModelClient.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ModelClient.cs index 5bc60589f35..08959d3204c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ModelClient.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// varClient [JsonConstructor] - public ModelClient(string varClient) + public ModelClient(Option varClient = default) { - VarClient = varClient; + VarClientOption = varClient; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClient + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClientOption { get; private set; } + /// /// Gets or Sets VarClient /// [JsonPropertyName("client")] - public string VarClient { get; set; } + public string? VarClient { get { return this. VarClientOption; } set { this.VarClientOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varClient = default; + Option varClient = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "client": - varClient = utf8JsonReader.GetString(); + varClient = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (varClient == null) - throw new ArgumentNullException(nameof(varClient), "Property is required for class ModelClient."); + if (varClient.IsSet && varClient.Value == null) + throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient."); return new ModelClient(varClient); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("client", modelClient.VarClient); + if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null) + throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient."); + + if (modelClient.VarClientOption.IsSet) + writer.WriteString("client", modelClient.VarClient); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Name.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Name.cs index 4648cf04f7d..464ad8d4f38 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Name.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Name.cs @@ -40,12 +40,12 @@ namespace UseSourceGeneration.Model /// snakeCase /// var123Number [JsonConstructor] - public Name(int varName, string property, int snakeCase, int var123Number) + public Name(int varName, Option property = default, Option snakeCase = default, Option var123Number = default) { VarName = varName; - Property = property; - SnakeCase = snakeCase; - Var123Number = var123Number; + PropertyOption = property; + SnakeCaseOption = snakeCase; + Var123NumberOption = var123Number; OnCreated(); } @@ -57,23 +57,44 @@ namespace UseSourceGeneration.Model [JsonPropertyName("name")] public int VarName { get; set; } + /// + /// Used to track the state of Property + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PropertyOption { get; private set; } + /// /// Gets or Sets Property /// [JsonPropertyName("property")] - public string Property { get; set; } + public string? Property { get { return this. PropertyOption; } set { this.PropertyOption = new(value); } } + + /// + /// Used to track the state of SnakeCase + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SnakeCaseOption { get; } /// /// Gets or Sets SnakeCase /// [JsonPropertyName("snake_case")] - public int SnakeCase { get; } + public int? SnakeCase { get { return this. SnakeCaseOption; } } + + /// + /// Used to track the state of Var123Number + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123NumberOption { get; } /// /// Gets or Sets Var123Number /// [JsonPropertyName("123Number")] - public int Var123Number { get; } + public int? Var123Number { get { return this. Var123NumberOption; } } /// /// Gets or Sets additional properties @@ -127,8 +148,12 @@ namespace UseSourceGeneration.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); - hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + if (SnakeCase != null) + hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); + + if (Var123Number != null) + hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -168,10 +193,10 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varName = default; - string? property = default; - int? snakeCase = default; - int? var123Number = default; + Option varName = default; + Option property = default; + Option snakeCase = default; + Option var123Number = default; while (utf8JsonReader.Read()) { @@ -190,18 +215,18 @@ namespace UseSourceGeneration.Model { case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varName = utf8JsonReader.GetInt32(); + varName = new Option(utf8JsonReader.GetInt32()); break; case "property": - property = utf8JsonReader.GetString(); + property = new Option(utf8JsonReader.GetString()!); break; case "snake_case": if (utf8JsonReader.TokenType != JsonTokenType.Null) - snakeCase = utf8JsonReader.GetInt32(); + snakeCase = new Option(utf8JsonReader.GetInt32()); break; case "123Number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - var123Number = utf8JsonReader.GetInt32(); + var123Number = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -209,19 +234,22 @@ namespace UseSourceGeneration.Model } } - if (varName == null) - throw new ArgumentNullException(nameof(varName), "Property is required for class Name."); + if (!varName.IsSet) + throw new ArgumentException("Property is required for class Name.", nameof(varName)); - if (property == null) - throw new ArgumentNullException(nameof(property), "Property is required for class Name."); + if (varName.IsSet && varName.Value == null) + throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name."); - if (snakeCase == null) - throw new ArgumentNullException(nameof(snakeCase), "Property is required for class Name."); + if (property.IsSet && property.Value == null) + throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name."); - if (var123Number == null) - throw new ArgumentNullException(nameof(var123Number), "Property is required for class Name."); + if (snakeCase.IsSet && snakeCase.Value == null) + throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name."); - return new Name(varName.Value, property, snakeCase.Value, var123Number.Value); + if (var123Number.IsSet && var123Number.Value == null) + throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name."); + + return new Name(varName.Value!.Value!, property, snakeCase, var123Number); } /// @@ -248,10 +276,19 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) { + if (name.PropertyOption.IsSet && name.Property == null) + throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name."); + writer.WriteNumber("name", name.VarName); - writer.WriteString("property", name.Property); - writer.WriteNumber("snake_case", name.SnakeCase); - writer.WriteNumber("123Number", name.Var123Number); + + if (name.PropertyOption.IsSet) + writer.WriteString("property", name.Property); + + if (name.SnakeCaseOption.IsSet) + writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value); + + if (name.Var123NumberOption.IsSet) + writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NotificationtestGetElementsV1ResponseMPayload.cs index ed43ab9fcd2..d453934498a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List>? aObjVariableobject = default; - int? pkiNotificationtestID = default; + Option>?> aObjVariableobject = default; + Option pkiNotificationtestID = default; while (utf8JsonReader.Read()) { @@ -133,11 +133,11 @@ namespace UseSourceGeneration.Model { case "a_objVariableobject": if (utf8JsonReader.TokenType != JsonTokenType.Null) - aObjVariableobject = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + aObjVariableobject = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "pkiNotificationtestID": if (utf8JsonReader.TokenType != JsonTokenType.Null) - pkiNotificationtestID = utf8JsonReader.GetInt32(); + pkiNotificationtestID = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -145,13 +145,19 @@ namespace UseSourceGeneration.Model } } - if (aObjVariableobject == null) - throw new ArgumentNullException(nameof(aObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!aObjVariableobject.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(aObjVariableobject)); - if (pkiNotificationtestID == null) - throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!pkiNotificationtestID.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(pkiNotificationtestID)); - return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject, pkiNotificationtestID.Value); + if (aObjVariableobject.IsSet && aObjVariableobject.Value == null) + throw new ArgumentNullException(nameof(aObjVariableobject), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + if (pkiNotificationtestID.IsSet && pkiNotificationtestID.Value == null) + throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject.Value!, pkiNotificationtestID.Value!.Value!); } /// @@ -178,6 +184,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) { + if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null) + throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + writer.WritePropertyName("a_objVariableobject"); JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions); writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableClass.cs index 5374e7a890e..e4dd3c1c683 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableClass.cs @@ -35,9 +35,8 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// - /// arrayItemsNullable - /// objectItemsNullable /// arrayAndItemsNullableProp + /// arrayItemsNullable /// arrayNullableProp /// booleanProp /// dateProp @@ -45,99 +44,184 @@ namespace UseSourceGeneration.Model /// integerProp /// numberProp /// objectAndItemsNullableProp + /// objectItemsNullable /// objectNullableProp /// stringProp [JsonConstructor] - public NullableClass(List arrayItemsNullable, Dictionary objectItemsNullable, List? arrayAndItemsNullableProp = default, List? arrayNullableProp = default, bool? booleanProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, int? integerProp = default, decimal? numberProp = default, Dictionary? objectAndItemsNullableProp = default, Dictionary? objectNullableProp = default, string? stringProp = default) : base() + public NullableClass(Option?> arrayAndItemsNullableProp = default, Option?> arrayItemsNullable = default, Option?> arrayNullableProp = default, Option booleanProp = default, Option dateProp = default, Option datetimeProp = default, Option integerProp = default, Option numberProp = default, Option?> objectAndItemsNullableProp = default, Option?> objectItemsNullable = default, Option?> objectNullableProp = default, Option stringProp = default) : base() { - ArrayItemsNullable = arrayItemsNullable; - ObjectItemsNullable = objectItemsNullable; - ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - ArrayNullableProp = arrayNullableProp; - BooleanProp = booleanProp; - DateProp = dateProp; - DatetimeProp = datetimeProp; - IntegerProp = integerProp; - NumberProp = numberProp; - ObjectAndItemsNullableProp = objectAndItemsNullableProp; - ObjectNullableProp = objectNullableProp; - StringProp = stringProp; + ArrayAndItemsNullablePropOption = arrayAndItemsNullableProp; + ArrayItemsNullableOption = arrayItemsNullable; + ArrayNullablePropOption = arrayNullableProp; + BooleanPropOption = booleanProp; + DatePropOption = dateProp; + DatetimePropOption = datetimeProp; + IntegerPropOption = integerProp; + NumberPropOption = numberProp; + ObjectAndItemsNullablePropOption = objectAndItemsNullableProp; + ObjectItemsNullableOption = objectItemsNullable; + ObjectNullablePropOption = objectNullableProp; + StringPropOption = stringProp; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets ArrayItemsNullable + /// Used to track the state of ArrayAndItemsNullableProp /// - [JsonPropertyName("array_items_nullable")] - public List ArrayItemsNullable { get; set; } - - /// - /// Gets or Sets ObjectItemsNullable - /// - [JsonPropertyName("object_items_nullable")] - public Dictionary ObjectItemsNullable { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// [JsonPropertyName("array_and_items_nullable_prop")] - public List? ArrayAndItemsNullableProp { get; set; } + public List? ArrayAndItemsNullableProp { get { return this. ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new(value); } } + + /// + /// Used to track the state of ArrayItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ArrayItemsNullable + /// + [JsonPropertyName("array_items_nullable")] + public List? ArrayItemsNullable { get { return this. ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new(value); } } + + /// + /// Used to track the state of ArrayNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayNullablePropOption { get; private set; } /// /// Gets or Sets ArrayNullableProp /// [JsonPropertyName("array_nullable_prop")] - public List? ArrayNullableProp { get; set; } + public List? ArrayNullableProp { get { return this. ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new(value); } } + + /// + /// Used to track the state of BooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BooleanPropOption { get; private set; } /// /// Gets or Sets BooleanProp /// [JsonPropertyName("boolean_prop")] - public bool? BooleanProp { get; set; } + public bool? BooleanProp { get { return this. BooleanPropOption; } set { this.BooleanPropOption = new(value); } } + + /// + /// Used to track the state of DateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatePropOption { get; private set; } /// /// Gets or Sets DateProp /// [JsonPropertyName("date_prop")] - public DateTime? DateProp { get; set; } + public DateTime? DateProp { get { return this. DatePropOption; } set { this.DatePropOption = new(value); } } + + /// + /// Used to track the state of DatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatetimePropOption { get; private set; } /// /// Gets or Sets DatetimeProp /// [JsonPropertyName("datetime_prop")] - public DateTime? DatetimeProp { get; set; } + public DateTime? DatetimeProp { get { return this. DatetimePropOption; } set { this.DatetimePropOption = new(value); } } + + /// + /// Used to track the state of IntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerPropOption { get; private set; } /// /// Gets or Sets IntegerProp /// [JsonPropertyName("integer_prop")] - public int? IntegerProp { get; set; } + public int? IntegerProp { get { return this. IntegerPropOption; } set { this.IntegerPropOption = new(value); } } + + /// + /// Used to track the state of NumberProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NumberPropOption { get; private set; } /// /// Gets or Sets NumberProp /// [JsonPropertyName("number_prop")] - public decimal? NumberProp { get; set; } + public decimal? NumberProp { get { return this. NumberPropOption; } set { this.NumberPropOption = new(value); } } + + /// + /// Used to track the state of ObjectAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ObjectAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// [JsonPropertyName("object_and_items_nullable_prop")] - public Dictionary? ObjectAndItemsNullableProp { get; set; } + public Dictionary? ObjectAndItemsNullableProp { get { return this. ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new(value); } } + + /// + /// Used to track the state of ObjectItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ObjectItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ObjectItemsNullable + /// + [JsonPropertyName("object_items_nullable")] + public Dictionary? ObjectItemsNullable { get { return this. ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new(value); } } + + /// + /// Used to track the state of ObjectNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ObjectNullablePropOption { get; private set; } /// /// Gets or Sets ObjectNullableProp /// [JsonPropertyName("object_nullable_prop")] - public Dictionary? ObjectNullableProp { get; set; } + public Dictionary? ObjectNullableProp { get { return this. ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new(value); } } + + /// + /// Used to track the state of StringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringPropOption { get; private set; } /// /// Gets or Sets StringProp /// [JsonPropertyName("string_prop")] - public string? StringProp { get; set; } + public string? StringProp { get { return this. StringPropOption; } set { this.StringPropOption = new(value); } } /// /// Gets or Sets additional properties @@ -154,9 +238,8 @@ namespace UseSourceGeneration.Model StringBuilder sb = new StringBuilder(); sb.Append("class NullableClass {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); - sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); - sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); sb.Append(" DateProp: ").Append(DateProp).Append("\n"); @@ -164,6 +247,7 @@ namespace UseSourceGeneration.Model sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -224,18 +308,18 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? arrayItemsNullable = default; - Dictionary? objectItemsNullable = default; - List? arrayAndItemsNullableProp = default; - List? arrayNullableProp = default; - bool? booleanProp = default; - DateTime? dateProp = default; - DateTime? datetimeProp = default; - int? integerProp = default; - decimal? numberProp = default; - Dictionary? objectAndItemsNullableProp = default; - Dictionary? objectNullableProp = default; - string? stringProp = default; + Option?> arrayAndItemsNullableProp = default; + Option?> arrayItemsNullable = default; + Option?> arrayNullableProp = default; + Option booleanProp = default; + Option dateProp = default; + Option datetimeProp = default; + Option integerProp = default; + Option numberProp = default; + Option?> objectAndItemsNullableProp = default; + Option?> objectItemsNullable = default; + Option?> objectNullableProp = default; + Option stringProp = default; while (utf8JsonReader.Read()) { @@ -252,52 +336,52 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { - case "array_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "object_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; case "array_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayAndItemsNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayItemsNullable = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "array_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "boolean_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - booleanProp = utf8JsonReader.GetBoolean(); + booleanProp = new Option(utf8JsonReader.GetBoolean()); break; case "date_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "datetime_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - datetimeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + datetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "integer_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - integerProp = utf8JsonReader.GetInt32(); + integerProp = new Option(utf8JsonReader.GetInt32()); break; case "number_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - numberProp = utf8JsonReader.GetDecimal(); + numberProp = new Option(utf8JsonReader.GetDecimal()); break; case "object_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectAndItemsNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectItemsNullable = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "object_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "string_prop": - stringProp = utf8JsonReader.GetString(); + stringProp = new Option(utf8JsonReader.GetString()); break; default: break; @@ -305,13 +389,13 @@ namespace UseSourceGeneration.Model } } - if (arrayItemsNullable == null) - throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is required for class NullableClass."); + if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null) + throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass."); - if (objectItemsNullable == null) - throw new ArgumentNullException(nameof(objectItemsNullable), "Property is required for class NullableClass."); + if (objectItemsNullable.IsSet && objectItemsNullable.Value == null) + throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass."); - return new NullableClass(arrayItemsNullable, objectItemsNullable, arrayAndItemsNullableProp, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectNullableProp, stringProp); + return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp); } /// @@ -338,45 +422,89 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("object_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("array_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("array_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.BooleanProp != null) - writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); - else - writer.WriteNull("boolean_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.DateProp != null) - writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(DatePropFormat)); - else - writer.WriteNull("date_prop"); + if (nullableClass.ArrayAndItemsNullablePropOption.IsSet) + if (nullableClass.ArrayAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("array_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_and_items_nullable_prop"); + if (nullableClass.ArrayItemsNullableOption.IsSet) + { + writer.WritePropertyName("array_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ArrayNullablePropOption.IsSet) + if (nullableClass.ArrayNullablePropOption.Value != null) + { + writer.WritePropertyName("array_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_nullable_prop"); + if (nullableClass.BooleanPropOption.IsSet) + if (nullableClass.BooleanPropOption.Value != null) + writer.WriteBoolean("boolean_prop", nullableClass.BooleanPropOption.Value!.Value); + else + writer.WriteNull("boolean_prop"); - if (nullableClass.DatetimeProp != null) - writer.WriteString("datetime_prop", nullableClass.DatetimeProp.Value.ToString(DatetimePropFormat)); - else - writer.WriteNull("datetime_prop"); + if (nullableClass.DatePropOption.IsSet) + if (nullableClass.DatePropOption.Value != null) + writer.WriteString("date_prop", nullableClass.DatePropOption.Value!.Value.ToString(DatePropFormat)); + else + writer.WriteNull("date_prop"); - if (nullableClass.IntegerProp != null) - writer.WriteNumber("integer_prop", nullableClass.IntegerProp.Value); - else - writer.WriteNull("integer_prop"); + if (nullableClass.DatetimePropOption.IsSet) + if (nullableClass.DatetimePropOption.Value != null) + writer.WriteString("datetime_prop", nullableClass.DatetimePropOption.Value!.Value.ToString(DatetimePropFormat)); + else + writer.WriteNull("datetime_prop"); - if (nullableClass.NumberProp != null) - writer.WriteNumber("number_prop", nullableClass.NumberProp.Value); - else - writer.WriteNull("number_prop"); + if (nullableClass.IntegerPropOption.IsSet) + if (nullableClass.IntegerPropOption.Value != null) + writer.WriteNumber("integer_prop", nullableClass.IntegerPropOption.Value!.Value); + else + writer.WriteNull("integer_prop"); - writer.WritePropertyName("object_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("object_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); - writer.WriteString("string_prop", nullableClass.StringProp); + if (nullableClass.NumberPropOption.IsSet) + if (nullableClass.NumberPropOption.Value != null) + writer.WriteNumber("number_prop", nullableClass.NumberPropOption.Value!.Value); + else + writer.WriteNull("number_prop"); + + if (nullableClass.ObjectAndItemsNullablePropOption.IsSet) + if (nullableClass.ObjectAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("object_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_and_items_nullable_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet) + { + writer.WritePropertyName("object_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ObjectNullablePropOption.IsSet) + if (nullableClass.ObjectNullablePropOption.Value != null) + { + writer.WritePropertyName("object_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_nullable_prop"); + if (nullableClass.StringPropOption.IsSet) + if (nullableClass.StringPropOption.Value != null) + writer.WriteString("string_prop", nullableClass.StringProp); + else + writer.WriteNull("string_prop"); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableGuidClass.cs index eb5434dc5ba..4bb7bbfc88c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableGuidClass.cs @@ -37,20 +37,27 @@ namespace UseSourceGeneration.Model /// /// uuid [JsonConstructor] - public NullableGuidClass(Guid? uuid = default) + public NullableGuidClass(Option uuid = default) { - Uuid = uuid; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid? Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -105,7 +112,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Guid? uuid = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -124,7 +131,7 @@ namespace UseSourceGeneration.Model { case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -159,11 +166,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { - - if (nullableGuidClass.Uuid == null) - writer.WriteNull("uuid"); - else - writer.WriteString("uuid", nullableGuidClass.Uuid.Value); + if (nullableGuidClass.UuidOption.IsSet) + if (nullableGuidClass.UuidOption.Value != null) + writer.WriteString("uuid", nullableGuidClass.UuidOption.Value!.Value); + else + writer.WriteNull("uuid"); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableShape.cs index 8a1f0995af6..5e07a4b642a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NullableShape.cs @@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; Quadrilateral? quadrilateral = null; Triangle? triangle = null; @@ -188,7 +188,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -196,14 +196,17 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class NullableShape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class NullableShape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType); + return new NullableShape(quadrilateral, shapeType.Value!); if (triangle != null) - return new NullableShape(triangle, shapeType); + return new NullableShape(triangle, shapeType.Value!); throw new JsonException(); } @@ -242,6 +245,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { + if (nullableShape.ShapeType == null) + throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); + writer.WriteString("shapeType", nullableShape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NumberOnly.cs index 740f496eb9d..6362c24186d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/NumberOnly.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// justNumber [JsonConstructor] - public NumberOnly(decimal justNumber) + public NumberOnly(Option justNumber = default) { - JustNumber = justNumber; + JustNumberOption = justNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of JustNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustNumberOption { get; private set; } + /// /// Gets or Sets JustNumber /// [JsonPropertyName("JustNumber")] - public decimal JustNumber { get; set; } + public decimal? JustNumber { get { return this. JustNumberOption; } set { this.JustNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? justNumber = default; + Option justNumber = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "JustNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - justNumber = utf8JsonReader.GetDecimal(); + justNumber = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -131,10 +138,10 @@ namespace UseSourceGeneration.Model } } - if (justNumber == null) - throw new ArgumentNullException(nameof(justNumber), "Property is required for class NumberOnly."); + if (justNumber.IsSet && justNumber.Value == null) + throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly."); - return new NumberOnly(justNumber.Value); + return new NumberOnly(justNumber); } /// @@ -161,7 +168,8 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("JustNumber", numberOnly.JustNumber); + if (numberOnly.JustNumberOption.IsSet) + writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ObjectWithDeprecatedFields.cs index 729b057bdb4..506fddc846e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ObjectWithDeprecatedFields.cs @@ -40,43 +40,71 @@ namespace UseSourceGeneration.Model /// id /// uuid [JsonConstructor] - public ObjectWithDeprecatedFields(List bars, DeprecatedObject deprecatedRef, decimal id, string uuid) + public ObjectWithDeprecatedFields(Option?> bars = default, Option deprecatedRef = default, Option id = default, Option uuid = default) { - Bars = bars; - DeprecatedRef = deprecatedRef; - Id = id; - Uuid = uuid; + BarsOption = bars; + DeprecatedRefOption = deprecatedRef; + IdOption = id; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bars + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> BarsOption { get; private set; } + /// /// Gets or Sets Bars /// [JsonPropertyName("bars")] [Obsolete] - public List Bars { get; set; } + public List? Bars { get { return this. BarsOption; } set { this.BarsOption = new(value); } } + + /// + /// Used to track the state of DeprecatedRef + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeprecatedRefOption { get; private set; } /// /// Gets or Sets DeprecatedRef /// [JsonPropertyName("deprecatedRef")] [Obsolete] - public DeprecatedObject DeprecatedRef { get; set; } + public DeprecatedObject? DeprecatedRef { get { return this. DeprecatedRefOption; } set { this.DeprecatedRefOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] [Obsolete] - public decimal Id { get; set; } + public decimal? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public string Uuid { get; set; } + public string? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -134,10 +162,10 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? bars = default; - DeprecatedObject? deprecatedRef = default; - decimal? id = default; - string? uuid = default; + Option?> bars = default; + Option deprecatedRef = default; + Option id = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -156,18 +184,18 @@ namespace UseSourceGeneration.Model { case "bars": if (utf8JsonReader.TokenType != JsonTokenType.Null) - bars = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + bars = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "deprecatedRef": if (utf8JsonReader.TokenType != JsonTokenType.Null) - deprecatedRef = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + deprecatedRef = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetDecimal(); + id = new Option(utf8JsonReader.GetDecimal()); break; case "uuid": - uuid = utf8JsonReader.GetString(); + uuid = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -175,19 +203,19 @@ namespace UseSourceGeneration.Model } } - if (bars == null) - throw new ArgumentNullException(nameof(bars), "Property is required for class ObjectWithDeprecatedFields."); + if (bars.IsSet && bars.Value == null) + throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (deprecatedRef == null) - throw new ArgumentNullException(nameof(deprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + if (deprecatedRef.IsSet && deprecatedRef.Value == null) + throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class ObjectWithDeprecatedFields."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class ObjectWithDeprecatedFields."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields."); - return new ObjectWithDeprecatedFields(bars, deprecatedRef, id.Value, uuid); + return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid); } /// @@ -214,12 +242,30 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("bars"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); - writer.WritePropertyName("deprecatedRef"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); - writer.WriteNumber("id", objectWithDeprecatedFields.Id); - writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); + if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.BarsOption.IsSet) + { + writer.WritePropertyName("bars"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet) + { + writer.WritePropertyName("deprecatedRef"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.IdOption.IsSet) + writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value); + + if (objectWithDeprecatedFields.UuidOption.IsSet) + writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs index 5283e0ae275..fd9c7e70a51 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs @@ -35,21 +35,21 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// + /// complete (default to false) /// id /// petId /// quantity /// shipDate /// Order Status - /// complete (default to false) [JsonConstructor] - public Order(long id, long petId, int quantity, DateTime shipDate, StatusEnum status, bool complete = false) + public Order(Option complete = default, Option id = default, Option petId = default, Option quantity = default, Option shipDate = default, Option status = default) { - Id = id; - PetId = petId; - Quantity = quantity; - ShipDate = shipDate; - Status = status; - Complete = complete; + CompleteOption = complete; + IdOption = id; + PetIdOption = petId; + QuantityOption = quantity; + ShipDateOption = shipDate; + StatusOption = status; OnCreated(); } @@ -122,9 +122,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Placed) return "placed"; @@ -137,43 +136,85 @@ namespace UseSourceGeneration.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// Order Status /// /// Order Status [JsonPropertyName("status")] - public StatusEnum Status { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } } + + /// + /// Used to track the state of Complete + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CompleteOption { get; private set; } + + /// + /// Gets or Sets Complete + /// + [JsonPropertyName("complete")] + public bool? Complete { get { return this. CompleteOption; } set { this.CompleteOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of PetId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PetIdOption { get; private set; } /// /// Gets or Sets PetId /// [JsonPropertyName("petId")] - public long PetId { get; set; } + public long? PetId { get { return this. PetIdOption; } set { this.PetIdOption = new(value); } } + + /// + /// Used to track the state of Quantity + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option QuantityOption { get; private set; } /// /// Gets or Sets Quantity /// [JsonPropertyName("quantity")] - public int Quantity { get; set; } + public int? Quantity { get { return this. QuantityOption; } set { this.QuantityOption = new(value); } } + + /// + /// Used to track the state of ShipDate + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShipDateOption { get; private set; } /// /// Gets or Sets ShipDate /// /// 2020-02-02T20:20:20.000222Z [JsonPropertyName("shipDate")] - public DateTime ShipDate { get; set; } - - /// - /// Gets or Sets Complete - /// - [JsonPropertyName("complete")] - public bool Complete { get; set; } + public DateTime? ShipDate { get { return this. ShipDateOption; } set { this.ShipDateOption = new(value); } } /// /// Gets or Sets additional properties @@ -189,12 +230,12 @@ namespace UseSourceGeneration.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Order {\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" PetId: ").Append(PetId).Append("\n"); sb.Append(" Quantity: ").Append(Quantity).Append("\n"); sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -238,12 +279,12 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - long? petId = default; - int? quantity = default; - DateTime? shipDate = default; - Order.StatusEnum? status = default; - bool? complete = default; + Option complete = default; + Option id = default; + Option petId = default; + Option quantity = default; + Option shipDate = default; + Option status = default; while (utf8JsonReader.Read()) { @@ -260,31 +301,30 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { + case "complete": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + complete = new Option(utf8JsonReader.GetBoolean()); + break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "petId": if (utf8JsonReader.TokenType != JsonTokenType.Null) - petId = utf8JsonReader.GetInt64(); + petId = new Option(utf8JsonReader.GetInt64()); break; case "quantity": if (utf8JsonReader.TokenType != JsonTokenType.Null) - quantity = utf8JsonReader.GetInt32(); + quantity = new Option(utf8JsonReader.GetInt32()); break; case "shipDate": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shipDate = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shipDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "status": string? statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Order.StatusEnumFromStringOrDefault(statusRawValue); - break; - case "complete": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - complete = utf8JsonReader.GetBoolean(); + if (statusRawValue != null) + status = new Option(Order.StatusEnumFromStringOrDefault(statusRawValue)); break; default: break; @@ -292,25 +332,25 @@ namespace UseSourceGeneration.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Order."); + if (complete.IsSet && complete.Value == null) + throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order."); - if (petId == null) - throw new ArgumentNullException(nameof(petId), "Property is required for class Order."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order."); - if (quantity == null) - throw new ArgumentNullException(nameof(quantity), "Property is required for class Order."); + if (petId.IsSet && petId.Value == null) + throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order."); - if (shipDate == null) - throw new ArgumentNullException(nameof(shipDate), "Property is required for class Order."); + if (quantity.IsSet && quantity.Value == null) + throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Order."); + if (shipDate.IsSet && shipDate.Value == null) + throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order."); - if (complete == null) - throw new ArgumentNullException(nameof(complete), "Property is required for class Order."); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order."); - return new Order(id.Value, petId.Value, quantity.Value, shipDate.Value, status.Value, complete.Value); + return new Order(complete, id, petId, quantity, shipDate, status); } /// @@ -337,18 +377,26 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", order.Id); - writer.WriteNumber("petId", order.PetId); - writer.WriteNumber("quantity", order.Quantity); - writer.WriteString("shipDate", order.ShipDate.ToString(ShipDateFormat)); + if (order.CompleteOption.IsSet) + writer.WriteBoolean("complete", order.CompleteOption.Value!.Value); - var statusRawValue = Order.StatusEnumToJsonValue(order.Status); + if (order.IdOption.IsSet) + writer.WriteNumber("id", order.IdOption.Value!.Value); + + if (order.PetIdOption.IsSet) + writer.WriteNumber("petId", order.PetIdOption.Value!.Value); + + if (order.QuantityOption.IsSet) + writer.WriteNumber("quantity", order.QuantityOption.Value!.Value); + + if (order.ShipDateOption.IsSet) + writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat)); + + var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - - writer.WriteBoolean("complete", order.Complete); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/OuterComposite.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/OuterComposite.cs index 87526afade0..929cfede69a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/OuterComposite.cs @@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model /// myNumber /// myString [JsonConstructor] - public OuterComposite(bool myBoolean, decimal myNumber, string myString) + public OuterComposite(Option myBoolean = default, Option myNumber = default, Option myString = default) { - MyBoolean = myBoolean; - MyNumber = myNumber; - MyString = myString; + MyBooleanOption = myBoolean; + MyNumberOption = myNumber; + MyStringOption = myString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MyBoolean + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyBooleanOption { get; private set; } + /// /// Gets or Sets MyBoolean /// [JsonPropertyName("my_boolean")] - public bool MyBoolean { get; set; } + public bool? MyBoolean { get { return this. MyBooleanOption; } set { this.MyBooleanOption = new(value); } } + + /// + /// Used to track the state of MyNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyNumberOption { get; private set; } /// /// Gets or Sets MyNumber /// [JsonPropertyName("my_number")] - public decimal MyNumber { get; set; } + public decimal? MyNumber { get { return this. MyNumberOption; } set { this.MyNumberOption = new(value); } } + + /// + /// Used to track the state of MyString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyStringOption { get; private set; } /// /// Gets or Sets MyString /// [JsonPropertyName("my_string")] - public string MyString { get; set; } + public string? MyString { get { return this. MyStringOption; } set { this.MyStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -122,9 +143,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - bool? myBoolean = default; - decimal? myNumber = default; - string? myString = default; + Option myBoolean = default; + Option myNumber = default; + Option myString = default; while (utf8JsonReader.Read()) { @@ -143,14 +164,14 @@ namespace UseSourceGeneration.Model { case "my_boolean": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myBoolean = utf8JsonReader.GetBoolean(); + myBoolean = new Option(utf8JsonReader.GetBoolean()); break; case "my_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myNumber = utf8JsonReader.GetDecimal(); + myNumber = new Option(utf8JsonReader.GetDecimal()); break; case "my_string": - myString = utf8JsonReader.GetString(); + myString = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -158,16 +179,16 @@ namespace UseSourceGeneration.Model } } - if (myBoolean == null) - throw new ArgumentNullException(nameof(myBoolean), "Property is required for class OuterComposite."); + if (myBoolean.IsSet && myBoolean.Value == null) + throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite."); - if (myNumber == null) - throw new ArgumentNullException(nameof(myNumber), "Property is required for class OuterComposite."); + if (myNumber.IsSet && myNumber.Value == null) + throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite."); - if (myString == null) - throw new ArgumentNullException(nameof(myString), "Property is required for class OuterComposite."); + if (myString.IsSet && myString.Value == null) + throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite."); - return new OuterComposite(myBoolean.Value, myNumber.Value, myString); + return new OuterComposite(myBoolean, myNumber, myString); } /// @@ -194,9 +215,17 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteBoolean("my_boolean", outerComposite.MyBoolean); - writer.WriteNumber("my_number", outerComposite.MyNumber); - writer.WriteString("my_string", outerComposite.MyString); + if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null) + throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite."); + + if (outerComposite.MyBooleanOption.IsSet) + writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value); + + if (outerComposite.MyNumberOption.IsSet) + writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value); + + if (outerComposite.MyStringOption.IsSet) + writer.WriteString("my_string", outerComposite.MyString); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ParentPet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ParentPet.cs index 1162f9a2a32..5244fe8b0ef 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ParentPet.cs @@ -80,7 +80,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -98,7 +98,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -106,10 +106,13 @@ namespace UseSourceGeneration.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ParentPet."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ParentPet.", nameof(petType)); - return new ParentPet(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); + + return new ParentPet(petType.Value!); } /// @@ -136,6 +139,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet.PetType == null) + throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); + writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs index 8b15e328ca8..2f1abbea359 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs @@ -35,21 +35,21 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// - /// category - /// id /// name /// photoUrls + /// category + /// id /// pet status in the store /// tags [JsonConstructor] - public Pet(Category category, long id, string name, List photoUrls, StatusEnum status, List tags) + public Pet(string name, List photoUrls, Option category = default, Option id = default, Option status = default, Option?> tags = default) { - Category = category; - Id = id; Name = name; PhotoUrls = photoUrls; - Status = status; - Tags = tags; + CategoryOption = category; + IdOption = id; + StatusOption = status; + TagsOption = tags; OnCreated(); } @@ -122,9 +122,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Available) return "available"; @@ -137,24 +136,19 @@ namespace UseSourceGeneration.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// pet status in the store /// /// pet status in the store [JsonPropertyName("status")] - public StatusEnum Status { get; set; } - - /// - /// Gets or Sets Category - /// - [JsonPropertyName("category")] - public Category Category { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } } /// /// Gets or Sets Name @@ -169,11 +163,44 @@ namespace UseSourceGeneration.Model [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } + /// + /// Used to track the state of Category + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryOption { get; private set; } + + /// + /// Gets or Sets Category + /// + [JsonPropertyName("category")] + public Category? Category { get { return this. CategoryOption; } set { this.CategoryOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Tags + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> TagsOption { get; private set; } + /// /// Gets or Sets Tags /// [JsonPropertyName("tags")] - public List Tags { get; set; } + public List? Tags { get { return this. TagsOption; } set { this.TagsOption = new(value); } } /// /// Gets or Sets additional properties @@ -189,10 +216,10 @@ namespace UseSourceGeneration.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Pet {\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); sb.Append(" Tags: ").Append(Tags).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -233,12 +260,12 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Category? category = default; - long? id = default; - string? name = default; - List? photoUrls = default; - Pet.StatusEnum? status = default; - List? tags = default; + Option name = default; + Option?> photoUrls = default; + Option category = default; + Option id = default; + Option status = default; + Option?> tags = default; while (utf8JsonReader.Read()) { @@ -255,30 +282,29 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { - case "category": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - category = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; case "photoUrls": if (utf8JsonReader.TokenType != JsonTokenType.Null) - photoUrls = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + photoUrls = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "category": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + category = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); break; case "status": string? statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Pet.StatusEnumFromStringOrDefault(statusRawValue); + if (statusRawValue != null) + status = new Option(Pet.StatusEnumFromStringOrDefault(statusRawValue)); break; case "tags": if (utf8JsonReader.TokenType != JsonTokenType.Null) - tags = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + tags = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -286,25 +312,31 @@ namespace UseSourceGeneration.Model } } - if (category == null) - throw new ArgumentNullException(nameof(category), "Property is required for class Pet."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(name)); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Pet."); + if (!photoUrls.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(photoUrls)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Pet."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Pet."); - if (photoUrls == null) - throw new ArgumentNullException(nameof(photoUrls), "Property is required for class Pet."); + if (photoUrls.IsSet && photoUrls.Value == null) + throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Pet."); + if (category.IsSet && category.Value == null) + throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet."); - if (tags == null) - throw new ArgumentNullException(nameof(tags), "Property is required for class Pet."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet."); - return new Pet(category, id.Value, name, photoUrls, status.Value, tags); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet."); + + if (tags.IsSet && tags.Value == null) + throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet."); + + return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags); } /// @@ -331,21 +363,41 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("category"); - JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); - writer.WriteNumber("id", pet.Id); + if (pet.Name == null) + throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet."); + + if (pet.PhotoUrls == null) + throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet."); + + if (pet.CategoryOption.IsSet && pet.Category == null) + throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet."); + + if (pet.TagsOption.IsSet && pet.Tags == null) + throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet."); + writer.WriteString("name", pet.Name); + writer.WritePropertyName("photoUrls"); JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions); + if (pet.CategoryOption.IsSet) + { + writer.WritePropertyName("category"); + JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); + } + if (pet.IdOption.IsSet) + writer.WriteNumber("id", pet.IdOption.Value!.Value); - var statusRawValue = Pet.StatusEnumToJsonValue(pet.Status); + var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - writer.WritePropertyName("tags"); - JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + if (pet.TagsOption.IsSet) + { + writer.WritePropertyName("tags"); + JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pig.cs index 3f9fdf20cd8..09e650c7df0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pig.cs @@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; BasquePig? basquePig = null; DanishPig? danishPig = null; @@ -188,7 +188,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -196,14 +196,17 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Pig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Pig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className); + return new Pig(basquePig, className.Value!); if (danishPig != null) - return new Pig(danishPig, className); + return new Pig(danishPig, className.Value!); throw new JsonException(); } @@ -242,6 +245,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { + if (pig.ClassName == null) + throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); + writer.WriteString("className", pig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Quadrilateral.cs index 8b6c244ab73..dfb4799a35e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Quadrilateral.cs @@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; + Option quadrilateralType = default; ComplexQuadrilateral? complexQuadrilateral = null; SimpleQuadrilateral? simpleQuadrilateral = null; @@ -188,7 +188,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -196,14 +196,17 @@ namespace UseSourceGeneration.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class Quadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class Quadrilateral.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType); + return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value!); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType); + return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value!); throw new JsonException(); } @@ -242,6 +245,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); + writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/QuadrilateralInterface.cs index 91f6a55eb20..671d8dac199 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/QuadrilateralInterface.cs @@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; + Option quadrilateralType = default; while (utf8JsonReader.Read()) { @@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,10 +130,13 @@ namespace UseSourceGeneration.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class QuadrilateralInterface."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class QuadrilateralInterface.", nameof(quadrilateralType)); - return new QuadrilateralInterface(quadrilateralType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class QuadrilateralInterface."); + + return new QuadrilateralInterface(quadrilateralType.Value!); } /// @@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateralInterface.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface."); + writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ReadOnlyFirst.cs index 5ecf5400320..b63c0cbc81e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ReadOnlyFirst.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// bar /// baz [JsonConstructor] - public ReadOnlyFirst(string bar, string baz) + public ReadOnlyFirst(Option bar = default, Option baz = default) { - Bar = bar; - Baz = baz; + BarOption = bar; + BazOption = baz; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string? Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Baz + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BazOption { get; private set; } /// /// Gets or Sets Baz /// [JsonPropertyName("baz")] - public string Baz { get; set; } + public string? Baz { get { return this. BazOption; } set { this.BazOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,7 +123,9 @@ namespace UseSourceGeneration.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -149,8 +165,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? bar = default; - string? baz = default; + Option bar = default; + Option baz = default; while (utf8JsonReader.Read()) { @@ -168,10 +184,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()!); break; case "baz": - baz = utf8JsonReader.GetString(); + baz = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -179,11 +195,11 @@ namespace UseSourceGeneration.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class ReadOnlyFirst."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst."); - if (baz == null) - throw new ArgumentNullException(nameof(baz), "Property is required for class ReadOnlyFirst."); + if (baz.IsSet && baz.Value == null) + throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst."); return new ReadOnlyFirst(bar, baz); } @@ -212,8 +228,17 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", readOnlyFirst.Bar); - writer.WriteString("baz", readOnlyFirst.Baz); + if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BarOption.IsSet) + writer.WriteString("bar", readOnlyFirst.Bar); + + if (readOnlyFirst.BazOption.IsSet) + writer.WriteString("baz", readOnlyFirst.Baz); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs new file mode 100644 index 00000000000..21ebb68608f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs @@ -0,0 +1,2396 @@ +// +/* + * 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 + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = UseSourceGeneration.Client.ClientUtils; +using System.Text.Json.Serialization.Metadata; +using UseSourceGeneration.Client; + +namespace UseSourceGeneration.Model +{ + /// + /// RequiredClass + /// + public partial class RequiredClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// requiredNotNullableDateProp + /// requiredNotnullableArrayOfString + /// requiredNotnullableBooleanProp + /// requiredNotnullableDatetimeProp + /// requiredNotnullableEnumInteger + /// requiredNotnullableEnumIntegerOnly + /// requiredNotnullableEnumString + /// requiredNotnullableOuterEnumDefaultValue + /// requiredNotnullableStringProp + /// requiredNotnullableUuid + /// requiredNotnullableintegerProp + /// requiredNullableArrayOfString + /// requiredNullableBooleanProp + /// requiredNullableDateProp + /// requiredNullableDatetimeProp + /// requiredNullableEnumInteger + /// requiredNullableEnumIntegerOnly + /// requiredNullableEnumString + /// requiredNullableIntegerProp + /// requiredNullableOuterEnumDefaultValue + /// requiredNullableStringProp + /// requiredNullableUuid + /// notRequiredNotnullableDateProp + /// notRequiredNotnullableintegerProp + /// notRequiredNullableDateProp + /// notRequiredNullableIntegerProp + /// notrequiredNotnullableArrayOfString + /// notrequiredNotnullableBooleanProp + /// notrequiredNotnullableDatetimeProp + /// notrequiredNotnullableEnumInteger + /// notrequiredNotnullableEnumIntegerOnly + /// notrequiredNotnullableEnumString + /// notrequiredNotnullableOuterEnumDefaultValue + /// notrequiredNotnullableStringProp + /// notrequiredNotnullableUuid + /// notrequiredNullableArrayOfString + /// notrequiredNullableBooleanProp + /// notrequiredNullableDatetimeProp + /// notrequiredNullableEnumInteger + /// notrequiredNullableEnumIntegerOnly + /// notrequiredNullableEnumString + /// notrequiredNullableOuterEnumDefaultValue + /// notrequiredNullableStringProp + /// notrequiredNullableUuid + [JsonConstructor] + public RequiredClass(DateTime requiredNotNullableDateProp, List requiredNotnullableArrayOfString, bool requiredNotnullableBooleanProp, DateTime requiredNotnullableDatetimeProp, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue, string requiredNotnullableStringProp, Guid requiredNotnullableUuid, int requiredNotnullableintegerProp, List? requiredNullableArrayOfString = default, bool? requiredNullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime? requiredNullableDatetimeProp = default, RequiredNullableEnumIntegerEnum? requiredNullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum? requiredNullableEnumIntegerOnly = default, RequiredNullableEnumStringEnum? requiredNullableEnumString = default, int? requiredNullableIntegerProp = default, OuterEnumDefaultValue? requiredNullableOuterEnumDefaultValue = default, string? requiredNullableStringProp = default, Guid? requiredNullableUuid = default, Option notRequiredNotnullableDateProp = default, Option notRequiredNotnullableintegerProp = default, Option notRequiredNullableDateProp = default, Option notRequiredNullableIntegerProp = default, Option?> notrequiredNotnullableArrayOfString = default, Option notrequiredNotnullableBooleanProp = default, Option notrequiredNotnullableDatetimeProp = default, Option notrequiredNotnullableEnumInteger = default, Option notrequiredNotnullableEnumIntegerOnly = default, Option notrequiredNotnullableEnumString = default, Option notrequiredNotnullableOuterEnumDefaultValue = default, Option notrequiredNotnullableStringProp = default, Option notrequiredNotnullableUuid = default, Option?> notrequiredNullableArrayOfString = default, Option notrequiredNullableBooleanProp = default, Option notrequiredNullableDatetimeProp = default, Option notrequiredNullableEnumInteger = default, Option notrequiredNullableEnumIntegerOnly = default, Option notrequiredNullableEnumString = default, Option notrequiredNullableOuterEnumDefaultValue = default, Option notrequiredNullableStringProp = default, Option notrequiredNullableUuid = default) + { + RequiredNotNullableDateProp = requiredNotNullableDateProp; + RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + RequiredNotnullableEnumString = requiredNotnullableEnumString; + RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + RequiredNotnullableStringProp = requiredNotnullableStringProp; + RequiredNotnullableUuid = requiredNotnullableUuid; + RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + RequiredNullableArrayOfString = requiredNullableArrayOfString; + RequiredNullableBooleanProp = requiredNullableBooleanProp; + RequiredNullableDateProp = requiredNullableDateProp; + RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + RequiredNullableEnumInteger = requiredNullableEnumInteger; + RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + RequiredNullableEnumString = requiredNullableEnumString; + RequiredNullableIntegerProp = requiredNullableIntegerProp; + RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + RequiredNullableStringProp = requiredNullableStringProp; + RequiredNullableUuid = requiredNullableUuid; + NotRequiredNotnullableDatePropOption = notRequiredNotnullableDateProp; + NotRequiredNotnullableintegerPropOption = notRequiredNotnullableintegerProp; + NotRequiredNullableDatePropOption = notRequiredNullableDateProp; + NotRequiredNullableIntegerPropOption = notRequiredNullableIntegerProp; + NotrequiredNotnullableArrayOfStringOption = notrequiredNotnullableArrayOfString; + NotrequiredNotnullableBooleanPropOption = notrequiredNotnullableBooleanProp; + NotrequiredNotnullableDatetimePropOption = notrequiredNotnullableDatetimeProp; + NotrequiredNotnullableEnumIntegerOption = notrequiredNotnullableEnumInteger; + NotrequiredNotnullableEnumIntegerOnlyOption = notrequiredNotnullableEnumIntegerOnly; + NotrequiredNotnullableEnumStringOption = notrequiredNotnullableEnumString; + NotrequiredNotnullableOuterEnumDefaultValueOption = notrequiredNotnullableOuterEnumDefaultValue; + NotrequiredNotnullableStringPropOption = notrequiredNotnullableStringProp; + NotrequiredNotnullableUuidOption = notrequiredNotnullableUuid; + NotrequiredNullableArrayOfStringOption = notrequiredNullableArrayOfString; + NotrequiredNullableBooleanPropOption = notrequiredNullableBooleanProp; + NotrequiredNullableDatetimePropOption = notrequiredNullableDatetimeProp; + NotrequiredNullableEnumIntegerOption = notrequiredNullableEnumInteger; + NotrequiredNullableEnumIntegerOnlyOption = notrequiredNullableEnumIntegerOnly; + NotrequiredNullableEnumStringOption = notrequiredNullableEnumString; + NotrequiredNullableOuterEnumDefaultValueOption = notrequiredNullableOuterEnumDefaultValue; + NotrequiredNullableStringPropOption = notrequiredNullableStringProp; + NotrequiredNullableUuidOption = notrequiredNullableUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum? RequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerEnumToJsonValue(RequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [JsonPropertyName("required_notnullable_enum_integer")] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum? RequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(RequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("required_notnullable_enum_integer_only")] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNotnullableEnumString + /// + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumStringEnum RequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumStringEnum? RequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNotnullableEnumStringEnumToJsonValue(RequiredNotnullableEnumStringEnum value) + { + if (value == RequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [JsonPropertyName("required_notnullable_enum_string")] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerEnum RequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerEnum? RequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerEnumToJsonValue(RequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [JsonPropertyName("required_nullable_enum_integer")] + public RequiredNullableEnumIntegerEnum? RequiredNullableEnumInteger { get; set; } + + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerOnlyEnumToJsonValue(RequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("required_nullable_enum_integer_only")] + public RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNullableEnumString + /// + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumStringEnum RequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumStringEnum? RequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string? RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == RequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [JsonPropertyName("required_nullable_enum_string")] + public RequiredNullableEnumStringEnum? RequiredNullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum NotrequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerEnumToJsonValue(NotrequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [JsonPropertyName("notrequired_notnullable_enum_integer")] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get { return this.NotrequiredNotnullableEnumIntegerOption; } set { this.NotrequiredNotnullableEnumIntegerOption = new(value); } } + + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum NotrequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_notnullable_enum_integer_only")] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get { return this.NotrequiredNotnullableEnumIntegerOnlyOption; } set { this.NotrequiredNotnullableEnumIntegerOnlyOption = new(value); } } + + /// + /// Defines NotrequiredNotnullableEnumString + /// + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum NotrequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNotnullableEnumStringEnumToJsonValue(NotrequiredNotnullableEnumStringEnum? value) + { + if (value == NotrequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [JsonPropertyName("notrequired_notnullable_enum_string")] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get { return this.NotrequiredNotnullableEnumStringOption; } set { this.NotrequiredNotnullableEnumStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get { return this.NotrequiredNotnullableOuterEnumDefaultValueOption; } set { this.NotrequiredNotnullableOuterEnumDefaultValueOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum NotrequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerEnumToJsonValue(NotrequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [JsonPropertyName("notrequired_nullable_enum_integer")] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get { return this.NotrequiredNullableEnumIntegerOption; } set { this.NotrequiredNullableEnumIntegerOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum NotrequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_nullable_enum_integer_only")] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get { return this.NotrequiredNullableEnumIntegerOnlyOption; } set { this.NotrequiredNullableEnumIntegerOnlyOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumString + /// + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumStringEnum NotrequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string? NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == NotrequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [JsonPropertyName("notrequired_nullable_enum_string")] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get { return this.NotrequiredNullableEnumStringOption; } set { this.NotrequiredNullableEnumStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get { return this.NotrequiredNullableOuterEnumDefaultValueOption; } set { this.NotrequiredNullableOuterEnumDefaultValueOption = new(value); } } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonPropertyName("required_not_nullable_date_prop")] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [JsonPropertyName("required_notnullable_array_of_string")] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [JsonPropertyName("required_notnullable_boolean_prop")] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [JsonPropertyName("required_notnullable_datetime_prop")] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [JsonPropertyName("required_notnullable_string_prop")] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_notnullable_uuid")] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [JsonPropertyName("required_notnullableinteger_prop")] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [JsonPropertyName("required_nullable_array_of_string")] + public List? RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [JsonPropertyName("required_nullable_boolean_prop")] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonPropertyName("required_nullable_date_prop")] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [JsonPropertyName("required_nullable_datetime_prop")] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [JsonPropertyName("required_nullable_integer_prop")] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [JsonPropertyName("required_nullable_string_prop")] + public string? RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_nullable_uuid")] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Used to track the state of NotRequiredNotnullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonPropertyName("not_required_notnullable_date_prop")] + public DateTime? NotRequiredNotnullableDateProp { get { return this. NotRequiredNotnullableDatePropOption; } set { this.NotRequiredNotnullableDatePropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNotnullableintegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableintegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [JsonPropertyName("not_required_notnullableinteger_prop")] + public int? NotRequiredNotnullableintegerProp { get { return this. NotRequiredNotnullableintegerPropOption; } set { this.NotRequiredNotnullableintegerPropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonPropertyName("not_required_nullable_date_prop")] + public DateTime? NotRequiredNullableDateProp { get { return this. NotRequiredNullableDatePropOption; } set { this.NotRequiredNullableDatePropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNullableIntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableIntegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [JsonPropertyName("not_required_nullable_integer_prop")] + public int? NotRequiredNullableIntegerProp { get { return this. NotRequiredNullableIntegerPropOption; } set { this.NotRequiredNullableIntegerPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> NotrequiredNotnullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [JsonPropertyName("notrequired_notnullable_array_of_string")] + public List? NotrequiredNotnullableArrayOfString { get { return this. NotrequiredNotnullableArrayOfStringOption; } set { this.NotrequiredNotnullableArrayOfStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [JsonPropertyName("notrequired_notnullable_boolean_prop")] + public bool? NotrequiredNotnullableBooleanProp { get { return this. NotrequiredNotnullableBooleanPropOption; } set { this.NotrequiredNotnullableBooleanPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [JsonPropertyName("notrequired_notnullable_datetime_prop")] + public DateTime? NotrequiredNotnullableDatetimeProp { get { return this. NotrequiredNotnullableDatetimePropOption; } set { this.NotrequiredNotnullableDatetimePropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [JsonPropertyName("notrequired_notnullable_string_prop")] + public string? NotrequiredNotnullableStringProp { get { return this. NotrequiredNotnullableStringPropOption; } set { this.NotrequiredNotnullableStringPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_notnullable_uuid")] + public Guid? NotrequiredNotnullableUuid { get { return this. NotrequiredNotnullableUuidOption; } set { this.NotrequiredNotnullableUuidOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> NotrequiredNullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [JsonPropertyName("notrequired_nullable_array_of_string")] + public List? NotrequiredNullableArrayOfString { get { return this. NotrequiredNullableArrayOfStringOption; } set { this.NotrequiredNullableArrayOfStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [JsonPropertyName("notrequired_nullable_boolean_prop")] + public bool? NotrequiredNullableBooleanProp { get { return this. NotrequiredNullableBooleanPropOption; } set { this.NotrequiredNullableBooleanPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [JsonPropertyName("notrequired_nullable_datetime_prop")] + public DateTime? NotrequiredNullableDatetimeProp { get { return this. NotrequiredNullableDatetimePropOption; } set { this.NotrequiredNullableDatetimePropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [JsonPropertyName("notrequired_nullable_string_prop")] + public string? NotrequiredNullableStringProp { get { return this. NotrequiredNullableStringPropOption; } set { this.NotrequiredNullableStringPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_nullable_uuid")] + public Guid? NotrequiredNullableUuid { get { return this. NotrequiredNullableUuidOption; } set { this.NotrequiredNullableUuidOption = new(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize RequiredNotNullableDateProp + /// + public static string RequiredNotNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNotnullableDatetimeProp + /// + public static string RequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize RequiredNullableDateProp + /// + public static string RequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNullableDatetimeProp + /// + public static string RequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotRequiredNotnullableDateProp + /// + public static string NotRequiredNotnullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotRequiredNullableDateProp + /// + public static string NotRequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotrequiredNotnullableDatetimeProp + /// + public static string NotrequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotrequiredNullableDatetimeProp + /// + public static string NotrequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option requiredNotNullableDateProp = default; + Option?> requiredNotnullableArrayOfString = default; + Option requiredNotnullableBooleanProp = default; + Option requiredNotnullableDatetimeProp = default; + Option requiredNotnullableEnumInteger = default; + Option requiredNotnullableEnumIntegerOnly = default; + Option requiredNotnullableEnumString = default; + Option requiredNotnullableOuterEnumDefaultValue = default; + Option requiredNotnullableStringProp = default; + Option requiredNotnullableUuid = default; + Option requiredNotnullableintegerProp = default; + Option?> requiredNullableArrayOfString = default; + Option requiredNullableBooleanProp = default; + Option requiredNullableDateProp = default; + Option requiredNullableDatetimeProp = default; + Option requiredNullableEnumInteger = default; + Option requiredNullableEnumIntegerOnly = default; + Option requiredNullableEnumString = default; + Option requiredNullableIntegerProp = default; + Option requiredNullableOuterEnumDefaultValue = default; + Option requiredNullableStringProp = default; + Option requiredNullableUuid = default; + Option notRequiredNotnullableDateProp = default; + Option notRequiredNotnullableintegerProp = default; + Option notRequiredNullableDateProp = default; + Option notRequiredNullableIntegerProp = default; + Option?> notrequiredNotnullableArrayOfString = default; + Option notrequiredNotnullableBooleanProp = default; + Option notrequiredNotnullableDatetimeProp = default; + Option notrequiredNotnullableEnumInteger = default; + Option notrequiredNotnullableEnumIntegerOnly = default; + Option notrequiredNotnullableEnumString = default; + Option notrequiredNotnullableOuterEnumDefaultValue = default; + Option notrequiredNotnullableStringProp = default; + Option notrequiredNotnullableUuid = default; + Option?> notrequiredNullableArrayOfString = default; + Option notrequiredNullableBooleanProp = default; + Option notrequiredNullableDatetimeProp = default; + Option notrequiredNullableEnumInteger = default; + Option notrequiredNullableEnumIntegerOnly = default; + Option notrequiredNullableEnumString = default; + Option notrequiredNullableOuterEnumDefaultValue = default; + Option notrequiredNullableStringProp = default; + Option notrequiredNullableUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "required_not_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "required_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumInteger = new Option((RequiredClass.RequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumIntegerOnly = new Option((RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_string": + string? requiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumStringRawValue != null) + requiredNotnullableEnumString = new Option(RequiredClass.RequiredNotnullableEnumStringEnumFromStringOrDefault(requiredNotnullableEnumStringRawValue)); + break; + case "required_notnullable_outerEnumDefaultValue": + string? requiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableOuterEnumDefaultValueRawValue != null) + requiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "required_notnullable_string_prop": + requiredNotnullableStringProp = new Option(utf8JsonReader.GetString()!); + break; + case "required_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumInteger = new Option((RequiredClass.RequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumIntegerOnly = new Option((RequiredClass.RequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_string": + string? requiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumStringRawValue != null) + requiredNullableEnumString = new Option(RequiredClass.RequiredNullableEnumStringEnumFromStringOrDefault(requiredNullableEnumStringRawValue)); + break; + case "required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_outerEnumDefaultValue": + string? requiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + requiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNullableOuterEnumDefaultValueRawValue)); + break; + case "required_nullable_string_prop": + requiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "not_required_notnullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "notrequired_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumInteger = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_string": + string? notrequiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumStringRawValue != null) + notrequiredNotnullableEnumString = new Option(RequiredClass.NotrequiredNotnullableEnumStringEnumFromStringOrDefault(notrequiredNotnullableEnumStringRawValue)); + break; + case "notrequired_notnullable_outerEnumDefaultValue": + string? notrequiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableOuterEnumDefaultValueRawValue != null) + notrequiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_notnullable_string_prop": + notrequiredNotnullableStringProp = new Option(utf8JsonReader.GetString()!); + break; + case "notrequired_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "notrequired_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumInteger = new Option((RequiredClass.NotrequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_string": + string? notrequiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumStringRawValue != null) + notrequiredNullableEnumString = new Option(RequiredClass.NotrequiredNullableEnumStringEnumFromStringOrDefault(notrequiredNullableEnumStringRawValue)); + break; + case "notrequired_nullable_outerEnumDefaultValue": + string? notrequiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableOuterEnumDefaultValueRawValue != null) + notrequiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_nullable_string_prop": + notrequiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!requiredNotNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotNullableDateProp)); + + if (!requiredNotnullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableArrayOfString)); + + if (!requiredNotnullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableBooleanProp)); + + if (!requiredNotnullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableDatetimeProp)); + + if (!requiredNotnullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumInteger)); + + if (!requiredNotnullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumIntegerOnly)); + + if (!requiredNotnullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumString)); + + if (!requiredNotnullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableOuterEnumDefaultValue)); + + if (!requiredNotnullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableStringProp)); + + if (!requiredNotnullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableUuid)); + + if (!requiredNotnullableintegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableintegerProp)); + + if (!requiredNullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableArrayOfString)); + + if (!requiredNullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableBooleanProp)); + + if (!requiredNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDateProp)); + + if (!requiredNullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDatetimeProp)); + + if (!requiredNullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumInteger)); + + if (!requiredNullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumIntegerOnly)); + + if (!requiredNullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumString)); + + if (!requiredNullableIntegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableIntegerProp)); + + if (!requiredNullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableOuterEnumDefaultValue)); + + if (!requiredNullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableStringProp)); + + if (!requiredNullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableUuid)); + + if (requiredNotNullableDateProp.IsSet && requiredNotNullableDateProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotNullableDateProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableArrayOfString.IsSet && requiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableBooleanProp.IsSet && requiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableDatetimeProp.IsSet && requiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumInteger.IsSet && requiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumIntegerOnly.IsSet && requiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumString.IsSet && requiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableOuterEnumDefaultValue.IsSet && requiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableStringProp.IsSet && requiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableUuid.IsSet && requiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + if (requiredClass.RequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.RequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat)); + + writer.WritePropertyName("required_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNotnullableArrayOfString, jsonSerializerOptions); + writer.WriteBoolean("required_notnullable_boolean_prop", requiredClass.RequiredNotnullableBooleanProp); + + writer.WriteString("required_notnullable_datetime_prop", requiredClass.RequiredNotnullableDatetimeProp.ToString(RequiredNotnullableDatetimePropFormat)); + + writer.WriteNumber("required_notnullable_enum_integer", RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNotnullableEnumInteger)); + + writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly)); + + var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString); + if (requiredNotnullableEnumStringRawValue != null) + writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue); + else + writer.WriteNull("required_notnullable_enum_string"); + + var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue); + writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue); + + writer.WriteString("required_notnullable_string_prop", requiredClass.RequiredNotnullableStringProp); + + writer.WriteString("required_notnullable_uuid", requiredClass.RequiredNotnullableUuid); + + writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp); + + if (requiredClass.RequiredNullableArrayOfString != null) + { + writer.WritePropertyName("required_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("required_nullable_array_of_string"); + if (requiredClass.RequiredNullableBooleanProp != null) + writer.WriteBoolean("required_nullable_boolean_prop", requiredClass.RequiredNullableBooleanProp.Value); + else + writer.WriteNull("required_nullable_boolean_prop"); + + if (requiredClass.RequiredNullableDateProp != null) + writer.WriteString("required_nullable_date_prop", requiredClass.RequiredNullableDateProp.Value.ToString(RequiredNullableDatePropFormat)); + else + writer.WriteNull("required_nullable_date_prop"); + + if (requiredClass.RequiredNullableDatetimeProp != null) + writer.WriteString("required_nullable_datetime_prop", requiredClass.RequiredNullableDatetimeProp.Value.ToString(RequiredNullableDatetimePropFormat)); + else + writer.WriteNull("required_nullable_datetime_prop"); + + if (requiredClass.RequiredNullableEnumInteger != null) + writer.WriteNumber("required_nullable_enum_integer", RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNullableEnumInteger.Value)); + else + writer.WriteNull("required_nullable_enum_integer"); + + if (requiredClass.RequiredNullableEnumIntegerOnly != null) + writer.WriteNumber("required_nullable_enum_integer_only", RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNullableEnumIntegerOnly.Value)); + else + writer.WriteNull("required_nullable_enum_integer_only"); + + var requiredNullableEnumStringRawValue = RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClass.RequiredNullableEnumString!.Value); + if (requiredNullableEnumStringRawValue != null) + writer.WriteString("required_nullable_enum_string", requiredNullableEnumStringRawValue); + else + writer.WriteNull("required_nullable_enum_string"); + + if (requiredClass.RequiredNullableIntegerProp != null) + writer.WriteNumber("required_nullable_integer_prop", requiredClass.RequiredNullableIntegerProp.Value); + else + writer.WriteNull("required_nullable_integer_prop"); + + if (requiredClass.RequiredNullableOuterEnumDefaultValue == null) + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + else + { + var requiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNullableOuterEnumDefaultValue.Value); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + writer.WriteString("required_nullable_outerEnumDefaultValue", requiredNullableOuterEnumDefaultValueRawValue); + else + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + } + + if (requiredClass.RequiredNullableStringProp != null) + writer.WriteString("required_nullable_string_prop", requiredClass.RequiredNullableStringProp); + else + writer.WriteNull("required_nullable_string_prop"); + + if (requiredClass.RequiredNullableUuid != null) + writer.WriteString("required_nullable_uuid", requiredClass.RequiredNullableUuid.Value); + else + writer.WriteNull("required_nullable_uuid"); + + if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet) + writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat)); + + if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet) + writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value); + + if (requiredClass.NotRequiredNullableDatePropOption.IsSet) + if (requiredClass.NotRequiredNullableDatePropOption.Value != null) + writer.WriteString("not_required_nullable_date_prop", requiredClass.NotRequiredNullableDatePropOption.Value!.Value.ToString(NotRequiredNullableDatePropFormat)); + else + writer.WriteNull("not_required_nullable_date_prop"); + + if (requiredClass.NotRequiredNullableIntegerPropOption.IsSet) + if (requiredClass.NotRequiredNullableIntegerPropOption.Value != null) + writer.WriteNumber("not_required_nullable_integer_prop", requiredClass.NotRequiredNullableIntegerPropOption.Value!.Value); + else + writer.WriteNull("not_required_nullable_integer_prop"); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet) + { + writer.WritePropertyName("notrequired_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions); + } + if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet) + writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value); + + if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet) + writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value)); + + var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value); + if (notrequiredNotnullableEnumStringRawValue != null) + writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue); + else + writer.WriteNull("notrequired_notnullable_enum_string"); + + if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet) + { + var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue!.Value); + writer.WriteString("notrequired_notnullable_outerEnumDefaultValue", notrequiredNotnullableOuterEnumDefaultValueRawValue); + } + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet) + writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp); + + if (requiredClass.NotrequiredNotnullableUuidOption.IsSet) + writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value); + + if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet) + if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null) + { + writer.WritePropertyName("notrequired_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("notrequired_nullable_array_of_string"); + if (requiredClass.NotrequiredNullableBooleanPropOption.IsSet) + if (requiredClass.NotrequiredNullableBooleanPropOption.Value != null) + writer.WriteBoolean("notrequired_nullable_boolean_prop", requiredClass.NotrequiredNullableBooleanPropOption.Value!.Value); + else + writer.WriteNull("notrequired_nullable_boolean_prop"); + + if (requiredClass.NotrequiredNullableDatetimePropOption.IsSet) + if (requiredClass.NotrequiredNullableDatetimePropOption.Value != null) + writer.WriteString("notrequired_nullable_datetime_prop", requiredClass.NotrequiredNullableDatetimePropOption.Value!.Value.ToString(NotrequiredNullableDatetimePropFormat)); + else + writer.WriteNull("notrequired_nullable_datetime_prop"); + + if (requiredClass.NotrequiredNullableEnumIntegerOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer", RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOption.Value!.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer"); + + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer_only", RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value!.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer_only"); + + var notrequiredNullableEnumStringRawValue = RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNullableEnumStringOption.Value!.Value); + if (notrequiredNullableEnumStringRawValue != null) + writer.WriteString("notrequired_nullable_enum_string", notrequiredNullableEnumStringRawValue); + else + writer.WriteNull("notrequired_nullable_enum_string"); + + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.IsSet) + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption!.Value != null) + { + var notrequiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value!.Value); + writer.WriteString("notrequired_nullable_outerEnumDefaultValue", notrequiredNullableOuterEnumDefaultValueRawValue); + } + else + writer.WriteNull("notrequired_nullable_outerEnumDefaultValue"); + if (requiredClass.NotrequiredNullableStringPropOption.IsSet) + if (requiredClass.NotrequiredNullableStringPropOption.Value != null) + writer.WriteString("notrequired_nullable_string_prop", requiredClass.NotrequiredNullableStringProp); + else + writer.WriteNull("notrequired_nullable_string_prop"); + + if (requiredClass.NotrequiredNullableUuidOption.IsSet) + if (requiredClass.NotrequiredNullableUuidOption.Value != null) + writer.WriteString("notrequired_nullable_uuid", requiredClass.NotrequiredNullableUuidOption.Value!.Value); + else + writer.WriteNull("notrequired_nullable_uuid"); + } + } + + /// + /// The RequiredClassSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(RequiredClass))] + public partial class RequiredClassSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Return.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Return.cs index 454e16dd0f5..3a3bf398ebc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Return.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Return.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// varReturn [JsonConstructor] - public Return(int varReturn) + public Return(Option varReturn = default) { - VarReturn = varReturn; + VarReturnOption = varReturn; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarReturn + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarReturnOption { get; private set; } + /// /// Gets or Sets VarReturn /// [JsonPropertyName("return")] - public int VarReturn { get; set; } + public int? VarReturn { get { return this. VarReturnOption; } set { this.VarReturnOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varReturn = default; + Option varReturn = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "return": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varReturn = utf8JsonReader.GetInt32(); + varReturn = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -131,10 +138,10 @@ namespace UseSourceGeneration.Model } } - if (varReturn == null) - throw new ArgumentNullException(nameof(varReturn), "Property is required for class Return."); + if (varReturn.IsSet && varReturn.Value == null) + throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return."); - return new Return(varReturn.Value); + return new Return(varReturn); } /// @@ -161,7 +168,8 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("return", varReturn.VarReturn); + if (varReturn.VarReturnOption.IsSet) + writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHash.cs index 3485ce95577..7597e889587 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHash.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// role /// roleUuid [JsonConstructor] - public RolesReportsHash(RolesReportsHashRole role, Guid roleUuid) + public RolesReportsHash(Option role = default, Option roleUuid = default) { - Role = role; - RoleUuid = roleUuid; + RoleOption = role; + RoleUuidOption = roleUuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Role + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleOption { get; private set; } + /// /// Gets or Sets Role /// [JsonPropertyName("role")] - public RolesReportsHashRole Role { get; set; } + public RolesReportsHashRole? Role { get { return this. RoleOption; } set { this.RoleOption = new(value); } } + + /// + /// Used to track the state of RoleUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleUuidOption { get; private set; } /// /// Gets or Sets RoleUuid /// [JsonPropertyName("role_uuid")] - public Guid RoleUuid { get; set; } + public Guid? RoleUuid { get { return this. RoleUuidOption; } set { this.RoleUuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - RolesReportsHashRole? role = default; - Guid? roleUuid = default; + Option role = default; + Option roleUuid = default; while (utf8JsonReader.Read()) { @@ -133,11 +147,11 @@ namespace UseSourceGeneration.Model { case "role": if (utf8JsonReader.TokenType != JsonTokenType.Null) - role = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + role = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "role_uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - roleUuid = utf8JsonReader.GetGuid(); + roleUuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -145,13 +159,13 @@ namespace UseSourceGeneration.Model } } - if (role == null) - throw new ArgumentNullException(nameof(role), "Property is required for class RolesReportsHash."); + if (role.IsSet && role.Value == null) + throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash."); - if (roleUuid == null) - throw new ArgumentNullException(nameof(roleUuid), "Property is required for class RolesReportsHash."); + if (roleUuid.IsSet && roleUuid.Value == null) + throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash."); - return new RolesReportsHash(role, roleUuid.Value); + return new RolesReportsHash(role, roleUuid); } /// @@ -178,9 +192,16 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("role"); - JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); - writer.WriteString("role_uuid", rolesReportsHash.RoleUuid); + if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null) + throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash."); + + if (rolesReportsHash.RoleOption.IsSet) + { + writer.WritePropertyName("role"); + JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); + } + if (rolesReportsHash.RoleUuidOption.IsSet) + writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHashRole.cs index 9c20ab46bad..d74e74a0cdb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RolesReportsHashRole.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// name [JsonConstructor] - public RolesReportsHashRole(string name) + public RolesReportsHashRole(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class RolesReportsHashRole."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole."); return new RolesReportsHashRole(name); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", rolesReportsHashRole.Name); + if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null) + throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole."); + + if (rolesReportsHashRole.NameOption.IsSet) + writer.WriteString("name", rolesReportsHashRole.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ScaleneTriangle.cs index 39f7d8cc72f..df238cd6fb8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ScaleneTriangle.cs @@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; - string? triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -132,10 +132,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -143,13 +143,19 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ScaleneTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class ScaleneTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(triangleType)); - return new ScaleneTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ScaleneTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class ScaleneTriangle."); + + return new ScaleneTriangle(shapeType.Value!, triangleType.Value!); } /// @@ -176,7 +182,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (scaleneTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle."); + + if (scaleneTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle."); + writer.WriteString("shapeType", scaleneTriangle.ShapeType); + writer.WriteString("triangleType", scaleneTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Shape.cs index 7100b878d3b..d7f628a58c9 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Shape.cs @@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; Quadrilateral? quadrilateral = null; Triangle? triangle = null; @@ -188,7 +188,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -196,14 +196,17 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class Shape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class Shape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType); + return new Shape(quadrilateral, shapeType.Value!); if (triangle != null) - return new Shape(triangle, shapeType); + return new Shape(triangle, shapeType.Value!); throw new JsonException(); } @@ -242,6 +245,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { + if (shape.ShapeType == null) + throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); + writer.WriteString("shapeType", shape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeInterface.cs index 0a994154af0..bd75259c119 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeInterface.cs @@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,10 +130,13 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeInterface."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeInterface.", nameof(shapeType)); - return new ShapeInterface(shapeType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeInterface."); + + return new ShapeInterface(shapeType.Value!); } /// @@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) { + if (shapeInterface.ShapeType == null) + throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface."); + writer.WriteString("shapeType", shapeInterface.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeOrNull.cs index c0b313a2f36..b7063afd9a1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ShapeOrNull.cs @@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; Quadrilateral? quadrilateral = null; Triangle? triangle = null; @@ -188,7 +188,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -196,14 +196,17 @@ namespace UseSourceGeneration.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeOrNull."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType); + return new ShapeOrNull(quadrilateral, shapeType.Value!); if (triangle != null) - return new ShapeOrNull(triangle, shapeType); + return new ShapeOrNull(triangle, shapeType.Value!); throw new JsonException(); } @@ -242,6 +245,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { + if (shapeOrNull.ShapeType == null) + throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); + writer.WriteString("shapeType", shapeOrNull.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SimpleQuadrilateral.cs index c41dcdc9dcf..9e2ecd14d85 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SimpleQuadrilateral.cs @@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; - string? shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -132,10 +132,10 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -143,13 +143,19 @@ namespace UseSourceGeneration.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class SimpleQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class SimpleQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(shapeType)); - return new SimpleQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class SimpleQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class SimpleQuadrilateral."); + + return new SimpleQuadrilateral(quadrilateralType.Value!, shapeType.Value!); } /// @@ -176,7 +182,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (simpleQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral."); + + if (simpleQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral."); + writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", simpleQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SpecialModelName.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SpecialModelName.cs index 06b9d48e469..4ce1e685dc6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/SpecialModelName.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// varSpecialModelName /// specialPropertyName [JsonConstructor] - public SpecialModelName(string varSpecialModelName, long specialPropertyName) + public SpecialModelName(Option varSpecialModelName = default, Option specialPropertyName = default) { - VarSpecialModelName = varSpecialModelName; - SpecialPropertyName = specialPropertyName; + VarSpecialModelNameOption = varSpecialModelName; + SpecialPropertyNameOption = specialPropertyName; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarSpecialModelName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarSpecialModelNameOption { get; private set; } + /// /// Gets or Sets VarSpecialModelName /// [JsonPropertyName("_special_model.name_")] - public string VarSpecialModelName { get; set; } + public string? VarSpecialModelName { get { return this. VarSpecialModelNameOption; } set { this.VarSpecialModelNameOption = new(value); } } + + /// + /// Used to track the state of SpecialPropertyName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SpecialPropertyNameOption { get; private set; } /// /// Gets or Sets SpecialPropertyName /// [JsonPropertyName("$special[property.name]")] - public long SpecialPropertyName { get; set; } + public long? SpecialPropertyName { get { return this. SpecialPropertyNameOption; } set { this.SpecialPropertyNameOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varSpecialModelName = default; - long? specialPropertyName = default; + Option varSpecialModelName = default; + Option specialPropertyName = default; while (utf8JsonReader.Read()) { @@ -132,11 +146,11 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "_special_model.name_": - varSpecialModelName = utf8JsonReader.GetString(); + varSpecialModelName = new Option(utf8JsonReader.GetString()!); break; case "$special[property.name]": if (utf8JsonReader.TokenType != JsonTokenType.Null) - specialPropertyName = utf8JsonReader.GetInt64(); + specialPropertyName = new Option(utf8JsonReader.GetInt64()); break; default: break; @@ -144,13 +158,13 @@ namespace UseSourceGeneration.Model } } - if (varSpecialModelName == null) - throw new ArgumentNullException(nameof(varSpecialModelName), "Property is required for class SpecialModelName."); + if (varSpecialModelName.IsSet && varSpecialModelName.Value == null) + throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName."); - if (specialPropertyName == null) - throw new ArgumentNullException(nameof(specialPropertyName), "Property is required for class SpecialModelName."); + if (specialPropertyName.IsSet && specialPropertyName.Value == null) + throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName."); - return new SpecialModelName(varSpecialModelName, specialPropertyName.Value); + return new SpecialModelName(varSpecialModelName, specialPropertyName); } /// @@ -177,8 +191,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); - writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyName); + if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null) + throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName."); + + if (specialModelName.VarSpecialModelNameOption.IsSet) + writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); + + if (specialModelName.SpecialPropertyNameOption.IsSet) + writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Tag.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Tag.cs index 1bf8c4ad9a0..a29366ecfa7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Tag.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Tag.cs @@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model /// id /// name [JsonConstructor] - public Tag(long id, string name) + public Tag(Option id = default, Option name = default) { - Id = id; - Name = name; + IdOption = id; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string? name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -133,10 +147,10 @@ namespace UseSourceGeneration.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -144,13 +158,13 @@ namespace UseSourceGeneration.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Tag."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Tag."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag."); - return new Tag(id.Value, name); + return new Tag(id, name); } /// @@ -177,8 +191,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", tag.Id); - writer.WriteString("name", tag.Name); + if (tag.NameOption.IsSet && tag.Name == null) + throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag."); + + if (tag.IdOption.IsSet) + writer.WriteNumber("id", tag.IdOption.Value!.Value); + + if (tag.NameOption.IsSet) + writer.WriteString("name", tag.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordList.cs index 4249ff2fb47..c253c134a3a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordList.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// value [JsonConstructor] - public TestCollectionEndingWithWordList(string value) + public TestCollectionEndingWithWordList(Option value = default) { - Value = value; + ValueOption = value; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Value + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ValueOption { get; private set; } + /// /// Gets or Sets Value /// [JsonPropertyName("value")] - public string Value { get; set; } + public string? Value { get { return this. ValueOption; } set { this.ValueOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? value = default; + Option value = default; while (utf8JsonReader.Read()) { @@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "value": - value = utf8JsonReader.GetString(); + value = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,8 +137,8 @@ namespace UseSourceGeneration.Model } } - if (value == null) - throw new ArgumentNullException(nameof(value), "Property is required for class TestCollectionEndingWithWordList."); + if (value.IsSet && value.Value == null) + throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList."); return new TestCollectionEndingWithWordList(value); } @@ -160,7 +167,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("value", testCollectionEndingWithWordList.Value); + if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList."); + + if (testCollectionEndingWithWordList.ValueOption.IsSet) + writer.WriteString("value", testCollectionEndingWithWordList.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordListObject.cs index ed130760a75..fe73bc2ded6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestCollectionEndingWithWordListObject.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// testCollectionEndingWithWordList [JsonConstructor] - public TestCollectionEndingWithWordListObject(List testCollectionEndingWithWordList) + public TestCollectionEndingWithWordListObject(Option?> testCollectionEndingWithWordList = default) { - TestCollectionEndingWithWordList = testCollectionEndingWithWordList; + TestCollectionEndingWithWordListOption = testCollectionEndingWithWordList; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of TestCollectionEndingWithWordList + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> TestCollectionEndingWithWordListOption { get; private set; } + /// /// Gets or Sets TestCollectionEndingWithWordList /// [JsonPropertyName("TestCollectionEndingWithWordList")] - public List TestCollectionEndingWithWordList { get; set; } + public List? TestCollectionEndingWithWordList { get { return this. TestCollectionEndingWithWordListOption; } set { this.TestCollectionEndingWithWordListOption = new(value); } } /// /// Gets or Sets additional properties @@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? testCollectionEndingWithWordList = default; + Option?> testCollectionEndingWithWordList = default; while (utf8JsonReader.Read()) { @@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model { case "TestCollectionEndingWithWordList": if (utf8JsonReader.TokenType != JsonTokenType.Null) - testCollectionEndingWithWordList = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + testCollectionEndingWithWordList = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -131,8 +138,8 @@ namespace UseSourceGeneration.Model } } - if (testCollectionEndingWithWordList == null) - throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject."); return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList); } @@ -161,8 +168,14 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("TestCollectionEndingWithWordList"); - JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet) + { + writer.WritePropertyName("TestCollectionEndingWithWordList"); + JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index dd3c3ec026a..3c5aea9665a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model /// /// someProperty [JsonConstructor] - public TestInlineFreeformAdditionalPropertiesRequest(string someProperty) : base() + public TestInlineFreeformAdditionalPropertiesRequest(Option someProperty = default) : base() { - SomeProperty = someProperty; + SomePropertyOption = someProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SomeProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomePropertyOption { get; private set; } + /// /// Gets or Sets SomeProperty /// [JsonPropertyName("someProperty")] - public string SomeProperty { get; set; } + public string? SomeProperty { get { return this. SomePropertyOption; } set { this.SomePropertyOption = new(value); } } /// /// Gets or Sets additional properties @@ -115,7 +122,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? someProperty = default; + Option someProperty = default; while (utf8JsonReader.Read()) { @@ -133,7 +140,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "someProperty": - someProperty = utf8JsonReader.GetString(); + someProperty = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -141,8 +148,8 @@ namespace UseSourceGeneration.Model } } - if (someProperty == null) - throw new ArgumentNullException(nameof(someProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + if (someProperty.IsSet && someProperty.Value == null) + throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest."); return new TestInlineFreeformAdditionalPropertiesRequest(someProperty); } @@ -171,7 +178,11 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet) + writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Triangle.cs index bddcf663a29..93209579387 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Triangle.cs @@ -154,7 +154,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? triangleType = default; + Option triangleType = default; EquilateralTriangle? equilateralTriangle = null; IsoscelesTriangle? isoscelesTriangle = null; @@ -211,7 +211,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -219,17 +219,20 @@ namespace UseSourceGeneration.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class Triangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class Triangle.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType); + return new Triangle(equilateralTriangle, triangleType.Value!); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType); + return new Triangle(isoscelesTriangle, triangleType.Value!); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType); + return new Triangle(scaleneTriangle, triangleType.Value!); throw new JsonException(); } @@ -273,6 +276,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { + if (triangle.TriangleType == null) + throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); + writer.WriteString("triangleType", triangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TriangleInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TriangleInterface.cs index adc70c646cb..3e50cd4e326 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/TriangleInterface.cs @@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? triangleType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -130,10 +130,13 @@ namespace UseSourceGeneration.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class TriangleInterface."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class TriangleInterface.", nameof(triangleType)); - return new TriangleInterface(triangleType); + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class TriangleInterface."); + + return new TriangleInterface(triangleType.Value!); } /// @@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) { + if (triangleInterface.TriangleType == null) + throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface."); + writer.WriteString("triangleType", triangleInterface.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/User.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/User.cs index 684c3ff5a2e..c36799b77ed 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/User.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/User.cs @@ -35,114 +35,198 @@ namespace UseSourceGeneration.Model /// /// Initializes a new instance of the class. /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// email /// firstName /// id /// lastName /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// password /// phone /// User Status /// username - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonConstructor] - public User(string email, string firstName, long id, string lastName, Object objectWithNoDeclaredProps, string password, string phone, int userStatus, string username, Object? anyTypeProp = default, Object? anyTypePropNullable = default, Object? objectWithNoDeclaredPropsNullable = default) + public User(Option anyTypeProp = default, Option anyTypePropNullable = default, Option email = default, Option firstName = default, Option id = default, Option lastName = default, Option objectWithNoDeclaredProps = default, Option objectWithNoDeclaredPropsNullable = default, Option password = default, Option phone = default, Option userStatus = default, Option username = default) { - Email = email; - FirstName = firstName; - Id = id; - LastName = lastName; - ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - Password = password; - Phone = phone; - UserStatus = userStatus; - Username = username; - AnyTypeProp = anyTypeProp; - AnyTypePropNullable = anyTypePropNullable; - ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypePropOption = anyTypeProp; + AnyTypePropNullableOption = anyTypePropNullable; + EmailOption = email; + FirstNameOption = firstName; + IdOption = id; + LastNameOption = lastName; + ObjectWithNoDeclaredPropsOption = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullableOption = objectWithNoDeclaredPropsNullable; + PasswordOption = password; + PhoneOption = phone; + UserStatusOption = userStatus; + UsernameOption = username; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets Email + /// Used to track the state of AnyTypeProp /// - [JsonPropertyName("email")] - public string Email { get; set; } - - /// - /// Gets or Sets FirstName - /// - [JsonPropertyName("firstName")] - public string FirstName { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } - - /// - /// Gets or Sets LastName - /// - [JsonPropertyName("lastName")] - public string LastName { get; set; } - - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [JsonPropertyName("objectWithNoDeclaredProps")] - public Object ObjectWithNoDeclaredProps { get; set; } - - /// - /// Gets or Sets Password - /// - [JsonPropertyName("password")] - public string Password { get; set; } - - /// - /// Gets or Sets Phone - /// - [JsonPropertyName("phone")] - public string Phone { get; set; } - - /// - /// User Status - /// - /// User Status - [JsonPropertyName("userStatus")] - public int UserStatus { get; set; } - - /// - /// Gets or Sets Username - /// - [JsonPropertyName("username")] - public string Username { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 [JsonPropertyName("anyTypeProp")] - public Object? AnyTypeProp { get; set; } + public Object? AnyTypeProp { get { return this. AnyTypePropOption; } set { this.AnyTypePropOption = new(value); } } + + /// + /// Used to track the state of AnyTypePropNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropNullableOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. [JsonPropertyName("anyTypePropNullable")] - public Object? AnyTypePropNullable { get; set; } + public Object? AnyTypePropNullable { get { return this. AnyTypePropNullableOption; } set { this.AnyTypePropNullableOption = new(value); } } + + /// + /// Used to track the state of Email + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmailOption { get; private set; } + + /// + /// Gets or Sets Email + /// + [JsonPropertyName("email")] + public string? Email { get { return this. EmailOption; } set { this.EmailOption = new(value); } } + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string? FirstName { get { return this. FirstNameOption; } set { this.FirstNameOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string? LastName { get { return this. LastNameOption; } set { this.LastNameOption = new(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredProps + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsOption { get; private set; } + + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + [JsonPropertyName("objectWithNoDeclaredProps")] + public Object? ObjectWithNoDeclaredProps { get { return this. ObjectWithNoDeclaredPropsOption; } set { this.ObjectWithNoDeclaredPropsOption = new(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredPropsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsNullableOption { get; private set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonPropertyName("objectWithNoDeclaredPropsNullable")] - public Object? ObjectWithNoDeclaredPropsNullable { get; set; } + public Object? ObjectWithNoDeclaredPropsNullable { get { return this. ObjectWithNoDeclaredPropsNullableOption; } set { this.ObjectWithNoDeclaredPropsNullableOption = new(value); } } + + /// + /// Used to track the state of Password + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PasswordOption { get; private set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string? Password { get { return this. PasswordOption; } set { this.PasswordOption = new(value); } } + + /// + /// Used to track the state of Phone + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PhoneOption { get; private set; } + + /// + /// Gets or Sets Phone + /// + [JsonPropertyName("phone")] + public string? Phone { get { return this. PhoneOption; } set { this.PhoneOption = new(value); } } + + /// + /// Used to track the state of UserStatus + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UserStatusOption { get; private set; } + + /// + /// User Status + /// + /// User Status + [JsonPropertyName("userStatus")] + public int? UserStatus { get { return this. UserStatusOption; } set { this.UserStatusOption = new(value); } } + + /// + /// Used to track the state of Username + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UsernameOption { get; private set; } + + /// + /// Gets or Sets Username + /// + [JsonPropertyName("username")] + public string? Username { get { return this. UsernameOption; } set { this.UsernameOption = new(value); } } /// /// Gets or Sets additional properties @@ -158,18 +242,18 @@ namespace UseSourceGeneration.Model { StringBuilder sb = new StringBuilder(); sb.Append("class User {\n"); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); sb.Append(" Email: ").Append(Email).Append("\n"); sb.Append(" FirstName: ").Append(FirstName).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" LastName: ").Append(LastName).Append("\n"); sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" Phone: ").Append(Phone).Append("\n"); sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); sb.Append(" Username: ").Append(Username).Append("\n"); - sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); - sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); - sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -208,18 +292,18 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? email = default; - string? firstName = default; - long? id = default; - string? lastName = default; - Object? objectWithNoDeclaredProps = default; - string? password = default; - string? phone = default; - int? userStatus = default; - string? username = default; - Object? anyTypeProp = default; - Object? anyTypePropNullable = default; - Object? objectWithNoDeclaredPropsNullable = default; + Option anyTypeProp = default; + Option anyTypePropNullable = default; + Option email = default; + Option firstName = default; + Option id = default; + Option lastName = default; + Option objectWithNoDeclaredProps = default; + Option objectWithNoDeclaredPropsNullable = default; + Option password = default; + Option phone = default; + Option userStatus = default; + Option username = default; while (utf8JsonReader.Read()) { @@ -236,47 +320,47 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { - case "email": - email = utf8JsonReader.GetString(); - break; - case "firstName": - firstName = utf8JsonReader.GetString(); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; - case "lastName": - lastName = utf8JsonReader.GetString(); - break; - case "objectWithNoDeclaredProps": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredProps = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "password": - password = utf8JsonReader.GetString(); - break; - case "phone": - phone = utf8JsonReader.GetString(); - break; - case "userStatus": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - userStatus = utf8JsonReader.GetInt32(); - break; - case "username": - username = utf8JsonReader.GetString(); - break; case "anyTypeProp": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "anyTypePropNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypePropNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypePropNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "email": + email = new Option(utf8JsonReader.GetString()!); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()!); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()!); + break; + case "objectWithNoDeclaredProps": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredProps = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "objectWithNoDeclaredPropsNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredPropsNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + objectWithNoDeclaredPropsNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "password": + password = new Option(utf8JsonReader.GetString()!); + break; + case "phone": + phone = new Option(utf8JsonReader.GetString()!); + break; + case "userStatus": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + userStatus = new Option(utf8JsonReader.GetInt32()); + break; + case "username": + username = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -284,34 +368,34 @@ namespace UseSourceGeneration.Model } } - if (email == null) - throw new ArgumentNullException(nameof(email), "Property is required for class User."); + if (email.IsSet && email.Value == null) + throw new ArgumentNullException(nameof(email), "Property is not nullable for class User."); - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class User."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class User."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class User."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class User."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User."); - if (objectWithNoDeclaredProps == null) - throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is required for class User."); + if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null) + throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class User."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class User."); - if (phone == null) - throw new ArgumentNullException(nameof(phone), "Property is required for class User."); + if (phone.IsSet && phone.Value == null) + throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User."); - if (userStatus == null) - throw new ArgumentNullException(nameof(userStatus), "Property is required for class User."); + if (userStatus.IsSet && userStatus.Value == null) + throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User."); - if (username == null) - throw new ArgumentNullException(nameof(username), "Property is required for class User."); + if (username.IsSet && username.Value == null) + throw new ArgumentNullException(nameof(username), "Property is not nullable for class User."); - return new User(email, firstName, id.Value, lastName, objectWithNoDeclaredProps, password, phone, userStatus.Value, username, anyTypeProp, anyTypePropNullable, objectWithNoDeclaredPropsNullable); + return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username); } /// @@ -338,22 +422,79 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("email", user.Email); - writer.WriteString("firstName", user.FirstName); - writer.WriteNumber("id", user.Id); - writer.WriteString("lastName", user.LastName); - writer.WritePropertyName("objectWithNoDeclaredProps"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); - writer.WriteString("password", user.Password); - writer.WriteString("phone", user.Phone); - writer.WriteNumber("userStatus", user.UserStatus); - writer.WriteString("username", user.Username); - writer.WritePropertyName("anyTypeProp"); - JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); - writer.WritePropertyName("anyTypePropNullable"); - JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); - writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + if (user.EmailOption.IsSet && user.Email == null) + throw new ArgumentNullException(nameof(user.Email), "Property is required for class User."); + + if (user.FirstNameOption.IsSet && user.FirstName == null) + throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User."); + + if (user.LastNameOption.IsSet && user.LastName == null) + throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User."); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null) + throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User."); + + if (user.PasswordOption.IsSet && user.Password == null) + throw new ArgumentNullException(nameof(user.Password), "Property is required for class User."); + + if (user.PhoneOption.IsSet && user.Phone == null) + throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User."); + + if (user.UsernameOption.IsSet && user.Username == null) + throw new ArgumentNullException(nameof(user.Username), "Property is required for class User."); + + if (user.AnyTypePropOption.IsSet) + if (user.AnyTypePropOption.Value != null) + { + writer.WritePropertyName("anyTypeProp"); + JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypeProp"); + if (user.AnyTypePropNullableOption.IsSet) + if (user.AnyTypePropNullableOption.Value != null) + { + writer.WritePropertyName("anyTypePropNullable"); + JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypePropNullable"); + if (user.EmailOption.IsSet) + writer.WriteString("email", user.Email); + + if (user.FirstNameOption.IsSet) + writer.WriteString("firstName", user.FirstName); + + if (user.IdOption.IsSet) + writer.WriteNumber("id", user.IdOption.Value!.Value); + + if (user.LastNameOption.IsSet) + writer.WriteString("lastName", user.LastName); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet) + { + writer.WritePropertyName("objectWithNoDeclaredProps"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); + } + if (user.ObjectWithNoDeclaredPropsNullableOption.IsSet) + if (user.ObjectWithNoDeclaredPropsNullableOption.Value != null) + { + writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + } + else + writer.WriteNull("objectWithNoDeclaredPropsNullable"); + if (user.PasswordOption.IsSet) + writer.WriteString("password", user.Password); + + if (user.PhoneOption.IsSet) + writer.WriteString("phone", user.Phone); + + if (user.UserStatusOption.IsSet) + writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value); + + if (user.UsernameOption.IsSet) + writer.WriteString("username", user.Username); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Whale.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Whale.cs index 7d320ced8bb..40f40250f50 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Whale.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Whale.cs @@ -39,11 +39,11 @@ namespace UseSourceGeneration.Model /// hasBaleen /// hasTeeth [JsonConstructor] - public Whale(string className, bool hasBaleen, bool hasTeeth) + public Whale(string className, Option hasBaleen = default, Option hasTeeth = default) { ClassName = className; - HasBaleen = hasBaleen; - HasTeeth = hasTeeth; + HasBaleenOption = hasBaleen; + HasTeethOption = hasTeeth; OnCreated(); } @@ -55,17 +55,31 @@ namespace UseSourceGeneration.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of HasBaleen + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasBaleenOption { get; private set; } + /// /// Gets or Sets HasBaleen /// [JsonPropertyName("hasBaleen")] - public bool HasBaleen { get; set; } + public bool? HasBaleen { get { return this. HasBaleenOption; } set { this.HasBaleenOption = new(value); } } + + /// + /// Used to track the state of HasTeeth + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasTeethOption { get; private set; } /// /// Gets or Sets HasTeeth /// [JsonPropertyName("hasTeeth")] - public bool HasTeeth { get; set; } + public bool? HasTeeth { get { return this. HasTeethOption; } set { this.HasTeethOption = new(value); } } /// /// Gets or Sets additional properties @@ -122,9 +136,9 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - bool? hasBaleen = default; - bool? hasTeeth = default; + Option className = default; + Option hasBaleen = default; + Option hasTeeth = default; while (utf8JsonReader.Read()) { @@ -142,15 +156,15 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; case "hasBaleen": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasBaleen = utf8JsonReader.GetBoolean(); + hasBaleen = new Option(utf8JsonReader.GetBoolean()); break; case "hasTeeth": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasTeeth = utf8JsonReader.GetBoolean(); + hasTeeth = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -158,16 +172,19 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Whale."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Whale.", nameof(className)); - if (hasBaleen == null) - throw new ArgumentNullException(nameof(hasBaleen), "Property is required for class Whale."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale."); - if (hasTeeth == null) - throw new ArgumentNullException(nameof(hasTeeth), "Property is required for class Whale."); + if (hasBaleen.IsSet && hasBaleen.Value == null) + throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale."); - return new Whale(className, hasBaleen.Value, hasTeeth.Value); + if (hasTeeth.IsSet && hasTeeth.Value == null) + throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale."); + + return new Whale(className.Value!, hasBaleen, hasTeeth); } /// @@ -194,9 +211,16 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) { + if (whale.ClassName == null) + throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale."); + writer.WriteString("className", whale.ClassName); - writer.WriteBoolean("hasBaleen", whale.HasBaleen); - writer.WriteBoolean("hasTeeth", whale.HasTeeth); + + if (whale.HasBaleenOption.IsSet) + writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value); + + if (whale.HasTeethOption.IsSet) + writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs index 05aa8852c98..5e5d680c221 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs @@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model /// className /// type [JsonConstructor] - public Zebra(string className, TypeEnum type) : base() + public Zebra(string className, Option type = default) : base() { ClassName = className; - Type = type; + TypeOption = type; OnCreated(); } @@ -113,9 +113,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string TypeEnumToJsonValue(TypeEnum value) + public static string TypeEnumToJsonValue(TypeEnum? value) { - if (value == TypeEnum.Plains) return "plains"; @@ -128,11 +127,18 @@ namespace UseSourceGeneration.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public TypeEnum Type { get; set; } + public TypeEnum? Type { get { return this.TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets ClassName @@ -205,8 +211,8 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - Zebra.TypeEnum? type = default; + Option className = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -224,13 +230,12 @@ namespace UseSourceGeneration.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; case "type": string? typeRawValue = utf8JsonReader.GetString(); - type = typeRawValue == null - ? null - : Zebra.TypeEnumFromStringOrDefault(typeRawValue); + if (typeRawValue != null) + type = new Option(Zebra.TypeEnumFromStringOrDefault(typeRawValue)); break; default: break; @@ -238,13 +243,16 @@ namespace UseSourceGeneration.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Zebra."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Zebra.", nameof(className)); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Zebra."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra."); - return new Zebra(className, type.Value); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra."); + + return new Zebra(className.Value!, type); } /// @@ -271,9 +279,12 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) { + if (zebra.ClassName == null) + throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra."); + writer.WriteString("className", zebra.ClassName); - var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.Type); + var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value!.Value); if (typeRawValue != null) writer.WriteString("type", typeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs index 4240d64e5bd..57bf9caf969 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs @@ -37,9 +37,9 @@ namespace UseSourceGeneration.Model /// /// zeroBasedEnum [JsonConstructor] - public ZeroBasedEnumClass(ZeroBasedEnumEnum zeroBasedEnum) + public ZeroBasedEnumClass(Option zeroBasedEnum = default) { - ZeroBasedEnum = zeroBasedEnum; + ZeroBasedEnumOption = zeroBasedEnum; OnCreated(); } @@ -100,9 +100,8 @@ namespace UseSourceGeneration.Model /// /// /// - public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum value) + public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum? value) { - if (value == ZeroBasedEnumEnum.Unknown) return "unknown"; @@ -112,11 +111,18 @@ namespace UseSourceGeneration.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of ZeroBasedEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ZeroBasedEnumOption { get; private set; } + /// /// Gets or Sets ZeroBasedEnum /// [JsonPropertyName("ZeroBasedEnum")] - public ZeroBasedEnumEnum ZeroBasedEnum { get; set; } + public ZeroBasedEnumEnum? ZeroBasedEnum { get { return this.ZeroBasedEnumOption; } set { this.ZeroBasedEnumOption = new(value); } } /// /// Gets or Sets additional properties @@ -171,7 +177,7 @@ namespace UseSourceGeneration.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - ZeroBasedEnumClass.ZeroBasedEnumEnum? zeroBasedEnum = default; + Option zeroBasedEnum = default; while (utf8JsonReader.Read()) { @@ -190,9 +196,8 @@ namespace UseSourceGeneration.Model { case "ZeroBasedEnum": string? zeroBasedEnumRawValue = utf8JsonReader.GetString(); - zeroBasedEnum = zeroBasedEnumRawValue == null - ? null - : ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue); + if (zeroBasedEnumRawValue != null) + zeroBasedEnum = new Option(ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue)); break; default: break; @@ -200,10 +205,10 @@ namespace UseSourceGeneration.Model } } - if (zeroBasedEnum == null) - throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is required for class ZeroBasedEnumClass."); + if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null) + throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass."); - return new ZeroBasedEnumClass(zeroBasedEnum.Value); + return new ZeroBasedEnumClass(zeroBasedEnum); } /// @@ -230,8 +235,7 @@ namespace UseSourceGeneration.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) { - - var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnum); + var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value); if (zeroBasedEnumRawValue != null) writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES index 1179de6767b..05049077c2a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES @@ -79,6 +79,7 @@ docs/models/PolymorphicProperty.md docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md +docs/models/RequiredClass.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -206,6 +207,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/AdditionalPropertiesClass.md index f79869f95a7..2bbe882fcfc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/AdditionalPropertiesClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/AdditionalPropertiesClass.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Anytype1** | **Object** | | [optional] **EmptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] **MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] **MapProperty** | **Dictionary<string, string>** | | [optional] @@ -11,7 +12,6 @@ Name | Type | Description | Notes **MapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional] **MapWithUndeclaredPropertiesAnytype3** | **Dictionary<string, Object>** | | [optional] **MapWithUndeclaredPropertiesString** | **Dictionary<string, string>** | | [optional] -**Anytype1** | **Object** | | [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/docs/models/Drawing.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Drawing.md index 215793515f6..95f49b2ed60 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Drawing.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Drawing.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **MainShape** | [**Shape**](Shape.md) | | [optional] -**Shapes** | [**List<Shape>**](Shape.md) | | [optional] **NullableShape** | [**NullableShape**](NullableShape.md) | | [optional] **ShapeOrNull** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] +**Shapes** | [**List<Shape>**](Shape.md) | | [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/docs/models/EnumTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/EnumTest.md index 53bbfe31e77..ebd7ccf2c86 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/EnumTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/EnumTest.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] **EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **EnumString** | **string** | | [optional] -**EnumStringRequired** | **string** | | +**OuterEnum** | **OuterEnum** | | [optional] **OuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] **OuterEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional] -**OuterEnum** | **OuterEnum** | | [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/docs/models/FormatTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/FormatTest.md index 28f1a809358..ab628ed7bc0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/FormatTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/FormatTest.md @@ -4,9 +4,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Binary** | **System.IO.Stream** | | [optional] **VarByte** | **byte[]** | | **Date** | **DateTime** | | +**Number** | **decimal** | | +**Password** | **string** | | +**Binary** | **System.IO.Stream** | | [optional] **DateTime** | **DateTime** | | [optional] **VarDecimal** | **decimal** | | [optional] **VarDouble** | **double** | | [optional] @@ -14,8 +16,6 @@ Name | Type | Description | Notes **Int32** | **int** | | [optional] **Int64** | **long** | | [optional] **Integer** | **int** | | [optional] -**Number** | **decimal** | | -**Password** | **string** | | **PatternWithBackslash** | **string** | None | [optional] **PatternWithDigits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional] **PatternWithDigitsAndDelimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableClass.md index 394feef77db..5d9965f55c0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableClass.md @@ -4,9 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ArrayItemsNullable** | **List<Object>** | | [optional] -**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ArrayAndItemsNullableProp** | **List<Object>** | | [optional] +**ArrayItemsNullable** | **List<Object>** | | [optional] **ArrayNullableProp** | **List<Object>** | | [optional] **BooleanProp** | **bool** | | [optional] **DateProp** | **DateTime** | | [optional] @@ -14,6 +13,7 @@ Name | Type | Description | Notes **IntegerProp** | **int** | | [optional] **NumberProp** | **decimal** | | [optional] **ObjectAndItemsNullableProp** | **Dictionary<string, Object>** | | [optional] +**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ObjectNullableProp** | **Dictionary<string, Object>** | | [optional] **StringProp** | **string** | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Order.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Order.md index ca5d8992a51..f7d6827ed5c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Order.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Order.md @@ -4,12 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Complete** | **bool** | | [optional] [default to false] **Id** | **long** | | [optional] **PetId** | **long** | | [optional] **Quantity** | **int** | | [optional] **ShipDate** | **DateTime** | | [optional] **Status** | **string** | Order Status | [optional] -**Complete** | **bool** | | [optional] [default to false] [[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/docs/models/Pet.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pet.md index b13bb576b45..4f019b613bd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pet.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pet.md @@ -4,10 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Category** | [**Category**](Category.md) | | [optional] -**Id** | **long** | | [optional] **Name** | **string** | | **PhotoUrls** | **List<string>** | | +**Category** | [**Category**](Category.md) | | [optional] +**Id** | **long** | | [optional] **Status** | **string** | pet status in the store | [optional] **Tags** | [**List<Tag>**](Tag.md) | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/RequiredClass.md new file mode 100644 index 00000000000..8f148be840b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNotNullableDateProp** | **DateTime** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNotnullableEnumInteger** | **int** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**RequiredNotnullableEnumString** | **string** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableStringProp** | **string** | | +**RequiredNotnullableUuid** | **Guid** | | +**RequiredNotnullableintegerProp** | **int** | | +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNullableBooleanProp** | **bool** | | +**RequiredNullableDateProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime** | | +**RequiredNullableEnumInteger** | **int** | | +**RequiredNullableEnumIntegerOnly** | **int** | | +**RequiredNullableEnumString** | **string** | | +**RequiredNullableIntegerProp** | **int** | | +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNullableStringProp** | **string** | | +**RequiredNullableUuid** | **Guid** | | +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**NotRequiredNullableDateProp** | **DateTime** | | [optional] +**NotRequiredNullableIntegerProp** | **int** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNullableBooleanProp** | **bool** | | [optional] +**NotrequiredNullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNullableEnumInteger** | **int** | | [optional] +**NotrequiredNullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNullableUuid** | **Guid** | | [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/docs/models/User.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/User.md index 455f031674d..b5700f1c75d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/User.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/User.md @@ -4,18 +4,18 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] +**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] **Email** | **string** | | [optional] **FirstName** | **string** | | [optional] **Id** | **long** | | [optional] **LastName** | **string** | | [optional] **ObjectWithNoDeclaredProps** | **Object** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional] +**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] **Password** | **string** | | [optional] **Phone** | **string** | | [optional] **UserStatus** | **int** | User Status | [optional] **Username** | **string** | | [optional] -**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] -**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] -**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [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/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..6e8958b1b74 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,452 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs index ec7ac60448e..e37ccad5913 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -143,6 +143,8 @@ namespace Org.OpenAPITools.Client return EnumArrays.JustSymbolEnumToJsonValue(enumArraysJustSymbolEnum); if (obj is EnumClass enumClass) return EnumClassValueConverter.ToJsonValue(enumClass); + if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) + return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is EnumTest.EnumIntegerEnum enumTestEnumIntegerEnum) return EnumTest.EnumIntegerEnumToJsonValue(enumTestEnumIntegerEnum).ToString(); if (obj is EnumTest.EnumIntegerOnlyEnum enumTestEnumIntegerOnlyEnum) @@ -151,8 +153,6 @@ namespace Org.OpenAPITools.Client return EnumTest.EnumNumberEnumToJsonValue(enumTestEnumNumberEnum).ToString(); if (obj is EnumTest.EnumStringEnum enumTestEnumStringEnum) return EnumTest.EnumStringEnumToJsonValue(enumTestEnumStringEnum); - if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) - return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is MapTest.InnerEnum mapTestInnerEnum) return MapTest.InnerEnumToJsonValue(mapTestInnerEnum); if (obj is Order.StatusEnum orderStatusEnum) @@ -169,6 +169,30 @@ namespace Org.OpenAPITools.Client return OuterEnumTestValueConverter.ToJsonValue(outerEnumTest); if (obj is Pet.StatusEnum petStatusEnum) return Pet.StatusEnumToJsonValue(petStatusEnum); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerEnum requiredClassRequiredNotnullableEnumIntegerEnum) + return RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum requiredClassRequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumStringEnum requiredClassRequiredNotnullableEnumStringEnum) + return RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClassRequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.RequiredNullableEnumIntegerEnum requiredClassRequiredNullableEnumIntegerEnum) + return RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClassRequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumIntegerOnlyEnum requiredClassRequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) + return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerEnum requiredClassNotrequiredNotnullableEnumIntegerEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumStringEnum requiredClassNotrequiredNotnullableEnumStringEnum) + return RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClassNotrequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerEnum requiredClassNotrequiredNullableEnumIntegerEnum) + return RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum requiredClassNotrequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumStringEnum requiredClassNotrequiredNullableEnumStringEnum) + return RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClassNotrequiredNullableEnumStringEnum); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs index 968417a9e74..a26741d84b7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -116,6 +116,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/Option.cs index 7aa655c9b81..e6fd1c26872 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/Option.cs @@ -37,5 +37,17 @@ namespace Org.OpenAPITools.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs index 22464eec75f..c96ec917c52 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Activity.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// activityOutputs [JsonConstructor] - public Activity(Dictionary> activityOutputs) + public Activity(Option>?> activityOutputs = default) { - ActivityOutputs = activityOutputs; + ActivityOutputsOption = activityOutputs; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ActivityOutputs + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ActivityOutputsOption { get; private set; } + /// /// Gets or Sets ActivityOutputs /// [JsonPropertyName("activity_outputs")] - public Dictionary> ActivityOutputs { get; set; } + public Dictionary>? ActivityOutputs { get { return this. ActivityOutputsOption; } set { this.ActivityOutputsOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary>? activityOutputs = default; + Option>?> activityOutputs = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "activity_outputs": if (utf8JsonReader.TokenType != JsonTokenType.Null) - activityOutputs = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + activityOutputs = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -129,8 +137,8 @@ namespace Org.OpenAPITools.Model } } - if (activityOutputs == null) - throw new ArgumentNullException(nameof(activityOutputs), "Property is required for class Activity."); + if (activityOutputs.IsSet && activityOutputs.Value == null) + throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity."); return new Activity(activityOutputs); } @@ -159,8 +167,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("activity_outputs"); - JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null) + throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity."); + + if (activity.ActivityOutputsOption.IsSet) + { + writer.WritePropertyName("activity_outputs"); + JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index 39c2e8b05e6..78bdf9d3aba 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// prop1 /// prop2 [JsonConstructor] - public ActivityOutputElementRepresentation(string prop1, Object prop2) + public ActivityOutputElementRepresentation(Option prop1 = default, Option prop2 = default) { - Prop1 = prop1; - Prop2 = prop2; + Prop1Option = prop1; + Prop2Option = prop2; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Prop1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop1Option { get; private set; } + /// /// Gets or Sets Prop1 /// [JsonPropertyName("prop1")] - public string Prop1 { get; set; } + public string? Prop1 { get { return this. Prop1Option; } set { this.Prop1Option = new(value); } } + + /// + /// Used to track the state of Prop2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop2Option { get; private set; } /// /// Gets or Sets Prop2 /// [JsonPropertyName("prop2")] - public Object Prop2 { get; set; } + public Object? Prop2 { get { return this. Prop2Option; } set { this.Prop2Option = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? prop1 = default; - Object? prop2 = default; + Option prop1 = default; + Option prop2 = default; while (utf8JsonReader.Read()) { @@ -130,11 +145,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "prop1": - prop1 = utf8JsonReader.GetString(); + prop1 = new Option(utf8JsonReader.GetString()!); break; case "prop2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - prop2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + prop2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -142,11 +157,11 @@ namespace Org.OpenAPITools.Model } } - if (prop1 == null) - throw new ArgumentNullException(nameof(prop1), "Property is required for class ActivityOutputElementRepresentation."); + if (prop1.IsSet && prop1.Value == null) + throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation."); - if (prop2 == null) - throw new ArgumentNullException(nameof(prop2), "Property is required for class ActivityOutputElementRepresentation."); + if (prop2.IsSet && prop2.Value == null) + throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation."); return new ActivityOutputElementRepresentation(prop1, prop2); } @@ -175,9 +190,20 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); - writer.WritePropertyName("prop2"); - JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop1Option.IsSet) + writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); + + if (activityOutputElementRepresentation.Prop2Option.IsSet) + { + writer.WritePropertyName("prop2"); + JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 37ab8b4f3b4..d373bc67722 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,6 +34,7 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// anytype1 /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// mapOfMapProperty /// mapProperty @@ -40,71 +42,126 @@ namespace Org.OpenAPITools.Model /// mapWithUndeclaredPropertiesAnytype2 /// mapWithUndeclaredPropertiesAnytype3 /// mapWithUndeclaredPropertiesString - /// anytype1 [JsonConstructor] - public AdditionalPropertiesClass(Object emptyMap, Dictionary> mapOfMapProperty, Dictionary mapProperty, Object mapWithUndeclaredPropertiesAnytype1, Object mapWithUndeclaredPropertiesAnytype2, Dictionary mapWithUndeclaredPropertiesAnytype3, Dictionary mapWithUndeclaredPropertiesString, Object? anytype1 = default) + public AdditionalPropertiesClass(Option anytype1 = default, Option emptyMap = default, Option>?> mapOfMapProperty = default, Option?> mapProperty = default, Option mapWithUndeclaredPropertiesAnytype1 = default, Option mapWithUndeclaredPropertiesAnytype2 = default, Option?> mapWithUndeclaredPropertiesAnytype3 = default, Option?> mapWithUndeclaredPropertiesString = default) { - EmptyMap = emptyMap; - MapOfMapProperty = mapOfMapProperty; - MapProperty = mapProperty; - MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - Anytype1 = anytype1; + Anytype1Option = anytype1; + EmptyMapOption = emptyMap; + MapOfMapPropertyOption = mapOfMapProperty; + MapPropertyOption = mapProperty; + MapWithUndeclaredPropertiesAnytype1Option = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2Option = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3Option = mapWithUndeclaredPropertiesAnytype3; + MapWithUndeclaredPropertiesStringOption = mapWithUndeclaredPropertiesString; OnCreated(); } partial void OnCreated(); /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// Used to track the state of Anytype1 /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [JsonPropertyName("empty_map")] - public Object EmptyMap { get; set; } - - /// - /// Gets or Sets MapOfMapProperty - /// - [JsonPropertyName("map_of_map_property")] - public Dictionary> MapOfMapProperty { get; set; } - - /// - /// Gets or Sets MapProperty - /// - [JsonPropertyName("map_property")] - public Dictionary MapProperty { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_1")] - public Object MapWithUndeclaredPropertiesAnytype1 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_2")] - public Object MapWithUndeclaredPropertiesAnytype2 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_3")] - public Dictionary MapWithUndeclaredPropertiesAnytype3 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesString - /// - [JsonPropertyName("map_with_undeclared_properties_string")] - public Dictionary MapWithUndeclaredPropertiesString { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Anytype1Option { get; private set; } /// /// Gets or Sets Anytype1 /// [JsonPropertyName("anytype_1")] - public Object? Anytype1 { get; set; } + public Object? Anytype1 { get { return this. Anytype1Option; } set { this.Anytype1Option = new(value); } } + + /// + /// Used to track the state of EmptyMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmptyMapOption { get; private set; } + + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + [JsonPropertyName("empty_map")] + public Object? EmptyMap { get { return this. EmptyMapOption; } set { this.EmptyMapOption = new(value); } } + + /// + /// Used to track the state of MapOfMapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> MapOfMapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [JsonPropertyName("map_of_map_property")] + public Dictionary>? MapOfMapProperty { get { return this. MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new(value); } } + + /// + /// Used to track the state of MapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapProperty + /// + [JsonPropertyName("map_property")] + public Dictionary? MapProperty { get { return this. MapPropertyOption; } set { this.MapPropertyOption = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype1Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] + public Object? MapWithUndeclaredPropertiesAnytype1 { get { return this. MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype2Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] + public Object? MapWithUndeclaredPropertiesAnytype2 { get { return this. MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype3 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapWithUndeclaredPropertiesAnytype3Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] + public Dictionary? MapWithUndeclaredPropertiesAnytype3 { get { return this. MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapWithUndeclaredPropertiesStringOption { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesString + /// + [JsonPropertyName("map_with_undeclared_properties_string")] + public Dictionary? MapWithUndeclaredPropertiesString { get { return this. MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -120,6 +177,7 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); @@ -127,7 +185,6 @@ namespace Org.OpenAPITools.Model sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); - sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -166,14 +223,14 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Object? emptyMap = default; - Dictionary>? mapOfMapProperty = default; - Dictionary? mapProperty = default; - Object? mapWithUndeclaredPropertiesAnytype1 = default; - Object? mapWithUndeclaredPropertiesAnytype2 = default; - Dictionary? mapWithUndeclaredPropertiesAnytype3 = default; - Dictionary? mapWithUndeclaredPropertiesString = default; - Object? anytype1 = default; + Option anytype1 = default; + Option emptyMap = default; + Option>?> mapOfMapProperty = default; + Option?> mapProperty = default; + Option mapWithUndeclaredPropertiesAnytype1 = default; + Option mapWithUndeclaredPropertiesAnytype2 = default; + Option?> mapWithUndeclaredPropertiesAnytype3 = default; + Option?> mapWithUndeclaredPropertiesString = default; while (utf8JsonReader.Read()) { @@ -190,37 +247,37 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; case "empty_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - emptyMap = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + emptyMap = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_of_map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfMapProperty = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapOfMapProperty = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapProperty = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapProperty = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_anytype_1": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_anytype_2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_anytype_3": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype3 = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype3 = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_with_undeclared_properties_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "anytype_1": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - anytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -228,28 +285,28 @@ namespace Org.OpenAPITools.Model } } - if (emptyMap == null) - throw new ArgumentNullException(nameof(emptyMap), "Property is required for class AdditionalPropertiesClass."); + if (emptyMap.IsSet && emptyMap.Value == null) + throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapOfMapProperty == null) - throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null) + throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapProperty == null) - throw new ArgumentNullException(nameof(mapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapProperty.IsSet && mapProperty.Value == null) + throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype1 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype2 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype3 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesString == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass."); - return new AdditionalPropertiesClass(emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString, anytype1); + return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString); } /// @@ -276,22 +333,70 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("empty_map"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); - writer.WritePropertyName("map_of_map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_string"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); - writer.WritePropertyName("anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.Anytype1Option.IsSet) + if (additionalPropertiesClass.Anytype1Option.Value != null) + { + writer.WritePropertyName("anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + } + else + writer.WriteNull("anytype_1"); + if (additionalPropertiesClass.EmptyMapOption.IsSet) + { + writer.WritePropertyName("empty_map"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet) + { + writer.WritePropertyName("map_of_map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapPropertyOption.IsSet) + { + writer.WritePropertyName("map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_string"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs index dd36cad8328..10b1c44a8c0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,10 +37,10 @@ namespace Org.OpenAPITools.Model /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, string color = @"red") + public Animal(string className, Option color = default) { ClassName = className; - Color = color; + ColorOption = color; OnCreated(); } @@ -51,11 +52,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Gets or Sets additional properties @@ -121,8 +129,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - string? color = default; + Option className = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -140,10 +148,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -151,13 +159,16 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Animal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Animal.", nameof(className)); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Animal."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal."); - return new Animal(className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); + + return new Animal(className.Value!, color); } /// @@ -184,8 +195,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { + if (animal.ClassName == null) + throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); + + if (animal.ColorOption.IsSet && animal.Color == null) + throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); + writer.WriteString("className", animal.ClassName); - writer.WriteString("color", animal.Color); + + if (animal.ColorOption.IsSet) + writer.WriteString("color", animal.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs index a9e4c983c62..844d79e43e1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -37,33 +38,54 @@ namespace Org.OpenAPITools.Model /// message /// type [JsonConstructor] - public ApiResponse(int code, string message, string type) + public ApiResponse(Option code = default, Option message = default, Option type = default) { - Code = code; - Message = message; - Type = type; + CodeOption = code; + MessageOption = message; + TypeOption = type; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + /// /// Gets or Sets Code /// [JsonPropertyName("code")] - public int Code { get; set; } + public int? Code { get { return this. CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Message + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MessageOption { get; private set; } /// /// Gets or Sets Message /// [JsonPropertyName("message")] - public string Message { get; set; } + public string? Message { get { return this. MessageOption; } set { this.MessageOption = new(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public string Type { get; set; } + public string? Type { get { return this. TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets additional properties @@ -120,9 +142,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? code = default; - string? message = default; - string? type = default; + Option code = default; + Option message = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -141,13 +163,13 @@ namespace Org.OpenAPITools.Model { case "code": if (utf8JsonReader.TokenType != JsonTokenType.Null) - code = utf8JsonReader.GetInt32(); + code = new Option(utf8JsonReader.GetInt32()); break; case "message": - message = utf8JsonReader.GetString(); + message = new Option(utf8JsonReader.GetString()!); break; case "type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -155,16 +177,16 @@ namespace Org.OpenAPITools.Model } } - if (code == null) - throw new ArgumentNullException(nameof(code), "Property is required for class ApiResponse."); + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse."); - if (message == null) - throw new ArgumentNullException(nameof(message), "Property is required for class ApiResponse."); + if (message.IsSet && message.Value == null) + throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class ApiResponse."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse."); - return new ApiResponse(code.Value, message, type); + return new ApiResponse(code, message, type); } /// @@ -191,9 +213,20 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("code", apiResponse.Code); - writer.WriteString("message", apiResponse.Message); - writer.WriteString("type", apiResponse.Type); + if (apiResponse.MessageOption.IsSet && apiResponse.Message == null) + throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse."); + + if (apiResponse.TypeOption.IsSet && apiResponse.Type == null) + throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse."); + + if (apiResponse.CodeOption.IsSet) + writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value); + + if (apiResponse.MessageOption.IsSet) + writer.WriteString("message", apiResponse.Message); + + if (apiResponse.TypeOption.IsSet) + writer.WriteString("type", apiResponse.Type); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs index 39c4ddd6c25..d50ea4406a0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -37,33 +38,54 @@ namespace Org.OpenAPITools.Model /// cultivar /// origin [JsonConstructor] - public Apple(string colorCode, string cultivar, string origin) + public Apple(Option colorCode = default, Option cultivar = default, Option origin = default) { - ColorCode = colorCode; - Cultivar = cultivar; - Origin = origin; + ColorCodeOption = colorCode; + CultivarOption = cultivar; + OriginOption = origin; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ColorCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorCodeOption { get; private set; } + /// /// Gets or Sets ColorCode /// [JsonPropertyName("color_code")] - public string ColorCode { get; set; } + public string? ColorCode { get { return this. ColorCodeOption; } set { this.ColorCodeOption = new(value); } } + + /// + /// Used to track the state of Cultivar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CultivarOption { get; private set; } /// /// Gets or Sets Cultivar /// [JsonPropertyName("cultivar")] - public string Cultivar { get; set; } + public string? Cultivar { get { return this. CultivarOption; } set { this.CultivarOption = new(value); } } + + /// + /// Used to track the state of Origin + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OriginOption { get; private set; } /// /// Gets or Sets Origin /// [JsonPropertyName("origin")] - public string Origin { get; set; } + public string? Origin { get { return this. OriginOption; } set { this.OriginOption = new(value); } } /// /// Gets or Sets additional properties @@ -94,28 +116,31 @@ namespace Org.OpenAPITools.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - if (this.ColorCode != null) { + if (this.ColorCodeOption.Value != null) { // ColorCode (string) pattern Regex regexColorCode = new Regex(@"^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$", RegexOptions.CultureInvariant); - if (!regexColorCode.Match(this.ColorCode).Success) + + if (this.ColorCodeOption.Value != null &&!regexColorCode.Match(this.ColorCodeOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ColorCode, must match a pattern of " + regexColorCode, new [] { "ColorCode" }); } } - if (this.Cultivar != null) { + if (this.CultivarOption.Value != null) { // Cultivar (string) pattern Regex regexCultivar = new Regex(@"^[a-zA-Z\s]*$", RegexOptions.CultureInvariant); - if (!regexCultivar.Match(this.Cultivar).Success) + + if (this.CultivarOption.Value != null &&!regexCultivar.Match(this.CultivarOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Cultivar, must match a pattern of " + regexCultivar, new [] { "Cultivar" }); } } - if (this.Origin != null) { + if (this.OriginOption.Value != null) { // Origin (string) pattern Regex regexOrigin = new Regex(@"^[A-Z\s]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexOrigin.Match(this.Origin).Success) + + if (this.OriginOption.Value != null &&!regexOrigin.Match(this.OriginOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Origin, must match a pattern of " + regexOrigin, new [] { "Origin" }); } @@ -147,9 +172,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? colorCode = default; - string? cultivar = default; - string? origin = default; + Option colorCode = default; + Option cultivar = default; + Option origin = default; while (utf8JsonReader.Read()) { @@ -167,13 +192,13 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color_code": - colorCode = utf8JsonReader.GetString(); + colorCode = new Option(utf8JsonReader.GetString()!); break; case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()!); break; case "origin": - origin = utf8JsonReader.GetString(); + origin = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -181,14 +206,14 @@ namespace Org.OpenAPITools.Model } } - if (colorCode == null) - throw new ArgumentNullException(nameof(colorCode), "Property is required for class Apple."); + if (colorCode.IsSet && colorCode.Value == null) + throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple."); - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class Apple."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple."); - if (origin == null) - throw new ArgumentNullException(nameof(origin), "Property is required for class Apple."); + if (origin.IsSet && origin.Value == null) + throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple."); return new Apple(colorCode, cultivar, origin); } @@ -217,9 +242,23 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color_code", apple.ColorCode); - writer.WriteString("cultivar", apple.Cultivar); - writer.WriteString("origin", apple.Origin); + if (apple.ColorCodeOption.IsSet && apple.ColorCode == null) + throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple."); + + if (apple.CultivarOption.IsSet && apple.Cultivar == null) + throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple."); + + if (apple.OriginOption.IsSet && apple.Origin == null) + throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple."); + + if (apple.ColorCodeOption.IsSet) + writer.WriteString("color_code", apple.ColorCode); + + if (apple.CultivarOption.IsSet) + writer.WriteString("cultivar", apple.Cultivar); + + if (apple.OriginOption.IsSet) + writer.WriteString("origin", apple.Origin); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs index ca139374d18..0fb31ae3185 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,10 +37,10 @@ namespace Org.OpenAPITools.Model /// cultivar /// mealy [JsonConstructor] - public AppleReq(string cultivar, bool mealy) + public AppleReq(string cultivar, Option mealy = default) { Cultivar = cultivar; - Mealy = mealy; + MealyOption = mealy; OnCreated(); } @@ -51,11 +52,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("cultivar")] public string Cultivar { get; set; } + /// + /// Used to track the state of Mealy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MealyOption { get; private set; } + /// /// Gets or Sets Mealy /// [JsonPropertyName("mealy")] - public bool Mealy { get; set; } + public bool? Mealy { get { return this. MealyOption; } set { this.MealyOption = new(value); } } /// /// Returns the string presentation of the object @@ -104,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? cultivar = default; - bool? mealy = default; + Option cultivar = default; + Option mealy = default; while (utf8JsonReader.Read()) { @@ -123,11 +131,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()!); break; case "mealy": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mealy = utf8JsonReader.GetBoolean(); + mealy = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -135,13 +143,16 @@ namespace Org.OpenAPITools.Model } } - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class AppleReq."); + if (!cultivar.IsSet) + throw new ArgumentException("Property is required for class AppleReq.", nameof(cultivar)); - if (mealy == null) - throw new ArgumentNullException(nameof(mealy), "Property is required for class AppleReq."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq."); - return new AppleReq(cultivar, mealy.Value); + if (mealy.IsSet && mealy.Value == null) + throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq."); + + return new AppleReq(cultivar.Value!, mealy); } /// @@ -168,8 +179,13 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) { + if (appleReq.Cultivar == null) + throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq."); + writer.WriteString("cultivar", appleReq.Cultivar); - writer.WriteBoolean("mealy", appleReq.Mealy); + + if (appleReq.MealyOption.IsSet) + writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 78ae23d63d6..c723d43d16c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// arrayArrayNumber [JsonConstructor] - public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber) + public ArrayOfArrayOfNumberOnly(Option>?> arrayArrayNumber = default) { - ArrayArrayNumber = arrayArrayNumber; + ArrayArrayNumberOption = arrayArrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ArrayArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayArrayNumber /// [JsonPropertyName("ArrayArrayNumber")] - public List> ArrayArrayNumber { get; set; } + public List>? ArrayArrayNumber { get { return this. ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List>? arrayArrayNumber = default; + Option>?> arrayArrayNumber = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "ArrayArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayNumber = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayNumber = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -129,8 +137,8 @@ namespace Org.OpenAPITools.Model } } - if (arrayArrayNumber == null) - throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly."); return new ArrayOfArrayOfNumberOnly(arrayArrayNumber); } @@ -159,8 +167,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 29af43d6c8b..f1929407e89 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// arrayNumber [JsonConstructor] - public ArrayOfNumberOnly(List arrayNumber) + public ArrayOfNumberOnly(Option?> arrayNumber = default) { - ArrayNumber = arrayNumber; + ArrayNumberOption = arrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayNumber /// [JsonPropertyName("ArrayNumber")] - public List ArrayNumber { get; set; } + public List? ArrayNumber { get { return this. ArrayNumberOption; } set { this.ArrayNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? arrayNumber = default; + Option?> arrayNumber = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "ArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNumber = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNumber = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -129,8 +137,8 @@ namespace Org.OpenAPITools.Model } } - if (arrayNumber == null) - throw new ArgumentNullException(nameof(arrayNumber), "Property is required for class ArrayOfNumberOnly."); + if (arrayNumber.IsSet && arrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly."); return new ArrayOfNumberOnly(arrayNumber); } @@ -159,8 +167,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly."); + + if (arrayOfNumberOnly.ArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs index c021f61cca5..f6ecfbb72d6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -37,33 +38,54 @@ namespace Org.OpenAPITools.Model /// arrayArrayOfModel /// arrayOfString [JsonConstructor] - public ArrayTest(List> arrayArrayOfInteger, List> arrayArrayOfModel, List arrayOfString) + public ArrayTest(Option>?> arrayArrayOfInteger = default, Option>?> arrayArrayOfModel = default, Option?> arrayOfString = default) { - ArrayArrayOfInteger = arrayArrayOfInteger; - ArrayArrayOfModel = arrayArrayOfModel; - ArrayOfString = arrayOfString; + ArrayArrayOfIntegerOption = arrayArrayOfInteger; + ArrayArrayOfModelOption = arrayArrayOfModel; + ArrayOfStringOption = arrayOfString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayOfInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ArrayArrayOfIntegerOption { get; private set; } + /// /// Gets or Sets ArrayArrayOfInteger /// [JsonPropertyName("array_array_of_integer")] - public List> ArrayArrayOfInteger { get; set; } + public List>? ArrayArrayOfInteger { get { return this. ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new(value); } } + + /// + /// Used to track the state of ArrayArrayOfModel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> ArrayArrayOfModelOption { get; private set; } /// /// Gets or Sets ArrayArrayOfModel /// [JsonPropertyName("array_array_of_model")] - public List> ArrayArrayOfModel { get; set; } + public List>? ArrayArrayOfModel { get { return this. ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new(value); } } + + /// + /// Used to track the state of ArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayOfStringOption { get; private set; } /// /// Gets or Sets ArrayOfString /// [JsonPropertyName("array_of_string")] - public List ArrayOfString { get; set; } + public List? ArrayOfString { get { return this. ArrayOfStringOption; } set { this.ArrayOfStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -120,9 +142,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List>? arrayArrayOfInteger = default; - List>? arrayArrayOfModel = default; - List? arrayOfString = default; + Option>?> arrayArrayOfInteger = default; + Option>?> arrayArrayOfModel = default; + Option?> arrayOfString = default; while (utf8JsonReader.Read()) { @@ -141,15 +163,15 @@ namespace Org.OpenAPITools.Model { case "array_array_of_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfInteger = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfInteger = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "array_array_of_model": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfModel = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfModel = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "array_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayOfString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -157,14 +179,14 @@ namespace Org.OpenAPITools.Model } } - if (arrayArrayOfInteger == null) - throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is required for class ArrayTest."); + if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest."); - if (arrayArrayOfModel == null) - throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is required for class ArrayTest."); + if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest."); - if (arrayOfString == null) - throw new ArgumentNullException(nameof(arrayOfString), "Property is required for class ArrayTest."); + if (arrayOfString.IsSet && arrayOfString.Value == null) + throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest."); return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString); } @@ -193,12 +215,30 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_array_of_integer"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); - writer.WritePropertyName("array_array_of_model"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); - writer.WritePropertyName("array_of_string"); - JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfIntegerOption.IsSet) + { + writer.WritePropertyName("array_array_of_integer"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); + } + if (arrayTest.ArrayArrayOfModelOption.IsSet) + { + writer.WritePropertyName("array_array_of_model"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); + } + if (arrayTest.ArrayOfStringOption.IsSet) + { + writer.WritePropertyName("array_of_string"); + JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs index a73515d6023..de17f0c9387 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// lengthCm [JsonConstructor] - public Banana(decimal lengthCm) + public Banana(Option lengthCm = default) { - LengthCm = lengthCm; + LengthCmOption = lengthCm; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of LengthCm + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LengthCmOption { get; private set; } + /// /// Gets or Sets LengthCm /// [JsonPropertyName("lengthCm")] - public decimal LengthCm { get; set; } + public decimal? LengthCm { get { return this. LengthCmOption; } set { this.LengthCmOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; + Option lengthCm = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class Banana."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana."); - return new Banana(lengthCm.Value); + return new Banana(lengthCm); } /// @@ -159,7 +167,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("lengthCm", banana.LengthCm); + if (banana.LengthCmOption.IsSet) + writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs index 20d095383d7..399687d74f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,10 +37,10 @@ namespace Org.OpenAPITools.Model /// lengthCm /// sweet [JsonConstructor] - public BananaReq(decimal lengthCm, bool sweet) + public BananaReq(decimal lengthCm, Option sweet = default) { LengthCm = lengthCm; - Sweet = sweet; + SweetOption = sweet; OnCreated(); } @@ -51,11 +52,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } + /// + /// Used to track the state of Sweet + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SweetOption { get; private set; } + /// /// Gets or Sets Sweet /// [JsonPropertyName("sweet")] - public bool Sweet { get; set; } + public bool? Sweet { get { return this. SweetOption; } set { this.SweetOption = new(value); } } /// /// Returns the string presentation of the object @@ -104,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; - bool? sweet = default; + Option lengthCm = default; + Option sweet = default; while (utf8JsonReader.Read()) { @@ -124,11 +132,11 @@ namespace Org.OpenAPITools.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; case "sweet": if (utf8JsonReader.TokenType != JsonTokenType.Null) - sweet = utf8JsonReader.GetBoolean(); + sweet = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -136,13 +144,16 @@ namespace Org.OpenAPITools.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class BananaReq."); + if (!lengthCm.IsSet) + throw new ArgumentException("Property is required for class BananaReq.", nameof(lengthCm)); - if (sweet == null) - throw new ArgumentNullException(nameof(sweet), "Property is required for class BananaReq."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq."); - return new BananaReq(lengthCm.Value, sweet.Value); + if (sweet.IsSet && sweet.Value == null) + throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq."); + + return new BananaReq(lengthCm.Value!.Value!, sweet); } /// @@ -170,7 +181,9 @@ namespace Org.OpenAPITools.Model public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); - writer.WriteBoolean("sweet", bananaReq.Sweet); + + if (bananaReq.SweetOption.IsSet) + writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs index 87c83d423c1..6388a29478f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,7 +103,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -120,7 +121,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,10 +129,13 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class BasquePig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class BasquePig.", nameof(className)); - return new BasquePig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class BasquePig."); + + return new BasquePig(className.Value!); } /// @@ -158,6 +162,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) { + if (basquePig.ClassName == null) + throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig."); + writer.WriteString("className", basquePig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs index 53520c57a3d..d2cbece80d4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -40,55 +41,97 @@ namespace Org.OpenAPITools.Model /// smallCamel /// smallSnake [JsonConstructor] - public Capitalization(string aTTNAME, string capitalCamel, string capitalSnake, string sCAETHFlowPoints, string smallCamel, string smallSnake) + public Capitalization(Option aTTNAME = default, Option capitalCamel = default, Option capitalSnake = default, Option sCAETHFlowPoints = default, Option smallCamel = default, Option smallSnake = default) { - ATT_NAME = aTTNAME; - CapitalCamel = capitalCamel; - CapitalSnake = capitalSnake; - SCAETHFlowPoints = sCAETHFlowPoints; - SmallCamel = smallCamel; - SmallSnake = smallSnake; + ATT_NAMEOption = aTTNAME; + CapitalCamelOption = capitalCamel; + CapitalSnakeOption = capitalSnake; + SCAETHFlowPointsOption = sCAETHFlowPoints; + SmallCamelOption = smallCamel; + SmallSnakeOption = smallSnake; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ATT_NAME + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ATT_NAMEOption { get; private set; } + /// /// Name of the pet /// /// Name of the pet [JsonPropertyName("ATT_NAME")] - public string ATT_NAME { get; set; } + public string? ATT_NAME { get { return this. ATT_NAMEOption; } set { this.ATT_NAMEOption = new(value); } } + + /// + /// Used to track the state of CapitalCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalCamelOption { get; private set; } /// /// Gets or Sets CapitalCamel /// [JsonPropertyName("CapitalCamel")] - public string CapitalCamel { get; set; } + public string? CapitalCamel { get { return this. CapitalCamelOption; } set { this.CapitalCamelOption = new(value); } } + + /// + /// Used to track the state of CapitalSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalSnakeOption { get; private set; } /// /// Gets or Sets CapitalSnake /// [JsonPropertyName("Capital_Snake")] - public string CapitalSnake { get; set; } + public string? CapitalSnake { get { return this. CapitalSnakeOption; } set { this.CapitalSnakeOption = new(value); } } + + /// + /// Used to track the state of SCAETHFlowPoints + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SCAETHFlowPointsOption { get; private set; } /// /// Gets or Sets SCAETHFlowPoints /// [JsonPropertyName("SCA_ETH_Flow_Points")] - public string SCAETHFlowPoints { get; set; } + public string? SCAETHFlowPoints { get { return this. SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new(value); } } + + /// + /// Used to track the state of SmallCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallCamelOption { get; private set; } /// /// Gets or Sets SmallCamel /// [JsonPropertyName("smallCamel")] - public string SmallCamel { get; set; } + public string? SmallCamel { get { return this. SmallCamelOption; } set { this.SmallCamelOption = new(value); } } + + /// + /// Used to track the state of SmallSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallSnakeOption { get; private set; } /// /// Gets or Sets SmallSnake /// [JsonPropertyName("small_Snake")] - public string SmallSnake { get; set; } + public string? SmallSnake { get { return this. SmallSnakeOption; } set { this.SmallSnakeOption = new(value); } } /// /// Gets or Sets additional properties @@ -148,12 +191,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? aTTNAME = default; - string? capitalCamel = default; - string? capitalSnake = default; - string? sCAETHFlowPoints = default; - string? smallCamel = default; - string? smallSnake = default; + Option aTTNAME = default; + Option capitalCamel = default; + Option capitalSnake = default; + Option sCAETHFlowPoints = default; + Option smallCamel = default; + Option smallSnake = default; while (utf8JsonReader.Read()) { @@ -171,22 +214,22 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "ATT_NAME": - aTTNAME = utf8JsonReader.GetString(); + aTTNAME = new Option(utf8JsonReader.GetString()!); break; case "CapitalCamel": - capitalCamel = utf8JsonReader.GetString(); + capitalCamel = new Option(utf8JsonReader.GetString()!); break; case "Capital_Snake": - capitalSnake = utf8JsonReader.GetString(); + capitalSnake = new Option(utf8JsonReader.GetString()!); break; case "SCA_ETH_Flow_Points": - sCAETHFlowPoints = utf8JsonReader.GetString(); + sCAETHFlowPoints = new Option(utf8JsonReader.GetString()!); break; case "smallCamel": - smallCamel = utf8JsonReader.GetString(); + smallCamel = new Option(utf8JsonReader.GetString()!); break; case "small_Snake": - smallSnake = utf8JsonReader.GetString(); + smallSnake = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -194,23 +237,23 @@ namespace Org.OpenAPITools.Model } } - if (aTTNAME == null) - throw new ArgumentNullException(nameof(aTTNAME), "Property is required for class Capitalization."); + if (aTTNAME.IsSet && aTTNAME.Value == null) + throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization."); - if (capitalCamel == null) - throw new ArgumentNullException(nameof(capitalCamel), "Property is required for class Capitalization."); + if (capitalCamel.IsSet && capitalCamel.Value == null) + throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization."); - if (capitalSnake == null) - throw new ArgumentNullException(nameof(capitalSnake), "Property is required for class Capitalization."); + if (capitalSnake.IsSet && capitalSnake.Value == null) + throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization."); - if (sCAETHFlowPoints == null) - throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is required for class Capitalization."); + if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null) + throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization."); - if (smallCamel == null) - throw new ArgumentNullException(nameof(smallCamel), "Property is required for class Capitalization."); + if (smallCamel.IsSet && smallCamel.Value == null) + throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization."); - if (smallSnake == null) - throw new ArgumentNullException(nameof(smallSnake), "Property is required for class Capitalization."); + if (smallSnake.IsSet && smallSnake.Value == null) + throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization."); return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake); } @@ -239,12 +282,41 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("ATT_NAME", capitalization.ATT_NAME); - writer.WriteString("CapitalCamel", capitalization.CapitalCamel); - writer.WriteString("Capital_Snake", capitalization.CapitalSnake); - writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); - writer.WriteString("smallCamel", capitalization.SmallCamel); - writer.WriteString("small_Snake", capitalization.SmallSnake); + if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null) + throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization."); + + if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null) + throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization."); + + if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null) + throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization."); + + if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null) + throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization."); + + if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null) + throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization."); + + if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null) + throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization."); + + if (capitalization.ATT_NAMEOption.IsSet) + writer.WriteString("ATT_NAME", capitalization.ATT_NAME); + + if (capitalization.CapitalCamelOption.IsSet) + writer.WriteString("CapitalCamel", capitalization.CapitalCamel); + + if (capitalization.CapitalSnakeOption.IsSet) + writer.WriteString("Capital_Snake", capitalization.CapitalSnake); + + if (capitalization.SCAETHFlowPointsOption.IsSet) + writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); + + if (capitalization.SmallCamelOption.IsSet) + writer.WriteString("smallCamel", capitalization.SmallCamel); + + if (capitalization.SmallSnakeOption.IsSet) + writer.WriteString("small_Snake", capitalization.SmallSnake); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs index 2a0960e3a90..b914d1dd4d6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,22 +35,29 @@ namespace Org.OpenAPITools.Model /// Initializes a new instance of the class. /// /// className - /// declawed /// color (default to "red") + /// declawed [JsonConstructor] - public Cat(string className, bool declawed, string color = @"red") : base(className, color) + public Cat(string className, Option color = default, Option declawed = default) : base(className, color) { - Declawed = declawed; + DeclawedOption = declawed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Declawed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeclawedOption { get; private set; } + /// /// Gets or Sets Declawed /// [JsonPropertyName("declawed")] - public bool Declawed { get; set; } + public bool? Declawed { get { return this. DeclawedOption; } set { this.DeclawedOption = new(value); } } /// /// Returns the string presentation of the object @@ -88,9 +96,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - bool? declawed = default; - string? color = default; + Option className = default; + Option color = default; + Option declawed = default; while (utf8JsonReader.Read()) { @@ -108,14 +116,14 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); + break; + case "color": + color = new Option(utf8JsonReader.GetString()!); break; case "declawed": if (utf8JsonReader.TokenType != JsonTokenType.Null) - declawed = utf8JsonReader.GetBoolean(); - break; - case "color": - color = utf8JsonReader.GetString(); + declawed = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -123,16 +131,19 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Cat."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Cat.", nameof(className)); - if (declawed == null) - throw new ArgumentNullException(nameof(declawed), "Property is required for class Cat."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Cat."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat."); - return new Cat(className, declawed.Value, color); + if (declawed.IsSet && declawed.Value == null) + throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); + + return new Cat(className.Value!, color, declawed); } /// @@ -159,9 +170,19 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { + if (cat.ClassName == null) + throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); + + if (cat.ColorOption.IsSet && cat.Color == null) + throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); + writer.WriteString("className", cat.ClassName); - writer.WriteBoolean("declawed", cat.Declawed); - writer.WriteString("color", cat.Color); + + if (cat.ColorOption.IsSet) + writer.WriteString("color", cat.Color); + + if (cat.DeclawedOption.IsSet) + writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs index 714575af8f4..55a7984769b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,20 +37,27 @@ namespace Org.OpenAPITools.Model /// id /// name (default to "default-name") [JsonConstructor] - public Category(long id, string name = @"default-name") + public Category(Option id = default, string name = @"default-name") { - Id = id; + IdOption = id; Name = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } /// /// Gets or Sets Name @@ -111,8 +119,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string? name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -131,10 +139,10 @@ namespace Org.OpenAPITools.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -142,13 +150,16 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Category."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Category.", nameof(name)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Category."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category."); - return new Category(id.Value, name); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category."); + + return new Category(id, name.Value!); } /// @@ -175,7 +186,12 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", category.Id); + if (category.Name == null) + throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category."); + + if (category.IdOption.IsSet) + writer.WriteNumber("id", category.IdOption.Value!.Value); + writer.WriteString("name", category.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs index 36f89e4c793..123bbee8012 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,10 +37,10 @@ namespace Org.OpenAPITools.Model /// name /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(string name, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value)) { - Name = name; - PetType = petType; + NameOption = name; + PetTypeOption = petType; OnCreated(); } @@ -89,26 +90,39 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string PetTypeEnumToJsonValue(PetTypeEnum value) + public static string PetTypeEnumToJsonValue(PetTypeEnum? value) { - if (value == PetTypeEnum.ChildCat) return "ChildCat"; throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of PetType + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new Option PetTypeOption { get; private set; } + /// /// Gets or Sets PetType /// [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } + public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Returns the string presentation of the object @@ -148,8 +162,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? name = default; - ChildCat.PetTypeEnum? petType = default; + Option name = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -167,13 +181,12 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; case "pet_type": string? petTypeRawValue = utf8JsonReader.GetString(); - petType = petTypeRawValue == null - ? null - : ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue); + if (petTypeRawValue != null) + petType = new Option(ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue)); break; default: break; @@ -181,13 +194,13 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class ChildCat."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ChildCat."); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value); + return new ChildCat(name, petType); } /// @@ -214,9 +227,13 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", childCat.Name); + if (childCat.NameOption.IsSet && childCat.Name == null) + throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat."); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); + if (childCat.NameOption.IsSet) + writer.WriteString("name", childCat.Name); + + var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value!.Value); if (petTypeRawValue != null) writer.WriteString("pet_type", petTypeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs index 66a7dee91d8..995f04192dc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// varClass [JsonConstructor] - public ClassModel(string varClass) + public ClassModel(Option varClass = default) { - VarClass = varClass; + VarClassOption = varClass; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("_class")] - public string VarClass { get; set; } + public string? VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varClass = default; + Option varClass = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "_class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class ClassModel."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel."); return new ClassModel(varClass); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_class", classModel.VarClass); + if (classModel.VarClassOption.IsSet && classModel.VarClass == null) + throw new ArgumentNullException(nameof(classModel.VarClass), "Property is required for class ClassModel."); + + if (classModel.VarClassOption.IsSet) + writer.WriteString("_class", classModel.VarClass); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 01f2390005d..6e9034b20b2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -111,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; - string? shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -130,10 +131,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -141,13 +142,19 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class ComplexQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ComplexQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(shapeType)); - return new ComplexQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class ComplexQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ComplexQuadrilateral."); + + return new ComplexQuadrilateral(quadrilateralType.Value!, shapeType.Value!); } /// @@ -174,7 +181,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (complexQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral."); + + if (complexQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral."); + writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", complexQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs index fd9ee9d3683..cb41bcddcd6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,7 +103,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -120,7 +121,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,10 +129,13 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class DanishPig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class DanishPig.", nameof(className)); - return new DanishPig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class DanishPig."); + + return new DanishPig(className.Value!); } /// @@ -158,6 +162,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) { + if (danishPig.ClassName == null) + throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig."); + writer.WriteString("className", danishPig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 6a9c5d4a795..ee5fb40abb3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,20 +36,27 @@ namespace Org.OpenAPITools.Model /// /// dateOnlyProperty [JsonConstructor] - public DateOnlyClass(DateTime dateOnlyProperty) + public DateOnlyClass(Option dateOnlyProperty = default) { - DateOnlyProperty = dateOnlyProperty; + DateOnlyPropertyOption = dateOnlyProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateOnlyProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateOnlyPropertyOption { get; private set; } + /// /// Gets or Sets DateOnlyProperty /// /// Fri Jul 21 00:00:00 UTC 2017 [JsonPropertyName("dateOnlyProperty")] - public DateTime DateOnlyProperty { get; set; } + public DateTime? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new(value); } } /// /// Gets or Sets additional properties @@ -108,7 +116,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateOnlyProperty = default; + Option dateOnlyProperty = default; while (utf8JsonReader.Read()) { @@ -127,7 +135,7 @@ namespace Org.OpenAPITools.Model { case "dateOnlyProperty": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -135,10 +143,10 @@ namespace Org.OpenAPITools.Model } } - if (dateOnlyProperty == null) - throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is required for class DateOnlyClass."); + if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null) + throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass."); - return new DateOnlyClass(dateOnlyProperty.Value); + return new DateOnlyClass(dateOnlyProperty); } /// @@ -165,7 +173,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(DateOnlyPropertyFormat)); + if (dateOnlyClass.DateOnlyPropertyOption.IsSet) + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat)); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 84ebd0792c3..77dea9cffa7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// name [JsonConstructor] - public DeprecatedObject(string name) + public DeprecatedObject(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class DeprecatedObject."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject."); return new DeprecatedObject(name); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", deprecatedObject.Name); + if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null) + throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject."); + + if (deprecatedObject.NameOption.IsSet) + writer.WriteString("name", deprecatedObject.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs index fa2bab08024..7891f26505a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,23 +34,30 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// breed /// className + /// breed /// color (default to "red") [JsonConstructor] - public Dog(string breed, string className, string color = @"red") : base(className, color) + public Dog(string className, Option breed = default, Option color = default) : base(className, color) { - Breed = breed; + BreedOption = breed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Breed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BreedOption { get; private set; } + /// /// Gets or Sets Breed /// [JsonPropertyName("breed")] - public string Breed { get; set; } + public string? Breed { get { return this. BreedOption; } set { this.BreedOption = new(value); } } /// /// Returns the string presentation of the object @@ -88,9 +96,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? breed = default; - string? className = default; - string? color = default; + Option className = default; + Option breed = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -107,14 +115,14 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "breed": - breed = utf8JsonReader.GetString(); - break; case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); + break; + case "breed": + breed = new Option(utf8JsonReader.GetString()!); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -122,16 +130,19 @@ namespace Org.OpenAPITools.Model } } - if (breed == null) - throw new ArgumentNullException(nameof(breed), "Property is required for class Dog."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Dog.", nameof(className)); - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Dog."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Dog."); + if (breed.IsSet && breed.Value == null) + throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog."); - return new Dog(breed, className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); + + return new Dog(className.Value!, breed, color); } /// @@ -158,9 +169,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("breed", dog.Breed); + if (dog.ClassName == null) + throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); + + if (dog.BreedOption.IsSet && dog.Breed == null) + throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); + + if (dog.ColorOption.IsSet && dog.Color == null) + throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog."); + writer.WriteString("className", dog.ClassName); - writer.WriteString("color", dog.Color); + + if (dog.BreedOption.IsSet) + writer.WriteString("breed", dog.Breed); + + if (dog.ColorOption.IsSet) + writer.WriteString("color", dog.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs index 8f5fff0f79a..3fd22bea878 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,44 +35,72 @@ namespace Org.OpenAPITools.Model /// Initializes a new instance of the class. /// /// mainShape - /// shapes /// nullableShape /// shapeOrNull + /// shapes [JsonConstructor] - public Drawing(Shape mainShape, List shapes, NullableShape? nullableShape = default, ShapeOrNull? shapeOrNull = default) : base() + public Drawing(Option mainShape = default, Option nullableShape = default, Option shapeOrNull = default, Option?> shapes = default) : base() { - MainShape = mainShape; - Shapes = shapes; - NullableShape = nullableShape; - ShapeOrNull = shapeOrNull; + MainShapeOption = mainShape; + NullableShapeOption = nullableShape; + ShapeOrNullOption = shapeOrNull; + ShapesOption = shapes; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MainShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MainShapeOption { get; private set; } + /// /// Gets or Sets MainShape /// [JsonPropertyName("mainShape")] - public Shape MainShape { get; set; } + public Shape? MainShape { get { return this. MainShapeOption; } set { this.MainShapeOption = new(value); } } /// - /// Gets or Sets Shapes + /// Used to track the state of NullableShape /// - [JsonPropertyName("shapes")] - public List Shapes { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableShapeOption { get; private set; } /// /// Gets or Sets NullableShape /// [JsonPropertyName("nullableShape")] - public NullableShape? NullableShape { get; set; } + public NullableShape? NullableShape { get { return this. NullableShapeOption; } set { this.NullableShapeOption = new(value); } } + + /// + /// Used to track the state of ShapeOrNull + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShapeOrNullOption { get; private set; } /// /// Gets or Sets ShapeOrNull /// [JsonPropertyName("shapeOrNull")] - public ShapeOrNull? ShapeOrNull { get; set; } + public ShapeOrNull? ShapeOrNull { get { return this. ShapeOrNullOption; } set { this.ShapeOrNullOption = new(value); } } + + /// + /// Used to track the state of Shapes + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ShapesOption { get; private set; } + + /// + /// Gets or Sets Shapes + /// + [JsonPropertyName("shapes")] + public List? Shapes { get { return this. ShapesOption; } set { this.ShapesOption = new(value); } } /// /// Gets or Sets additional properties @@ -89,9 +118,9 @@ namespace Org.OpenAPITools.Model sb.Append("class Drawing {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" MainShape: ").Append(MainShape).Append("\n"); - sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -140,10 +169,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Shape? mainShape = default; - List? shapes = default; - NullableShape? nullableShape = default; - ShapeOrNull? shapeOrNull = default; + Option mainShape = default; + Option nullableShape = default; + Option shapeOrNull = default; + Option?> shapes = default; while (utf8JsonReader.Read()) { @@ -162,19 +191,19 @@ namespace Org.OpenAPITools.Model { case "mainShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mainShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "shapes": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapes = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mainShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "nullableShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - nullableShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapeOrNull = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapes": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -182,13 +211,13 @@ namespace Org.OpenAPITools.Model } } - if (mainShape == null) - throw new ArgumentNullException(nameof(mainShape), "Property is required for class Drawing."); + if (mainShape.IsSet && mainShape.Value == null) + throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapes == null) - throw new ArgumentNullException(nameof(shapes), "Property is required for class Drawing."); + if (shapes.IsSet && shapes.Value == null) + throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); - return new Drawing(mainShape, shapes, nullableShape, shapeOrNull); + return new Drawing(mainShape, nullableShape, shapeOrNull, shapes); } /// @@ -215,14 +244,38 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("mainShape"); - JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); - writer.WritePropertyName("shapes"); - JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); - writer.WritePropertyName("nullableShape"); - JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) + throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) + throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); + + if (drawing.MainShapeOption.IsSet) + { + writer.WritePropertyName("mainShape"); + JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); + } + if (drawing.NullableShapeOption.IsSet) + if (drawing.NullableShapeOption.Value != null) + { + writer.WritePropertyName("nullableShape"); + JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); + } + else + writer.WriteNull("nullableShape"); + if (drawing.ShapeOrNullOption.IsSet) + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); + if (drawing.ShapesOption.IsSet) + { + writer.WritePropertyName("shapes"); + JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs index c9a92f18c9f..4347dd97453 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,10 +37,10 @@ namespace Org.OpenAPITools.Model /// arrayEnum /// justSymbol [JsonConstructor] - public EnumArrays(List arrayEnum, JustSymbolEnum justSymbol) + public EnumArrays(Option?> arrayEnum = default, Option justSymbol = default) { - ArrayEnum = arrayEnum; - JustSymbol = justSymbol; + ArrayEnumOption = arrayEnum; + JustSymbolOption = justSymbol; OnCreated(); } @@ -100,9 +101,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum value) + public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum? value) { - if (value == ArrayEnumEnum.Fish) return "fish"; @@ -167,9 +167,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string JustSymbolEnumToJsonValue(JustSymbolEnum value) + public static string JustSymbolEnumToJsonValue(JustSymbolEnum? value) { - if (value == JustSymbolEnum.GreaterThanOrEqualTo) return ">="; @@ -179,17 +178,31 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of JustSymbol + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustSymbolOption { get; private set; } + /// /// Gets or Sets JustSymbol /// [JsonPropertyName("just_symbol")] - public JustSymbolEnum JustSymbol { get; set; } + public JustSymbolEnum? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new(value); } } + + /// + /// Used to track the state of ArrayEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayEnumOption { get; private set; } /// /// Gets or Sets ArrayEnum /// [JsonPropertyName("array_enum")] - public List ArrayEnum { get; set; } + public List? ArrayEnum { get { return this. ArrayEnumOption; } set { this.ArrayEnumOption = new(value); } } /// /// Gets or Sets additional properties @@ -245,8 +258,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? arrayEnum = default; - EnumArrays.JustSymbolEnum? justSymbol = default; + Option?> arrayEnum = default; + Option justSymbol = default; while (utf8JsonReader.Read()) { @@ -265,13 +278,12 @@ namespace Org.OpenAPITools.Model { case "array_enum": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayEnum = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayEnum = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "just_symbol": string? justSymbolRawValue = utf8JsonReader.GetString(); - justSymbol = justSymbolRawValue == null - ? null - : EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue); + if (justSymbolRawValue != null) + justSymbol = new Option(EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue)); break; default: break; @@ -279,13 +291,13 @@ namespace Org.OpenAPITools.Model } } - if (arrayEnum == null) - throw new ArgumentNullException(nameof(arrayEnum), "Property is required for class EnumArrays."); + if (arrayEnum.IsSet && arrayEnum.Value == null) + throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays."); - if (justSymbol == null) - throw new ArgumentNullException(nameof(justSymbol), "Property is required for class EnumArrays."); + if (justSymbol.IsSet && justSymbol.Value == null) + throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays."); - return new EnumArrays(arrayEnum, justSymbol.Value); + return new EnumArrays(arrayEnum, justSymbol); } /// @@ -312,10 +324,15 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_enum"); - JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null) + throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays."); - var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbol); + if (enumArrays.ArrayEnumOption.IsSet) + { + writer.WritePropertyName("array_enum"); + JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + } + var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value!.Value); if (justSymbolRawValue != null) writer.WriteString("just_symbol", justSymbolRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs index 76dcba15b39..03b2780c484 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs index ac3f81f956a..25b33663930 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,392 +34,32 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// enumStringRequired /// enumInteger /// enumIntegerOnly /// enumNumber /// enumString - /// enumStringRequired + /// outerEnum /// outerEnumDefaultValue /// outerEnumInteger /// outerEnumIntegerDefaultValue - /// outerEnum [JsonConstructor] - public EnumTest(EnumIntegerEnum enumInteger, EnumIntegerOnlyEnum enumIntegerOnly, EnumNumberEnum enumNumber, EnumStringEnum enumString, EnumStringRequiredEnum enumStringRequired, OuterEnumDefaultValue outerEnumDefaultValue, OuterEnumInteger outerEnumInteger, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue, OuterEnum? outerEnum = default) + public EnumTest(EnumStringRequiredEnum enumStringRequired, Option enumInteger = default, Option enumIntegerOnly = default, Option enumNumber = default, Option enumString = default, Option outerEnum = default, Option outerEnumDefaultValue = default, Option outerEnumInteger = default, Option outerEnumIntegerDefaultValue = default) { - EnumInteger = enumInteger; - EnumIntegerOnly = enumIntegerOnly; - EnumNumber = enumNumber; - EnumString = enumString; EnumStringRequired = enumStringRequired; - OuterEnumDefaultValue = outerEnumDefaultValue; - OuterEnumInteger = outerEnumInteger; - OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - OuterEnum = outerEnum; + EnumIntegerOption = enumInteger; + EnumIntegerOnlyOption = enumIntegerOnly; + EnumNumberOption = enumNumber; + EnumStringOption = enumString; + OuterEnumOption = outerEnum; + OuterEnumDefaultValueOption = outerEnumDefaultValue; + OuterEnumIntegerOption = outerEnumInteger; + OuterEnumIntegerDefaultValueOption = outerEnumIntegerDefaultValue; OnCreated(); } partial void OnCreated(); - /// - /// Defines EnumInteger - /// - public enum EnumIntegerEnum - { - /// - /// Enum NUMBER_1 for value: 1 - /// - NUMBER_1 = 1, - - /// - /// Enum NUMBER_MINUS_1 for value: -1 - /// - NUMBER_MINUS_1 = -1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerEnum EnumIntegerEnumFromString(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumInteger - /// - [JsonPropertyName("enum_integer")] - public EnumIntegerEnum EnumInteger { get; set; } - - /// - /// Defines EnumIntegerOnly - /// - public enum EnumIntegerOnlyEnum - { - /// - /// Enum NUMBER_2 for value: 2 - /// - NUMBER_2 = 2, - - /// - /// Enum NUMBER_MINUS_2 for value: -2 - /// - NUMBER_MINUS_2 = -2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumIntegerOnly - /// - [JsonPropertyName("enum_integer_only")] - public EnumIntegerOnlyEnum EnumIntegerOnly { get; set; } - - /// - /// Defines EnumNumber - /// - public enum EnumNumberEnum - { - /// - /// Enum NUMBER_1_DOT_1 for value: 1.1 - /// - NUMBER_1_DOT_1 = 1, - - /// - /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 - /// - NUMBER_MINUS_1_DOT_2 = 2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumNumberEnum EnumNumberEnumFromString(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static double EnumNumberEnumToJsonValue(EnumNumberEnum value) - { - - if (value == EnumNumberEnum.NUMBER_1_DOT_1) - return 1.1; - - if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) - return -1.2; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumNumber - /// - [JsonPropertyName("enum_number")] - public EnumNumberEnum EnumNumber { get; set; } - - /// - /// Defines EnumString - /// - public enum EnumStringEnum - { - /// - /// Enum UPPER for value: UPPER - /// - UPPER = 1, - - /// - /// Enum Lower for value: lower - /// - Lower = 2, - - /// - /// Enum Empty for value: - /// - Empty = 3, - - /// - /// Enum ValuewithTab for value: Value\twith tab - /// - ValuewithTab = 4, - - /// - /// Enum ValueWithQuote for value: Value with \" quote - /// - ValueWithQuote = 5, - - /// - /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote - /// - ValueWithEscapedQuote = 6, - - /// - /// Enum Duplicatevalue for value: Duplicate\nvalue - /// - Duplicatevalue = 7, - - /// - /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue - /// - Duplicatevalue2 = 8 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumStringEnum EnumStringEnumFromString(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static string EnumStringEnumToJsonValue(EnumStringEnum value) - { - - if (value == EnumStringEnum.UPPER) - return "UPPER"; - - if (value == EnumStringEnum.Lower) - return "lower"; - - if (value == EnumStringEnum.Empty) - return ""; - - if (value == EnumStringEnum.ValuewithTab) - return "Value\twith tab"; - - if (value == EnumStringEnum.ValueWithQuote) - return "Value with \" quote"; - - if (value == EnumStringEnum.ValueWithEscapedQuote) - return "Value with escaped \" quote"; - - if (value == EnumStringEnum.Duplicatevalue) - return "Duplicate\nvalue"; - - if (value == EnumStringEnum.Duplicatevalue2) - return "Duplicate\r\nvalue"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumString - /// - [JsonPropertyName("enum_string")] - public EnumStringEnum EnumString { get; set; } - /// /// Defines EnumStringRequired /// @@ -542,7 +183,6 @@ namespace Org.OpenAPITools.Model /// public static string EnumStringRequiredEnumToJsonValue(EnumStringRequiredEnum value) { - if (value == EnumStringRequiredEnum.UPPER) return "UPPER"; @@ -577,28 +217,442 @@ namespace Org.OpenAPITools.Model public EnumStringRequiredEnum EnumStringRequired { get; set; } /// - /// Gets or Sets OuterEnumDefaultValue + /// Defines EnumInteger /// - [JsonPropertyName("outerEnumDefaultValue")] - public OuterEnumDefaultValue OuterEnumDefaultValue { get; set; } + public enum EnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } /// - /// Gets or Sets OuterEnumInteger + /// Returns a /// - [JsonPropertyName("outerEnumInteger")] - public OuterEnumInteger OuterEnumInteger { get; set; } + /// + /// + /// + public static EnumIntegerEnum EnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); + } /// - /// Gets or Sets OuterEnumIntegerDefaultValue + /// Returns a /// - [JsonPropertyName("outerEnumIntegerDefaultValue")] - public OuterEnumIntegerDefaultValue OuterEnumIntegerDefaultValue { get; set; } + /// + /// + public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOption { get; private set; } + + /// + /// Gets or Sets EnumInteger + /// + [JsonPropertyName("enum_integer")] + public EnumIntegerEnum? EnumInteger { get { return this.EnumIntegerOption; } set { this.EnumIntegerOption = new(value); } } + + /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets EnumIntegerOnly + /// + [JsonPropertyName("enum_integer_only")] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get { return this.EnumIntegerOnlyOption; } set { this.EnumIntegerOnlyOption = new(value); } } + + /// + /// Defines EnumNumber + /// + public enum EnumNumberEnum + { + /// + /// Enum NUMBER_1_DOT_1 for value: 1.1 + /// + NUMBER_1_DOT_1 = 1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 + /// + NUMBER_MINUS_1_DOT_2 = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumNumberEnum EnumNumberEnumFromString(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static double EnumNumberEnumToJsonValue(EnumNumberEnum? value) + { + if (value == EnumNumberEnum.NUMBER_1_DOT_1) + return 1.1; + + if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) + return -1.2; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumNumberOption { get; private set; } + + /// + /// Gets or Sets EnumNumber + /// + [JsonPropertyName("enum_number")] + public EnumNumberEnum? EnumNumber { get { return this.EnumNumberOption; } set { this.EnumNumberOption = new(value); } } + + /// + /// Defines EnumString + /// + public enum EnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumStringEnum EnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string EnumStringEnumToJsonValue(EnumStringEnum? value) + { + if (value == EnumStringEnum.UPPER) + return "UPPER"; + + if (value == EnumStringEnum.Lower) + return "lower"; + + if (value == EnumStringEnum.Empty) + return ""; + + if (value == EnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumStringOption { get; private set; } + + /// + /// Gets or Sets EnumString + /// + [JsonPropertyName("enum_string")] + public EnumStringEnum? EnumString { get { return this.EnumStringOption; } set { this.EnumStringOption = new(value); } } + + /// + /// Used to track the state of OuterEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumOption { get; private set; } /// /// Gets or Sets OuterEnum /// [JsonPropertyName("outerEnum")] - public OuterEnum? OuterEnum { get; set; } + public OuterEnum? OuterEnum { get { return this.OuterEnumOption; } set { this.OuterEnumOption = new(value); } } + + /// + /// Used to track the state of OuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumDefaultValue + /// + [JsonPropertyName("outerEnumDefaultValue")] + public OuterEnumDefaultValue? OuterEnumDefaultValue { get { return this.OuterEnumDefaultValueOption; } set { this.OuterEnumDefaultValueOption = new(value); } } + + /// + /// Used to track the state of OuterEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets OuterEnumInteger + /// + [JsonPropertyName("outerEnumInteger")] + public OuterEnumInteger? OuterEnumInteger { get { return this.OuterEnumIntegerOption; } set { this.OuterEnumIntegerOption = new(value); } } + + /// + /// Used to track the state of OuterEnumIntegerDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumIntegerDefaultValue + /// + [JsonPropertyName("outerEnumIntegerDefaultValue")] + public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get { return this.OuterEnumIntegerDefaultValueOption; } set { this.OuterEnumIntegerDefaultValueOption = new(value); } } /// /// Gets or Sets additional properties @@ -614,15 +668,15 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EnumTest {\n"); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" EnumString: ").Append(EnumString).Append("\n"); - sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); - sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -661,15 +715,15 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - EnumTest.EnumIntegerEnum? enumInteger = default; - EnumTest.EnumIntegerOnlyEnum? enumIntegerOnly = default; - EnumTest.EnumNumberEnum? enumNumber = default; - EnumTest.EnumStringEnum? enumString = default; - EnumTest.EnumStringRequiredEnum? enumStringRequired = default; - OuterEnumDefaultValue? outerEnumDefaultValue = default; - OuterEnumInteger? outerEnumInteger = default; - OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default; - OuterEnum? outerEnum = default; + Option enumStringRequired = default; + Option enumInteger = default; + Option enumIntegerOnly = default; + Option enumNumber = default; + Option enumString = default; + Option outerEnum = default; + Option outerEnumDefaultValue = default; + Option outerEnumInteger = default; + Option outerEnumIntegerDefaultValue = default; while (utf8JsonReader.Read()) { @@ -686,53 +740,47 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "enum_string_required": + string? enumStringRequiredRawValue = utf8JsonReader.GetString(); + if (enumStringRequiredRawValue != null) + enumStringRequired = new Option(EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue)); + break; case "enum_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumInteger = (EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32(); + enumInteger = new Option((EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32()); break; case "enum_integer_only": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumIntegerOnly = (EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32(); + enumIntegerOnly = new Option((EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); break; case "enum_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumNumber = (EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32(); + enumNumber = new Option((EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32()); break; case "enum_string": string? enumStringRawValue = utf8JsonReader.GetString(); - enumString = enumStringRawValue == null - ? null - : EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue); - break; - case "enum_string_required": - string? enumStringRequiredRawValue = utf8JsonReader.GetString(); - enumStringRequired = enumStringRequiredRawValue == null - ? null - : EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue); - break; - case "outerEnumDefaultValue": - string? outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumDefaultValue = outerEnumDefaultValueRawValue == null - ? null - : OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue); - break; - case "outerEnumInteger": - string? outerEnumIntegerRawValue = utf8JsonReader.GetString(); - outerEnumInteger = outerEnumIntegerRawValue == null - ? null - : OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue); - break; - case "outerEnumIntegerDefaultValue": - string? outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumIntegerDefaultValue = outerEnumIntegerDefaultValueRawValue == null - ? null - : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue); + if (enumStringRawValue != null) + enumString = new Option(EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue)); break; case "outerEnum": string? outerEnumRawValue = utf8JsonReader.GetString(); - outerEnum = outerEnumRawValue == null - ? null - : OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue); + if (outerEnumRawValue != null) + outerEnum = new Option(OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue)); + break; + case "outerEnumDefaultValue": + string? outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumDefaultValueRawValue != null) + outerEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue)); + break; + case "outerEnumInteger": + string? outerEnumIntegerRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerRawValue != null) + outerEnumInteger = new Option(OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue)); + break; + case "outerEnumIntegerDefaultValue": + string? outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerDefaultValueRawValue != null) + outerEnumIntegerDefaultValue = new Option(OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue)); break; default: break; @@ -740,31 +788,34 @@ namespace Org.OpenAPITools.Model } } - if (enumInteger == null) - throw new ArgumentNullException(nameof(enumInteger), "Property is required for class EnumTest."); + if (!enumStringRequired.IsSet) + throw new ArgumentException("Property is required for class EnumTest.", nameof(enumStringRequired)); - if (enumIntegerOnly == null) - throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is required for class EnumTest."); + if (enumStringRequired.IsSet && enumStringRequired.Value == null) + throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest."); - if (enumNumber == null) - throw new ArgumentNullException(nameof(enumNumber), "Property is required for class EnumTest."); + if (enumInteger.IsSet && enumInteger.Value == null) + throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest."); - if (enumString == null) - throw new ArgumentNullException(nameof(enumString), "Property is required for class EnumTest."); + if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest."); - if (enumStringRequired == null) - throw new ArgumentNullException(nameof(enumStringRequired), "Property is required for class EnumTest."); + if (enumNumber.IsSet && enumNumber.Value == null) + throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest."); - if (outerEnumDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is required for class EnumTest."); + if (enumString.IsSet && enumString.Value == null) + throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest."); - if (outerEnumInteger == null) - throw new ArgumentNullException(nameof(outerEnumInteger), "Property is required for class EnumTest."); + if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest."); - if (outerEnumIntegerDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is required for class EnumTest."); + if (outerEnumInteger.IsSet && outerEnumInteger.Value == null) + throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest."); - return new EnumTest(enumInteger.Value, enumIntegerOnly.Value, enumNumber.Value, enumString.Value, enumStringRequired.Value, outerEnumDefaultValue.Value, outerEnumInteger.Value, outerEnumIntegerDefaultValue.Value, outerEnum); + if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest."); + + return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue); } /// @@ -791,43 +842,49 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumInteger)); - writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnly)); - writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumber)); - - var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumString); - if (enumStringRawValue != null) - writer.WriteString("enum_string", enumStringRawValue); - else - writer.WriteNull("enum_string"); - var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); if (enumStringRequiredRawValue != null) writer.WriteString("enum_string_required", enumStringRequiredRawValue); else writer.WriteNull("enum_string_required"); - var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue); + if (enumTest.EnumIntegerOption.IsSet) + writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value)); - if (outerEnumDefaultValueRawValue != null) - writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + if (enumTest.EnumIntegerOnlyOption.IsSet) + writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value)); + + if (enumTest.EnumNumberOption.IsSet) + writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value)); + + var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value); + if (enumStringRawValue != null) + writer.WriteString("enum_string", enumStringRawValue); else - writer.WriteNull("outerEnumDefaultValue"); + writer.WriteNull("enum_string"); - var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger); - writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); - var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue); - writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); - - if (enumTest.OuterEnum == null) - writer.WriteNull("outerEnum"); - else - { - var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnum.Value); - if (outerEnumRawValue != null) + if (enumTest.OuterEnumOption.IsSet) + if (enumTest.OuterEnumOption!.Value != null) + { + var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnumOption.Value!.Value); writer.WriteString("outerEnum", outerEnumRawValue); + } else writer.WriteNull("outerEnum"); + if (enumTest.OuterEnumDefaultValueOption.IsSet) + { + var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue!.Value); + writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + } + if (enumTest.OuterEnumIntegerOption.IsSet) + { + var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger!.Value); + writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); + } + if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet) + { + var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue!.Value); + writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 717de0e356f..67be73e69d8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -111,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; - string? triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -130,10 +131,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -141,13 +142,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class EquilateralTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class EquilateralTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(triangleType)); - return new EquilateralTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class EquilateralTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class EquilateralTriangle."); + + return new EquilateralTriangle(shapeType.Value!, triangleType.Value!); } /// @@ -174,7 +181,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (equilateralTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle."); + + if (equilateralTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle."); + writer.WriteString("shapeType", equilateralTriangle.ShapeType); + writer.WriteString("triangleType", equilateralTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs index f0e27f10fa3..84bcc677147 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,20 +36,27 @@ namespace Org.OpenAPITools.Model /// /// Test capitalization [JsonConstructor] - public File(string sourceURI) + public File(Option sourceURI = default) { - SourceURI = sourceURI; + SourceURIOption = sourceURI; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SourceURI + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SourceURIOption { get; private set; } + /// /// Test capitalization /// /// Test capitalization [JsonPropertyName("sourceURI")] - public string SourceURI { get; set; } + public string? SourceURI { get { return this. SourceURIOption; } set { this.SourceURIOption = new(value); } } /// /// Gets or Sets additional properties @@ -103,7 +111,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? sourceURI = default; + Option sourceURI = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "sourceURI": - sourceURI = utf8JsonReader.GetString(); + sourceURI = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -129,8 +137,8 @@ namespace Org.OpenAPITools.Model } } - if (sourceURI == null) - throw new ArgumentNullException(nameof(sourceURI), "Property is required for class File."); + if (sourceURI.IsSet && sourceURI.Value == null) + throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File."); return new File(sourceURI); } @@ -159,7 +167,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("sourceURI", file.SourceURI); + if (file.SourceURIOption.IsSet && file.SourceURI == null) + throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File."); + + if (file.SourceURIOption.IsSet) + writer.WriteString("sourceURI", file.SourceURI); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index da341a59421..8791b3498ae 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// file /// files [JsonConstructor] - public FileSchemaTestClass(File file, List files) + public FileSchemaTestClass(Option file = default, Option?> files = default) { - File = file; - Files = files; + FileOption = file; + FilesOption = files; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of File + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FileOption { get; private set; } + /// /// Gets or Sets File /// [JsonPropertyName("file")] - public File File { get; set; } + public File? File { get { return this. FileOption; } set { this.FileOption = new(value); } } + + /// + /// Used to track the state of Files + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> FilesOption { get; private set; } /// /// Gets or Sets Files /// [JsonPropertyName("files")] - public List Files { get; set; } + public List? Files { get { return this. FilesOption; } set { this.FilesOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - File? file = default; - List? files = default; + Option file = default; + Option?> files = default; while (utf8JsonReader.Read()) { @@ -131,11 +146,11 @@ namespace Org.OpenAPITools.Model { case "file": if (utf8JsonReader.TokenType != JsonTokenType.Null) - file = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + file = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "files": if (utf8JsonReader.TokenType != JsonTokenType.Null) - files = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + files = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -143,11 +158,11 @@ namespace Org.OpenAPITools.Model } } - if (file == null) - throw new ArgumentNullException(nameof(file), "Property is required for class FileSchemaTestClass."); + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass."); - if (files == null) - throw new ArgumentNullException(nameof(files), "Property is required for class FileSchemaTestClass."); + if (files.IsSet && files.Value == null) + throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass."); return new FileSchemaTestClass(file, files); } @@ -176,10 +191,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("file"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); - writer.WritePropertyName("files"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FileOption.IsSet) + { + writer.WritePropertyName("file"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); + } + if (fileSchemaTestClass.FilesOption.IsSet) + { + writer.WritePropertyName("files"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs index 3628416eb0d..85d6ba28af3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// bar (default to "bar") [JsonConstructor] - public Foo(string bar = @"bar") + public Foo(Option bar = default) { - Bar = bar; + BarOption = bar; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; private set; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; set; } + public string? Bar { get { return this. BarOption; } set { this.BarOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? bar = default; + Option bar = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class Foo."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo."); return new Foo(bar); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", foo.Bar); + if (foo.BarOption.IsSet && foo.Bar == null) + throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo."); + + if (foo.BarOption.IsSet) + writer.WriteString("bar", foo.Bar); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index 6f2670034f2..09e11f0babb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// varString [JsonConstructor] - public FooGetDefaultResponse(Foo varString) + public FooGetDefaultResponse(Option varString = default) { - VarString = varString; + VarStringOption = varString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } + /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public Foo VarString { get; set; } + public Foo? VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Foo? varString = default; + Option varString = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varString = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varString = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -129,8 +137,8 @@ namespace Org.OpenAPITools.Model } } - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FooGetDefaultResponse."); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse."); return new FooGetDefaultResponse(varString); } @@ -159,8 +167,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("string"); - JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + if (fooGetDefaultResponse.VarStringOption.IsSet && fooGetDefaultResponse.VarString == null) + throw new ArgumentNullException(nameof(fooGetDefaultResponse.VarString), "Property is required for class FooGetDefaultResponse."); + + if (fooGetDefaultResponse.VarStringOption.IsSet) + { + writer.WritePropertyName("string"); + JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs index 9066cc903b6..5a8af6da0de 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,9 +34,11 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// binary /// varByte /// date + /// number + /// password + /// binary /// dateTime /// varDecimal /// varDouble @@ -43,8 +46,6 @@ namespace Org.OpenAPITools.Model /// int32 /// int64 /// integer - /// number - /// password /// None /// A string that is a 10 digit number. Can have leading zeros. /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. @@ -53,38 +54,32 @@ namespace Org.OpenAPITools.Model /// unsignedLong /// uuid [JsonConstructor] - public FormatTest(System.IO.Stream binary, byte[] varByte, DateTime date, DateTime dateTime, decimal varDecimal, double varDouble, float varFloat, int int32, long int64, int integer, decimal number, string password, string patternWithBackslash, string patternWithDigits, string patternWithDigitsAndDelimiter, string varString, uint unsignedInteger, ulong unsignedLong, Guid uuid) + 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) { - Binary = binary; VarByte = varByte; Date = date; - DateTime = dateTime; - VarDecimal = varDecimal; - VarDouble = varDouble; - VarFloat = varFloat; - Int32 = int32; - Int64 = int64; - Integer = integer; Number = number; Password = password; - PatternWithBackslash = patternWithBackslash; - PatternWithDigits = patternWithDigits; - PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - VarString = varString; - UnsignedInteger = unsignedInteger; - UnsignedLong = unsignedLong; - Uuid = uuid; + BinaryOption = binary; + DateTimeOption = dateTime; + VarDecimalOption = varDecimal; + VarDoubleOption = varDouble; + VarFloatOption = varFloat; + Int32Option = int32; + Int64Option = int64; + IntegerOption = integer; + PatternWithBackslashOption = patternWithBackslash; + PatternWithDigitsOption = patternWithDigits; + PatternWithDigitsAndDelimiterOption = patternWithDigitsAndDelimiter; + VarStringOption = varString; + UnsignedIntegerOption = unsignedInteger; + UnsignedLongOption = unsignedLong; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); - /// - /// Gets or Sets Binary - /// - [JsonPropertyName("binary")] - public System.IO.Stream Binary { get; set; } - /// /// Gets or Sets VarByte /// @@ -98,49 +93,6 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("date")] public DateTime Date { get; set; } - /// - /// Gets or Sets DateTime - /// - /// 2007-12-03T10:15:30+01:00 - [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } - - /// - /// Gets or Sets VarDecimal - /// - [JsonPropertyName("decimal")] - public decimal VarDecimal { get; set; } - - /// - /// Gets or Sets VarDouble - /// - [JsonPropertyName("double")] - public double VarDouble { get; set; } - - /// - /// Gets or Sets VarFloat - /// - [JsonPropertyName("float")] - public float VarFloat { get; set; } - - /// - /// Gets or Sets Int32 - /// - [JsonPropertyName("int32")] - public int Int32 { get; set; } - - /// - /// Gets or Sets Int64 - /// - [JsonPropertyName("int64")] - public long Int64 { get; set; } - - /// - /// Gets or Sets Integer - /// - [JsonPropertyName("integer")] - public int Integer { get; set; } - /// /// Gets or Sets Number /// @@ -153,51 +105,205 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("password")] public string Password { get; set; } + /// + /// Used to track the state of Binary + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BinaryOption { get; private set; } + + /// + /// Gets or Sets Binary + /// + [JsonPropertyName("binary")] + public System.IO.Stream? Binary { get { return this. BinaryOption; } set { this.BinaryOption = new(value); } } + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + /// 2007-12-03T10:15:30+01:00 + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } } + + /// + /// Used to track the state of VarDecimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDecimalOption { get; private set; } + + /// + /// Gets or Sets VarDecimal + /// + [JsonPropertyName("decimal")] + public decimal? VarDecimal { get { return this. VarDecimalOption; } set { this.VarDecimalOption = new(value); } } + + /// + /// Used to track the state of VarDouble + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDoubleOption { get; private set; } + + /// + /// Gets or Sets VarDouble + /// + [JsonPropertyName("double")] + public double? VarDouble { get { return this. VarDoubleOption; } set { this.VarDoubleOption = new(value); } } + + /// + /// Used to track the state of VarFloat + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarFloatOption { get; private set; } + + /// + /// Gets or Sets VarFloat + /// + [JsonPropertyName("float")] + public float? VarFloat { get { return this. VarFloatOption; } set { this.VarFloatOption = new(value); } } + + /// + /// Used to track the state of Int32 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int32Option { get; private set; } + + /// + /// Gets or Sets Int32 + /// + [JsonPropertyName("int32")] + public int? Int32 { get { return this. Int32Option; } set { this.Int32Option = new(value); } } + + /// + /// Used to track the state of Int64 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int64Option { get; private set; } + + /// + /// Gets or Sets Int64 + /// + [JsonPropertyName("int64")] + public long? Int64 { get { return this. Int64Option; } set { this.Int64Option = new(value); } } + + /// + /// Used to track the state of Integer + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerOption { get; private set; } + + /// + /// Gets or Sets Integer + /// + [JsonPropertyName("integer")] + public int? Integer { get { return this. IntegerOption; } set { this.IntegerOption = new(value); } } + + /// + /// Used to track the state of PatternWithBackslash + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithBackslashOption { get; private set; } + /// /// None /// /// None [JsonPropertyName("pattern_with_backslash")] - public string PatternWithBackslash { get; set; } + public string? PatternWithBackslash { get { return this. PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new(value); } } + + /// + /// Used to track the state of PatternWithDigits + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsOption { get; private set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. [JsonPropertyName("pattern_with_digits")] - public string PatternWithDigits { get; set; } + public string? PatternWithDigits { get { return this. PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new(value); } } + + /// + /// Used to track the state of PatternWithDigitsAndDelimiter + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsAndDelimiterOption { get; private set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. [JsonPropertyName("pattern_with_digits_and_delimiter")] - public string PatternWithDigitsAndDelimiter { get; set; } + public string? PatternWithDigitsAndDelimiter { get { return this. PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new(value); } } + + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public string VarString { get; set; } + public string? VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } } + + /// + /// Used to track the state of UnsignedInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedIntegerOption { get; private set; } /// /// Gets or Sets UnsignedInteger /// [JsonPropertyName("unsigned_integer")] - public uint UnsignedInteger { get; set; } + public uint? UnsignedInteger { get { return this. UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new(value); } } + + /// + /// Used to track the state of UnsignedLong + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedLongOption { get; private set; } /// /// Gets or Sets UnsignedLong /// [JsonPropertyName("unsigned_long")] - public ulong UnsignedLong { get; set; } + public ulong? UnsignedLong { get { return this. UnsignedLongOption; } set { this.UnsignedLongOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -213,9 +319,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class FormatTest {\n"); - sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" VarByte: ").Append(VarByte).Append("\n"); sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" DateTime: ").Append(DateTime).Append("\n"); sb.Append(" VarDecimal: ").Append(VarDecimal).Append("\n"); sb.Append(" VarDouble: ").Append(VarDouble).Append("\n"); @@ -223,8 +331,6 @@ namespace Org.OpenAPITools.Model sb.Append(" Int32: ").Append(Int32).Append("\n"); sb.Append(" Int64: ").Append(Int64).Append("\n"); sb.Append(" Integer: ").Append(Integer).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" PatternWithBackslash: ").Append(PatternWithBackslash).Append("\n"); sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); @@ -244,54 +350,6 @@ namespace Org.OpenAPITools.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - // VarDouble (double) maximum - if (this.VarDouble > (double)123.4) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); - } - - // VarDouble (double) minimum - if (this.VarDouble < (double)67.8) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); - } - - // VarFloat (float) maximum - if (this.VarFloat > (float)987.6) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); - } - - // VarFloat (float) minimum - if (this.VarFloat < (float)54.3) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); - } - - // Int32 (int) maximum - if (this.Int32 > (int)200) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); - } - - // Int32 (int) minimum - if (this.Int32 < (int)20) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); - } - - // Integer (int) maximum - if (this.Integer > (int)100) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); - } - - // Integer (int) minimum - if (this.Integer < (int)10) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); - } - // Number (decimal) maximum if (this.Number > (decimal)543.2) { @@ -316,50 +374,102 @@ namespace Org.OpenAPITools.Model yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); } - if (this.PatternWithBackslash != null) { + // VarDouble (double) maximum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value > (double)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); + } + + // VarDouble (double) minimum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value < (double)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); + } + + // VarFloat (float) maximum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value > (float)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); + } + + // VarFloat (float) minimum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value < (float)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); + } + + // Int32 (int) maximum + if (this.Int32Option.IsSet && this.Int32Option.Value > (int)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int) minimum + if (this.Int32Option.IsSet && this.Int32Option.Value < (int)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Integer (int) maximum + if (this.IntegerOption.IsSet && this.IntegerOption.Value > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int) minimum + if (this.IntegerOption.IsSet && this.IntegerOption.Value < (int)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + if (this.PatternWithBackslashOption.Value != null) { // PatternWithBackslash (string) pattern Regex regexPatternWithBackslash = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$", RegexOptions.CultureInvariant); - if (!regexPatternWithBackslash.Match(this.PatternWithBackslash).Success) + + if (this.PatternWithBackslashOption.Value != null &&!regexPatternWithBackslash.Match(this.PatternWithBackslashOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithBackslash, must match a pattern of " + regexPatternWithBackslash, new [] { "PatternWithBackslash" }); } } - if (this.PatternWithDigits != null) { + if (this.PatternWithDigitsOption.Value != null) { // PatternWithDigits (string) pattern Regex regexPatternWithDigits = new Regex(@"^\d{10}$", RegexOptions.CultureInvariant); - if (!regexPatternWithDigits.Match(this.PatternWithDigits).Success) + + if (this.PatternWithDigitsOption.Value != null &&!regexPatternWithDigits.Match(this.PatternWithDigitsOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigits, must match a pattern of " + regexPatternWithDigits, new [] { "PatternWithDigits" }); } } - if (this.PatternWithDigitsAndDelimiter != null) { + if (this.PatternWithDigitsAndDelimiterOption.Value != null) { // PatternWithDigitsAndDelimiter (string) pattern Regex regexPatternWithDigitsAndDelimiter = new Regex(@"^image_\d{1,3}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiter).Success) + + if (this.PatternWithDigitsAndDelimiterOption.Value != null &&!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiterOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigitsAndDelimiter, must match a pattern of " + regexPatternWithDigitsAndDelimiter, new [] { "PatternWithDigitsAndDelimiter" }); } } - if (this.VarString != null) { + if (this.VarStringOption.Value != null) { // VarString (string) pattern Regex regexVarString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexVarString.Match(this.VarString).Success) + + if (this.VarStringOption.Value != null &&!regexVarString.Match(this.VarStringOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarString, must match a pattern of " + regexVarString, new [] { "VarString" }); } } // UnsignedInteger (uint) maximum - if (this.UnsignedInteger > (uint)200) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value > (uint)200) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value less than or equal to 200.", new [] { "UnsignedInteger" }); } // UnsignedInteger (uint) minimum - if (this.UnsignedInteger < (uint)20) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value < (uint)20) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value greater than or equal to 20.", new [] { "UnsignedInteger" }); } @@ -400,25 +510,25 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - System.IO.Stream? binary = default; - byte[]? varByte = default; - DateTime? date = default; - DateTime? dateTime = default; - decimal? varDecimal = default; - double? varDouble = default; - float? varFloat = default; - int? int32 = default; - long? int64 = default; - int? integer = default; - decimal? number = default; - string? password = default; - string? patternWithBackslash = default; - string? patternWithDigits = default; - string? patternWithDigitsAndDelimiter = default; - string? varString = default; - uint? unsignedInteger = default; - ulong? unsignedLong = default; - Guid? uuid = default; + Option varByte = default; + Option date = default; + Option number = default; + Option password = default; + 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; while (utf8JsonReader.Read()) { @@ -435,76 +545,76 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "binary": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - binary = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; case "byte": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varByte = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varByte = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "date": if (utf8JsonReader.TokenType != JsonTokenType.Null) - date = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "dateTime": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "decimal": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDecimal = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "double": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDouble = utf8JsonReader.GetDouble(); - break; - case "float": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varFloat = (float)utf8JsonReader.GetDouble(); - break; - case "int32": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int32 = utf8JsonReader.GetInt32(); - break; - case "int64": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int64 = utf8JsonReader.GetInt64(); - break; - case "integer": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - integer = utf8JsonReader.GetInt32(); + date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - number = utf8JsonReader.GetDecimal(); + number = new Option(utf8JsonReader.GetDecimal()); break; case "password": - password = utf8JsonReader.GetString(); + password = new Option(utf8JsonReader.GetString()!); + break; + case "binary": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + binary = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "decimal": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDecimal = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "double": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDouble = new Option(utf8JsonReader.GetDouble()); + break; + case "float": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varFloat = new Option((float)utf8JsonReader.GetDouble()); + break; + case "int32": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int32 = new Option(utf8JsonReader.GetInt32()); + break; + case "int64": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int64 = new Option(utf8JsonReader.GetInt64()); + break; + case "integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integer = new Option(utf8JsonReader.GetInt32()); break; case "pattern_with_backslash": - patternWithBackslash = utf8JsonReader.GetString(); + patternWithBackslash = new Option(utf8JsonReader.GetString()!); break; case "pattern_with_digits": - patternWithDigits = utf8JsonReader.GetString(); + patternWithDigits = new Option(utf8JsonReader.GetString()!); break; case "pattern_with_digits_and_delimiter": - patternWithDigitsAndDelimiter = utf8JsonReader.GetString(); + patternWithDigitsAndDelimiter = new Option(utf8JsonReader.GetString()!); break; case "string": - varString = utf8JsonReader.GetString(); + varString = new Option(utf8JsonReader.GetString()!); break; case "unsigned_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedInteger = utf8JsonReader.GetUInt32(); + unsignedInteger = new Option(utf8JsonReader.GetUInt32()); break; case "unsigned_long": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedLong = utf8JsonReader.GetUInt64(); + unsignedLong = new Option(utf8JsonReader.GetUInt64()); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -512,64 +622,76 @@ namespace Org.OpenAPITools.Model } } - if (binary == null) - throw new ArgumentNullException(nameof(binary), "Property is required for class FormatTest."); + if (!varByte.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(varByte)); - if (varByte == null) - throw new ArgumentNullException(nameof(varByte), "Property is required for class FormatTest."); + if (!date.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(date)); - if (date == null) - throw new ArgumentNullException(nameof(date), "Property is required for class FormatTest."); + if (!number.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(number)); - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class FormatTest."); + if (!password.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(password)); - if (varDecimal == null) - throw new ArgumentNullException(nameof(varDecimal), "Property is required for class FormatTest."); + if (varByte.IsSet && varByte.Value == null) + throw new ArgumentNullException(nameof(varByte), "Property is not nullable for class FormatTest."); - if (varDouble == null) - throw new ArgumentNullException(nameof(varDouble), "Property is required for class FormatTest."); + if (date.IsSet && date.Value == null) + throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest."); - if (varFloat == null) - throw new ArgumentNullException(nameof(varFloat), "Property is required for class FormatTest."); + if (number.IsSet && number.Value == null) + throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest."); - if (int32 == null) - throw new ArgumentNullException(nameof(int32), "Property is required for class FormatTest."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class FormatTest."); - if (int64 == null) - throw new ArgumentNullException(nameof(int64), "Property is required for class FormatTest."); + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest."); - if (integer == null) - throw new ArgumentNullException(nameof(integer), "Property is required for class FormatTest."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest."); - if (number == null) - throw new ArgumentNullException(nameof(number), "Property is required for class FormatTest."); + if (varDecimal.IsSet && varDecimal.Value == null) + throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class FormatTest."); + if (varDouble.IsSet && varDouble.Value == null) + throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest."); - if (patternWithBackslash == null) - throw new ArgumentNullException(nameof(patternWithBackslash), "Property is required for class FormatTest."); + if (varFloat.IsSet && varFloat.Value == null) + throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest."); - if (patternWithDigits == null) - throw new ArgumentNullException(nameof(patternWithDigits), "Property is required for class FormatTest."); + if (int32.IsSet && int32.Value == null) + throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest."); - if (patternWithDigitsAndDelimiter == null) - throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + if (int64.IsSet && int64.Value == null) + throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest."); - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FormatTest."); + if (integer.IsSet && integer.Value == null) + throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest."); - if (unsignedInteger == null) - throw new ArgumentNullException(nameof(unsignedInteger), "Property is required for class FormatTest."); + if (patternWithBackslash.IsSet && patternWithBackslash.Value == null) + throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest."); - if (unsignedLong == null) - throw new ArgumentNullException(nameof(unsignedLong), "Property is required for class FormatTest."); + if (patternWithDigits.IsSet && patternWithDigits.Value == null) + throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class FormatTest."); + if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null) + throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest."); - return new FormatTest(binary, varByte, date.Value, dateTime.Value, varDecimal.Value, varDouble.Value, varFloat.Value, int32.Value, int64.Value, integer.Value, number.Value, password, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger.Value, unsignedLong.Value, uuid.Value); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest."); + + if (unsignedInteger.IsSet && unsignedInteger.Value == null) + throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest."); + + if (unsignedLong.IsSet && unsignedLong.Value == null) + throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest."); + + 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, int64, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid); } /// @@ -596,28 +718,83 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("binary"); - JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + if (formatTest.VarByte == null) + throw new ArgumentNullException(nameof(formatTest.VarByte), "Property is required for class FormatTest."); + + if (formatTest.Password == null) + throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest."); + + if (formatTest.BinaryOption.IsSet && formatTest.Binary == null) + throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest."); + + if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + + if (formatTest.VarStringOption.IsSet && formatTest.VarString == null) + throw new ArgumentNullException(nameof(formatTest.VarString), "Property is required for class FormatTest."); + writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.VarByte, jsonSerializerOptions); writer.WriteString("date", formatTest.Date.ToString(DateFormat)); - writer.WriteString("dateTime", formatTest.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("decimal"); - JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); - writer.WriteNumber("double", formatTest.VarDouble); - writer.WriteNumber("float", formatTest.VarFloat); - writer.WriteNumber("int32", formatTest.Int32); - writer.WriteNumber("int64", formatTest.Int64); - writer.WriteNumber("integer", formatTest.Integer); + writer.WriteNumber("number", formatTest.Number); + writer.WriteString("password", formatTest.Password); - writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); - writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); - writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); - writer.WriteString("string", formatTest.VarString); - writer.WriteNumber("unsigned_integer", formatTest.UnsignedInteger); - writer.WriteNumber("unsigned_long", formatTest.UnsignedLong); - writer.WriteString("uuid", formatTest.Uuid); + + if (formatTest.BinaryOption.IsSet) + { + writer.WritePropertyName("binary"); + JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + } + if (formatTest.DateTimeOption.IsSet) + writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat)); + + if (formatTest.VarDecimalOption.IsSet) + { + writer.WritePropertyName("decimal"); + JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); + } + if (formatTest.VarDoubleOption.IsSet) + writer.WriteNumber("double", formatTest.VarDoubleOption.Value!.Value); + + if (formatTest.VarFloatOption.IsSet) + writer.WriteNumber("float", formatTest.VarFloatOption.Value!.Value); + + if (formatTest.Int32Option.IsSet) + writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value); + + if (formatTest.Int64Option.IsSet) + writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value); + + if (formatTest.IntegerOption.IsSet) + writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value); + + if (formatTest.PatternWithBackslashOption.IsSet) + writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); + + if (formatTest.PatternWithDigitsOption.IsSet) + writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet) + writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); + + if (formatTest.VarStringOption.IsSet) + writer.WriteString("string", formatTest.VarString); + + if (formatTest.UnsignedIntegerOption.IsSet) + writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value); + + if (formatTest.UnsignedLongOption.IsSet) + writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value); + + if (formatTest.UuidOption.IsSet) + writer.WriteString("uuid", formatTest.UuidOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs index c3e213f48a4..ebb0d41f720 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,10 +36,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Apple apple, string color) + public Fruit(Apple apple, Option color = default) { Apple = apple; - Color = color; + ColorOption = color; OnCreated(); } @@ -47,10 +48,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Banana banana, string color) + public Fruit(Banana banana, Option color = default) { Banana = banana; - Color = color; + ColorOption = color; OnCreated(); } @@ -66,11 +67,18 @@ namespace Org.OpenAPITools.Model /// public Banana? Banana { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Returns the string presentation of the object @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? color = default; + Option color = default; Apple? apple = default; Banana? banana = default; @@ -158,7 +166,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -166,8 +174,8 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Fruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); if (apple != null) return new Fruit(apple, color); @@ -202,7 +210,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", fruit.Color); + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs index 56212b9c18d..46c3c3b2540 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs index 9ed8b2db2d1..0170c34db96 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,31 +37,52 @@ namespace Org.OpenAPITools.Model /// /// /// color - public GmFruit(Apple? apple, Banana? banana, string color) + public GmFruit(Option apple, Option banana, Option color = default) { - Apple = apple; - Banana = banana; - Color = color; + AppleOption = apple; + BananaOption = banana; + ColorOption = color; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + /// /// Gets or Sets Apple /// - public Apple? Apple { get; set; } + public Apple? Apple { get { return this.AppleOption; } set { this.AppleOption = new(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } /// /// Gets or Sets Banana /// - public Banana? Banana { get; set; } + public Banana? Banana { get { return this.BananaOption; } set { this.BananaOption = new(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Returns the string presentation of the object @@ -108,7 +130,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? color = default; + Option color = default; Apple? apple = default; Banana? banana = default; @@ -148,7 +170,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -156,10 +178,17 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class GmFruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit."); - return new GmFruit(apple, banana, color); + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new GmFruit(appleParsedValue, bananaParsedValue, color); } /// @@ -173,16 +202,16 @@ namespace Org.OpenAPITools.Model { writer.WriteStartObject(); - if (gmFruit.Apple != null) + if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { - AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Apple.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.Apple, jsonSerializerOptions); + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); } - if (gmFruit.Banana != null) + if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null) { - BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Banana.GetType())); - BananaJsonConverter.WriteProperties(ref writer, gmFruit.Banana, jsonSerializerOptions); + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } WriteProperties(ref writer, gmFruit, jsonSerializerOptions); @@ -198,7 +227,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", gmFruit.Color); + if (gmFruit.ColorOption.IsSet && gmFruit.Color == null) + throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit."); + + if (gmFruit.ColorOption.IsSet) + writer.WriteString("color", gmFruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index cb7fe43f91c..a0068cc6781 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -112,7 +113,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -130,7 +131,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -138,10 +139,13 @@ namespace Org.OpenAPITools.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class GrandparentAnimal."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class GrandparentAnimal.", nameof(petType)); - return new GrandparentAnimal(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); + + return new GrandparentAnimal(petType.Value!); } /// @@ -168,6 +172,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { + if (grandparentAnimal.PetType == null) + throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); + writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 3b8c651908c..e9fac6f25e5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// bar /// foo [JsonConstructor] - internal HasOnlyReadOnly(string bar, string foo) + internal HasOnlyReadOnly(Option bar = default, Option foo = default) { - Bar = bar; - Foo = foo; + BarOption = bar; + FooOption = foo; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string? Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Foo + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FooOption { get; } /// /// Gets or Sets Foo /// [JsonPropertyName("foo")] - public string Foo { get; } + public string? Foo { get { return this. FooOption; } } /// /// Gets or Sets additional properties @@ -107,8 +122,12 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); - hashCode = (hashCode * 59) + Foo.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + if (Foo != null) + hashCode = (hashCode * 59) + Foo.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -148,8 +167,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? bar = default; - string? foo = default; + Option bar = default; + Option foo = default; while (utf8JsonReader.Read()) { @@ -167,10 +186,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()!); break; case "foo": - foo = utf8JsonReader.GetString(); + foo = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -178,11 +197,11 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class HasOnlyReadOnly."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly."); - if (foo == null) - throw new ArgumentNullException(nameof(foo), "Property is required for class HasOnlyReadOnly."); + if (foo.IsSet && foo.Value == null) + throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly."); return new HasOnlyReadOnly(bar, foo); } @@ -211,8 +230,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", hasOnlyReadOnly.Bar); - writer.WriteString("foo", hasOnlyReadOnly.Foo); + if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.BarOption.IsSet) + writer.WriteString("bar", hasOnlyReadOnly.Bar); + + if (hasOnlyReadOnly.FooOption.IsSet) + writer.WriteString("foo", hasOnlyReadOnly.Foo); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs index ccdc21a0685..e95d79fee9d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// nullableMessage [JsonConstructor] - public HealthCheckResult(string? nullableMessage = default) + public HealthCheckResult(Option nullableMessage = default) { - NullableMessage = nullableMessage; + NullableMessageOption = nullableMessage; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of NullableMessage + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableMessageOption { get; private set; } + /// /// Gets or Sets NullableMessage /// [JsonPropertyName("NullableMessage")] - public string? NullableMessage { get; set; } + public string? NullableMessage { get { return this. NullableMessageOption; } set { this.NullableMessageOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? nullableMessage = default; + Option nullableMessage = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "NullableMessage": - nullableMessage = utf8JsonReader.GetString(); + nullableMessage = new Option(utf8JsonReader.GetString()); break; default: break; @@ -155,7 +163,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + if (healthCheckResult.NullableMessageOption.IsSet) + if (healthCheckResult.NullableMessageOption.Value != null) + writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + else + writer.WriteNull("NullableMessage"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index f33f99e6dfb..378561b5e32 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -104,8 +105,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; - string? triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -123,10 +124,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -134,13 +135,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class IsoscelesTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class IsoscelesTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(triangleType)); - return new IsoscelesTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class IsoscelesTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class IsoscelesTriangle."); + + return new IsoscelesTriangle(shapeType.Value!, triangleType.Value!); } /// @@ -167,7 +174,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (isoscelesTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle."); + + if (isoscelesTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle."); + writer.WriteString("shapeType", isoscelesTriangle.ShapeType); + writer.WriteString("triangleType", isoscelesTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs index 8f55db6ee70..a14d5e9973b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// var123List [JsonConstructor] - public List(string var123List) + public List(Option var123List = default) { - Var123List = var123List; + Var123ListOption = var123List; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Var123List + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123ListOption { get; private set; } + /// /// Gets or Sets Var123List /// [JsonPropertyName("123-list")] - public string Var123List { get; set; } + public string? Var123List { get { return this. Var123ListOption; } set { this.Var123ListOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? var123List = default; + Option var123List = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "123-list": - var123List = utf8JsonReader.GetString(); + var123List = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (var123List == null) - throw new ArgumentNullException(nameof(var123List), "Property is required for class List."); + if (var123List.IsSet && var123List.Value == null) + throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List."); return new List(var123List); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("123-list", list.Var123List); + if (list.Var123ListOption.IsSet && list.Var123List == null) + throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List."); + + if (list.Var123ListOption.IsSet) + writer.WriteString("123-list", list.Var123List); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 8253e7ac7bc..639e2b6c76d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// escapedLiteralString (default to "C:\\Users\\username") /// unescapedLiteralString (default to "C:\Users\username") [JsonConstructor] - public LiteralStringClass(string escapedLiteralString = @"C:\\Users\\username", string unescapedLiteralString = @"C:\Users\username") + public LiteralStringClass(Option escapedLiteralString = default, Option unescapedLiteralString = default) { - EscapedLiteralString = escapedLiteralString; - UnescapedLiteralString = unescapedLiteralString; + EscapedLiteralStringOption = escapedLiteralString; + UnescapedLiteralStringOption = unescapedLiteralString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of EscapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EscapedLiteralStringOption { get; private set; } + /// /// Gets or Sets EscapedLiteralString /// [JsonPropertyName("escapedLiteralString")] - public string EscapedLiteralString { get; set; } + public string? EscapedLiteralString { get { return this. EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new(value); } } + + /// + /// Used to track the state of UnescapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnescapedLiteralStringOption { get; private set; } /// /// Gets or Sets UnescapedLiteralString /// [JsonPropertyName("unescapedLiteralString")] - public string UnescapedLiteralString { get; set; } + public string? UnescapedLiteralString { get { return this. UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? escapedLiteralString = default; - string? unescapedLiteralString = default; + Option escapedLiteralString = default; + Option unescapedLiteralString = default; while (utf8JsonReader.Read()) { @@ -130,10 +145,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "escapedLiteralString": - escapedLiteralString = utf8JsonReader.GetString(); + escapedLiteralString = new Option(utf8JsonReader.GetString()!); break; case "unescapedLiteralString": - unescapedLiteralString = utf8JsonReader.GetString(); + unescapedLiteralString = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -141,11 +156,11 @@ namespace Org.OpenAPITools.Model } } - if (escapedLiteralString == null) - throw new ArgumentNullException(nameof(escapedLiteralString), "Property is required for class LiteralStringClass."); + if (escapedLiteralString.IsSet && escapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass."); - if (unescapedLiteralString == null) - throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is required for class LiteralStringClass."); + if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass."); return new LiteralStringClass(escapedLiteralString, unescapedLiteralString); } @@ -174,8 +189,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); - writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); + if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.EscapedLiteralStringOption.IsSet) + writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet) + writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs index 0910cbbb0a1..40b4a549ca6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -152,7 +153,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; Pig? pig = null; Whale? whale = null; @@ -209,7 +210,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -217,17 +218,20 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Mammal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Mammal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className); + return new Mammal(pig, className.Value!); if (whale != null) - return new Mammal(whale, className); + return new Mammal(whale, className.Value!); if (zebra != null) - return new Mammal(zebra, className); + return new Mammal(zebra, className.Value!); throw new JsonException(); } @@ -271,6 +275,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { + if (mammal.ClassName == null) + throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); + writer.WriteString("className", mammal.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs index e5442a41c59..e5303dbc788 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,12 +39,12 @@ namespace Org.OpenAPITools.Model /// mapMapOfString /// mapOfEnumString [JsonConstructor] - public MapTest(Dictionary directMap, Dictionary indirectMap, Dictionary> mapMapOfString, Dictionary mapOfEnumString) + public MapTest(Option?> directMap = default, Option?> indirectMap = default, Option>?> mapMapOfString = default, Option?> mapOfEnumString = default) { - DirectMap = directMap; - IndirectMap = indirectMap; - MapMapOfString = mapMapOfString; - MapOfEnumString = mapOfEnumString; + DirectMapOption = directMap; + IndirectMapOption = indirectMap; + MapMapOfStringOption = mapMapOfString; + MapOfEnumStringOption = mapOfEnumString; OnCreated(); } @@ -104,9 +105,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string InnerEnumToJsonValue(InnerEnum value) + public static string InnerEnumToJsonValue(InnerEnum? value) { - if (value == InnerEnum.UPPER) return "UPPER"; @@ -116,29 +116,57 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of DirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DirectMapOption { get; private set; } + /// /// Gets or Sets DirectMap /// [JsonPropertyName("direct_map")] - public Dictionary DirectMap { get; set; } + public Dictionary? DirectMap { get { return this. DirectMapOption; } set { this.DirectMapOption = new(value); } } + + /// + /// Used to track the state of IndirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> IndirectMapOption { get; private set; } /// /// Gets or Sets IndirectMap /// [JsonPropertyName("indirect_map")] - public Dictionary IndirectMap { get; set; } + public Dictionary? IndirectMap { get { return this. IndirectMapOption; } set { this.IndirectMapOption = new(value); } } + + /// + /// Used to track the state of MapMapOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>?> MapMapOfStringOption { get; private set; } /// /// Gets or Sets MapMapOfString /// [JsonPropertyName("map_map_of_string")] - public Dictionary> MapMapOfString { get; set; } + public Dictionary>? MapMapOfString { get { return this. MapMapOfStringOption; } set { this.MapMapOfStringOption = new(value); } } + + /// + /// Used to track the state of MapOfEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapOfEnumStringOption { get; private set; } /// /// Gets or Sets MapOfEnumString /// [JsonPropertyName("map_of_enum_string")] - public Dictionary MapOfEnumString { get; set; } + public Dictionary? MapOfEnumString { get { return this. MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -196,10 +224,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary? directMap = default; - Dictionary? indirectMap = default; - Dictionary>? mapMapOfString = default; - Dictionary? mapOfEnumString = default; + Option?> directMap = default; + Option?> indirectMap = default; + Option>?> mapMapOfString = default; + Option?> mapOfEnumString = default; while (utf8JsonReader.Read()) { @@ -218,19 +246,19 @@ namespace Org.OpenAPITools.Model { case "direct_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - directMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + directMap = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "indirect_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - indirectMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + indirectMap = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_map_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapMapOfString = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapMapOfString = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "map_of_enum_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfEnumString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapOfEnumString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -238,17 +266,17 @@ namespace Org.OpenAPITools.Model } } - if (directMap == null) - throw new ArgumentNullException(nameof(directMap), "Property is required for class MapTest."); + if (directMap.IsSet && directMap.Value == null) + throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest."); - if (indirectMap == null) - throw new ArgumentNullException(nameof(indirectMap), "Property is required for class MapTest."); + if (indirectMap.IsSet && indirectMap.Value == null) + throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest."); - if (mapMapOfString == null) - throw new ArgumentNullException(nameof(mapMapOfString), "Property is required for class MapTest."); + if (mapMapOfString.IsSet && mapMapOfString.Value == null) + throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest."); - if (mapOfEnumString == null) - throw new ArgumentNullException(nameof(mapOfEnumString), "Property is required for class MapTest."); + if (mapOfEnumString.IsSet && mapOfEnumString.Value == null) + throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest."); return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString); } @@ -277,14 +305,38 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("direct_map"); - JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); - writer.WritePropertyName("indirect_map"); - JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); - writer.WritePropertyName("map_map_of_string"); - JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); - writer.WritePropertyName("map_of_enum_string"); - JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null) + throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest."); + + if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null) + throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest."); + + if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null) + throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest."); + + if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null) + throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest."); + + if (mapTest.DirectMapOption.IsSet) + { + writer.WritePropertyName("direct_map"); + JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); + } + if (mapTest.IndirectMapOption.IsSet) + { + writer.WritePropertyName("indirect_map"); + JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); + } + if (mapTest.MapMapOfStringOption.IsSet) + { + writer.WritePropertyName("map_map_of_string"); + JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); + } + if (mapTest.MapOfEnumStringOption.IsSet) + { + writer.WritePropertyName("map_of_enum_string"); + JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 2ea2d79b05d..f8d1ff8356a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,40 +39,68 @@ namespace Org.OpenAPITools.Model /// uuid /// uuidWithPattern [JsonConstructor] - public MixedPropertiesAndAdditionalPropertiesClass(DateTime dateTime, Dictionary map, Guid uuid, Guid uuidWithPattern) + public MixedPropertiesAndAdditionalPropertiesClass(Option dateTime = default, Option?> map = default, Option uuid = default, Option uuidWithPattern = default) { - DateTime = dateTime; - Map = map; - Uuid = uuid; - UuidWithPattern = uuidWithPattern; + DateTimeOption = dateTime; + MapOption = map; + UuidOption = uuid; + UuidWithPatternOption = uuidWithPattern; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + /// /// Gets or Sets DateTime /// [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } } + + /// + /// Used to track the state of Map + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> MapOption { get; private set; } /// /// Gets or Sets Map /// [JsonPropertyName("map")] - public Dictionary Map { get; set; } + public Dictionary? Map { get { return this. MapOption; } set { this.MapOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// Used to track the state of UuidWithPattern + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidWithPatternOption { get; private set; } /// /// Gets or Sets UuidWithPattern /// [JsonPropertyName("uuid_with_pattern")] - public Guid UuidWithPattern { get; set; } + public Guid? UuidWithPattern { get { return this. UuidWithPatternOption; } set { this.UuidWithPatternOption = new(value); } } /// /// Gets or Sets additional properties @@ -105,7 +134,8 @@ namespace Org.OpenAPITools.Model { // UuidWithPattern (Guid) pattern Regex regexUuidWithPattern = new Regex(@"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", RegexOptions.CultureInvariant); - if (!regexUuidWithPattern.Match(this.UuidWithPattern.ToString()).Success) + + if (this.UuidWithPatternOption.Value != null &&!regexUuidWithPattern.Match(this.UuidWithPatternOption.Value.ToString()!).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UuidWithPattern, must match a pattern of " + regexUuidWithPattern, new [] { "UuidWithPattern" }); } @@ -140,10 +170,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateTime = default; - Dictionary? map = default; - Guid? uuid = default; - Guid? uuidWithPattern = default; + Option dateTime = default; + Option?> map = default; + Option uuid = default; + Option uuidWithPattern = default; while (utf8JsonReader.Read()) { @@ -162,19 +192,19 @@ namespace Org.OpenAPITools.Model { case "dateTime": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - map = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + map = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; case "uuid_with_pattern": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuidWithPattern = utf8JsonReader.GetGuid(); + uuidWithPattern = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -182,19 +212,19 @@ namespace Org.OpenAPITools.Model } } - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (map == null) - throw new ArgumentNullException(nameof(map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (map.IsSet && map.Value == null) + throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuidWithPattern == null) - throw new ArgumentNullException(nameof(uuidWithPattern), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuidWithPattern.IsSet && uuidWithPattern.Value == null) + throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - return new MixedPropertiesAndAdditionalPropertiesClass(dateTime.Value, map, uuid.Value, uuidWithPattern.Value); + return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern); } /// @@ -221,11 +251,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("map"); - JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); - writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.Uuid); - writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern); + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null) + throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet) + writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat)); + + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet) + { + writer.WritePropertyName("map"); + JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); + } + if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet) + writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value); + + if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet) + writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs index b017d071583..42e64ef2054 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// varClass /// name [JsonConstructor] - public Model200Response(string varClass, int name) + public Model200Response(Option varClass = default, Option name = default) { - VarClass = varClass; - Name = name; + VarClassOption = varClass; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("class")] - public string VarClass { get; set; } + public string? VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public int Name { get; set; } + public int? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varClass = default; - int? name = default; + Option varClass = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -130,11 +145,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()!); break; case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - name = utf8JsonReader.GetInt32(); + name = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -142,13 +157,13 @@ namespace Org.OpenAPITools.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class Model200Response."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Model200Response."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response."); - return new Model200Response(varClass, name.Value); + return new Model200Response(varClass, name); } /// @@ -175,8 +190,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("class", model200Response.VarClass); - writer.WriteNumber("name", model200Response.Name); + if (model200Response.VarClassOption.IsSet && model200Response.VarClass == null) + throw new ArgumentNullException(nameof(model200Response.VarClass), "Property is required for class Model200Response."); + + if (model200Response.VarClassOption.IsSet) + writer.WriteString("class", model200Response.VarClass); + + if (model200Response.NameOption.IsSet) + writer.WriteNumber("name", model200Response.NameOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs index 1883e1d09c8..36196906905 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// varClient [JsonConstructor] - public ModelClient(string varClient) + public ModelClient(Option varClient = default) { - VarClient = varClient; + VarClientOption = varClient; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClient + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClientOption { get; private set; } + /// /// Gets or Sets VarClient /// [JsonPropertyName("client")] - public string VarClient { get; set; } + public string? VarClient { get { return this. VarClientOption; } set { this.VarClientOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varClient = default; + Option varClient = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "client": - varClient = utf8JsonReader.GetString(); + varClient = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (varClient == null) - throw new ArgumentNullException(nameof(varClient), "Property is required for class ModelClient."); + if (varClient.IsSet && varClient.Value == null) + throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient."); return new ModelClient(varClient); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("client", modelClient.VarClient); + if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null) + throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient."); + + if (modelClient.VarClientOption.IsSet) + writer.WriteString("client", modelClient.VarClient); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs index 83161d26894..91afe1999fc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,12 +39,12 @@ namespace Org.OpenAPITools.Model /// snakeCase /// var123Number [JsonConstructor] - public Name(int varName, string property, int snakeCase, int var123Number) + public Name(int varName, Option property = default, Option snakeCase = default, Option var123Number = default) { VarName = varName; - Property = property; - SnakeCase = snakeCase; - Var123Number = var123Number; + PropertyOption = property; + SnakeCaseOption = snakeCase; + Var123NumberOption = var123Number; OnCreated(); } @@ -55,23 +56,44 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("name")] public int VarName { get; set; } + /// + /// Used to track the state of Property + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PropertyOption { get; private set; } + /// /// Gets or Sets Property /// [JsonPropertyName("property")] - public string Property { get; set; } + public string? Property { get { return this. PropertyOption; } set { this.PropertyOption = new(value); } } + + /// + /// Used to track the state of SnakeCase + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SnakeCaseOption { get; } /// /// Gets or Sets SnakeCase /// [JsonPropertyName("snake_case")] - public int SnakeCase { get; } + public int? SnakeCase { get { return this. SnakeCaseOption; } } + + /// + /// Used to track the state of Var123Number + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123NumberOption { get; } /// /// Gets or Sets Var123Number /// [JsonPropertyName("123Number")] - public int Var123Number { get; } + public int? Var123Number { get { return this. Var123NumberOption; } } /// /// Gets or Sets additional properties @@ -125,8 +147,12 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); - hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + if (SnakeCase != null) + hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); + + if (Var123Number != null) + hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -166,10 +192,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varName = default; - string? property = default; - int? snakeCase = default; - int? var123Number = default; + Option varName = default; + Option property = default; + Option snakeCase = default; + Option var123Number = default; while (utf8JsonReader.Read()) { @@ -188,18 +214,18 @@ namespace Org.OpenAPITools.Model { case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varName = utf8JsonReader.GetInt32(); + varName = new Option(utf8JsonReader.GetInt32()); break; case "property": - property = utf8JsonReader.GetString(); + property = new Option(utf8JsonReader.GetString()!); break; case "snake_case": if (utf8JsonReader.TokenType != JsonTokenType.Null) - snakeCase = utf8JsonReader.GetInt32(); + snakeCase = new Option(utf8JsonReader.GetInt32()); break; case "123Number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - var123Number = utf8JsonReader.GetInt32(); + var123Number = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -207,19 +233,22 @@ namespace Org.OpenAPITools.Model } } - if (varName == null) - throw new ArgumentNullException(nameof(varName), "Property is required for class Name."); + if (!varName.IsSet) + throw new ArgumentException("Property is required for class Name.", nameof(varName)); - if (property == null) - throw new ArgumentNullException(nameof(property), "Property is required for class Name."); + if (varName.IsSet && varName.Value == null) + throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name."); - if (snakeCase == null) - throw new ArgumentNullException(nameof(snakeCase), "Property is required for class Name."); + if (property.IsSet && property.Value == null) + throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name."); - if (var123Number == null) - throw new ArgumentNullException(nameof(var123Number), "Property is required for class Name."); + if (snakeCase.IsSet && snakeCase.Value == null) + throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name."); - return new Name(varName.Value, property, snakeCase.Value, var123Number.Value); + if (var123Number.IsSet && var123Number.Value == null) + throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name."); + + return new Name(varName.Value!.Value!, property, snakeCase, var123Number); } /// @@ -246,10 +275,19 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) { + if (name.PropertyOption.IsSet && name.Property == null) + throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name."); + writer.WriteNumber("name", name.VarName); - writer.WriteString("property", name.Property); - writer.WriteNumber("snake_case", name.SnakeCase); - writer.WriteNumber("123Number", name.Var123Number); + + if (name.PropertyOption.IsSet) + writer.WriteString("property", name.Property); + + if (name.SnakeCaseOption.IsSet) + writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value); + + if (name.Var123NumberOption.IsSet) + writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index 23f7775d890..0be2516e511 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -111,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List>? aObjVariableobject = default; - int? pkiNotificationtestID = default; + Option>?> aObjVariableobject = default; + Option pkiNotificationtestID = default; while (utf8JsonReader.Read()) { @@ -131,11 +132,11 @@ namespace Org.OpenAPITools.Model { case "a_objVariableobject": if (utf8JsonReader.TokenType != JsonTokenType.Null) - aObjVariableobject = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + aObjVariableobject = new Option>?>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "pkiNotificationtestID": if (utf8JsonReader.TokenType != JsonTokenType.Null) - pkiNotificationtestID = utf8JsonReader.GetInt32(); + pkiNotificationtestID = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -143,13 +144,19 @@ namespace Org.OpenAPITools.Model } } - if (aObjVariableobject == null) - throw new ArgumentNullException(nameof(aObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!aObjVariableobject.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(aObjVariableobject)); - if (pkiNotificationtestID == null) - throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!pkiNotificationtestID.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(pkiNotificationtestID)); - return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject, pkiNotificationtestID.Value); + if (aObjVariableobject.IsSet && aObjVariableobject.Value == null) + throw new ArgumentNullException(nameof(aObjVariableobject), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + if (pkiNotificationtestID.IsSet && pkiNotificationtestID.Value == null) + throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject.Value!, pkiNotificationtestID.Value!.Value!); } /// @@ -176,6 +183,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) { + if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null) + throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + writer.WritePropertyName("a_objVariableobject"); JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions); writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs index 91674633497..8b33b92c468 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,9 +34,8 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// arrayItemsNullable - /// objectItemsNullable /// arrayAndItemsNullableProp + /// arrayItemsNullable /// arrayNullableProp /// booleanProp /// dateProp @@ -43,99 +43,184 @@ namespace Org.OpenAPITools.Model /// integerProp /// numberProp /// objectAndItemsNullableProp + /// objectItemsNullable /// objectNullableProp /// stringProp [JsonConstructor] - public NullableClass(List arrayItemsNullable, Dictionary objectItemsNullable, List? arrayAndItemsNullableProp = default, List? arrayNullableProp = default, bool? booleanProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, int? integerProp = default, decimal? numberProp = default, Dictionary? objectAndItemsNullableProp = default, Dictionary? objectNullableProp = default, string? stringProp = default) : base() + public NullableClass(Option?> arrayAndItemsNullableProp = default, Option?> arrayItemsNullable = default, Option?> arrayNullableProp = default, Option booleanProp = default, Option dateProp = default, Option datetimeProp = default, Option integerProp = default, Option numberProp = default, Option?> objectAndItemsNullableProp = default, Option?> objectItemsNullable = default, Option?> objectNullableProp = default, Option stringProp = default) : base() { - ArrayItemsNullable = arrayItemsNullable; - ObjectItemsNullable = objectItemsNullable; - ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - ArrayNullableProp = arrayNullableProp; - BooleanProp = booleanProp; - DateProp = dateProp; - DatetimeProp = datetimeProp; - IntegerProp = integerProp; - NumberProp = numberProp; - ObjectAndItemsNullableProp = objectAndItemsNullableProp; - ObjectNullableProp = objectNullableProp; - StringProp = stringProp; + ArrayAndItemsNullablePropOption = arrayAndItemsNullableProp; + ArrayItemsNullableOption = arrayItemsNullable; + ArrayNullablePropOption = arrayNullableProp; + BooleanPropOption = booleanProp; + DatePropOption = dateProp; + DatetimePropOption = datetimeProp; + IntegerPropOption = integerProp; + NumberPropOption = numberProp; + ObjectAndItemsNullablePropOption = objectAndItemsNullableProp; + ObjectItemsNullableOption = objectItemsNullable; + ObjectNullablePropOption = objectNullableProp; + StringPropOption = stringProp; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets ArrayItemsNullable + /// Used to track the state of ArrayAndItemsNullableProp /// - [JsonPropertyName("array_items_nullable")] - public List ArrayItemsNullable { get; set; } - - /// - /// Gets or Sets ObjectItemsNullable - /// - [JsonPropertyName("object_items_nullable")] - public Dictionary ObjectItemsNullable { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// [JsonPropertyName("array_and_items_nullable_prop")] - public List? ArrayAndItemsNullableProp { get; set; } + public List? ArrayAndItemsNullableProp { get { return this. ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new(value); } } + + /// + /// Used to track the state of ArrayItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ArrayItemsNullable + /// + [JsonPropertyName("array_items_nullable")] + public List? ArrayItemsNullable { get { return this. ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new(value); } } + + /// + /// Used to track the state of ArrayNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ArrayNullablePropOption { get; private set; } /// /// Gets or Sets ArrayNullableProp /// [JsonPropertyName("array_nullable_prop")] - public List? ArrayNullableProp { get; set; } + public List? ArrayNullableProp { get { return this. ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new(value); } } + + /// + /// Used to track the state of BooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BooleanPropOption { get; private set; } /// /// Gets or Sets BooleanProp /// [JsonPropertyName("boolean_prop")] - public bool? BooleanProp { get; set; } + public bool? BooleanProp { get { return this. BooleanPropOption; } set { this.BooleanPropOption = new(value); } } + + /// + /// Used to track the state of DateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatePropOption { get; private set; } /// /// Gets or Sets DateProp /// [JsonPropertyName("date_prop")] - public DateTime? DateProp { get; set; } + public DateTime? DateProp { get { return this. DatePropOption; } set { this.DatePropOption = new(value); } } + + /// + /// Used to track the state of DatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatetimePropOption { get; private set; } /// /// Gets or Sets DatetimeProp /// [JsonPropertyName("datetime_prop")] - public DateTime? DatetimeProp { get; set; } + public DateTime? DatetimeProp { get { return this. DatetimePropOption; } set { this.DatetimePropOption = new(value); } } + + /// + /// Used to track the state of IntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerPropOption { get; private set; } /// /// Gets or Sets IntegerProp /// [JsonPropertyName("integer_prop")] - public int? IntegerProp { get; set; } + public int? IntegerProp { get { return this. IntegerPropOption; } set { this.IntegerPropOption = new(value); } } + + /// + /// Used to track the state of NumberProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NumberPropOption { get; private set; } /// /// Gets or Sets NumberProp /// [JsonPropertyName("number_prop")] - public decimal? NumberProp { get; set; } + public decimal? NumberProp { get { return this. NumberPropOption; } set { this.NumberPropOption = new(value); } } + + /// + /// Used to track the state of ObjectAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ObjectAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// [JsonPropertyName("object_and_items_nullable_prop")] - public Dictionary? ObjectAndItemsNullableProp { get; set; } + public Dictionary? ObjectAndItemsNullableProp { get { return this. ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new(value); } } + + /// + /// Used to track the state of ObjectItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ObjectItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ObjectItemsNullable + /// + [JsonPropertyName("object_items_nullable")] + public Dictionary? ObjectItemsNullable { get { return this. ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new(value); } } + + /// + /// Used to track the state of ObjectNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ObjectNullablePropOption { get; private set; } /// /// Gets or Sets ObjectNullableProp /// [JsonPropertyName("object_nullable_prop")] - public Dictionary? ObjectNullableProp { get; set; } + public Dictionary? ObjectNullableProp { get { return this. ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new(value); } } + + /// + /// Used to track the state of StringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringPropOption { get; private set; } /// /// Gets or Sets StringProp /// [JsonPropertyName("string_prop")] - public string? StringProp { get; set; } + public string? StringProp { get { return this. StringPropOption; } set { this.StringPropOption = new(value); } } /// /// Gets or Sets additional properties @@ -152,9 +237,8 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class NullableClass {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); - sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); - sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); sb.Append(" DateProp: ").Append(DateProp).Append("\n"); @@ -162,6 +246,7 @@ namespace Org.OpenAPITools.Model sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -222,18 +307,18 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? arrayItemsNullable = default; - Dictionary? objectItemsNullable = default; - List? arrayAndItemsNullableProp = default; - List? arrayNullableProp = default; - bool? booleanProp = default; - DateTime? dateProp = default; - DateTime? datetimeProp = default; - int? integerProp = default; - decimal? numberProp = default; - Dictionary? objectAndItemsNullableProp = default; - Dictionary? objectNullableProp = default; - string? stringProp = default; + Option?> arrayAndItemsNullableProp = default; + Option?> arrayItemsNullable = default; + Option?> arrayNullableProp = default; + Option booleanProp = default; + Option dateProp = default; + Option datetimeProp = default; + Option integerProp = default; + Option numberProp = default; + Option?> objectAndItemsNullableProp = default; + Option?> objectItemsNullable = default; + Option?> objectNullableProp = default; + Option stringProp = default; while (utf8JsonReader.Read()) { @@ -250,52 +335,52 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "array_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "object_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; case "array_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayAndItemsNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayItemsNullable = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "array_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "boolean_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - booleanProp = utf8JsonReader.GetBoolean(); + booleanProp = new Option(utf8JsonReader.GetBoolean()); break; case "date_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "datetime_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - datetimeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + datetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "integer_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - integerProp = utf8JsonReader.GetInt32(); + integerProp = new Option(utf8JsonReader.GetInt32()); break; case "number_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - numberProp = utf8JsonReader.GetDecimal(); + numberProp = new Option(utf8JsonReader.GetDecimal()); break; case "object_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectAndItemsNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectItemsNullable = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "object_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectNullableProp = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "string_prop": - stringProp = utf8JsonReader.GetString(); + stringProp = new Option(utf8JsonReader.GetString()); break; default: break; @@ -303,13 +388,13 @@ namespace Org.OpenAPITools.Model } } - if (arrayItemsNullable == null) - throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is required for class NullableClass."); + if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null) + throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass."); - if (objectItemsNullable == null) - throw new ArgumentNullException(nameof(objectItemsNullable), "Property is required for class NullableClass."); + if (objectItemsNullable.IsSet && objectItemsNullable.Value == null) + throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass."); - return new NullableClass(arrayItemsNullable, objectItemsNullable, arrayAndItemsNullableProp, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectNullableProp, stringProp); + return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp); } /// @@ -336,45 +421,89 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("object_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("array_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("array_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.BooleanProp != null) - writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); - else - writer.WriteNull("boolean_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.DateProp != null) - writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(DatePropFormat)); - else - writer.WriteNull("date_prop"); + if (nullableClass.ArrayAndItemsNullablePropOption.IsSet) + if (nullableClass.ArrayAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("array_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_and_items_nullable_prop"); + if (nullableClass.ArrayItemsNullableOption.IsSet) + { + writer.WritePropertyName("array_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ArrayNullablePropOption.IsSet) + if (nullableClass.ArrayNullablePropOption.Value != null) + { + writer.WritePropertyName("array_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_nullable_prop"); + if (nullableClass.BooleanPropOption.IsSet) + if (nullableClass.BooleanPropOption.Value != null) + writer.WriteBoolean("boolean_prop", nullableClass.BooleanPropOption.Value!.Value); + else + writer.WriteNull("boolean_prop"); - if (nullableClass.DatetimeProp != null) - writer.WriteString("datetime_prop", nullableClass.DatetimeProp.Value.ToString(DatetimePropFormat)); - else - writer.WriteNull("datetime_prop"); + if (nullableClass.DatePropOption.IsSet) + if (nullableClass.DatePropOption.Value != null) + writer.WriteString("date_prop", nullableClass.DatePropOption.Value!.Value.ToString(DatePropFormat)); + else + writer.WriteNull("date_prop"); - if (nullableClass.IntegerProp != null) - writer.WriteNumber("integer_prop", nullableClass.IntegerProp.Value); - else - writer.WriteNull("integer_prop"); + if (nullableClass.DatetimePropOption.IsSet) + if (nullableClass.DatetimePropOption.Value != null) + writer.WriteString("datetime_prop", nullableClass.DatetimePropOption.Value!.Value.ToString(DatetimePropFormat)); + else + writer.WriteNull("datetime_prop"); - if (nullableClass.NumberProp != null) - writer.WriteNumber("number_prop", nullableClass.NumberProp.Value); - else - writer.WriteNull("number_prop"); + if (nullableClass.IntegerPropOption.IsSet) + if (nullableClass.IntegerPropOption.Value != null) + writer.WriteNumber("integer_prop", nullableClass.IntegerPropOption.Value!.Value); + else + writer.WriteNull("integer_prop"); - writer.WritePropertyName("object_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("object_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); - writer.WriteString("string_prop", nullableClass.StringProp); + if (nullableClass.NumberPropOption.IsSet) + if (nullableClass.NumberPropOption.Value != null) + writer.WriteNumber("number_prop", nullableClass.NumberPropOption.Value!.Value); + else + writer.WriteNull("number_prop"); + + if (nullableClass.ObjectAndItemsNullablePropOption.IsSet) + if (nullableClass.ObjectAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("object_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_and_items_nullable_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet) + { + writer.WritePropertyName("object_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ObjectNullablePropOption.IsSet) + if (nullableClass.ObjectNullablePropOption.Value != null) + { + writer.WritePropertyName("object_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_nullable_prop"); + if (nullableClass.StringPropOption.IsSet) + if (nullableClass.StringPropOption.Value != null) + writer.WriteString("string_prop", nullableClass.StringProp); + else + writer.WriteNull("string_prop"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableGuidClass.cs index b5d1bc4e420..a2e4d0f271f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,20 +36,27 @@ namespace Org.OpenAPITools.Model /// /// uuid [JsonConstructor] - public NullableGuidClass(Guid? uuid = default) + public NullableGuidClass(Option uuid = default) { - Uuid = uuid; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid? Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -103,7 +111,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Guid? uuid = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -122,7 +130,7 @@ namespace Org.OpenAPITools.Model { case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -157,11 +165,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { - - if (nullableGuidClass.Uuid == null) - writer.WriteNull("uuid"); - else - writer.WriteString("uuid", nullableGuidClass.Uuid.Value); + if (nullableGuidClass.UuidOption.IsSet) + if (nullableGuidClass.UuidOption.Value != null) + writer.WriteString("uuid", nullableGuidClass.UuidOption.Value!.Value); + else + writer.WriteNull("uuid"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs index c6f4dea3585..863a29111dd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -135,7 +136,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; Quadrilateral? quadrilateral = null; Triangle? triangle = null; @@ -186,7 +187,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -194,14 +195,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class NullableShape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class NullableShape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType); + return new NullableShape(quadrilateral, shapeType.Value!); if (triangle != null) - return new NullableShape(triangle, shapeType); + return new NullableShape(triangle, shapeType.Value!); throw new JsonException(); } @@ -240,6 +244,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { + if (nullableShape.ShapeType == null) + throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); + writer.WriteString("shapeType", nullableShape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs index 3e05a195454..4692869f619 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// justNumber [JsonConstructor] - public NumberOnly(decimal justNumber) + public NumberOnly(Option justNumber = default) { - JustNumber = justNumber; + JustNumberOption = justNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of JustNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustNumberOption { get; private set; } + /// /// Gets or Sets JustNumber /// [JsonPropertyName("JustNumber")] - public decimal JustNumber { get; set; } + public decimal? JustNumber { get { return this. JustNumberOption; } set { this.JustNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? justNumber = default; + Option justNumber = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "JustNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - justNumber = utf8JsonReader.GetDecimal(); + justNumber = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model } } - if (justNumber == null) - throw new ArgumentNullException(nameof(justNumber), "Property is required for class NumberOnly."); + if (justNumber.IsSet && justNumber.Value == null) + throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly."); - return new NumberOnly(justNumber.Value); + return new NumberOnly(justNumber); } /// @@ -159,7 +167,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("JustNumber", numberOnly.JustNumber); + if (numberOnly.JustNumberOption.IsSet) + writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index 84957dfb469..6b6087eefac 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,43 +39,71 @@ namespace Org.OpenAPITools.Model /// id /// uuid [JsonConstructor] - public ObjectWithDeprecatedFields(List bars, DeprecatedObject deprecatedRef, decimal id, string uuid) + public ObjectWithDeprecatedFields(Option?> bars = default, Option deprecatedRef = default, Option id = default, Option uuid = default) { - Bars = bars; - DeprecatedRef = deprecatedRef; - Id = id; - Uuid = uuid; + BarsOption = bars; + DeprecatedRefOption = deprecatedRef; + IdOption = id; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bars + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> BarsOption { get; private set; } + /// /// Gets or Sets Bars /// [JsonPropertyName("bars")] [Obsolete] - public List Bars { get; set; } + public List? Bars { get { return this. BarsOption; } set { this.BarsOption = new(value); } } + + /// + /// Used to track the state of DeprecatedRef + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeprecatedRefOption { get; private set; } /// /// Gets or Sets DeprecatedRef /// [JsonPropertyName("deprecatedRef")] [Obsolete] - public DeprecatedObject DeprecatedRef { get; set; } + public DeprecatedObject? DeprecatedRef { get { return this. DeprecatedRefOption; } set { this.DeprecatedRefOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] [Obsolete] - public decimal Id { get; set; } + public decimal? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public string Uuid { get; set; } + public string? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -132,10 +161,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? bars = default; - DeprecatedObject? deprecatedRef = default; - decimal? id = default; - string? uuid = default; + Option?> bars = default; + Option deprecatedRef = default; + Option id = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -154,18 +183,18 @@ namespace Org.OpenAPITools.Model { case "bars": if (utf8JsonReader.TokenType != JsonTokenType.Null) - bars = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + bars = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "deprecatedRef": if (utf8JsonReader.TokenType != JsonTokenType.Null) - deprecatedRef = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + deprecatedRef = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetDecimal(); + id = new Option(utf8JsonReader.GetDecimal()); break; case "uuid": - uuid = utf8JsonReader.GetString(); + uuid = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -173,19 +202,19 @@ namespace Org.OpenAPITools.Model } } - if (bars == null) - throw new ArgumentNullException(nameof(bars), "Property is required for class ObjectWithDeprecatedFields."); + if (bars.IsSet && bars.Value == null) + throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (deprecatedRef == null) - throw new ArgumentNullException(nameof(deprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + if (deprecatedRef.IsSet && deprecatedRef.Value == null) + throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class ObjectWithDeprecatedFields."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class ObjectWithDeprecatedFields."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields."); - return new ObjectWithDeprecatedFields(bars, deprecatedRef, id.Value, uuid); + return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid); } /// @@ -212,12 +241,30 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("bars"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); - writer.WritePropertyName("deprecatedRef"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); - writer.WriteNumber("id", objectWithDeprecatedFields.Id); - writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); + if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.BarsOption.IsSet) + { + writer.WritePropertyName("bars"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet) + { + writer.WritePropertyName("deprecatedRef"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.IdOption.IsSet) + writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value); + + if (objectWithDeprecatedFields.UuidOption.IsSet) + writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OneOfString.cs index e84b8aae250..a0a54c25067 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OneOfString.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs index 4fc1f5cccf3..7b771cdc8b5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,21 +34,21 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// complete (default to false) /// id /// petId /// quantity /// shipDate /// Order Status - /// complete (default to false) [JsonConstructor] - public Order(long id, long petId, int quantity, DateTime shipDate, StatusEnum status, bool complete = false) + public Order(Option complete = default, Option id = default, Option petId = default, Option quantity = default, Option shipDate = default, Option status = default) { - Id = id; - PetId = petId; - Quantity = quantity; - ShipDate = shipDate; - Status = status; - Complete = complete; + CompleteOption = complete; + IdOption = id; + PetIdOption = petId; + QuantityOption = quantity; + ShipDateOption = shipDate; + StatusOption = status; OnCreated(); } @@ -120,9 +121,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Placed) return "placed"; @@ -135,43 +135,85 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// Order Status /// /// Order Status [JsonPropertyName("status")] - public StatusEnum Status { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } } + + /// + /// Used to track the state of Complete + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CompleteOption { get; private set; } + + /// + /// Gets or Sets Complete + /// + [JsonPropertyName("complete")] + public bool? Complete { get { return this. CompleteOption; } set { this.CompleteOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of PetId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PetIdOption { get; private set; } /// /// Gets or Sets PetId /// [JsonPropertyName("petId")] - public long PetId { get; set; } + public long? PetId { get { return this. PetIdOption; } set { this.PetIdOption = new(value); } } + + /// + /// Used to track the state of Quantity + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option QuantityOption { get; private set; } /// /// Gets or Sets Quantity /// [JsonPropertyName("quantity")] - public int Quantity { get; set; } + public int? Quantity { get { return this. QuantityOption; } set { this.QuantityOption = new(value); } } + + /// + /// Used to track the state of ShipDate + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShipDateOption { get; private set; } /// /// Gets or Sets ShipDate /// /// 2020-02-02T20:20:20.000222Z [JsonPropertyName("shipDate")] - public DateTime ShipDate { get; set; } - - /// - /// Gets or Sets Complete - /// - [JsonPropertyName("complete")] - public bool Complete { get; set; } + public DateTime? ShipDate { get { return this. ShipDateOption; } set { this.ShipDateOption = new(value); } } /// /// Gets or Sets additional properties @@ -187,12 +229,12 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Order {\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" PetId: ").Append(PetId).Append("\n"); sb.Append(" Quantity: ").Append(Quantity).Append("\n"); sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -236,12 +278,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - long? petId = default; - int? quantity = default; - DateTime? shipDate = default; - Order.StatusEnum? status = default; - bool? complete = default; + Option complete = default; + Option id = default; + Option petId = default; + Option quantity = default; + Option shipDate = default; + Option status = default; while (utf8JsonReader.Read()) { @@ -258,31 +300,30 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "complete": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + complete = new Option(utf8JsonReader.GetBoolean()); + break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "petId": if (utf8JsonReader.TokenType != JsonTokenType.Null) - petId = utf8JsonReader.GetInt64(); + petId = new Option(utf8JsonReader.GetInt64()); break; case "quantity": if (utf8JsonReader.TokenType != JsonTokenType.Null) - quantity = utf8JsonReader.GetInt32(); + quantity = new Option(utf8JsonReader.GetInt32()); break; case "shipDate": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shipDate = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shipDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "status": string? statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Order.StatusEnumFromStringOrDefault(statusRawValue); - break; - case "complete": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - complete = utf8JsonReader.GetBoolean(); + if (statusRawValue != null) + status = new Option(Order.StatusEnumFromStringOrDefault(statusRawValue)); break; default: break; @@ -290,25 +331,25 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Order."); + if (complete.IsSet && complete.Value == null) + throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order."); - if (petId == null) - throw new ArgumentNullException(nameof(petId), "Property is required for class Order."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order."); - if (quantity == null) - throw new ArgumentNullException(nameof(quantity), "Property is required for class Order."); + if (petId.IsSet && petId.Value == null) + throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order."); - if (shipDate == null) - throw new ArgumentNullException(nameof(shipDate), "Property is required for class Order."); + if (quantity.IsSet && quantity.Value == null) + throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Order."); + if (shipDate.IsSet && shipDate.Value == null) + throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order."); - if (complete == null) - throw new ArgumentNullException(nameof(complete), "Property is required for class Order."); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order."); - return new Order(id.Value, petId.Value, quantity.Value, shipDate.Value, status.Value, complete.Value); + return new Order(complete, id, petId, quantity, shipDate, status); } /// @@ -335,18 +376,26 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", order.Id); - writer.WriteNumber("petId", order.PetId); - writer.WriteNumber("quantity", order.Quantity); - writer.WriteString("shipDate", order.ShipDate.ToString(ShipDateFormat)); + if (order.CompleteOption.IsSet) + writer.WriteBoolean("complete", order.CompleteOption.Value!.Value); - var statusRawValue = Order.StatusEnumToJsonValue(order.Status); + if (order.IdOption.IsSet) + writer.WriteNumber("id", order.IdOption.Value!.Value); + + if (order.PetIdOption.IsSet) + writer.WriteNumber("petId", order.PetIdOption.Value!.Value); + + if (order.QuantityOption.IsSet) + writer.WriteNumber("quantity", order.QuantityOption.Value!.Value); + + if (order.ShipDateOption.IsSet) + writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat)); + + var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - - writer.WriteBoolean("complete", order.Complete); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs index 944b48cec72..06993578e15 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -37,33 +38,54 @@ namespace Org.OpenAPITools.Model /// myNumber /// myString [JsonConstructor] - public OuterComposite(bool myBoolean, decimal myNumber, string myString) + public OuterComposite(Option myBoolean = default, Option myNumber = default, Option myString = default) { - MyBoolean = myBoolean; - MyNumber = myNumber; - MyString = myString; + MyBooleanOption = myBoolean; + MyNumberOption = myNumber; + MyStringOption = myString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MyBoolean + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyBooleanOption { get; private set; } + /// /// Gets or Sets MyBoolean /// [JsonPropertyName("my_boolean")] - public bool MyBoolean { get; set; } + public bool? MyBoolean { get { return this. MyBooleanOption; } set { this.MyBooleanOption = new(value); } } + + /// + /// Used to track the state of MyNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyNumberOption { get; private set; } /// /// Gets or Sets MyNumber /// [JsonPropertyName("my_number")] - public decimal MyNumber { get; set; } + public decimal? MyNumber { get { return this. MyNumberOption; } set { this.MyNumberOption = new(value); } } + + /// + /// Used to track the state of MyString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyStringOption { get; private set; } /// /// Gets or Sets MyString /// [JsonPropertyName("my_string")] - public string MyString { get; set; } + public string? MyString { get { return this. MyStringOption; } set { this.MyStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -120,9 +142,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - bool? myBoolean = default; - decimal? myNumber = default; - string? myString = default; + Option myBoolean = default; + Option myNumber = default; + Option myString = default; while (utf8JsonReader.Read()) { @@ -141,14 +163,14 @@ namespace Org.OpenAPITools.Model { case "my_boolean": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myBoolean = utf8JsonReader.GetBoolean(); + myBoolean = new Option(utf8JsonReader.GetBoolean()); break; case "my_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myNumber = utf8JsonReader.GetDecimal(); + myNumber = new Option(utf8JsonReader.GetDecimal()); break; case "my_string": - myString = utf8JsonReader.GetString(); + myString = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -156,16 +178,16 @@ namespace Org.OpenAPITools.Model } } - if (myBoolean == null) - throw new ArgumentNullException(nameof(myBoolean), "Property is required for class OuterComposite."); + if (myBoolean.IsSet && myBoolean.Value == null) + throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite."); - if (myNumber == null) - throw new ArgumentNullException(nameof(myNumber), "Property is required for class OuterComposite."); + if (myNumber.IsSet && myNumber.Value == null) + throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite."); - if (myString == null) - throw new ArgumentNullException(nameof(myString), "Property is required for class OuterComposite."); + if (myString.IsSet && myString.Value == null) + throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite."); - return new OuterComposite(myBoolean.Value, myNumber.Value, myString); + return new OuterComposite(myBoolean, myNumber, myString); } /// @@ -192,9 +214,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteBoolean("my_boolean", outerComposite.MyBoolean); - writer.WriteNumber("my_number", outerComposite.MyNumber); - writer.WriteString("my_string", outerComposite.MyString); + if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null) + throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite."); + + if (outerComposite.MyBooleanOption.IsSet) + writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value); + + if (outerComposite.MyNumberOption.IsSet) + writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value); + + if (outerComposite.MyStringOption.IsSet) + writer.WriteString("my_string", outerComposite.MyString); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs index 01f4f467627..96af6f3670d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index 7903c829648..a50d5c056ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index a09978af1c3..41ecebcf8f5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index 4a73f8886ac..902dbb06639 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumTest.cs index 9a549df1f0a..03a8ccdecac 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumTest.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs index 73fc6e3e5ed..de4aa64ceab 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -78,7 +79,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -96,7 +97,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -104,10 +105,13 @@ namespace Org.OpenAPITools.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ParentPet."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ParentPet.", nameof(petType)); - return new ParentPet(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); + + return new ParentPet(petType.Value!); } /// @@ -134,6 +138,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet.PetType == null) + throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); + writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs index 1754664e96d..f1381bcc877 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,21 +34,21 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// category - /// id /// name /// photoUrls + /// category + /// id /// pet status in the store /// tags [JsonConstructor] - public Pet(Category category, long id, string name, List photoUrls, StatusEnum status, List tags) + public Pet(string name, List photoUrls, Option category = default, Option id = default, Option status = default, Option?> tags = default) { - Category = category; - Id = id; Name = name; PhotoUrls = photoUrls; - Status = status; - Tags = tags; + CategoryOption = category; + IdOption = id; + StatusOption = status; + TagsOption = tags; OnCreated(); } @@ -120,9 +121,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Available) return "available"; @@ -135,24 +135,19 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// pet status in the store /// /// pet status in the store [JsonPropertyName("status")] - public StatusEnum Status { get; set; } - - /// - /// Gets or Sets Category - /// - [JsonPropertyName("category")] - public Category Category { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } } /// /// Gets or Sets Name @@ -167,11 +162,44 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } + /// + /// Used to track the state of Category + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryOption { get; private set; } + + /// + /// Gets or Sets Category + /// + [JsonPropertyName("category")] + public Category? Category { get { return this. CategoryOption; } set { this.CategoryOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Tags + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> TagsOption { get; private set; } + /// /// Gets or Sets Tags /// [JsonPropertyName("tags")] - public List Tags { get; set; } + public List? Tags { get { return this. TagsOption; } set { this.TagsOption = new(value); } } /// /// Gets or Sets additional properties @@ -187,10 +215,10 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Pet {\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); sb.Append(" Tags: ").Append(Tags).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -231,12 +259,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Category? category = default; - long? id = default; - string? name = default; - List? photoUrls = default; - Pet.StatusEnum? status = default; - List? tags = default; + Option name = default; + Option?> photoUrls = default; + Option category = default; + Option id = default; + Option status = default; + Option?> tags = default; while (utf8JsonReader.Read()) { @@ -253,30 +281,29 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "category": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - category = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; case "photoUrls": if (utf8JsonReader.TokenType != JsonTokenType.Null) - photoUrls = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + photoUrls = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "category": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + category = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); break; case "status": string? statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Pet.StatusEnumFromStringOrDefault(statusRawValue); + if (statusRawValue != null) + status = new Option(Pet.StatusEnumFromStringOrDefault(statusRawValue)); break; case "tags": if (utf8JsonReader.TokenType != JsonTokenType.Null) - tags = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + tags = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -284,25 +311,31 @@ namespace Org.OpenAPITools.Model } } - if (category == null) - throw new ArgumentNullException(nameof(category), "Property is required for class Pet."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(name)); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Pet."); + if (!photoUrls.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(photoUrls)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Pet."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Pet."); - if (photoUrls == null) - throw new ArgumentNullException(nameof(photoUrls), "Property is required for class Pet."); + if (photoUrls.IsSet && photoUrls.Value == null) + throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Pet."); + if (category.IsSet && category.Value == null) + throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet."); - if (tags == null) - throw new ArgumentNullException(nameof(tags), "Property is required for class Pet."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet."); - return new Pet(category, id.Value, name, photoUrls, status.Value, tags); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet."); + + if (tags.IsSet && tags.Value == null) + throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet."); + + return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags); } /// @@ -329,21 +362,41 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("category"); - JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); - writer.WriteNumber("id", pet.Id); + if (pet.Name == null) + throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet."); + + if (pet.PhotoUrls == null) + throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet."); + + if (pet.CategoryOption.IsSet && pet.Category == null) + throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet."); + + if (pet.TagsOption.IsSet && pet.Tags == null) + throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet."); + writer.WriteString("name", pet.Name); + writer.WritePropertyName("photoUrls"); JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions); + if (pet.CategoryOption.IsSet) + { + writer.WritePropertyName("category"); + JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); + } + if (pet.IdOption.IsSet) + writer.WriteNumber("id", pet.IdOption.Value!.Value); - var statusRawValue = Pet.StatusEnumToJsonValue(pet.Status); + var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - writer.WritePropertyName("tags"); - JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + if (pet.TagsOption.IsSet) + { + writer.WritePropertyName("tags"); + JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs index 07ecf267e65..727999c5928 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -135,7 +136,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; + Option className = default; BasquePig? basquePig = null; DanishPig? danishPig = null; @@ -186,7 +187,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -194,14 +195,17 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Pig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Pig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className); + return new Pig(basquePig, className.Value!); if (danishPig != null) - return new Pig(danishPig, className); + return new Pig(danishPig, className.Value!); throw new JsonException(); } @@ -240,6 +244,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { + if (pig.ClassName == null) + throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); + writer.WriteString("className", pig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 2093843c8d9..1333f4a725d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs index 2ac725986a2..5b20c6e3068 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -135,7 +136,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; + Option quadrilateralType = default; ComplexQuadrilateral? complexQuadrilateral = null; SimpleQuadrilateral? simpleQuadrilateral = null; @@ -186,7 +187,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -194,14 +195,17 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class Quadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class Quadrilateral.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType); + return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value!); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType); + return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value!); throw new JsonException(); } @@ -240,6 +244,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); + writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index a0be1966124..9a15b8828a3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,7 +103,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; + Option quadrilateralType = default; while (utf8JsonReader.Read()) { @@ -120,7 +121,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,10 +129,13 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class QuadrilateralInterface."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class QuadrilateralInterface.", nameof(quadrilateralType)); - return new QuadrilateralInterface(quadrilateralType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class QuadrilateralInterface."); + + return new QuadrilateralInterface(quadrilateralType.Value!); } /// @@ -158,6 +162,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateralInterface.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface."); + writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 7dae6b8bb18..945d3a77f61 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// bar /// baz [JsonConstructor] - public ReadOnlyFirst(string bar, string baz) + public ReadOnlyFirst(Option bar = default, Option baz = default) { - Bar = bar; - Baz = baz; + BarOption = bar; + BazOption = baz; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string? Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Baz + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BazOption { get; private set; } /// /// Gets or Sets Baz /// [JsonPropertyName("baz")] - public string Baz { get; set; } + public string? Baz { get { return this. BazOption; } set { this.BazOption = new(value); } } /// /// Gets or Sets additional properties @@ -107,7 +122,9 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -147,8 +164,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? bar = default; - string? baz = default; + Option bar = default; + Option baz = default; while (utf8JsonReader.Read()) { @@ -166,10 +183,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()!); break; case "baz": - baz = utf8JsonReader.GetString(); + baz = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -177,11 +194,11 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class ReadOnlyFirst."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst."); - if (baz == null) - throw new ArgumentNullException(nameof(baz), "Property is required for class ReadOnlyFirst."); + if (baz.IsSet && baz.Value == null) + throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst."); return new ReadOnlyFirst(bar, baz); } @@ -210,8 +227,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", readOnlyFirst.Bar); - writer.WriteString("baz", readOnlyFirst.Baz); + if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BarOption.IsSet) + writer.WriteString("bar", readOnlyFirst.Bar); + + if (readOnlyFirst.BazOption.IsSet) + writer.WriteString("baz", readOnlyFirst.Baz); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..1ab35bd5ff6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,2388 @@ +// +/* + * 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 + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + public partial class RequiredClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// requiredNotNullableDateProp + /// requiredNotnullableArrayOfString + /// requiredNotnullableBooleanProp + /// requiredNotnullableDatetimeProp + /// requiredNotnullableEnumInteger + /// requiredNotnullableEnumIntegerOnly + /// requiredNotnullableEnumString + /// requiredNotnullableOuterEnumDefaultValue + /// requiredNotnullableStringProp + /// requiredNotnullableUuid + /// requiredNotnullableintegerProp + /// requiredNullableArrayOfString + /// requiredNullableBooleanProp + /// requiredNullableDateProp + /// requiredNullableDatetimeProp + /// requiredNullableEnumInteger + /// requiredNullableEnumIntegerOnly + /// requiredNullableEnumString + /// requiredNullableIntegerProp + /// requiredNullableOuterEnumDefaultValue + /// requiredNullableStringProp + /// requiredNullableUuid + /// notRequiredNotnullableDateProp + /// notRequiredNotnullableintegerProp + /// notRequiredNullableDateProp + /// notRequiredNullableIntegerProp + /// notrequiredNotnullableArrayOfString + /// notrequiredNotnullableBooleanProp + /// notrequiredNotnullableDatetimeProp + /// notrequiredNotnullableEnumInteger + /// notrequiredNotnullableEnumIntegerOnly + /// notrequiredNotnullableEnumString + /// notrequiredNotnullableOuterEnumDefaultValue + /// notrequiredNotnullableStringProp + /// notrequiredNotnullableUuid + /// notrequiredNullableArrayOfString + /// notrequiredNullableBooleanProp + /// notrequiredNullableDatetimeProp + /// notrequiredNullableEnumInteger + /// notrequiredNullableEnumIntegerOnly + /// notrequiredNullableEnumString + /// notrequiredNullableOuterEnumDefaultValue + /// notrequiredNullableStringProp + /// notrequiredNullableUuid + [JsonConstructor] + public RequiredClass(DateTime requiredNotNullableDateProp, List requiredNotnullableArrayOfString, bool requiredNotnullableBooleanProp, DateTime requiredNotnullableDatetimeProp, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue, string requiredNotnullableStringProp, Guid requiredNotnullableUuid, int requiredNotnullableintegerProp, List? requiredNullableArrayOfString = default, bool? requiredNullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime? requiredNullableDatetimeProp = default, RequiredNullableEnumIntegerEnum? requiredNullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum? requiredNullableEnumIntegerOnly = default, RequiredNullableEnumStringEnum? requiredNullableEnumString = default, int? requiredNullableIntegerProp = default, OuterEnumDefaultValue? requiredNullableOuterEnumDefaultValue = default, string? requiredNullableStringProp = default, Guid? requiredNullableUuid = default, Option notRequiredNotnullableDateProp = default, Option notRequiredNotnullableintegerProp = default, Option notRequiredNullableDateProp = default, Option notRequiredNullableIntegerProp = default, Option?> notrequiredNotnullableArrayOfString = default, Option notrequiredNotnullableBooleanProp = default, Option notrequiredNotnullableDatetimeProp = default, Option notrequiredNotnullableEnumInteger = default, Option notrequiredNotnullableEnumIntegerOnly = default, Option notrequiredNotnullableEnumString = default, Option notrequiredNotnullableOuterEnumDefaultValue = default, Option notrequiredNotnullableStringProp = default, Option notrequiredNotnullableUuid = default, Option?> notrequiredNullableArrayOfString = default, Option notrequiredNullableBooleanProp = default, Option notrequiredNullableDatetimeProp = default, Option notrequiredNullableEnumInteger = default, Option notrequiredNullableEnumIntegerOnly = default, Option notrequiredNullableEnumString = default, Option notrequiredNullableOuterEnumDefaultValue = default, Option notrequiredNullableStringProp = default, Option notrequiredNullableUuid = default) + { + RequiredNotNullableDateProp = requiredNotNullableDateProp; + RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + RequiredNotnullableEnumString = requiredNotnullableEnumString; + RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + RequiredNotnullableStringProp = requiredNotnullableStringProp; + RequiredNotnullableUuid = requiredNotnullableUuid; + RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + RequiredNullableArrayOfString = requiredNullableArrayOfString; + RequiredNullableBooleanProp = requiredNullableBooleanProp; + RequiredNullableDateProp = requiredNullableDateProp; + RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + RequiredNullableEnumInteger = requiredNullableEnumInteger; + RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + RequiredNullableEnumString = requiredNullableEnumString; + RequiredNullableIntegerProp = requiredNullableIntegerProp; + RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + RequiredNullableStringProp = requiredNullableStringProp; + RequiredNullableUuid = requiredNullableUuid; + NotRequiredNotnullableDatePropOption = notRequiredNotnullableDateProp; + NotRequiredNotnullableintegerPropOption = notRequiredNotnullableintegerProp; + NotRequiredNullableDatePropOption = notRequiredNullableDateProp; + NotRequiredNullableIntegerPropOption = notRequiredNullableIntegerProp; + NotrequiredNotnullableArrayOfStringOption = notrequiredNotnullableArrayOfString; + NotrequiredNotnullableBooleanPropOption = notrequiredNotnullableBooleanProp; + NotrequiredNotnullableDatetimePropOption = notrequiredNotnullableDatetimeProp; + NotrequiredNotnullableEnumIntegerOption = notrequiredNotnullableEnumInteger; + NotrequiredNotnullableEnumIntegerOnlyOption = notrequiredNotnullableEnumIntegerOnly; + NotrequiredNotnullableEnumStringOption = notrequiredNotnullableEnumString; + NotrequiredNotnullableOuterEnumDefaultValueOption = notrequiredNotnullableOuterEnumDefaultValue; + NotrequiredNotnullableStringPropOption = notrequiredNotnullableStringProp; + NotrequiredNotnullableUuidOption = notrequiredNotnullableUuid; + NotrequiredNullableArrayOfStringOption = notrequiredNullableArrayOfString; + NotrequiredNullableBooleanPropOption = notrequiredNullableBooleanProp; + NotrequiredNullableDatetimePropOption = notrequiredNullableDatetimeProp; + NotrequiredNullableEnumIntegerOption = notrequiredNullableEnumInteger; + NotrequiredNullableEnumIntegerOnlyOption = notrequiredNullableEnumIntegerOnly; + NotrequiredNullableEnumStringOption = notrequiredNullableEnumString; + NotrequiredNullableOuterEnumDefaultValueOption = notrequiredNullableOuterEnumDefaultValue; + NotrequiredNullableStringPropOption = notrequiredNullableStringProp; + NotrequiredNullableUuidOption = notrequiredNullableUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum? RequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerEnumToJsonValue(RequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [JsonPropertyName("required_notnullable_enum_integer")] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum? RequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(RequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("required_notnullable_enum_integer_only")] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNotnullableEnumString + /// + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumStringEnum RequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumStringEnum? RequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNotnullableEnumStringEnumToJsonValue(RequiredNotnullableEnumStringEnum value) + { + if (value == RequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [JsonPropertyName("required_notnullable_enum_string")] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerEnum RequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerEnum? RequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerEnumToJsonValue(RequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [JsonPropertyName("required_nullable_enum_integer")] + public RequiredNullableEnumIntegerEnum? RequiredNullableEnumInteger { get; set; } + + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerOnlyEnumToJsonValue(RequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("required_nullable_enum_integer_only")] + public RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNullableEnumString + /// + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumStringEnum RequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumStringEnum? RequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string? RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == RequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [JsonPropertyName("required_nullable_enum_string")] + public RequiredNullableEnumStringEnum? RequiredNullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum NotrequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerEnumToJsonValue(NotrequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [JsonPropertyName("notrequired_notnullable_enum_integer")] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get { return this.NotrequiredNotnullableEnumIntegerOption; } set { this.NotrequiredNotnullableEnumIntegerOption = new(value); } } + + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum NotrequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_notnullable_enum_integer_only")] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get { return this.NotrequiredNotnullableEnumIntegerOnlyOption; } set { this.NotrequiredNotnullableEnumIntegerOnlyOption = new(value); } } + + /// + /// Defines NotrequiredNotnullableEnumString + /// + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum NotrequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNotnullableEnumStringEnumToJsonValue(NotrequiredNotnullableEnumStringEnum? value) + { + if (value == NotrequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [JsonPropertyName("notrequired_notnullable_enum_string")] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get { return this.NotrequiredNotnullableEnumStringOption; } set { this.NotrequiredNotnullableEnumStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get { return this.NotrequiredNotnullableOuterEnumDefaultValueOption; } set { this.NotrequiredNotnullableOuterEnumDefaultValueOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum NotrequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerEnumToJsonValue(NotrequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [JsonPropertyName("notrequired_nullable_enum_integer")] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get { return this.NotrequiredNullableEnumIntegerOption; } set { this.NotrequiredNullableEnumIntegerOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum NotrequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_nullable_enum_integer_only")] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get { return this.NotrequiredNullableEnumIntegerOnlyOption; } set { this.NotrequiredNullableEnumIntegerOnlyOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumString + /// + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumStringEnum NotrequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string? NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == NotrequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [JsonPropertyName("notrequired_nullable_enum_string")] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get { return this.NotrequiredNullableEnumStringOption; } set { this.NotrequiredNullableEnumStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get { return this.NotrequiredNullableOuterEnumDefaultValueOption; } set { this.NotrequiredNullableOuterEnumDefaultValueOption = new(value); } } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonPropertyName("required_not_nullable_date_prop")] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [JsonPropertyName("required_notnullable_array_of_string")] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [JsonPropertyName("required_notnullable_boolean_prop")] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [JsonPropertyName("required_notnullable_datetime_prop")] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [JsonPropertyName("required_notnullable_string_prop")] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_notnullable_uuid")] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [JsonPropertyName("required_notnullableinteger_prop")] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [JsonPropertyName("required_nullable_array_of_string")] + public List? RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [JsonPropertyName("required_nullable_boolean_prop")] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonPropertyName("required_nullable_date_prop")] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [JsonPropertyName("required_nullable_datetime_prop")] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [JsonPropertyName("required_nullable_integer_prop")] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [JsonPropertyName("required_nullable_string_prop")] + public string? RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_nullable_uuid")] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Used to track the state of NotRequiredNotnullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonPropertyName("not_required_notnullable_date_prop")] + public DateTime? NotRequiredNotnullableDateProp { get { return this. NotRequiredNotnullableDatePropOption; } set { this.NotRequiredNotnullableDatePropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNotnullableintegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableintegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [JsonPropertyName("not_required_notnullableinteger_prop")] + public int? NotRequiredNotnullableintegerProp { get { return this. NotRequiredNotnullableintegerPropOption; } set { this.NotRequiredNotnullableintegerPropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonPropertyName("not_required_nullable_date_prop")] + public DateTime? NotRequiredNullableDateProp { get { return this. NotRequiredNullableDatePropOption; } set { this.NotRequiredNullableDatePropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNullableIntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableIntegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [JsonPropertyName("not_required_nullable_integer_prop")] + public int? NotRequiredNullableIntegerProp { get { return this. NotRequiredNullableIntegerPropOption; } set { this.NotRequiredNullableIntegerPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> NotrequiredNotnullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [JsonPropertyName("notrequired_notnullable_array_of_string")] + public List? NotrequiredNotnullableArrayOfString { get { return this. NotrequiredNotnullableArrayOfStringOption; } set { this.NotrequiredNotnullableArrayOfStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [JsonPropertyName("notrequired_notnullable_boolean_prop")] + public bool? NotrequiredNotnullableBooleanProp { get { return this. NotrequiredNotnullableBooleanPropOption; } set { this.NotrequiredNotnullableBooleanPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [JsonPropertyName("notrequired_notnullable_datetime_prop")] + public DateTime? NotrequiredNotnullableDatetimeProp { get { return this. NotrequiredNotnullableDatetimePropOption; } set { this.NotrequiredNotnullableDatetimePropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [JsonPropertyName("notrequired_notnullable_string_prop")] + public string? NotrequiredNotnullableStringProp { get { return this. NotrequiredNotnullableStringPropOption; } set { this.NotrequiredNotnullableStringPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_notnullable_uuid")] + public Guid? NotrequiredNotnullableUuid { get { return this. NotrequiredNotnullableUuidOption; } set { this.NotrequiredNotnullableUuidOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> NotrequiredNullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [JsonPropertyName("notrequired_nullable_array_of_string")] + public List? NotrequiredNullableArrayOfString { get { return this. NotrequiredNullableArrayOfStringOption; } set { this.NotrequiredNullableArrayOfStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [JsonPropertyName("notrequired_nullable_boolean_prop")] + public bool? NotrequiredNullableBooleanProp { get { return this. NotrequiredNullableBooleanPropOption; } set { this.NotrequiredNullableBooleanPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [JsonPropertyName("notrequired_nullable_datetime_prop")] + public DateTime? NotrequiredNullableDatetimeProp { get { return this. NotrequiredNullableDatetimePropOption; } set { this.NotrequiredNullableDatetimePropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [JsonPropertyName("notrequired_nullable_string_prop")] + public string? NotrequiredNullableStringProp { get { return this. NotrequiredNullableStringPropOption; } set { this.NotrequiredNullableStringPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_nullable_uuid")] + public Guid? NotrequiredNullableUuid { get { return this. NotrequiredNullableUuidOption; } set { this.NotrequiredNullableUuidOption = new(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize RequiredNotNullableDateProp + /// + public static string RequiredNotNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNotnullableDatetimeProp + /// + public static string RequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize RequiredNullableDateProp + /// + public static string RequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNullableDatetimeProp + /// + public static string RequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotRequiredNotnullableDateProp + /// + public static string NotRequiredNotnullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotRequiredNullableDateProp + /// + public static string NotRequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotrequiredNotnullableDatetimeProp + /// + public static string NotrequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotrequiredNullableDatetimeProp + /// + public static string NotrequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option requiredNotNullableDateProp = default; + Option?> requiredNotnullableArrayOfString = default; + Option requiredNotnullableBooleanProp = default; + Option requiredNotnullableDatetimeProp = default; + Option requiredNotnullableEnumInteger = default; + Option requiredNotnullableEnumIntegerOnly = default; + Option requiredNotnullableEnumString = default; + Option requiredNotnullableOuterEnumDefaultValue = default; + Option requiredNotnullableStringProp = default; + Option requiredNotnullableUuid = default; + Option requiredNotnullableintegerProp = default; + Option?> requiredNullableArrayOfString = default; + Option requiredNullableBooleanProp = default; + Option requiredNullableDateProp = default; + Option requiredNullableDatetimeProp = default; + Option requiredNullableEnumInteger = default; + Option requiredNullableEnumIntegerOnly = default; + Option requiredNullableEnumString = default; + Option requiredNullableIntegerProp = default; + Option requiredNullableOuterEnumDefaultValue = default; + Option requiredNullableStringProp = default; + Option requiredNullableUuid = default; + Option notRequiredNotnullableDateProp = default; + Option notRequiredNotnullableintegerProp = default; + Option notRequiredNullableDateProp = default; + Option notRequiredNullableIntegerProp = default; + Option?> notrequiredNotnullableArrayOfString = default; + Option notrequiredNotnullableBooleanProp = default; + Option notrequiredNotnullableDatetimeProp = default; + Option notrequiredNotnullableEnumInteger = default; + Option notrequiredNotnullableEnumIntegerOnly = default; + Option notrequiredNotnullableEnumString = default; + Option notrequiredNotnullableOuterEnumDefaultValue = default; + Option notrequiredNotnullableStringProp = default; + Option notrequiredNotnullableUuid = default; + Option?> notrequiredNullableArrayOfString = default; + Option notrequiredNullableBooleanProp = default; + Option notrequiredNullableDatetimeProp = default; + Option notrequiredNullableEnumInteger = default; + Option notrequiredNullableEnumIntegerOnly = default; + Option notrequiredNullableEnumString = default; + Option notrequiredNullableOuterEnumDefaultValue = default; + Option notrequiredNullableStringProp = default; + Option notrequiredNullableUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "required_not_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "required_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumInteger = new Option((RequiredClass.RequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumIntegerOnly = new Option((RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_string": + string? requiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumStringRawValue != null) + requiredNotnullableEnumString = new Option(RequiredClass.RequiredNotnullableEnumStringEnumFromStringOrDefault(requiredNotnullableEnumStringRawValue)); + break; + case "required_notnullable_outerEnumDefaultValue": + string? requiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableOuterEnumDefaultValueRawValue != null) + requiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "required_notnullable_string_prop": + requiredNotnullableStringProp = new Option(utf8JsonReader.GetString()!); + break; + case "required_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumInteger = new Option((RequiredClass.RequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumIntegerOnly = new Option((RequiredClass.RequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_string": + string? requiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumStringRawValue != null) + requiredNullableEnumString = new Option(RequiredClass.RequiredNullableEnumStringEnumFromStringOrDefault(requiredNullableEnumStringRawValue)); + break; + case "required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_outerEnumDefaultValue": + string? requiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + requiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNullableOuterEnumDefaultValueRawValue)); + break; + case "required_nullable_string_prop": + requiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "not_required_notnullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "notrequired_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumInteger = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_string": + string? notrequiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumStringRawValue != null) + notrequiredNotnullableEnumString = new Option(RequiredClass.NotrequiredNotnullableEnumStringEnumFromStringOrDefault(notrequiredNotnullableEnumStringRawValue)); + break; + case "notrequired_notnullable_outerEnumDefaultValue": + string? notrequiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableOuterEnumDefaultValueRawValue != null) + notrequiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_notnullable_string_prop": + notrequiredNotnullableStringProp = new Option(utf8JsonReader.GetString()!); + break; + case "notrequired_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "notrequired_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableArrayOfString = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumInteger = new Option((RequiredClass.NotrequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_string": + string? notrequiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumStringRawValue != null) + notrequiredNullableEnumString = new Option(RequiredClass.NotrequiredNullableEnumStringEnumFromStringOrDefault(notrequiredNullableEnumStringRawValue)); + break; + case "notrequired_nullable_outerEnumDefaultValue": + string? notrequiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableOuterEnumDefaultValueRawValue != null) + notrequiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_nullable_string_prop": + notrequiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!requiredNotNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotNullableDateProp)); + + if (!requiredNotnullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableArrayOfString)); + + if (!requiredNotnullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableBooleanProp)); + + if (!requiredNotnullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableDatetimeProp)); + + if (!requiredNotnullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumInteger)); + + if (!requiredNotnullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumIntegerOnly)); + + if (!requiredNotnullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumString)); + + if (!requiredNotnullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableOuterEnumDefaultValue)); + + if (!requiredNotnullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableStringProp)); + + if (!requiredNotnullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableUuid)); + + if (!requiredNotnullableintegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableintegerProp)); + + if (!requiredNullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableArrayOfString)); + + if (!requiredNullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableBooleanProp)); + + if (!requiredNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDateProp)); + + if (!requiredNullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDatetimeProp)); + + if (!requiredNullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumInteger)); + + if (!requiredNullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumIntegerOnly)); + + if (!requiredNullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumString)); + + if (!requiredNullableIntegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableIntegerProp)); + + if (!requiredNullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableOuterEnumDefaultValue)); + + if (!requiredNullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableStringProp)); + + if (!requiredNullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableUuid)); + + if (requiredNotNullableDateProp.IsSet && requiredNotNullableDateProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotNullableDateProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableArrayOfString.IsSet && requiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableBooleanProp.IsSet && requiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableDatetimeProp.IsSet && requiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumInteger.IsSet && requiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumIntegerOnly.IsSet && requiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumString.IsSet && requiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableOuterEnumDefaultValue.IsSet && requiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableStringProp.IsSet && requiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableUuid.IsSet && requiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + if (requiredClass.RequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.RequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat)); + + writer.WritePropertyName("required_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNotnullableArrayOfString, jsonSerializerOptions); + writer.WriteBoolean("required_notnullable_boolean_prop", requiredClass.RequiredNotnullableBooleanProp); + + writer.WriteString("required_notnullable_datetime_prop", requiredClass.RequiredNotnullableDatetimeProp.ToString(RequiredNotnullableDatetimePropFormat)); + + writer.WriteNumber("required_notnullable_enum_integer", RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNotnullableEnumInteger)); + + writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly)); + + var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString); + if (requiredNotnullableEnumStringRawValue != null) + writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue); + else + writer.WriteNull("required_notnullable_enum_string"); + + var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue); + writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue); + + writer.WriteString("required_notnullable_string_prop", requiredClass.RequiredNotnullableStringProp); + + writer.WriteString("required_notnullable_uuid", requiredClass.RequiredNotnullableUuid); + + writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp); + + if (requiredClass.RequiredNullableArrayOfString != null) + { + writer.WritePropertyName("required_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("required_nullable_array_of_string"); + if (requiredClass.RequiredNullableBooleanProp != null) + writer.WriteBoolean("required_nullable_boolean_prop", requiredClass.RequiredNullableBooleanProp.Value); + else + writer.WriteNull("required_nullable_boolean_prop"); + + if (requiredClass.RequiredNullableDateProp != null) + writer.WriteString("required_nullable_date_prop", requiredClass.RequiredNullableDateProp.Value.ToString(RequiredNullableDatePropFormat)); + else + writer.WriteNull("required_nullable_date_prop"); + + if (requiredClass.RequiredNullableDatetimeProp != null) + writer.WriteString("required_nullable_datetime_prop", requiredClass.RequiredNullableDatetimeProp.Value.ToString(RequiredNullableDatetimePropFormat)); + else + writer.WriteNull("required_nullable_datetime_prop"); + + if (requiredClass.RequiredNullableEnumInteger != null) + writer.WriteNumber("required_nullable_enum_integer", RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNullableEnumInteger.Value)); + else + writer.WriteNull("required_nullable_enum_integer"); + + if (requiredClass.RequiredNullableEnumIntegerOnly != null) + writer.WriteNumber("required_nullable_enum_integer_only", RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNullableEnumIntegerOnly.Value)); + else + writer.WriteNull("required_nullable_enum_integer_only"); + + var requiredNullableEnumStringRawValue = RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClass.RequiredNullableEnumString!.Value); + if (requiredNullableEnumStringRawValue != null) + writer.WriteString("required_nullable_enum_string", requiredNullableEnumStringRawValue); + else + writer.WriteNull("required_nullable_enum_string"); + + if (requiredClass.RequiredNullableIntegerProp != null) + writer.WriteNumber("required_nullable_integer_prop", requiredClass.RequiredNullableIntegerProp.Value); + else + writer.WriteNull("required_nullable_integer_prop"); + + if (requiredClass.RequiredNullableOuterEnumDefaultValue == null) + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + else + { + var requiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNullableOuterEnumDefaultValue.Value); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + writer.WriteString("required_nullable_outerEnumDefaultValue", requiredNullableOuterEnumDefaultValueRawValue); + else + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + } + + if (requiredClass.RequiredNullableStringProp != null) + writer.WriteString("required_nullable_string_prop", requiredClass.RequiredNullableStringProp); + else + writer.WriteNull("required_nullable_string_prop"); + + if (requiredClass.RequiredNullableUuid != null) + writer.WriteString("required_nullable_uuid", requiredClass.RequiredNullableUuid.Value); + else + writer.WriteNull("required_nullable_uuid"); + + if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet) + writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat)); + + if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet) + writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value); + + if (requiredClass.NotRequiredNullableDatePropOption.IsSet) + if (requiredClass.NotRequiredNullableDatePropOption.Value != null) + writer.WriteString("not_required_nullable_date_prop", requiredClass.NotRequiredNullableDatePropOption.Value!.Value.ToString(NotRequiredNullableDatePropFormat)); + else + writer.WriteNull("not_required_nullable_date_prop"); + + if (requiredClass.NotRequiredNullableIntegerPropOption.IsSet) + if (requiredClass.NotRequiredNullableIntegerPropOption.Value != null) + writer.WriteNumber("not_required_nullable_integer_prop", requiredClass.NotRequiredNullableIntegerPropOption.Value!.Value); + else + writer.WriteNull("not_required_nullable_integer_prop"); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet) + { + writer.WritePropertyName("notrequired_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions); + } + if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet) + writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value); + + if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet) + writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value)); + + var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value); + if (notrequiredNotnullableEnumStringRawValue != null) + writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue); + else + writer.WriteNull("notrequired_notnullable_enum_string"); + + if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet) + { + var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue!.Value); + writer.WriteString("notrequired_notnullable_outerEnumDefaultValue", notrequiredNotnullableOuterEnumDefaultValueRawValue); + } + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet) + writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp); + + if (requiredClass.NotrequiredNotnullableUuidOption.IsSet) + writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value); + + if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet) + if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null) + { + writer.WritePropertyName("notrequired_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("notrequired_nullable_array_of_string"); + if (requiredClass.NotrequiredNullableBooleanPropOption.IsSet) + if (requiredClass.NotrequiredNullableBooleanPropOption.Value != null) + writer.WriteBoolean("notrequired_nullable_boolean_prop", requiredClass.NotrequiredNullableBooleanPropOption.Value!.Value); + else + writer.WriteNull("notrequired_nullable_boolean_prop"); + + if (requiredClass.NotrequiredNullableDatetimePropOption.IsSet) + if (requiredClass.NotrequiredNullableDatetimePropOption.Value != null) + writer.WriteString("notrequired_nullable_datetime_prop", requiredClass.NotrequiredNullableDatetimePropOption.Value!.Value.ToString(NotrequiredNullableDatetimePropFormat)); + else + writer.WriteNull("notrequired_nullable_datetime_prop"); + + if (requiredClass.NotrequiredNullableEnumIntegerOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer", RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOption.Value!.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer"); + + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer_only", RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value!.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer_only"); + + var notrequiredNullableEnumStringRawValue = RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNullableEnumStringOption.Value!.Value); + if (notrequiredNullableEnumStringRawValue != null) + writer.WriteString("notrequired_nullable_enum_string", notrequiredNullableEnumStringRawValue); + else + writer.WriteNull("notrequired_nullable_enum_string"); + + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.IsSet) + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption!.Value != null) + { + var notrequiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value!.Value); + writer.WriteString("notrequired_nullable_outerEnumDefaultValue", notrequiredNullableOuterEnumDefaultValueRawValue); + } + else + writer.WriteNull("notrequired_nullable_outerEnumDefaultValue"); + if (requiredClass.NotrequiredNullableStringPropOption.IsSet) + if (requiredClass.NotrequiredNullableStringPropOption.Value != null) + writer.WriteString("notrequired_nullable_string_prop", requiredClass.NotrequiredNullableStringProp); + else + writer.WriteNull("notrequired_nullable_string_prop"); + + if (requiredClass.NotrequiredNullableUuidOption.IsSet) + if (requiredClass.NotrequiredNullableUuidOption.Value != null) + writer.WriteString("notrequired_nullable_uuid", requiredClass.NotrequiredNullableUuidOption.Value!.Value); + else + writer.WriteNull("notrequired_nullable_uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs index 262ecadf740..5449201bcf1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// varReturn [JsonConstructor] - public Return(int varReturn) + public Return(Option varReturn = default) { - VarReturn = varReturn; + VarReturnOption = varReturn; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarReturn + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarReturnOption { get; private set; } + /// /// Gets or Sets VarReturn /// [JsonPropertyName("return")] - public int VarReturn { get; set; } + public int? VarReturn { get { return this. VarReturnOption; } set { this.VarReturnOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varReturn = default; + Option varReturn = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "return": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varReturn = utf8JsonReader.GetInt32(); + varReturn = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model } } - if (varReturn == null) - throw new ArgumentNullException(nameof(varReturn), "Property is required for class Return."); + if (varReturn.IsSet && varReturn.Value == null) + throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return."); - return new Return(varReturn.Value); + return new Return(varReturn); } /// @@ -159,7 +167,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("return", varReturn.VarReturn); + if (varReturn.VarReturnOption.IsSet) + writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHash.cs index f7be23ecece..0a00cf07fd7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// role /// roleUuid [JsonConstructor] - public RolesReportsHash(RolesReportsHashRole role, Guid roleUuid) + public RolesReportsHash(Option role = default, Option roleUuid = default) { - Role = role; - RoleUuid = roleUuid; + RoleOption = role; + RoleUuidOption = roleUuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Role + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleOption { get; private set; } + /// /// Gets or Sets Role /// [JsonPropertyName("role")] - public RolesReportsHashRole Role { get; set; } + public RolesReportsHashRole? Role { get { return this. RoleOption; } set { this.RoleOption = new(value); } } + + /// + /// Used to track the state of RoleUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleUuidOption { get; private set; } /// /// Gets or Sets RoleUuid /// [JsonPropertyName("role_uuid")] - public Guid RoleUuid { get; set; } + public Guid? RoleUuid { get { return this. RoleUuidOption; } set { this.RoleUuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - RolesReportsHashRole? role = default; - Guid? roleUuid = default; + Option role = default; + Option roleUuid = default; while (utf8JsonReader.Read()) { @@ -131,11 +146,11 @@ namespace Org.OpenAPITools.Model { case "role": if (utf8JsonReader.TokenType != JsonTokenType.Null) - role = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + role = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "role_uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - roleUuid = utf8JsonReader.GetGuid(); + roleUuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -143,13 +158,13 @@ namespace Org.OpenAPITools.Model } } - if (role == null) - throw new ArgumentNullException(nameof(role), "Property is required for class RolesReportsHash."); + if (role.IsSet && role.Value == null) + throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash."); - if (roleUuid == null) - throw new ArgumentNullException(nameof(roleUuid), "Property is required for class RolesReportsHash."); + if (roleUuid.IsSet && roleUuid.Value == null) + throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash."); - return new RolesReportsHash(role, roleUuid.Value); + return new RolesReportsHash(role, roleUuid); } /// @@ -176,9 +191,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("role"); - JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); - writer.WriteString("role_uuid", rolesReportsHash.RoleUuid); + if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null) + throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash."); + + if (rolesReportsHash.RoleOption.IsSet) + { + writer.WritePropertyName("role"); + JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); + } + if (rolesReportsHash.RoleUuidOption.IsSet) + writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index f64e8c9cd62..51616042599 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// name [JsonConstructor] - public RolesReportsHashRole(string name) + public RolesReportsHashRole(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class RolesReportsHashRole."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole."); return new RolesReportsHashRole(name); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", rolesReportsHashRole.Name); + if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null) + throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole."); + + if (rolesReportsHashRole.NameOption.IsSet) + writer.WriteString("name", rolesReportsHashRole.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 9e9dc21151e..4cdb6d4aa46 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -111,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; - string? triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -130,10 +131,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -141,13 +142,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ScaleneTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class ScaleneTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(triangleType)); - return new ScaleneTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ScaleneTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class ScaleneTriangle."); + + return new ScaleneTriangle(shapeType.Value!, triangleType.Value!); } /// @@ -174,7 +181,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (scaleneTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle."); + + if (scaleneTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle."); + writer.WriteString("shapeType", scaleneTriangle.ShapeType); + writer.WriteString("triangleType", scaleneTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs index d8fbc094d19..f2e26ef8c5a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -135,7 +136,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; Quadrilateral? quadrilateral = null; Triangle? triangle = null; @@ -186,7 +187,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -194,14 +195,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class Shape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class Shape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType); + return new Shape(quadrilateral, shapeType.Value!); if (triangle != null) - return new Shape(triangle, shapeType); + return new Shape(triangle, shapeType.Value!); throw new JsonException(); } @@ -240,6 +244,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { + if (shape.ShapeType == null) + throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); + writer.WriteString("shapeType", shape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs index 1b0a8291f38..2780ac574a8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,7 +103,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -120,7 +121,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,10 +129,13 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeInterface."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeInterface.", nameof(shapeType)); - return new ShapeInterface(shapeType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeInterface."); + + return new ShapeInterface(shapeType.Value!); } /// @@ -158,6 +162,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) { + if (shapeInterface.ShapeType == null) + throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface."); + writer.WriteString("shapeType", shapeInterface.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 1b75eada511..b7c92c1f884 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -135,7 +136,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? shapeType = default; + Option shapeType = default; Quadrilateral? quadrilateral = null; Triangle? triangle = null; @@ -186,7 +187,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -194,14 +195,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeOrNull."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType); + return new ShapeOrNull(quadrilateral, shapeType.Value!); if (triangle != null) - return new ShapeOrNull(triangle, shapeType); + return new ShapeOrNull(triangle, shapeType.Value!); throw new JsonException(); } @@ -240,6 +244,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { + if (shapeOrNull.ShapeType == null) + throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); + writer.WriteString("shapeType", shapeOrNull.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 8945a243dfd..279d0b1faa0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -111,8 +112,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? quadrilateralType = default; - string? shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -130,10 +131,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()!); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -141,13 +142,19 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class SimpleQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class SimpleQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(shapeType)); - return new SimpleQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class SimpleQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class SimpleQuadrilateral."); + + return new SimpleQuadrilateral(quadrilateralType.Value!, shapeType.Value!); } /// @@ -174,7 +181,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (simpleQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral."); + + if (simpleQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral."); + writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", simpleQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs index 39baf9d3e4f..e627c778abc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// varSpecialModelName /// specialPropertyName [JsonConstructor] - public SpecialModelName(string varSpecialModelName, long specialPropertyName) + public SpecialModelName(Option varSpecialModelName = default, Option specialPropertyName = default) { - VarSpecialModelName = varSpecialModelName; - SpecialPropertyName = specialPropertyName; + VarSpecialModelNameOption = varSpecialModelName; + SpecialPropertyNameOption = specialPropertyName; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarSpecialModelName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarSpecialModelNameOption { get; private set; } + /// /// Gets or Sets VarSpecialModelName /// [JsonPropertyName("_special_model.name_")] - public string VarSpecialModelName { get; set; } + public string? VarSpecialModelName { get { return this. VarSpecialModelNameOption; } set { this.VarSpecialModelNameOption = new(value); } } + + /// + /// Used to track the state of SpecialPropertyName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SpecialPropertyNameOption { get; private set; } /// /// Gets or Sets SpecialPropertyName /// [JsonPropertyName("$special[property.name]")] - public long SpecialPropertyName { get; set; } + public long? SpecialPropertyName { get { return this. SpecialPropertyNameOption; } set { this.SpecialPropertyNameOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? varSpecialModelName = default; - long? specialPropertyName = default; + Option varSpecialModelName = default; + Option specialPropertyName = default; while (utf8JsonReader.Read()) { @@ -130,11 +145,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "_special_model.name_": - varSpecialModelName = utf8JsonReader.GetString(); + varSpecialModelName = new Option(utf8JsonReader.GetString()!); break; case "$special[property.name]": if (utf8JsonReader.TokenType != JsonTokenType.Null) - specialPropertyName = utf8JsonReader.GetInt64(); + specialPropertyName = new Option(utf8JsonReader.GetInt64()); break; default: break; @@ -142,13 +157,13 @@ namespace Org.OpenAPITools.Model } } - if (varSpecialModelName == null) - throw new ArgumentNullException(nameof(varSpecialModelName), "Property is required for class SpecialModelName."); + if (varSpecialModelName.IsSet && varSpecialModelName.Value == null) + throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName."); - if (specialPropertyName == null) - throw new ArgumentNullException(nameof(specialPropertyName), "Property is required for class SpecialModelName."); + if (specialPropertyName.IsSet && specialPropertyName.Value == null) + throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName."); - return new SpecialModelName(varSpecialModelName, specialPropertyName.Value); + return new SpecialModelName(varSpecialModelName, specialPropertyName); } /// @@ -175,8 +190,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); - writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyName); + if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null) + throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName."); + + if (specialModelName.VarSpecialModelNameOption.IsSet) + writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); + + if (specialModelName.SpecialPropertyNameOption.IsSet) + writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs index 1f69557e7d7..a8f5a1b3008 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,26 +37,40 @@ namespace Org.OpenAPITools.Model /// id /// name [JsonConstructor] - public Tag(long id, string name) + public Tag(Option id = default, Option name = default) { - Id = id; - Name = name; + IdOption = id; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,8 +126,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string? name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -131,10 +146,10 @@ namespace Org.OpenAPITools.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -142,13 +157,13 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Tag."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Tag."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag."); - return new Tag(id.Value, name); + return new Tag(id, name); } /// @@ -175,8 +190,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", tag.Id); - writer.WriteString("name", tag.Name); + if (tag.NameOption.IsSet && tag.Name == null) + throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag."); + + if (tag.IdOption.IsSet) + writer.WriteNumber("id", tag.IdOption.Value!.Value); + + if (tag.NameOption.IsSet) + writer.WriteString("name", tag.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index fa286e8f3fd..e98384c8205 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// value [JsonConstructor] - public TestCollectionEndingWithWordList(string value) + public TestCollectionEndingWithWordList(Option value = default) { - Value = value; + ValueOption = value; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Value + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ValueOption { get; private set; } + /// /// Gets or Sets Value /// [JsonPropertyName("value")] - public string Value { get; set; } + public string? Value { get { return this. ValueOption; } set { this.ValueOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? value = default; + Option value = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "value": - value = utf8JsonReader.GetString(); + value = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (value == null) - throw new ArgumentNullException(nameof(value), "Property is required for class TestCollectionEndingWithWordList."); + if (value.IsSet && value.Value == null) + throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList."); return new TestCollectionEndingWithWordList(value); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("value", testCollectionEndingWithWordList.Value); + if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList."); + + if (testCollectionEndingWithWordList.ValueOption.IsSet) + writer.WriteString("value", testCollectionEndingWithWordList.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 5c481470c71..75005fd9bf7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// testCollectionEndingWithWordList [JsonConstructor] - public TestCollectionEndingWithWordListObject(List testCollectionEndingWithWordList) + public TestCollectionEndingWithWordListObject(Option?> testCollectionEndingWithWordList = default) { - TestCollectionEndingWithWordList = testCollectionEndingWithWordList; + TestCollectionEndingWithWordListOption = testCollectionEndingWithWordList; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of TestCollectionEndingWithWordList + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> TestCollectionEndingWithWordListOption { get; private set; } + /// /// Gets or Sets TestCollectionEndingWithWordList /// [JsonPropertyName("TestCollectionEndingWithWordList")] - public List TestCollectionEndingWithWordList { get; set; } + public List? TestCollectionEndingWithWordList { get { return this. TestCollectionEndingWithWordListOption; } set { this.TestCollectionEndingWithWordListOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? testCollectionEndingWithWordList = default; + Option?> testCollectionEndingWithWordList = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "TestCollectionEndingWithWordList": if (utf8JsonReader.TokenType != JsonTokenType.Null) - testCollectionEndingWithWordList = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + testCollectionEndingWithWordList = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; default: break; @@ -129,8 +137,8 @@ namespace Org.OpenAPITools.Model } } - if (testCollectionEndingWithWordList == null) - throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject."); return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList); } @@ -159,8 +167,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("TestCollectionEndingWithWordList"); - JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet) + { + writer.WritePropertyName("TestCollectionEndingWithWordList"); + JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index 95ad0601f97..68f5aee3c68 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// someProperty [JsonConstructor] - public TestInlineFreeformAdditionalPropertiesRequest(string someProperty) : base() + public TestInlineFreeformAdditionalPropertiesRequest(Option someProperty = default) : base() { - SomeProperty = someProperty; + SomePropertyOption = someProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SomeProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomePropertyOption { get; private set; } + /// /// Gets or Sets SomeProperty /// [JsonPropertyName("someProperty")] - public string SomeProperty { get; set; } + public string? SomeProperty { get { return this. SomePropertyOption; } set { this.SomePropertyOption = new(value); } } /// /// Gets or Sets additional properties @@ -113,7 +121,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? someProperty = default; + Option someProperty = default; while (utf8JsonReader.Read()) { @@ -131,7 +139,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "someProperty": - someProperty = utf8JsonReader.GetString(); + someProperty = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -139,8 +147,8 @@ namespace Org.OpenAPITools.Model } } - if (someProperty == null) - throw new ArgumentNullException(nameof(someProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + if (someProperty.IsSet && someProperty.Value == null) + throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest."); return new TestInlineFreeformAdditionalPropertiesRequest(someProperty); } @@ -169,7 +177,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet) + writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs index c75c83f7d54..303afee787d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -152,7 +153,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? triangleType = default; + Option triangleType = default; EquilateralTriangle? equilateralTriangle = null; IsoscelesTriangle? isoscelesTriangle = null; @@ -209,7 +210,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -217,17 +218,20 @@ namespace Org.OpenAPITools.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class Triangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class Triangle.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType); + return new Triangle(equilateralTriangle, triangleType.Value!); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType); + return new Triangle(isoscelesTriangle, triangleType.Value!); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType); + return new Triangle(scaleneTriangle, triangleType.Value!); throw new JsonException(); } @@ -271,6 +275,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { + if (triangle.TriangleType == null) + throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); + writer.WriteString("triangleType", triangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs index a724643f732..f5bb5d307c8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,7 +103,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? triangleType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -120,7 +121,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,10 +129,13 @@ namespace Org.OpenAPITools.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class TriangleInterface."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class TriangleInterface.", nameof(triangleType)); - return new TriangleInterface(triangleType); + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class TriangleInterface."); + + return new TriangleInterface(triangleType.Value!); } /// @@ -158,6 +162,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) { + if (triangleInterface.TriangleType == null) + throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface."); + writer.WriteString("triangleType", triangleInterface.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs index 32df8b26742..64db3e2f462 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,114 +34,198 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// email /// firstName /// id /// lastName /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// password /// phone /// User Status /// username - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonConstructor] - public User(string email, string firstName, long id, string lastName, Object objectWithNoDeclaredProps, string password, string phone, int userStatus, string username, Object? anyTypeProp = default, Object? anyTypePropNullable = default, Object? objectWithNoDeclaredPropsNullable = default) + public User(Option anyTypeProp = default, Option anyTypePropNullable = default, Option email = default, Option firstName = default, Option id = default, Option lastName = default, Option objectWithNoDeclaredProps = default, Option objectWithNoDeclaredPropsNullable = default, Option password = default, Option phone = default, Option userStatus = default, Option username = default) { - Email = email; - FirstName = firstName; - Id = id; - LastName = lastName; - ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - Password = password; - Phone = phone; - UserStatus = userStatus; - Username = username; - AnyTypeProp = anyTypeProp; - AnyTypePropNullable = anyTypePropNullable; - ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypePropOption = anyTypeProp; + AnyTypePropNullableOption = anyTypePropNullable; + EmailOption = email; + FirstNameOption = firstName; + IdOption = id; + LastNameOption = lastName; + ObjectWithNoDeclaredPropsOption = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullableOption = objectWithNoDeclaredPropsNullable; + PasswordOption = password; + PhoneOption = phone; + UserStatusOption = userStatus; + UsernameOption = username; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets Email + /// Used to track the state of AnyTypeProp /// - [JsonPropertyName("email")] - public string Email { get; set; } - - /// - /// Gets or Sets FirstName - /// - [JsonPropertyName("firstName")] - public string FirstName { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } - - /// - /// Gets or Sets LastName - /// - [JsonPropertyName("lastName")] - public string LastName { get; set; } - - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [JsonPropertyName("objectWithNoDeclaredProps")] - public Object ObjectWithNoDeclaredProps { get; set; } - - /// - /// Gets or Sets Password - /// - [JsonPropertyName("password")] - public string Password { get; set; } - - /// - /// Gets or Sets Phone - /// - [JsonPropertyName("phone")] - public string Phone { get; set; } - - /// - /// User Status - /// - /// User Status - [JsonPropertyName("userStatus")] - public int UserStatus { get; set; } - - /// - /// Gets or Sets Username - /// - [JsonPropertyName("username")] - public string Username { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 [JsonPropertyName("anyTypeProp")] - public Object? AnyTypeProp { get; set; } + public Object? AnyTypeProp { get { return this. AnyTypePropOption; } set { this.AnyTypePropOption = new(value); } } + + /// + /// Used to track the state of AnyTypePropNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropNullableOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. [JsonPropertyName("anyTypePropNullable")] - public Object? AnyTypePropNullable { get; set; } + public Object? AnyTypePropNullable { get { return this. AnyTypePropNullableOption; } set { this.AnyTypePropNullableOption = new(value); } } + + /// + /// Used to track the state of Email + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmailOption { get; private set; } + + /// + /// Gets or Sets Email + /// + [JsonPropertyName("email")] + public string? Email { get { return this. EmailOption; } set { this.EmailOption = new(value); } } + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string? FirstName { get { return this. FirstNameOption; } set { this.FirstNameOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string? LastName { get { return this. LastNameOption; } set { this.LastNameOption = new(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredProps + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsOption { get; private set; } + + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + [JsonPropertyName("objectWithNoDeclaredProps")] + public Object? ObjectWithNoDeclaredProps { get { return this. ObjectWithNoDeclaredPropsOption; } set { this.ObjectWithNoDeclaredPropsOption = new(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredPropsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsNullableOption { get; private set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonPropertyName("objectWithNoDeclaredPropsNullable")] - public Object? ObjectWithNoDeclaredPropsNullable { get; set; } + public Object? ObjectWithNoDeclaredPropsNullable { get { return this. ObjectWithNoDeclaredPropsNullableOption; } set { this.ObjectWithNoDeclaredPropsNullableOption = new(value); } } + + /// + /// Used to track the state of Password + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PasswordOption { get; private set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string? Password { get { return this. PasswordOption; } set { this.PasswordOption = new(value); } } + + /// + /// Used to track the state of Phone + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PhoneOption { get; private set; } + + /// + /// Gets or Sets Phone + /// + [JsonPropertyName("phone")] + public string? Phone { get { return this. PhoneOption; } set { this.PhoneOption = new(value); } } + + /// + /// Used to track the state of UserStatus + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UserStatusOption { get; private set; } + + /// + /// User Status + /// + /// User Status + [JsonPropertyName("userStatus")] + public int? UserStatus { get { return this. UserStatusOption; } set { this.UserStatusOption = new(value); } } + + /// + /// Used to track the state of Username + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UsernameOption { get; private set; } + + /// + /// Gets or Sets Username + /// + [JsonPropertyName("username")] + public string? Username { get { return this. UsernameOption; } set { this.UsernameOption = new(value); } } /// /// Gets or Sets additional properties @@ -156,18 +241,18 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class User {\n"); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); sb.Append(" Email: ").Append(Email).Append("\n"); sb.Append(" FirstName: ").Append(FirstName).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" LastName: ").Append(LastName).Append("\n"); sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" Phone: ").Append(Phone).Append("\n"); sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); sb.Append(" Username: ").Append(Username).Append("\n"); - sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); - sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); - sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -206,18 +291,18 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? email = default; - string? firstName = default; - long? id = default; - string? lastName = default; - Object? objectWithNoDeclaredProps = default; - string? password = default; - string? phone = default; - int? userStatus = default; - string? username = default; - Object? anyTypeProp = default; - Object? anyTypePropNullable = default; - Object? objectWithNoDeclaredPropsNullable = default; + Option anyTypeProp = default; + Option anyTypePropNullable = default; + Option email = default; + Option firstName = default; + Option id = default; + Option lastName = default; + Option objectWithNoDeclaredProps = default; + Option objectWithNoDeclaredPropsNullable = default; + Option password = default; + Option phone = default; + Option userStatus = default; + Option username = default; while (utf8JsonReader.Read()) { @@ -234,47 +319,47 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "email": - email = utf8JsonReader.GetString(); - break; - case "firstName": - firstName = utf8JsonReader.GetString(); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; - case "lastName": - lastName = utf8JsonReader.GetString(); - break; - case "objectWithNoDeclaredProps": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredProps = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "password": - password = utf8JsonReader.GetString(); - break; - case "phone": - phone = utf8JsonReader.GetString(); - break; - case "userStatus": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - userStatus = utf8JsonReader.GetInt32(); - break; - case "username": - username = utf8JsonReader.GetString(); - break; case "anyTypeProp": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "anyTypePropNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypePropNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypePropNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "email": + email = new Option(utf8JsonReader.GetString()!); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()!); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()!); + break; + case "objectWithNoDeclaredProps": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredProps = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "objectWithNoDeclaredPropsNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredPropsNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + objectWithNoDeclaredPropsNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "password": + password = new Option(utf8JsonReader.GetString()!); + break; + case "phone": + phone = new Option(utf8JsonReader.GetString()!); + break; + case "userStatus": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + userStatus = new Option(utf8JsonReader.GetInt32()); + break; + case "username": + username = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -282,34 +367,34 @@ namespace Org.OpenAPITools.Model } } - if (email == null) - throw new ArgumentNullException(nameof(email), "Property is required for class User."); + if (email.IsSet && email.Value == null) + throw new ArgumentNullException(nameof(email), "Property is not nullable for class User."); - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class User."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class User."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class User."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class User."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User."); - if (objectWithNoDeclaredProps == null) - throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is required for class User."); + if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null) + throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class User."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class User."); - if (phone == null) - throw new ArgumentNullException(nameof(phone), "Property is required for class User."); + if (phone.IsSet && phone.Value == null) + throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User."); - if (userStatus == null) - throw new ArgumentNullException(nameof(userStatus), "Property is required for class User."); + if (userStatus.IsSet && userStatus.Value == null) + throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User."); - if (username == null) - throw new ArgumentNullException(nameof(username), "Property is required for class User."); + if (username.IsSet && username.Value == null) + throw new ArgumentNullException(nameof(username), "Property is not nullable for class User."); - return new User(email, firstName, id.Value, lastName, objectWithNoDeclaredProps, password, phone, userStatus.Value, username, anyTypeProp, anyTypePropNullable, objectWithNoDeclaredPropsNullable); + return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username); } /// @@ -336,22 +421,79 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("email", user.Email); - writer.WriteString("firstName", user.FirstName); - writer.WriteNumber("id", user.Id); - writer.WriteString("lastName", user.LastName); - writer.WritePropertyName("objectWithNoDeclaredProps"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); - writer.WriteString("password", user.Password); - writer.WriteString("phone", user.Phone); - writer.WriteNumber("userStatus", user.UserStatus); - writer.WriteString("username", user.Username); - writer.WritePropertyName("anyTypeProp"); - JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); - writer.WritePropertyName("anyTypePropNullable"); - JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); - writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + if (user.EmailOption.IsSet && user.Email == null) + throw new ArgumentNullException(nameof(user.Email), "Property is required for class User."); + + if (user.FirstNameOption.IsSet && user.FirstName == null) + throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User."); + + if (user.LastNameOption.IsSet && user.LastName == null) + throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User."); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null) + throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User."); + + if (user.PasswordOption.IsSet && user.Password == null) + throw new ArgumentNullException(nameof(user.Password), "Property is required for class User."); + + if (user.PhoneOption.IsSet && user.Phone == null) + throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User."); + + if (user.UsernameOption.IsSet && user.Username == null) + throw new ArgumentNullException(nameof(user.Username), "Property is required for class User."); + + if (user.AnyTypePropOption.IsSet) + if (user.AnyTypePropOption.Value != null) + { + writer.WritePropertyName("anyTypeProp"); + JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypeProp"); + if (user.AnyTypePropNullableOption.IsSet) + if (user.AnyTypePropNullableOption.Value != null) + { + writer.WritePropertyName("anyTypePropNullable"); + JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypePropNullable"); + if (user.EmailOption.IsSet) + writer.WriteString("email", user.Email); + + if (user.FirstNameOption.IsSet) + writer.WriteString("firstName", user.FirstName); + + if (user.IdOption.IsSet) + writer.WriteNumber("id", user.IdOption.Value!.Value); + + if (user.LastNameOption.IsSet) + writer.WriteString("lastName", user.LastName); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet) + { + writer.WritePropertyName("objectWithNoDeclaredProps"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); + } + if (user.ObjectWithNoDeclaredPropsNullableOption.IsSet) + if (user.ObjectWithNoDeclaredPropsNullableOption.Value != null) + { + writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + } + else + writer.WriteNull("objectWithNoDeclaredPropsNullable"); + if (user.PasswordOption.IsSet) + writer.WriteString("password", user.Password); + + if (user.PhoneOption.IsSet) + writer.WriteString("phone", user.Phone); + + if (user.UserStatusOption.IsSet) + writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value); + + if (user.UsernameOption.IsSet) + writer.WriteString("username", user.Username); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs index 59099f90e2d..00aeea839e6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -37,11 +38,11 @@ namespace Org.OpenAPITools.Model /// hasBaleen /// hasTeeth [JsonConstructor] - public Whale(string className, bool hasBaleen, bool hasTeeth) + public Whale(string className, Option hasBaleen = default, Option hasTeeth = default) { ClassName = className; - HasBaleen = hasBaleen; - HasTeeth = hasTeeth; + HasBaleenOption = hasBaleen; + HasTeethOption = hasTeeth; OnCreated(); } @@ -53,17 +54,31 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of HasBaleen + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasBaleenOption { get; private set; } + /// /// Gets or Sets HasBaleen /// [JsonPropertyName("hasBaleen")] - public bool HasBaleen { get; set; } + public bool? HasBaleen { get { return this. HasBaleenOption; } set { this.HasBaleenOption = new(value); } } + + /// + /// Used to track the state of HasTeeth + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasTeethOption { get; private set; } /// /// Gets or Sets HasTeeth /// [JsonPropertyName("hasTeeth")] - public bool HasTeeth { get; set; } + public bool? HasTeeth { get { return this. HasTeethOption; } set { this.HasTeethOption = new(value); } } /// /// Gets or Sets additional properties @@ -120,9 +135,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - bool? hasBaleen = default; - bool? hasTeeth = default; + Option className = default; + Option hasBaleen = default; + Option hasTeeth = default; while (utf8JsonReader.Read()) { @@ -140,15 +155,15 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; case "hasBaleen": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasBaleen = utf8JsonReader.GetBoolean(); + hasBaleen = new Option(utf8JsonReader.GetBoolean()); break; case "hasTeeth": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasTeeth = utf8JsonReader.GetBoolean(); + hasTeeth = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -156,16 +171,19 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Whale."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Whale.", nameof(className)); - if (hasBaleen == null) - throw new ArgumentNullException(nameof(hasBaleen), "Property is required for class Whale."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale."); - if (hasTeeth == null) - throw new ArgumentNullException(nameof(hasTeeth), "Property is required for class Whale."); + if (hasBaleen.IsSet && hasBaleen.Value == null) + throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale."); - return new Whale(className, hasBaleen.Value, hasTeeth.Value); + if (hasTeeth.IsSet && hasTeeth.Value == null) + throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale."); + + return new Whale(className.Value!, hasBaleen, hasTeeth); } /// @@ -192,9 +210,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) { + if (whale.ClassName == null) + throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale."); + writer.WriteString("className", whale.ClassName); - writer.WriteBoolean("hasBaleen", whale.HasBaleen); - writer.WriteBoolean("hasTeeth", whale.HasTeeth); + + if (whale.HasBaleenOption.IsSet) + writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value); + + if (whale.HasTeethOption.IsSet) + writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs index f3a1c274ec5..f009907a9d1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,10 +37,10 @@ namespace Org.OpenAPITools.Model /// className /// type [JsonConstructor] - public Zebra(string className, TypeEnum type) : base() + public Zebra(string className, Option type = default) : base() { ClassName = className; - Type = type; + TypeOption = type; OnCreated(); } @@ -111,9 +112,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string TypeEnumToJsonValue(TypeEnum value) + public static string TypeEnumToJsonValue(TypeEnum? value) { - if (value == TypeEnum.Plains) return "plains"; @@ -126,11 +126,18 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public TypeEnum Type { get; set; } + public TypeEnum? Type { get { return this.TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets ClassName @@ -203,8 +210,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? className = default; - Zebra.TypeEnum? type = default; + Option className = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -222,13 +229,12 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()!); break; case "type": string? typeRawValue = utf8JsonReader.GetString(); - type = typeRawValue == null - ? null - : Zebra.TypeEnumFromStringOrDefault(typeRawValue); + if (typeRawValue != null) + type = new Option(Zebra.TypeEnumFromStringOrDefault(typeRawValue)); break; default: break; @@ -236,13 +242,16 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Zebra."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Zebra.", nameof(className)); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Zebra."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra."); - return new Zebra(className, type.Value); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra."); + + return new Zebra(className.Value!, type); } /// @@ -269,9 +278,12 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) { + if (zebra.ClassName == null) + throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra."); + writer.WriteString("className", zebra.ClassName); - var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.Type); + var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value!.Value); if (typeRawValue != null) writer.WriteString("type", typeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs index 60223b9ff74..1db14d35a9e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 27d16e96c2b..c7083ab9d5b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,9 +36,9 @@ namespace Org.OpenAPITools.Model /// /// zeroBasedEnum [JsonConstructor] - public ZeroBasedEnumClass(ZeroBasedEnumEnum zeroBasedEnum) + public ZeroBasedEnumClass(Option zeroBasedEnum = default) { - ZeroBasedEnum = zeroBasedEnum; + ZeroBasedEnumOption = zeroBasedEnum; OnCreated(); } @@ -98,9 +99,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum value) + public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum? value) { - if (value == ZeroBasedEnumEnum.Unknown) return "unknown"; @@ -110,11 +110,18 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of ZeroBasedEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ZeroBasedEnumOption { get; private set; } + /// /// Gets or Sets ZeroBasedEnum /// [JsonPropertyName("ZeroBasedEnum")] - public ZeroBasedEnumEnum ZeroBasedEnum { get; set; } + public ZeroBasedEnumEnum? ZeroBasedEnum { get { return this.ZeroBasedEnumOption; } set { this.ZeroBasedEnumOption = new(value); } } /// /// Gets or Sets additional properties @@ -169,7 +176,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - ZeroBasedEnumClass.ZeroBasedEnumEnum? zeroBasedEnum = default; + Option zeroBasedEnum = default; while (utf8JsonReader.Read()) { @@ -188,9 +195,8 @@ namespace Org.OpenAPITools.Model { case "ZeroBasedEnum": string? zeroBasedEnumRawValue = utf8JsonReader.GetString(); - zeroBasedEnum = zeroBasedEnumRawValue == null - ? null - : ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue); + if (zeroBasedEnumRawValue != null) + zeroBasedEnum = new Option(ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue)); break; default: break; @@ -198,10 +204,10 @@ namespace Org.OpenAPITools.Model } } - if (zeroBasedEnum == null) - throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is required for class ZeroBasedEnumClass."); + if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null) + throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass."); - return new ZeroBasedEnumClass(zeroBasedEnum.Value); + return new ZeroBasedEnumClass(zeroBasedEnum); } /// @@ -228,8 +234,7 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) { - - var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnum); + var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value); if (zeroBasedEnumRawValue != null) writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES index 1179de6767b..05049077c2a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES @@ -79,6 +79,7 @@ docs/models/PolymorphicProperty.md docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md +docs/models/RequiredClass.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -206,6 +207,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/AdditionalPropertiesClass.md index f79869f95a7..2bbe882fcfc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/AdditionalPropertiesClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/AdditionalPropertiesClass.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Anytype1** | **Object** | | [optional] **EmptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] **MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] **MapProperty** | **Dictionary<string, string>** | | [optional] @@ -11,7 +12,6 @@ Name | Type | Description | Notes **MapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional] **MapWithUndeclaredPropertiesAnytype3** | **Dictionary<string, Object>** | | [optional] **MapWithUndeclaredPropertiesString** | **Dictionary<string, string>** | | [optional] -**Anytype1** | **Object** | | [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/docs/models/Drawing.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Drawing.md index 215793515f6..95f49b2ed60 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Drawing.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Drawing.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **MainShape** | [**Shape**](Shape.md) | | [optional] -**Shapes** | [**List<Shape>**](Shape.md) | | [optional] **NullableShape** | [**NullableShape**](NullableShape.md) | | [optional] **ShapeOrNull** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] +**Shapes** | [**List<Shape>**](Shape.md) | | [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/docs/models/EnumTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/EnumTest.md index 53bbfe31e77..ebd7ccf2c86 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/EnumTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/EnumTest.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] **EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **EnumString** | **string** | | [optional] -**EnumStringRequired** | **string** | | +**OuterEnum** | **OuterEnum** | | [optional] **OuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] **OuterEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional] -**OuterEnum** | **OuterEnum** | | [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/docs/models/FormatTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/FormatTest.md index 28f1a809358..ab628ed7bc0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/FormatTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/FormatTest.md @@ -4,9 +4,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Binary** | **System.IO.Stream** | | [optional] **VarByte** | **byte[]** | | **Date** | **DateTime** | | +**Number** | **decimal** | | +**Password** | **string** | | +**Binary** | **System.IO.Stream** | | [optional] **DateTime** | **DateTime** | | [optional] **VarDecimal** | **decimal** | | [optional] **VarDouble** | **double** | | [optional] @@ -14,8 +16,6 @@ Name | Type | Description | Notes **Int32** | **int** | | [optional] **Int64** | **long** | | [optional] **Integer** | **int** | | [optional] -**Number** | **decimal** | | -**Password** | **string** | | **PatternWithBackslash** | **string** | None | [optional] **PatternWithDigits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional] **PatternWithDigitsAndDelimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/NullableClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/NullableClass.md index 394feef77db..5d9965f55c0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/NullableClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/NullableClass.md @@ -4,9 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ArrayItemsNullable** | **List<Object>** | | [optional] -**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ArrayAndItemsNullableProp** | **List<Object>** | | [optional] +**ArrayItemsNullable** | **List<Object>** | | [optional] **ArrayNullableProp** | **List<Object>** | | [optional] **BooleanProp** | **bool** | | [optional] **DateProp** | **DateTime** | | [optional] @@ -14,6 +13,7 @@ Name | Type | Description | Notes **IntegerProp** | **int** | | [optional] **NumberProp** | **decimal** | | [optional] **ObjectAndItemsNullableProp** | **Dictionary<string, Object>** | | [optional] +**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ObjectNullableProp** | **Dictionary<string, Object>** | | [optional] **StringProp** | **string** | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Order.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Order.md index ca5d8992a51..f7d6827ed5c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Order.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Order.md @@ -4,12 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Complete** | **bool** | | [optional] [default to false] **Id** | **long** | | [optional] **PetId** | **long** | | [optional] **Quantity** | **int** | | [optional] **ShipDate** | **DateTime** | | [optional] **Status** | **string** | Order Status | [optional] -**Complete** | **bool** | | [optional] [default to false] [[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/docs/models/Pet.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Pet.md index b13bb576b45..4f019b613bd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Pet.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/Pet.md @@ -4,10 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Category** | [**Category**](Category.md) | | [optional] -**Id** | **long** | | [optional] **Name** | **string** | | **PhotoUrls** | **List<string>** | | +**Category** | [**Category**](Category.md) | | [optional] +**Id** | **long** | | [optional] **Status** | **string** | pet status in the store | [optional] **Tags** | [**List<Tag>**](Tag.md) | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/RequiredClass.md new file mode 100644 index 00000000000..8f148be840b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNotNullableDateProp** | **DateTime** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNotnullableEnumInteger** | **int** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**RequiredNotnullableEnumString** | **string** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableStringProp** | **string** | | +**RequiredNotnullableUuid** | **Guid** | | +**RequiredNotnullableintegerProp** | **int** | | +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNullableBooleanProp** | **bool** | | +**RequiredNullableDateProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime** | | +**RequiredNullableEnumInteger** | **int** | | +**RequiredNullableEnumIntegerOnly** | **int** | | +**RequiredNullableEnumString** | **string** | | +**RequiredNullableIntegerProp** | **int** | | +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNullableStringProp** | **string** | | +**RequiredNullableUuid** | **Guid** | | +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**NotRequiredNullableDateProp** | **DateTime** | | [optional] +**NotRequiredNullableIntegerProp** | **int** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNullableBooleanProp** | **bool** | | [optional] +**NotrequiredNullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNullableEnumInteger** | **int** | | [optional] +**NotrequiredNullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNullableUuid** | **Guid** | | [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/docs/models/User.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/User.md index 455f031674d..b5700f1c75d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/User.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/User.md @@ -4,18 +4,18 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] +**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] **Email** | **string** | | [optional] **FirstName** | **string** | | [optional] **Id** | **long** | | [optional] **LastName** | **string** | | [optional] **ObjectWithNoDeclaredProps** | **Object** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional] +**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] **Password** | **string** | | [optional] **Phone** | **string** | | [optional] **UserStatus** | **int** | User Status | [optional] **Username** | **string** | | [optional] -**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] -**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] -**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [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/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..6e8958b1b74 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,452 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs index e88b5ed621a..d2fe509d91f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -141,6 +141,8 @@ namespace Org.OpenAPITools.Client return EnumArrays.JustSymbolEnumToJsonValue(enumArraysJustSymbolEnum); if (obj is EnumClass enumClass) return EnumClassValueConverter.ToJsonValue(enumClass); + if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) + return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is EnumTest.EnumIntegerEnum enumTestEnumIntegerEnum) return EnumTest.EnumIntegerEnumToJsonValue(enumTestEnumIntegerEnum).ToString(); if (obj is EnumTest.EnumIntegerOnlyEnum enumTestEnumIntegerOnlyEnum) @@ -149,8 +151,6 @@ namespace Org.OpenAPITools.Client return EnumTest.EnumNumberEnumToJsonValue(enumTestEnumNumberEnum).ToString(); if (obj is EnumTest.EnumStringEnum enumTestEnumStringEnum) return EnumTest.EnumStringEnumToJsonValue(enumTestEnumStringEnum); - if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) - return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is MapTest.InnerEnum mapTestInnerEnum) return MapTest.InnerEnumToJsonValue(mapTestInnerEnum); if (obj is Order.StatusEnum orderStatusEnum) @@ -167,6 +167,30 @@ namespace Org.OpenAPITools.Client return OuterEnumTestValueConverter.ToJsonValue(outerEnumTest); if (obj is Pet.StatusEnum petStatusEnum) return Pet.StatusEnumToJsonValue(petStatusEnum); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerEnum requiredClassRequiredNotnullableEnumIntegerEnum) + return RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum requiredClassRequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumStringEnum requiredClassRequiredNotnullableEnumStringEnum) + return RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClassRequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.RequiredNullableEnumIntegerEnum requiredClassRequiredNullableEnumIntegerEnum) + return RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClassRequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumIntegerOnlyEnum requiredClassRequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) + return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerEnum requiredClassNotrequiredNotnullableEnumIntegerEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumStringEnum requiredClassNotrequiredNotnullableEnumStringEnum) + return RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClassNotrequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerEnum requiredClassNotrequiredNullableEnumIntegerEnum) + return RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum requiredClassNotrequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumStringEnum requiredClassNotrequiredNullableEnumStringEnum) + return RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClassNotrequiredNullableEnumStringEnum); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs index 5ea9415eba0..0cd32640adf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -114,6 +114,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/Option.cs index 70f41078bb6..8cf79a713b7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/Option.cs @@ -35,5 +35,17 @@ namespace Org.OpenAPITools.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs index 42747dee35e..14133851620 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Activity.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// activityOutputs [JsonConstructor] - public Activity(Dictionary> activityOutputs) + public Activity(Option>> activityOutputs = default) { - ActivityOutputs = activityOutputs; + ActivityOutputsOption = activityOutputs; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ActivityOutputs + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ActivityOutputsOption { get; private set; } + /// /// Gets or Sets ActivityOutputs /// [JsonPropertyName("activity_outputs")] - public Dictionary> ActivityOutputs { get; set; } + public Dictionary> ActivityOutputs { get { return this. ActivityOutputsOption; } set { this.ActivityOutputsOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary> activityOutputs = default; + Option>> activityOutputs = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "activity_outputs": if (utf8JsonReader.TokenType != JsonTokenType.Null) - activityOutputs = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + activityOutputs = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (activityOutputs == null) - throw new ArgumentNullException(nameof(activityOutputs), "Property is required for class Activity."); + if (activityOutputs.IsSet && activityOutputs.Value == null) + throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity."); return new Activity(activityOutputs); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("activity_outputs"); - JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null) + throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity."); + + if (activity.ActivityOutputsOption.IsSet) + { + writer.WritePropertyName("activity_outputs"); + JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index 233d362f51e..da158a14e41 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// prop1 /// prop2 [JsonConstructor] - public ActivityOutputElementRepresentation(string prop1, Object prop2) + public ActivityOutputElementRepresentation(Option prop1 = default, Option prop2 = default) { - Prop1 = prop1; - Prop2 = prop2; + Prop1Option = prop1; + Prop2Option = prop2; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Prop1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop1Option { get; private set; } + /// /// Gets or Sets Prop1 /// [JsonPropertyName("prop1")] - public string Prop1 { get; set; } + public string Prop1 { get { return this. Prop1Option; } set { this.Prop1Option = new(value); } } + + /// + /// Used to track the state of Prop2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop2Option { get; private set; } /// /// Gets or Sets Prop2 /// [JsonPropertyName("prop2")] - public Object Prop2 { get; set; } + public Object Prop2 { get { return this. Prop2Option; } set { this.Prop2Option = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string prop1 = default; - Object prop2 = default; + Option prop1 = default; + Option prop2 = default; while (utf8JsonReader.Read()) { @@ -128,11 +143,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "prop1": - prop1 = utf8JsonReader.GetString(); + prop1 = new Option(utf8JsonReader.GetString()); break; case "prop2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - prop2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + prop2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -140,11 +155,11 @@ namespace Org.OpenAPITools.Model } } - if (prop1 == null) - throw new ArgumentNullException(nameof(prop1), "Property is required for class ActivityOutputElementRepresentation."); + if (prop1.IsSet && prop1.Value == null) + throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation."); - if (prop2 == null) - throw new ArgumentNullException(nameof(prop2), "Property is required for class ActivityOutputElementRepresentation."); + if (prop2.IsSet && prop2.Value == null) + throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation."); return new ActivityOutputElementRepresentation(prop1, prop2); } @@ -173,9 +188,20 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); - writer.WritePropertyName("prop2"); - JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop1Option.IsSet) + writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); + + if (activityOutputElementRepresentation.Prop2Option.IsSet) + { + writer.WritePropertyName("prop2"); + JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index ed15d711b7a..a3170798f77 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,6 +32,7 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// anytype1 /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// mapOfMapProperty /// mapProperty @@ -38,71 +40,126 @@ namespace Org.OpenAPITools.Model /// mapWithUndeclaredPropertiesAnytype2 /// mapWithUndeclaredPropertiesAnytype3 /// mapWithUndeclaredPropertiesString - /// anytype1 [JsonConstructor] - public AdditionalPropertiesClass(Object emptyMap, Dictionary> mapOfMapProperty, Dictionary mapProperty, Object mapWithUndeclaredPropertiesAnytype1, Object mapWithUndeclaredPropertiesAnytype2, Dictionary mapWithUndeclaredPropertiesAnytype3, Dictionary mapWithUndeclaredPropertiesString, Object anytype1 = default) + public AdditionalPropertiesClass(Option anytype1 = default, Option emptyMap = default, Option>> mapOfMapProperty = default, Option> mapProperty = default, Option mapWithUndeclaredPropertiesAnytype1 = default, Option mapWithUndeclaredPropertiesAnytype2 = default, Option> mapWithUndeclaredPropertiesAnytype3 = default, Option> mapWithUndeclaredPropertiesString = default) { - EmptyMap = emptyMap; - MapOfMapProperty = mapOfMapProperty; - MapProperty = mapProperty; - MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - Anytype1 = anytype1; + Anytype1Option = anytype1; + EmptyMapOption = emptyMap; + MapOfMapPropertyOption = mapOfMapProperty; + MapPropertyOption = mapProperty; + MapWithUndeclaredPropertiesAnytype1Option = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2Option = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3Option = mapWithUndeclaredPropertiesAnytype3; + MapWithUndeclaredPropertiesStringOption = mapWithUndeclaredPropertiesString; OnCreated(); } partial void OnCreated(); /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// Used to track the state of Anytype1 /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [JsonPropertyName("empty_map")] - public Object EmptyMap { get; set; } - - /// - /// Gets or Sets MapOfMapProperty - /// - [JsonPropertyName("map_of_map_property")] - public Dictionary> MapOfMapProperty { get; set; } - - /// - /// Gets or Sets MapProperty - /// - [JsonPropertyName("map_property")] - public Dictionary MapProperty { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_1")] - public Object MapWithUndeclaredPropertiesAnytype1 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_2")] - public Object MapWithUndeclaredPropertiesAnytype2 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_3")] - public Dictionary MapWithUndeclaredPropertiesAnytype3 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesString - /// - [JsonPropertyName("map_with_undeclared_properties_string")] - public Dictionary MapWithUndeclaredPropertiesString { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Anytype1Option { get; private set; } /// /// Gets or Sets Anytype1 /// [JsonPropertyName("anytype_1")] - public Object Anytype1 { get; set; } + public Object Anytype1 { get { return this. Anytype1Option; } set { this.Anytype1Option = new(value); } } + + /// + /// Used to track the state of EmptyMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmptyMapOption { get; private set; } + + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + [JsonPropertyName("empty_map")] + public Object EmptyMap { get { return this. EmptyMapOption; } set { this.EmptyMapOption = new(value); } } + + /// + /// Used to track the state of MapOfMapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapOfMapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [JsonPropertyName("map_of_map_property")] + public Dictionary> MapOfMapProperty { get { return this. MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new(value); } } + + /// + /// Used to track the state of MapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapProperty + /// + [JsonPropertyName("map_property")] + public Dictionary MapProperty { get { return this. MapPropertyOption; } set { this.MapPropertyOption = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype1Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] + public Object MapWithUndeclaredPropertiesAnytype1 { get { return this. MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype2Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] + public Object MapWithUndeclaredPropertiesAnytype2 { get { return this. MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype3 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesAnytype3Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] + public Dictionary MapWithUndeclaredPropertiesAnytype3 { get { return this. MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesStringOption { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesString + /// + [JsonPropertyName("map_with_undeclared_properties_string")] + public Dictionary MapWithUndeclaredPropertiesString { get { return this. MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -118,6 +175,7 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); @@ -125,7 +183,6 @@ namespace Org.OpenAPITools.Model sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); - sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -164,14 +221,14 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Object emptyMap = default; - Dictionary> mapOfMapProperty = default; - Dictionary mapProperty = default; - Object mapWithUndeclaredPropertiesAnytype1 = default; - Object mapWithUndeclaredPropertiesAnytype2 = default; - Dictionary mapWithUndeclaredPropertiesAnytype3 = default; - Dictionary mapWithUndeclaredPropertiesString = default; - Object anytype1 = default; + Option anytype1 = default; + Option emptyMap = default; + Option>> mapOfMapProperty = default; + Option> mapProperty = default; + Option mapWithUndeclaredPropertiesAnytype1 = default; + Option mapWithUndeclaredPropertiesAnytype2 = default; + Option> mapWithUndeclaredPropertiesAnytype3 = default; + Option> mapWithUndeclaredPropertiesString = default; while (utf8JsonReader.Read()) { @@ -188,37 +245,37 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; case "empty_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - emptyMap = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + emptyMap = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_of_map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfMapProperty = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapOfMapProperty = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapProperty = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapProperty = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_anytype_1": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_anytype_2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_anytype_3": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype3 = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype3 = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "anytype_1": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - anytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -226,28 +283,28 @@ namespace Org.OpenAPITools.Model } } - if (emptyMap == null) - throw new ArgumentNullException(nameof(emptyMap), "Property is required for class AdditionalPropertiesClass."); + if (emptyMap.IsSet && emptyMap.Value == null) + throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapOfMapProperty == null) - throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null) + throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapProperty == null) - throw new ArgumentNullException(nameof(mapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapProperty.IsSet && mapProperty.Value == null) + throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype1 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype2 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype3 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesString == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass."); - return new AdditionalPropertiesClass(emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString, anytype1); + return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString); } /// @@ -274,22 +331,70 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("empty_map"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); - writer.WritePropertyName("map_of_map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_string"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); - writer.WritePropertyName("anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.Anytype1Option.IsSet) + if (additionalPropertiesClass.Anytype1Option.Value != null) + { + writer.WritePropertyName("anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + } + else + writer.WriteNull("anytype_1"); + if (additionalPropertiesClass.EmptyMapOption.IsSet) + { + writer.WritePropertyName("empty_map"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet) + { + writer.WritePropertyName("map_of_map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapPropertyOption.IsSet) + { + writer.WritePropertyName("map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_string"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs index 460543ebf0d..82333f58eb6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, string color = @"red") + public Animal(string className, Option color = default) { ClassName = className; - Color = color; + ColorOption = color; OnCreated(); } @@ -49,11 +50,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Gets or Sets additional properties @@ -119,8 +127,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - string color = default; + Option className = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -138,10 +146,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -149,13 +157,16 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Animal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Animal.", nameof(className)); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Animal."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal."); - return new Animal(className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); + + return new Animal(className.Value, color); } /// @@ -182,8 +193,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { + if (animal.ClassName == null) + throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); + + if (animal.ColorOption.IsSet && animal.Color == null) + throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); + writer.WriteString("className", animal.ClassName); - writer.WriteString("color", animal.Color); + + if (animal.ColorOption.IsSet) + writer.WriteString("color", animal.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs index 5a7be95495c..eebfe2c7516 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// message /// type [JsonConstructor] - public ApiResponse(int code, string message, string type) + public ApiResponse(Option code = default, Option message = default, Option type = default) { - Code = code; - Message = message; - Type = type; + CodeOption = code; + MessageOption = message; + TypeOption = type; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + /// /// Gets or Sets Code /// [JsonPropertyName("code")] - public int Code { get; set; } + public int? Code { get { return this. CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Message + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MessageOption { get; private set; } /// /// Gets or Sets Message /// [JsonPropertyName("message")] - public string Message { get; set; } + public string Message { get { return this. MessageOption; } set { this.MessageOption = new(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public string Type { get; set; } + public string Type { get { return this. TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets additional properties @@ -118,9 +140,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? code = default; - string message = default; - string type = default; + Option code = default; + Option message = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -139,13 +161,13 @@ namespace Org.OpenAPITools.Model { case "code": if (utf8JsonReader.TokenType != JsonTokenType.Null) - code = utf8JsonReader.GetInt32(); + code = new Option(utf8JsonReader.GetInt32()); break; case "message": - message = utf8JsonReader.GetString(); + message = new Option(utf8JsonReader.GetString()); break; case "type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()); break; default: break; @@ -153,16 +175,16 @@ namespace Org.OpenAPITools.Model } } - if (code == null) - throw new ArgumentNullException(nameof(code), "Property is required for class ApiResponse."); + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse."); - if (message == null) - throw new ArgumentNullException(nameof(message), "Property is required for class ApiResponse."); + if (message.IsSet && message.Value == null) + throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class ApiResponse."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse."); - return new ApiResponse(code.Value, message, type); + return new ApiResponse(code, message, type); } /// @@ -189,9 +211,20 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("code", apiResponse.Code); - writer.WriteString("message", apiResponse.Message); - writer.WriteString("type", apiResponse.Type); + if (apiResponse.MessageOption.IsSet && apiResponse.Message == null) + throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse."); + + if (apiResponse.TypeOption.IsSet && apiResponse.Type == null) + throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse."); + + if (apiResponse.CodeOption.IsSet) + writer.WriteNumber("code", apiResponse.CodeOption.Value.Value); + + if (apiResponse.MessageOption.IsSet) + writer.WriteString("message", apiResponse.Message); + + if (apiResponse.TypeOption.IsSet) + writer.WriteString("type", apiResponse.Type); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs index 31246df0422..a349e6c9d16 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// cultivar /// origin [JsonConstructor] - public Apple(string colorCode, string cultivar, string origin) + public Apple(Option colorCode = default, Option cultivar = default, Option origin = default) { - ColorCode = colorCode; - Cultivar = cultivar; - Origin = origin; + ColorCodeOption = colorCode; + CultivarOption = cultivar; + OriginOption = origin; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ColorCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorCodeOption { get; private set; } + /// /// Gets or Sets ColorCode /// [JsonPropertyName("color_code")] - public string ColorCode { get; set; } + public string ColorCode { get { return this. ColorCodeOption; } set { this.ColorCodeOption = new(value); } } + + /// + /// Used to track the state of Cultivar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CultivarOption { get; private set; } /// /// Gets or Sets Cultivar /// [JsonPropertyName("cultivar")] - public string Cultivar { get; set; } + public string Cultivar { get { return this. CultivarOption; } set { this.CultivarOption = new(value); } } + + /// + /// Used to track the state of Origin + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OriginOption { get; private set; } /// /// Gets or Sets Origin /// [JsonPropertyName("origin")] - public string Origin { get; set; } + public string Origin { get { return this. OriginOption; } set { this.OriginOption = new(value); } } /// /// Gets or Sets additional properties @@ -92,28 +114,31 @@ namespace Org.OpenAPITools.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - if (this.ColorCode != null) { + if (this.ColorCodeOption.Value != null) { // ColorCode (string) pattern Regex regexColorCode = new Regex(@"^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$", RegexOptions.CultureInvariant); - if (!regexColorCode.Match(this.ColorCode).Success) + + if (this.ColorCodeOption.Value != null &&!regexColorCode.Match(this.ColorCodeOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ColorCode, must match a pattern of " + regexColorCode, new [] { "ColorCode" }); } } - if (this.Cultivar != null) { + if (this.CultivarOption.Value != null) { // Cultivar (string) pattern Regex regexCultivar = new Regex(@"^[a-zA-Z\s]*$", RegexOptions.CultureInvariant); - if (!regexCultivar.Match(this.Cultivar).Success) + + if (this.CultivarOption.Value != null &&!regexCultivar.Match(this.CultivarOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Cultivar, must match a pattern of " + regexCultivar, new [] { "Cultivar" }); } } - if (this.Origin != null) { + if (this.OriginOption.Value != null) { // Origin (string) pattern Regex regexOrigin = new Regex(@"^[A-Z\s]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexOrigin.Match(this.Origin).Success) + + if (this.OriginOption.Value != null &&!regexOrigin.Match(this.OriginOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Origin, must match a pattern of " + regexOrigin, new [] { "Origin" }); } @@ -145,9 +170,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string colorCode = default; - string cultivar = default; - string origin = default; + Option colorCode = default; + Option cultivar = default; + Option origin = default; while (utf8JsonReader.Read()) { @@ -165,13 +190,13 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color_code": - colorCode = utf8JsonReader.GetString(); + colorCode = new Option(utf8JsonReader.GetString()); break; case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()); break; case "origin": - origin = utf8JsonReader.GetString(); + origin = new Option(utf8JsonReader.GetString()); break; default: break; @@ -179,14 +204,14 @@ namespace Org.OpenAPITools.Model } } - if (colorCode == null) - throw new ArgumentNullException(nameof(colorCode), "Property is required for class Apple."); + if (colorCode.IsSet && colorCode.Value == null) + throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple."); - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class Apple."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple."); - if (origin == null) - throw new ArgumentNullException(nameof(origin), "Property is required for class Apple."); + if (origin.IsSet && origin.Value == null) + throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple."); return new Apple(colorCode, cultivar, origin); } @@ -215,9 +240,23 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color_code", apple.ColorCode); - writer.WriteString("cultivar", apple.Cultivar); - writer.WriteString("origin", apple.Origin); + if (apple.ColorCodeOption.IsSet && apple.ColorCode == null) + throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple."); + + if (apple.CultivarOption.IsSet && apple.Cultivar == null) + throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple."); + + if (apple.OriginOption.IsSet && apple.Origin == null) + throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple."); + + if (apple.ColorCodeOption.IsSet) + writer.WriteString("color_code", apple.ColorCode); + + if (apple.CultivarOption.IsSet) + writer.WriteString("cultivar", apple.Cultivar); + + if (apple.OriginOption.IsSet) + writer.WriteString("origin", apple.Origin); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs index e0882d925c5..6bf9766e93c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// cultivar /// mealy [JsonConstructor] - public AppleReq(string cultivar, bool mealy) + public AppleReq(string cultivar, Option mealy = default) { Cultivar = cultivar; - Mealy = mealy; + MealyOption = mealy; OnCreated(); } @@ -49,11 +50,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("cultivar")] public string Cultivar { get; set; } + /// + /// Used to track the state of Mealy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MealyOption { get; private set; } + /// /// Gets or Sets Mealy /// [JsonPropertyName("mealy")] - public bool Mealy { get; set; } + public bool? Mealy { get { return this. MealyOption; } set { this.MealyOption = new(value); } } /// /// Returns the string presentation of the object @@ -102,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string cultivar = default; - bool? mealy = default; + Option cultivar = default; + Option mealy = default; while (utf8JsonReader.Read()) { @@ -121,11 +129,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()); break; case "mealy": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mealy = utf8JsonReader.GetBoolean(); + mealy = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -133,13 +141,16 @@ namespace Org.OpenAPITools.Model } } - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class AppleReq."); + if (!cultivar.IsSet) + throw new ArgumentException("Property is required for class AppleReq.", nameof(cultivar)); - if (mealy == null) - throw new ArgumentNullException(nameof(mealy), "Property is required for class AppleReq."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq."); - return new AppleReq(cultivar, mealy.Value); + if (mealy.IsSet && mealy.Value == null) + throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq."); + + return new AppleReq(cultivar.Value, mealy); } /// @@ -166,8 +177,13 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) { + if (appleReq.Cultivar == null) + throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq."); + writer.WriteString("cultivar", appleReq.Cultivar); - writer.WriteBoolean("mealy", appleReq.Mealy); + + if (appleReq.MealyOption.IsSet) + writer.WriteBoolean("mealy", appleReq.MealyOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 6fc0afdbc30..b18638bb4e1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// arrayArrayNumber [JsonConstructor] - public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber) + public ArrayOfArrayOfNumberOnly(Option>> arrayArrayNumber = default) { - ArrayArrayNumber = arrayArrayNumber; + ArrayArrayNumberOption = arrayArrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayArrayNumber /// [JsonPropertyName("ArrayArrayNumber")] - public List> ArrayArrayNumber { get; set; } + public List> ArrayArrayNumber { get { return this. ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List> arrayArrayNumber = default; + Option>> arrayArrayNumber = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "ArrayArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayNumber = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayNumber = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (arrayArrayNumber == null) - throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly."); return new ArrayOfArrayOfNumberOnly(arrayArrayNumber); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 0715a3fdf65..4b9756fa363 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// arrayNumber [JsonConstructor] - public ArrayOfNumberOnly(List arrayNumber) + public ArrayOfNumberOnly(Option> arrayNumber = default) { - ArrayNumber = arrayNumber; + ArrayNumberOption = arrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayNumber /// [JsonPropertyName("ArrayNumber")] - public List ArrayNumber { get; set; } + public List ArrayNumber { get { return this. ArrayNumberOption; } set { this.ArrayNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List arrayNumber = default; + Option> arrayNumber = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "ArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNumber = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNumber = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (arrayNumber == null) - throw new ArgumentNullException(nameof(arrayNumber), "Property is required for class ArrayOfNumberOnly."); + if (arrayNumber.IsSet && arrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly."); return new ArrayOfNumberOnly(arrayNumber); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly."); + + if (arrayOfNumberOnly.ArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs index 43088ca1d97..0bb57876ce1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// arrayArrayOfModel /// arrayOfString [JsonConstructor] - public ArrayTest(List> arrayArrayOfInteger, List> arrayArrayOfModel, List arrayOfString) + public ArrayTest(Option>> arrayArrayOfInteger = default, Option>> arrayArrayOfModel = default, Option> arrayOfString = default) { - ArrayArrayOfInteger = arrayArrayOfInteger; - ArrayArrayOfModel = arrayArrayOfModel; - ArrayOfString = arrayOfString; + ArrayArrayOfIntegerOption = arrayArrayOfInteger; + ArrayArrayOfModelOption = arrayArrayOfModel; + ArrayOfStringOption = arrayOfString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayOfInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfIntegerOption { get; private set; } + /// /// Gets or Sets ArrayArrayOfInteger /// [JsonPropertyName("array_array_of_integer")] - public List> ArrayArrayOfInteger { get; set; } + public List> ArrayArrayOfInteger { get { return this. ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new(value); } } + + /// + /// Used to track the state of ArrayArrayOfModel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfModelOption { get; private set; } /// /// Gets or Sets ArrayArrayOfModel /// [JsonPropertyName("array_array_of_model")] - public List> ArrayArrayOfModel { get; set; } + public List> ArrayArrayOfModel { get { return this. ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new(value); } } + + /// + /// Used to track the state of ArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayOfStringOption { get; private set; } /// /// Gets or Sets ArrayOfString /// [JsonPropertyName("array_of_string")] - public List ArrayOfString { get; set; } + public List ArrayOfString { get { return this. ArrayOfStringOption; } set { this.ArrayOfStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -118,9 +140,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List> arrayArrayOfInteger = default; - List> arrayArrayOfModel = default; - List arrayOfString = default; + Option>> arrayArrayOfInteger = default; + Option>> arrayArrayOfModel = default; + Option> arrayOfString = default; while (utf8JsonReader.Read()) { @@ -139,15 +161,15 @@ namespace Org.OpenAPITools.Model { case "array_array_of_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfInteger = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfInteger = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "array_array_of_model": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfModel = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfModel = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "array_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayOfString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -155,14 +177,14 @@ namespace Org.OpenAPITools.Model } } - if (arrayArrayOfInteger == null) - throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is required for class ArrayTest."); + if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest."); - if (arrayArrayOfModel == null) - throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is required for class ArrayTest."); + if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest."); - if (arrayOfString == null) - throw new ArgumentNullException(nameof(arrayOfString), "Property is required for class ArrayTest."); + if (arrayOfString.IsSet && arrayOfString.Value == null) + throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest."); return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString); } @@ -191,12 +213,30 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_array_of_integer"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); - writer.WritePropertyName("array_array_of_model"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); - writer.WritePropertyName("array_of_string"); - JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfIntegerOption.IsSet) + { + writer.WritePropertyName("array_array_of_integer"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); + } + if (arrayTest.ArrayArrayOfModelOption.IsSet) + { + writer.WritePropertyName("array_array_of_model"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); + } + if (arrayTest.ArrayOfStringOption.IsSet) + { + writer.WritePropertyName("array_of_string"); + JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs index 75bab7a8d05..bb644ada329 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// lengthCm [JsonConstructor] - public Banana(decimal lengthCm) + public Banana(Option lengthCm = default) { - LengthCm = lengthCm; + LengthCmOption = lengthCm; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of LengthCm + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LengthCmOption { get; private set; } + /// /// Gets or Sets LengthCm /// [JsonPropertyName("lengthCm")] - public decimal LengthCm { get; set; } + public decimal? LengthCm { get { return this. LengthCmOption; } set { this.LengthCmOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; + Option lengthCm = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -127,10 +135,10 @@ namespace Org.OpenAPITools.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class Banana."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana."); - return new Banana(lengthCm.Value); + return new Banana(lengthCm); } /// @@ -157,7 +165,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("lengthCm", banana.LengthCm); + if (banana.LengthCmOption.IsSet) + writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs index 61e5cf312cc..a7eb2c945be 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// lengthCm /// sweet [JsonConstructor] - public BananaReq(decimal lengthCm, bool sweet) + public BananaReq(decimal lengthCm, Option sweet = default) { LengthCm = lengthCm; - Sweet = sweet; + SweetOption = sweet; OnCreated(); } @@ -49,11 +50,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } + /// + /// Used to track the state of Sweet + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SweetOption { get; private set; } + /// /// Gets or Sets Sweet /// [JsonPropertyName("sweet")] - public bool Sweet { get; set; } + public bool? Sweet { get { return this. SweetOption; } set { this.SweetOption = new(value); } } /// /// Returns the string presentation of the object @@ -102,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; - bool? sweet = default; + Option lengthCm = default; + Option sweet = default; while (utf8JsonReader.Read()) { @@ -122,11 +130,11 @@ namespace Org.OpenAPITools.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; case "sweet": if (utf8JsonReader.TokenType != JsonTokenType.Null) - sweet = utf8JsonReader.GetBoolean(); + sweet = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -134,13 +142,16 @@ namespace Org.OpenAPITools.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class BananaReq."); + if (!lengthCm.IsSet) + throw new ArgumentException("Property is required for class BananaReq.", nameof(lengthCm)); - if (sweet == null) - throw new ArgumentNullException(nameof(sweet), "Property is required for class BananaReq."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq."); - return new BananaReq(lengthCm.Value, sweet.Value); + if (sweet.IsSet && sweet.Value == null) + throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq."); + + return new BananaReq(lengthCm.Value.Value, sweet); } /// @@ -168,7 +179,9 @@ namespace Org.OpenAPITools.Model public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); - writer.WriteBoolean("sweet", bananaReq.Sweet); + + if (bananaReq.SweetOption.IsSet) + writer.WriteBoolean("sweet", bananaReq.SweetOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs index c9e4a8bc712..53c20a25cd1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class BasquePig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class BasquePig.", nameof(className)); - return new BasquePig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class BasquePig."); + + return new BasquePig(className.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) { + if (basquePig.ClassName == null) + throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig."); + writer.WriteString("className", basquePig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs index ca7eb413c65..46859603bd1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,55 +39,97 @@ namespace Org.OpenAPITools.Model /// smallCamel /// smallSnake [JsonConstructor] - public Capitalization(string aTTNAME, string capitalCamel, string capitalSnake, string sCAETHFlowPoints, string smallCamel, string smallSnake) + public Capitalization(Option aTTNAME = default, Option capitalCamel = default, Option capitalSnake = default, Option sCAETHFlowPoints = default, Option smallCamel = default, Option smallSnake = default) { - ATT_NAME = aTTNAME; - CapitalCamel = capitalCamel; - CapitalSnake = capitalSnake; - SCAETHFlowPoints = sCAETHFlowPoints; - SmallCamel = smallCamel; - SmallSnake = smallSnake; + ATT_NAMEOption = aTTNAME; + CapitalCamelOption = capitalCamel; + CapitalSnakeOption = capitalSnake; + SCAETHFlowPointsOption = sCAETHFlowPoints; + SmallCamelOption = smallCamel; + SmallSnakeOption = smallSnake; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ATT_NAME + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ATT_NAMEOption { get; private set; } + /// /// Name of the pet /// /// Name of the pet [JsonPropertyName("ATT_NAME")] - public string ATT_NAME { get; set; } + public string ATT_NAME { get { return this. ATT_NAMEOption; } set { this.ATT_NAMEOption = new(value); } } + + /// + /// Used to track the state of CapitalCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalCamelOption { get; private set; } /// /// Gets or Sets CapitalCamel /// [JsonPropertyName("CapitalCamel")] - public string CapitalCamel { get; set; } + public string CapitalCamel { get { return this. CapitalCamelOption; } set { this.CapitalCamelOption = new(value); } } + + /// + /// Used to track the state of CapitalSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalSnakeOption { get; private set; } /// /// Gets or Sets CapitalSnake /// [JsonPropertyName("Capital_Snake")] - public string CapitalSnake { get; set; } + public string CapitalSnake { get { return this. CapitalSnakeOption; } set { this.CapitalSnakeOption = new(value); } } + + /// + /// Used to track the state of SCAETHFlowPoints + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SCAETHFlowPointsOption { get; private set; } /// /// Gets or Sets SCAETHFlowPoints /// [JsonPropertyName("SCA_ETH_Flow_Points")] - public string SCAETHFlowPoints { get; set; } + public string SCAETHFlowPoints { get { return this. SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new(value); } } + + /// + /// Used to track the state of SmallCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallCamelOption { get; private set; } /// /// Gets or Sets SmallCamel /// [JsonPropertyName("smallCamel")] - public string SmallCamel { get; set; } + public string SmallCamel { get { return this. SmallCamelOption; } set { this.SmallCamelOption = new(value); } } + + /// + /// Used to track the state of SmallSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallSnakeOption { get; private set; } /// /// Gets or Sets SmallSnake /// [JsonPropertyName("small_Snake")] - public string SmallSnake { get; set; } + public string SmallSnake { get { return this. SmallSnakeOption; } set { this.SmallSnakeOption = new(value); } } /// /// Gets or Sets additional properties @@ -146,12 +189,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string aTTNAME = default; - string capitalCamel = default; - string capitalSnake = default; - string sCAETHFlowPoints = default; - string smallCamel = default; - string smallSnake = default; + Option aTTNAME = default; + Option capitalCamel = default; + Option capitalSnake = default; + Option sCAETHFlowPoints = default; + Option smallCamel = default; + Option smallSnake = default; while (utf8JsonReader.Read()) { @@ -169,22 +212,22 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "ATT_NAME": - aTTNAME = utf8JsonReader.GetString(); + aTTNAME = new Option(utf8JsonReader.GetString()); break; case "CapitalCamel": - capitalCamel = utf8JsonReader.GetString(); + capitalCamel = new Option(utf8JsonReader.GetString()); break; case "Capital_Snake": - capitalSnake = utf8JsonReader.GetString(); + capitalSnake = new Option(utf8JsonReader.GetString()); break; case "SCA_ETH_Flow_Points": - sCAETHFlowPoints = utf8JsonReader.GetString(); + sCAETHFlowPoints = new Option(utf8JsonReader.GetString()); break; case "smallCamel": - smallCamel = utf8JsonReader.GetString(); + smallCamel = new Option(utf8JsonReader.GetString()); break; case "small_Snake": - smallSnake = utf8JsonReader.GetString(); + smallSnake = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,23 +235,23 @@ namespace Org.OpenAPITools.Model } } - if (aTTNAME == null) - throw new ArgumentNullException(nameof(aTTNAME), "Property is required for class Capitalization."); + if (aTTNAME.IsSet && aTTNAME.Value == null) + throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization."); - if (capitalCamel == null) - throw new ArgumentNullException(nameof(capitalCamel), "Property is required for class Capitalization."); + if (capitalCamel.IsSet && capitalCamel.Value == null) + throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization."); - if (capitalSnake == null) - throw new ArgumentNullException(nameof(capitalSnake), "Property is required for class Capitalization."); + if (capitalSnake.IsSet && capitalSnake.Value == null) + throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization."); - if (sCAETHFlowPoints == null) - throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is required for class Capitalization."); + if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null) + throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization."); - if (smallCamel == null) - throw new ArgumentNullException(nameof(smallCamel), "Property is required for class Capitalization."); + if (smallCamel.IsSet && smallCamel.Value == null) + throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization."); - if (smallSnake == null) - throw new ArgumentNullException(nameof(smallSnake), "Property is required for class Capitalization."); + if (smallSnake.IsSet && smallSnake.Value == null) + throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization."); return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake); } @@ -237,12 +280,41 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("ATT_NAME", capitalization.ATT_NAME); - writer.WriteString("CapitalCamel", capitalization.CapitalCamel); - writer.WriteString("Capital_Snake", capitalization.CapitalSnake); - writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); - writer.WriteString("smallCamel", capitalization.SmallCamel); - writer.WriteString("small_Snake", capitalization.SmallSnake); + if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null) + throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization."); + + if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null) + throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization."); + + if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null) + throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization."); + + if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null) + throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization."); + + if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null) + throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization."); + + if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null) + throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization."); + + if (capitalization.ATT_NAMEOption.IsSet) + writer.WriteString("ATT_NAME", capitalization.ATT_NAME); + + if (capitalization.CapitalCamelOption.IsSet) + writer.WriteString("CapitalCamel", capitalization.CapitalCamel); + + if (capitalization.CapitalSnakeOption.IsSet) + writer.WriteString("Capital_Snake", capitalization.CapitalSnake); + + if (capitalization.SCAETHFlowPointsOption.IsSet) + writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); + + if (capitalization.SmallCamelOption.IsSet) + writer.WriteString("smallCamel", capitalization.SmallCamel); + + if (capitalization.SmallSnakeOption.IsSet) + writer.WriteString("small_Snake", capitalization.SmallSnake); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs index 619fc52ce11..8de1a656de5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -32,22 +33,29 @@ namespace Org.OpenAPITools.Model /// Initializes a new instance of the class. /// /// className - /// declawed /// color (default to "red") + /// declawed [JsonConstructor] - public Cat(string className, bool declawed, string color = @"red") : base(className, color) + public Cat(string className, Option color = default, Option declawed = default) : base(className, color) { - Declawed = declawed; + DeclawedOption = declawed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Declawed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeclawedOption { get; private set; } + /// /// Gets or Sets Declawed /// [JsonPropertyName("declawed")] - public bool Declawed { get; set; } + public bool? Declawed { get { return this. DeclawedOption; } set { this.DeclawedOption = new(value); } } /// /// Returns the string presentation of the object @@ -86,9 +94,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - bool? declawed = default; - string color = default; + Option className = default; + Option color = default; + Option declawed = default; while (utf8JsonReader.Read()) { @@ -106,14 +114,14 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); break; case "declawed": if (utf8JsonReader.TokenType != JsonTokenType.Null) - declawed = utf8JsonReader.GetBoolean(); - break; - case "color": - color = utf8JsonReader.GetString(); + declawed = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -121,16 +129,19 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Cat."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Cat.", nameof(className)); - if (declawed == null) - throw new ArgumentNullException(nameof(declawed), "Property is required for class Cat."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Cat."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat."); - return new Cat(className, declawed.Value, color); + if (declawed.IsSet && declawed.Value == null) + throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); + + return new Cat(className.Value, color, declawed); } /// @@ -157,9 +168,19 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { + if (cat.ClassName == null) + throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); + + if (cat.ColorOption.IsSet && cat.Color == null) + throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); + writer.WriteString("className", cat.ClassName); - writer.WriteBoolean("declawed", cat.Declawed); - writer.WriteString("color", cat.Color); + + if (cat.ColorOption.IsSet) + writer.WriteString("color", cat.Color); + + if (cat.DeclawedOption.IsSet) + writer.WriteBoolean("declawed", cat.DeclawedOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs index 6139c304839..09d26fdb1fa 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,20 +35,27 @@ namespace Org.OpenAPITools.Model /// id /// name (default to "default-name") [JsonConstructor] - public Category(long id, string name = @"default-name") + public Category(Option id = default, string name = @"default-name") { - Id = id; + IdOption = id; Name = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } /// /// Gets or Sets Name @@ -109,8 +117,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -140,13 +148,16 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Category."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Category.", nameof(name)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Category."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category."); - return new Category(id.Value, name); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category."); + + return new Category(id, name.Value); } /// @@ -173,7 +184,12 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", category.Id); + if (category.Name == null) + throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category."); + + if (category.IdOption.IsSet) + writer.WriteNumber("id", category.IdOption.Value.Value); + writer.WriteString("name", category.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs index a3282125986..b10f05b2a5a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// name /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(string name, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value)) { - Name = name; - PetType = petType; + NameOption = name; + PetTypeOption = petType; OnCreated(); } @@ -87,26 +88,39 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string PetTypeEnumToJsonValue(PetTypeEnum value) + public static string PetTypeEnumToJsonValue(PetTypeEnum? value) { - if (value == PetTypeEnum.ChildCat) return "ChildCat"; throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of PetType + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new Option PetTypeOption { get; private set; } + /// /// Gets or Sets PetType /// [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } + public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Returns the string presentation of the object @@ -146,8 +160,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string name = default; - ChildCat.PetTypeEnum? petType = default; + Option name = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -165,13 +179,12 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; case "pet_type": string petTypeRawValue = utf8JsonReader.GetString(); - petType = petTypeRawValue == null - ? null - : ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue); + if (petTypeRawValue != null) + petType = new Option(ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue)); break; default: break; @@ -179,13 +192,13 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class ChildCat."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ChildCat."); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value); + return new ChildCat(name, petType); } /// @@ -212,9 +225,13 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", childCat.Name); + if (childCat.NameOption.IsSet && childCat.Name == null) + throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat."); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); + if (childCat.NameOption.IsSet) + writer.WriteString("name", childCat.Name); + + var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value.Value); if (petTypeRawValue != null) writer.WriteString("pet_type", petTypeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs index d1c65d36819..bbed8f0df13 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varClass [JsonConstructor] - public ClassModel(string varClass) + public ClassModel(Option varClass = default) { - VarClass = varClass; + VarClassOption = varClass; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("_class")] - public string VarClass { get; set; } + public string VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varClass = default; + Option varClass = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "_class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class ClassModel."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel."); return new ClassModel(varClass); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_class", classModel.VarClass); + if (classModel.VarClassOption.IsSet && classModel.VarClass == null) + throw new ArgumentNullException(nameof(classModel.VarClass), "Property is required for class ClassModel."); + + if (classModel.VarClassOption.IsSet) + writer.WriteString("_class", classModel.VarClass); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 79579247f7e..747b36ec65b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; - string shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class ComplexQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ComplexQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(shapeType)); - return new ComplexQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class ComplexQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ComplexQuadrilateral."); + + return new ComplexQuadrilateral(quadrilateralType.Value, shapeType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (complexQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral."); + + if (complexQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral."); + writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", complexQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs index 84439210bcf..c28634e4e13 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class DanishPig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class DanishPig.", nameof(className)); - return new DanishPig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class DanishPig."); + + return new DanishPig(className.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) { + if (danishPig.ClassName == null) + throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig."); + writer.WriteString("className", danishPig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 4420630af34..9b8aeb67815 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,20 +34,27 @@ namespace Org.OpenAPITools.Model /// /// dateOnlyProperty [JsonConstructor] - public DateOnlyClass(DateTime dateOnlyProperty) + public DateOnlyClass(Option dateOnlyProperty = default) { - DateOnlyProperty = dateOnlyProperty; + DateOnlyPropertyOption = dateOnlyProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateOnlyProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateOnlyPropertyOption { get; private set; } + /// /// Gets or Sets DateOnlyProperty /// /// Fri Jul 21 00:00:00 UTC 2017 [JsonPropertyName("dateOnlyProperty")] - public DateTime DateOnlyProperty { get; set; } + public DateTime? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new(value); } } /// /// Gets or Sets additional properties @@ -106,7 +114,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateOnlyProperty = default; + Option dateOnlyProperty = default; while (utf8JsonReader.Read()) { @@ -125,7 +133,7 @@ namespace Org.OpenAPITools.Model { case "dateOnlyProperty": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -133,10 +141,10 @@ namespace Org.OpenAPITools.Model } } - if (dateOnlyProperty == null) - throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is required for class DateOnlyClass."); + if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null) + throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass."); - return new DateOnlyClass(dateOnlyProperty.Value); + return new DateOnlyClass(dateOnlyProperty); } /// @@ -163,7 +171,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(DateOnlyPropertyFormat)); + if (dateOnlyClass.DateOnlyPropertyOption.IsSet) + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat)); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 16e3dfe57fa..6f0315de5d5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// name [JsonConstructor] - public DeprecatedObject(string name) + public DeprecatedObject(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class DeprecatedObject."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject."); return new DeprecatedObject(name); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", deprecatedObject.Name); + if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null) + throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject."); + + if (deprecatedObject.NameOption.IsSet) + writer.WriteString("name", deprecatedObject.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs index 810934b95ef..1d53127161c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,23 +32,30 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// breed /// className + /// breed /// color (default to "red") [JsonConstructor] - public Dog(string breed, string className, string color = @"red") : base(className, color) + public Dog(string className, Option breed = default, Option color = default) : base(className, color) { - Breed = breed; + BreedOption = breed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Breed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BreedOption { get; private set; } + /// /// Gets or Sets Breed /// [JsonPropertyName("breed")] - public string Breed { get; set; } + public string Breed { get { return this. BreedOption; } set { this.BreedOption = new(value); } } /// /// Returns the string presentation of the object @@ -86,9 +94,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string breed = default; - string className = default; - string color = default; + Option className = default; + Option breed = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -105,14 +113,14 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "breed": - breed = utf8JsonReader.GetString(); - break; case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); + break; + case "breed": + breed = new Option(utf8JsonReader.GetString()); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -120,16 +128,19 @@ namespace Org.OpenAPITools.Model } } - if (breed == null) - throw new ArgumentNullException(nameof(breed), "Property is required for class Dog."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Dog.", nameof(className)); - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Dog."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Dog."); + if (breed.IsSet && breed.Value == null) + throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog."); - return new Dog(breed, className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); + + return new Dog(className.Value, breed, color); } /// @@ -156,9 +167,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("breed", dog.Breed); + if (dog.ClassName == null) + throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); + + if (dog.BreedOption.IsSet && dog.Breed == null) + throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); + + if (dog.ColorOption.IsSet && dog.Color == null) + throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog."); + writer.WriteString("className", dog.ClassName); - writer.WriteString("color", dog.Color); + + if (dog.BreedOption.IsSet) + writer.WriteString("breed", dog.Breed); + + if (dog.ColorOption.IsSet) + writer.WriteString("color", dog.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs index 68f7676ff91..f8355e7576f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -32,44 +33,72 @@ namespace Org.OpenAPITools.Model /// Initializes a new instance of the class. /// /// mainShape - /// shapes /// nullableShape /// shapeOrNull + /// shapes [JsonConstructor] - public Drawing(Shape mainShape, List shapes, NullableShape nullableShape = default, ShapeOrNull shapeOrNull = default) : base() + public Drawing(Option mainShape = default, Option nullableShape = default, Option shapeOrNull = default, Option> shapes = default) : base() { - MainShape = mainShape; - Shapes = shapes; - NullableShape = nullableShape; - ShapeOrNull = shapeOrNull; + MainShapeOption = mainShape; + NullableShapeOption = nullableShape; + ShapeOrNullOption = shapeOrNull; + ShapesOption = shapes; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MainShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MainShapeOption { get; private set; } + /// /// Gets or Sets MainShape /// [JsonPropertyName("mainShape")] - public Shape MainShape { get; set; } + public Shape MainShape { get { return this. MainShapeOption; } set { this.MainShapeOption = new(value); } } /// - /// Gets or Sets Shapes + /// Used to track the state of NullableShape /// - [JsonPropertyName("shapes")] - public List Shapes { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableShapeOption { get; private set; } /// /// Gets or Sets NullableShape /// [JsonPropertyName("nullableShape")] - public NullableShape NullableShape { get; set; } + public NullableShape NullableShape { get { return this. NullableShapeOption; } set { this.NullableShapeOption = new(value); } } + + /// + /// Used to track the state of ShapeOrNull + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShapeOrNullOption { get; private set; } /// /// Gets or Sets ShapeOrNull /// [JsonPropertyName("shapeOrNull")] - public ShapeOrNull ShapeOrNull { get; set; } + public ShapeOrNull ShapeOrNull { get { return this. ShapeOrNullOption; } set { this.ShapeOrNullOption = new(value); } } + + /// + /// Used to track the state of Shapes + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ShapesOption { get; private set; } + + /// + /// Gets or Sets Shapes + /// + [JsonPropertyName("shapes")] + public List Shapes { get { return this. ShapesOption; } set { this.ShapesOption = new(value); } } /// /// Gets or Sets additional properties @@ -87,9 +116,9 @@ namespace Org.OpenAPITools.Model sb.Append("class Drawing {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" MainShape: ").Append(MainShape).Append("\n"); - sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -138,10 +167,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Shape mainShape = default; - List shapes = default; - NullableShape nullableShape = default; - ShapeOrNull shapeOrNull = default; + Option mainShape = default; + Option nullableShape = default; + Option shapeOrNull = default; + Option> shapes = default; while (utf8JsonReader.Read()) { @@ -160,19 +189,19 @@ namespace Org.OpenAPITools.Model { case "mainShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mainShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "shapes": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapes = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mainShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "nullableShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - nullableShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapeOrNull = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapes": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapes = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -180,13 +209,13 @@ namespace Org.OpenAPITools.Model } } - if (mainShape == null) - throw new ArgumentNullException(nameof(mainShape), "Property is required for class Drawing."); + if (mainShape.IsSet && mainShape.Value == null) + throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapes == null) - throw new ArgumentNullException(nameof(shapes), "Property is required for class Drawing."); + if (shapes.IsSet && shapes.Value == null) + throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); - return new Drawing(mainShape, shapes, nullableShape, shapeOrNull); + return new Drawing(mainShape, nullableShape, shapeOrNull, shapes); } /// @@ -213,14 +242,38 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("mainShape"); - JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); - writer.WritePropertyName("shapes"); - JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); - writer.WritePropertyName("nullableShape"); - JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) + throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) + throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); + + if (drawing.MainShapeOption.IsSet) + { + writer.WritePropertyName("mainShape"); + JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); + } + if (drawing.NullableShapeOption.IsSet) + if (drawing.NullableShapeOption.Value != null) + { + writer.WritePropertyName("nullableShape"); + JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); + } + else + writer.WriteNull("nullableShape"); + if (drawing.ShapeOrNullOption.IsSet) + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); + if (drawing.ShapesOption.IsSet) + { + writer.WritePropertyName("shapes"); + JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs index 58cf3e310f8..44ebb6856cb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// arrayEnum /// justSymbol [JsonConstructor] - public EnumArrays(List arrayEnum, JustSymbolEnum justSymbol) + public EnumArrays(Option> arrayEnum = default, Option justSymbol = default) { - ArrayEnum = arrayEnum; - JustSymbol = justSymbol; + ArrayEnumOption = arrayEnum; + JustSymbolOption = justSymbol; OnCreated(); } @@ -100,7 +101,6 @@ namespace Org.OpenAPITools.Model /// public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum value) { - if (value == ArrayEnumEnum.Fish) return "fish"; @@ -165,9 +165,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string JustSymbolEnumToJsonValue(JustSymbolEnum value) + public static string JustSymbolEnumToJsonValue(JustSymbolEnum? value) { - if (value == JustSymbolEnum.GreaterThanOrEqualTo) return ">="; @@ -177,17 +176,31 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of JustSymbol + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustSymbolOption { get; private set; } + /// /// Gets or Sets JustSymbol /// [JsonPropertyName("just_symbol")] - public JustSymbolEnum JustSymbol { get; set; } + public JustSymbolEnum? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new(value); } } + + /// + /// Used to track the state of ArrayEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayEnumOption { get; private set; } /// /// Gets or Sets ArrayEnum /// [JsonPropertyName("array_enum")] - public List ArrayEnum { get; set; } + public List ArrayEnum { get { return this. ArrayEnumOption; } set { this.ArrayEnumOption = new(value); } } /// /// Gets or Sets additional properties @@ -243,8 +256,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List arrayEnum = default; - EnumArrays.JustSymbolEnum? justSymbol = default; + Option> arrayEnum = default; + Option justSymbol = default; while (utf8JsonReader.Read()) { @@ -263,13 +276,12 @@ namespace Org.OpenAPITools.Model { case "array_enum": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayEnum = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayEnum = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "just_symbol": string justSymbolRawValue = utf8JsonReader.GetString(); - justSymbol = justSymbolRawValue == null - ? null - : EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue); + if (justSymbolRawValue != null) + justSymbol = new Option(EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue)); break; default: break; @@ -277,13 +289,13 @@ namespace Org.OpenAPITools.Model } } - if (arrayEnum == null) - throw new ArgumentNullException(nameof(arrayEnum), "Property is required for class EnumArrays."); + if (arrayEnum.IsSet && arrayEnum.Value == null) + throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays."); - if (justSymbol == null) - throw new ArgumentNullException(nameof(justSymbol), "Property is required for class EnumArrays."); + if (justSymbol.IsSet && justSymbol.Value == null) + throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays."); - return new EnumArrays(arrayEnum, justSymbol.Value); + return new EnumArrays(arrayEnum, justSymbol); } /// @@ -310,10 +322,15 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_enum"); - JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null) + throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays."); - var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbol); + if (enumArrays.ArrayEnumOption.IsSet) + { + writer.WritePropertyName("array_enum"); + JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + } + var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value.Value); if (justSymbolRawValue != null) writer.WriteString("just_symbol", justSymbolRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs index 94c2361c881..b1aff0adf0d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs index f3310c22a12..ce39b4cb9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,392 +32,32 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// enumStringRequired /// enumInteger /// enumIntegerOnly /// enumNumber /// enumString - /// enumStringRequired + /// outerEnum /// outerEnumDefaultValue /// outerEnumInteger /// outerEnumIntegerDefaultValue - /// outerEnum [JsonConstructor] - public EnumTest(EnumIntegerEnum enumInteger, EnumIntegerOnlyEnum enumIntegerOnly, EnumNumberEnum enumNumber, EnumStringEnum enumString, EnumStringRequiredEnum enumStringRequired, OuterEnumDefaultValue outerEnumDefaultValue, OuterEnumInteger outerEnumInteger, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue, OuterEnum? outerEnum = default) + public EnumTest(EnumStringRequiredEnum enumStringRequired, Option enumInteger = default, Option enumIntegerOnly = default, Option enumNumber = default, Option enumString = default, Option outerEnum = default, Option outerEnumDefaultValue = default, Option outerEnumInteger = default, Option outerEnumIntegerDefaultValue = default) { - EnumInteger = enumInteger; - EnumIntegerOnly = enumIntegerOnly; - EnumNumber = enumNumber; - EnumString = enumString; EnumStringRequired = enumStringRequired; - OuterEnumDefaultValue = outerEnumDefaultValue; - OuterEnumInteger = outerEnumInteger; - OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - OuterEnum = outerEnum; + EnumIntegerOption = enumInteger; + EnumIntegerOnlyOption = enumIntegerOnly; + EnumNumberOption = enumNumber; + EnumStringOption = enumString; + OuterEnumOption = outerEnum; + OuterEnumDefaultValueOption = outerEnumDefaultValue; + OuterEnumIntegerOption = outerEnumInteger; + OuterEnumIntegerDefaultValueOption = outerEnumIntegerDefaultValue; OnCreated(); } partial void OnCreated(); - /// - /// Defines EnumInteger - /// - public enum EnumIntegerEnum - { - /// - /// Enum NUMBER_1 for value: 1 - /// - NUMBER_1 = 1, - - /// - /// Enum NUMBER_MINUS_1 for value: -1 - /// - NUMBER_MINUS_1 = -1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerEnum EnumIntegerEnumFromString(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumInteger - /// - [JsonPropertyName("enum_integer")] - public EnumIntegerEnum EnumInteger { get; set; } - - /// - /// Defines EnumIntegerOnly - /// - public enum EnumIntegerOnlyEnum - { - /// - /// Enum NUMBER_2 for value: 2 - /// - NUMBER_2 = 2, - - /// - /// Enum NUMBER_MINUS_2 for value: -2 - /// - NUMBER_MINUS_2 = -2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumIntegerOnly - /// - [JsonPropertyName("enum_integer_only")] - public EnumIntegerOnlyEnum EnumIntegerOnly { get; set; } - - /// - /// Defines EnumNumber - /// - public enum EnumNumberEnum - { - /// - /// Enum NUMBER_1_DOT_1 for value: 1.1 - /// - NUMBER_1_DOT_1 = 1, - - /// - /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 - /// - NUMBER_MINUS_1_DOT_2 = 2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumNumberEnum EnumNumberEnumFromString(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static double EnumNumberEnumToJsonValue(EnumNumberEnum value) - { - - if (value == EnumNumberEnum.NUMBER_1_DOT_1) - return 1.1; - - if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) - return -1.2; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumNumber - /// - [JsonPropertyName("enum_number")] - public EnumNumberEnum EnumNumber { get; set; } - - /// - /// Defines EnumString - /// - public enum EnumStringEnum - { - /// - /// Enum UPPER for value: UPPER - /// - UPPER = 1, - - /// - /// Enum Lower for value: lower - /// - Lower = 2, - - /// - /// Enum Empty for value: - /// - Empty = 3, - - /// - /// Enum ValuewithTab for value: Value\twith tab - /// - ValuewithTab = 4, - - /// - /// Enum ValueWithQuote for value: Value with \" quote - /// - ValueWithQuote = 5, - - /// - /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote - /// - ValueWithEscapedQuote = 6, - - /// - /// Enum Duplicatevalue for value: Duplicate\nvalue - /// - Duplicatevalue = 7, - - /// - /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue - /// - Duplicatevalue2 = 8 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumStringEnum EnumStringEnumFromString(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static string EnumStringEnumToJsonValue(EnumStringEnum value) - { - - if (value == EnumStringEnum.UPPER) - return "UPPER"; - - if (value == EnumStringEnum.Lower) - return "lower"; - - if (value == EnumStringEnum.Empty) - return ""; - - if (value == EnumStringEnum.ValuewithTab) - return "Value\twith tab"; - - if (value == EnumStringEnum.ValueWithQuote) - return "Value with \" quote"; - - if (value == EnumStringEnum.ValueWithEscapedQuote) - return "Value with escaped \" quote"; - - if (value == EnumStringEnum.Duplicatevalue) - return "Duplicate\nvalue"; - - if (value == EnumStringEnum.Duplicatevalue2) - return "Duplicate\r\nvalue"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumString - /// - [JsonPropertyName("enum_string")] - public EnumStringEnum EnumString { get; set; } - /// /// Defines EnumStringRequired /// @@ -540,7 +181,6 @@ namespace Org.OpenAPITools.Model /// public static string EnumStringRequiredEnumToJsonValue(EnumStringRequiredEnum value) { - if (value == EnumStringRequiredEnum.UPPER) return "UPPER"; @@ -575,28 +215,442 @@ namespace Org.OpenAPITools.Model public EnumStringRequiredEnum EnumStringRequired { get; set; } /// - /// Gets or Sets OuterEnumDefaultValue + /// Defines EnumInteger /// - [JsonPropertyName("outerEnumDefaultValue")] - public OuterEnumDefaultValue OuterEnumDefaultValue { get; set; } + public enum EnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } /// - /// Gets or Sets OuterEnumInteger + /// Returns a /// - [JsonPropertyName("outerEnumInteger")] - public OuterEnumInteger OuterEnumInteger { get; set; } + /// + /// + /// + public static EnumIntegerEnum EnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); + } /// - /// Gets or Sets OuterEnumIntegerDefaultValue + /// Returns a /// - [JsonPropertyName("outerEnumIntegerDefaultValue")] - public OuterEnumIntegerDefaultValue OuterEnumIntegerDefaultValue { get; set; } + /// + /// + public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOption { get; private set; } + + /// + /// Gets or Sets EnumInteger + /// + [JsonPropertyName("enum_integer")] + public EnumIntegerEnum? EnumInteger { get { return this.EnumIntegerOption; } set { this.EnumIntegerOption = new(value); } } + + /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets EnumIntegerOnly + /// + [JsonPropertyName("enum_integer_only")] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get { return this.EnumIntegerOnlyOption; } set { this.EnumIntegerOnlyOption = new(value); } } + + /// + /// Defines EnumNumber + /// + public enum EnumNumberEnum + { + /// + /// Enum NUMBER_1_DOT_1 for value: 1.1 + /// + NUMBER_1_DOT_1 = 1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 + /// + NUMBER_MINUS_1_DOT_2 = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumNumberEnum EnumNumberEnumFromString(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static double EnumNumberEnumToJsonValue(EnumNumberEnum? value) + { + if (value == EnumNumberEnum.NUMBER_1_DOT_1) + return 1.1; + + if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) + return -1.2; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumNumberOption { get; private set; } + + /// + /// Gets or Sets EnumNumber + /// + [JsonPropertyName("enum_number")] + public EnumNumberEnum? EnumNumber { get { return this.EnumNumberOption; } set { this.EnumNumberOption = new(value); } } + + /// + /// Defines EnumString + /// + public enum EnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumStringEnum EnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string EnumStringEnumToJsonValue(EnumStringEnum? value) + { + if (value == EnumStringEnum.UPPER) + return "UPPER"; + + if (value == EnumStringEnum.Lower) + return "lower"; + + if (value == EnumStringEnum.Empty) + return ""; + + if (value == EnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumStringOption { get; private set; } + + /// + /// Gets or Sets EnumString + /// + [JsonPropertyName("enum_string")] + public EnumStringEnum? EnumString { get { return this.EnumStringOption; } set { this.EnumStringOption = new(value); } } + + /// + /// Used to track the state of OuterEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumOption { get; private set; } /// /// Gets or Sets OuterEnum /// [JsonPropertyName("outerEnum")] - public OuterEnum? OuterEnum { get; set; } + public OuterEnum? OuterEnum { get { return this.OuterEnumOption; } set { this.OuterEnumOption = new(value); } } + + /// + /// Used to track the state of OuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumDefaultValue + /// + [JsonPropertyName("outerEnumDefaultValue")] + public OuterEnumDefaultValue? OuterEnumDefaultValue { get { return this.OuterEnumDefaultValueOption; } set { this.OuterEnumDefaultValueOption = new(value); } } + + /// + /// Used to track the state of OuterEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets OuterEnumInteger + /// + [JsonPropertyName("outerEnumInteger")] + public OuterEnumInteger? OuterEnumInteger { get { return this.OuterEnumIntegerOption; } set { this.OuterEnumIntegerOption = new(value); } } + + /// + /// Used to track the state of OuterEnumIntegerDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumIntegerDefaultValue + /// + [JsonPropertyName("outerEnumIntegerDefaultValue")] + public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get { return this.OuterEnumIntegerDefaultValueOption; } set { this.OuterEnumIntegerDefaultValueOption = new(value); } } /// /// Gets or Sets additional properties @@ -612,15 +666,15 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EnumTest {\n"); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" EnumString: ").Append(EnumString).Append("\n"); - sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); - sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -659,15 +713,15 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - EnumTest.EnumIntegerEnum? enumInteger = default; - EnumTest.EnumIntegerOnlyEnum? enumIntegerOnly = default; - EnumTest.EnumNumberEnum? enumNumber = default; - EnumTest.EnumStringEnum? enumString = default; - EnumTest.EnumStringRequiredEnum? enumStringRequired = default; - OuterEnumDefaultValue? outerEnumDefaultValue = default; - OuterEnumInteger? outerEnumInteger = default; - OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default; - OuterEnum? outerEnum = default; + Option enumStringRequired = default; + Option enumInteger = default; + Option enumIntegerOnly = default; + Option enumNumber = default; + Option enumString = default; + Option outerEnum = default; + Option outerEnumDefaultValue = default; + Option outerEnumInteger = default; + Option outerEnumIntegerDefaultValue = default; while (utf8JsonReader.Read()) { @@ -684,53 +738,47 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "enum_string_required": + string enumStringRequiredRawValue = utf8JsonReader.GetString(); + if (enumStringRequiredRawValue != null) + enumStringRequired = new Option(EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue)); + break; case "enum_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumInteger = (EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32(); + enumInteger = new Option((EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32()); break; case "enum_integer_only": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumIntegerOnly = (EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32(); + enumIntegerOnly = new Option((EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); break; case "enum_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumNumber = (EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32(); + enumNumber = new Option((EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32()); break; case "enum_string": string enumStringRawValue = utf8JsonReader.GetString(); - enumString = enumStringRawValue == null - ? null - : EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue); - break; - case "enum_string_required": - string enumStringRequiredRawValue = utf8JsonReader.GetString(); - enumStringRequired = enumStringRequiredRawValue == null - ? null - : EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue); - break; - case "outerEnumDefaultValue": - string outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumDefaultValue = outerEnumDefaultValueRawValue == null - ? null - : OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue); - break; - case "outerEnumInteger": - string outerEnumIntegerRawValue = utf8JsonReader.GetString(); - outerEnumInteger = outerEnumIntegerRawValue == null - ? null - : OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue); - break; - case "outerEnumIntegerDefaultValue": - string outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumIntegerDefaultValue = outerEnumIntegerDefaultValueRawValue == null - ? null - : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue); + if (enumStringRawValue != null) + enumString = new Option(EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue)); break; case "outerEnum": string outerEnumRawValue = utf8JsonReader.GetString(); - outerEnum = outerEnumRawValue == null - ? null - : OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue); + if (outerEnumRawValue != null) + outerEnum = new Option(OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue)); + break; + case "outerEnumDefaultValue": + string outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumDefaultValueRawValue != null) + outerEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue)); + break; + case "outerEnumInteger": + string outerEnumIntegerRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerRawValue != null) + outerEnumInteger = new Option(OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue)); + break; + case "outerEnumIntegerDefaultValue": + string outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerDefaultValueRawValue != null) + outerEnumIntegerDefaultValue = new Option(OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue)); break; default: break; @@ -738,31 +786,34 @@ namespace Org.OpenAPITools.Model } } - if (enumInteger == null) - throw new ArgumentNullException(nameof(enumInteger), "Property is required for class EnumTest."); + if (!enumStringRequired.IsSet) + throw new ArgumentException("Property is required for class EnumTest.", nameof(enumStringRequired)); - if (enumIntegerOnly == null) - throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is required for class EnumTest."); + if (enumStringRequired.IsSet && enumStringRequired.Value == null) + throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest."); - if (enumNumber == null) - throw new ArgumentNullException(nameof(enumNumber), "Property is required for class EnumTest."); + if (enumInteger.IsSet && enumInteger.Value == null) + throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest."); - if (enumString == null) - throw new ArgumentNullException(nameof(enumString), "Property is required for class EnumTest."); + if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest."); - if (enumStringRequired == null) - throw new ArgumentNullException(nameof(enumStringRequired), "Property is required for class EnumTest."); + if (enumNumber.IsSet && enumNumber.Value == null) + throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest."); - if (outerEnumDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is required for class EnumTest."); + if (enumString.IsSet && enumString.Value == null) + throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest."); - if (outerEnumInteger == null) - throw new ArgumentNullException(nameof(outerEnumInteger), "Property is required for class EnumTest."); + if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest."); - if (outerEnumIntegerDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is required for class EnumTest."); + if (outerEnumInteger.IsSet && outerEnumInteger.Value == null) + throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest."); - return new EnumTest(enumInteger.Value, enumIntegerOnly.Value, enumNumber.Value, enumString.Value, enumStringRequired.Value, outerEnumDefaultValue.Value, outerEnumInteger.Value, outerEnumIntegerDefaultValue.Value, outerEnum); + if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest."); + + return new EnumTest(enumStringRequired.Value.Value, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue); } /// @@ -789,43 +840,49 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumInteger)); - writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnly)); - writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumber)); - - var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumString); - if (enumStringRawValue != null) - writer.WriteString("enum_string", enumStringRawValue); - else - writer.WriteNull("enum_string"); - var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); if (enumStringRequiredRawValue != null) writer.WriteString("enum_string_required", enumStringRequiredRawValue); else writer.WriteNull("enum_string_required"); - var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue); + if (enumTest.EnumIntegerOption.IsSet) + writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value.Value)); - if (outerEnumDefaultValueRawValue != null) - writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + if (enumTest.EnumIntegerOnlyOption.IsSet) + writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value.Value)); + + if (enumTest.EnumNumberOption.IsSet) + writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value.Value)); + + var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value.Value); + if (enumStringRawValue != null) + writer.WriteString("enum_string", enumStringRawValue); else - writer.WriteNull("outerEnumDefaultValue"); + writer.WriteNull("enum_string"); - var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger); - writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); - var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue); - writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); - - if (enumTest.OuterEnum == null) - writer.WriteNull("outerEnum"); - else - { - var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnum.Value); - if (outerEnumRawValue != null) + if (enumTest.OuterEnumOption.IsSet) + if (enumTest.OuterEnumOption.Value != null) + { + var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnumOption.Value.Value); writer.WriteString("outerEnum", outerEnumRawValue); + } else writer.WriteNull("outerEnum"); + if (enumTest.OuterEnumDefaultValueOption.IsSet) + { + var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue.Value); + writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + } + if (enumTest.OuterEnumIntegerOption.IsSet) + { + var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger.Value); + writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); + } + if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet) + { + var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue.Value); + writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 626748ff209..bbf4bf8f8e0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; - string triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class EquilateralTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class EquilateralTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(triangleType)); - return new EquilateralTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class EquilateralTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class EquilateralTriangle."); + + return new EquilateralTriangle(shapeType.Value, triangleType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (equilateralTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle."); + + if (equilateralTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle."); + writer.WriteString("shapeType", equilateralTriangle.ShapeType); + writer.WriteString("triangleType", equilateralTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs index 905e5452f7c..11754d37999 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,20 +34,27 @@ namespace Org.OpenAPITools.Model /// /// Test capitalization [JsonConstructor] - public File(string sourceURI) + public File(Option sourceURI = default) { - SourceURI = sourceURI; + SourceURIOption = sourceURI; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SourceURI + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SourceURIOption { get; private set; } + /// /// Test capitalization /// /// Test capitalization [JsonPropertyName("sourceURI")] - public string SourceURI { get; set; } + public string SourceURI { get { return this. SourceURIOption; } set { this.SourceURIOption = new(value); } } /// /// Gets or Sets additional properties @@ -101,7 +109,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string sourceURI = default; + Option sourceURI = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "sourceURI": - sourceURI = utf8JsonReader.GetString(); + sourceURI = new Option(utf8JsonReader.GetString()); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (sourceURI == null) - throw new ArgumentNullException(nameof(sourceURI), "Property is required for class File."); + if (sourceURI.IsSet && sourceURI.Value == null) + throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File."); return new File(sourceURI); } @@ -157,7 +165,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("sourceURI", file.SourceURI); + if (file.SourceURIOption.IsSet && file.SourceURI == null) + throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File."); + + if (file.SourceURIOption.IsSet) + writer.WriteString("sourceURI", file.SourceURI); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 722ba3b949f..6a07c6d1f95 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// file /// files [JsonConstructor] - public FileSchemaTestClass(File file, List files) + public FileSchemaTestClass(Option file = default, Option> files = default) { - File = file; - Files = files; + FileOption = file; + FilesOption = files; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of File + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FileOption { get; private set; } + /// /// Gets or Sets File /// [JsonPropertyName("file")] - public File File { get; set; } + public File File { get { return this. FileOption; } set { this.FileOption = new(value); } } + + /// + /// Used to track the state of Files + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> FilesOption { get; private set; } /// /// Gets or Sets Files /// [JsonPropertyName("files")] - public List Files { get; set; } + public List Files { get { return this. FilesOption; } set { this.FilesOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - File file = default; - List files = default; + Option file = default; + Option> files = default; while (utf8JsonReader.Read()) { @@ -129,11 +144,11 @@ namespace Org.OpenAPITools.Model { case "file": if (utf8JsonReader.TokenType != JsonTokenType.Null) - file = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + file = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "files": if (utf8JsonReader.TokenType != JsonTokenType.Null) - files = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + files = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -141,11 +156,11 @@ namespace Org.OpenAPITools.Model } } - if (file == null) - throw new ArgumentNullException(nameof(file), "Property is required for class FileSchemaTestClass."); + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass."); - if (files == null) - throw new ArgumentNullException(nameof(files), "Property is required for class FileSchemaTestClass."); + if (files.IsSet && files.Value == null) + throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass."); return new FileSchemaTestClass(file, files); } @@ -174,10 +189,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("file"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); - writer.WritePropertyName("files"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FileOption.IsSet) + { + writer.WritePropertyName("file"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); + } + if (fileSchemaTestClass.FilesOption.IsSet) + { + writer.WritePropertyName("files"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs index 9cfe3b508fe..98f8d13300a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// bar (default to "bar") [JsonConstructor] - public Foo(string bar = @"bar") + public Foo(Option bar = default) { - Bar = bar; + BarOption = bar; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; private set; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; set; } + public string Bar { get { return this. BarOption; } set { this.BarOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string bar = default; + Option bar = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class Foo."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo."); return new Foo(bar); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", foo.Bar); + if (foo.BarOption.IsSet && foo.Bar == null) + throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo."); + + if (foo.BarOption.IsSet) + writer.WriteString("bar", foo.Bar); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index c8291e8eae5..5834385cd5b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varString [JsonConstructor] - public FooGetDefaultResponse(Foo varString) + public FooGetDefaultResponse(Option varString = default) { - VarString = varString; + VarStringOption = varString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } + /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public Foo VarString { get; set; } + public Foo VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Foo varString = default; + Option varString = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varString = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varString = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FooGetDefaultResponse."); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse."); return new FooGetDefaultResponse(varString); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("string"); - JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + if (fooGetDefaultResponse.VarStringOption.IsSet && fooGetDefaultResponse.VarString == null) + throw new ArgumentNullException(nameof(fooGetDefaultResponse.VarString), "Property is required for class FooGetDefaultResponse."); + + if (fooGetDefaultResponse.VarStringOption.IsSet) + { + writer.WritePropertyName("string"); + JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs index 30a9b189932..ccf7c37ed7c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,9 +32,11 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// binary /// varByte /// date + /// number + /// password + /// binary /// dateTime /// varDecimal /// varDouble @@ -41,8 +44,6 @@ namespace Org.OpenAPITools.Model /// int32 /// int64 /// integer - /// number - /// password /// None /// A string that is a 10 digit number. Can have leading zeros. /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. @@ -51,38 +52,32 @@ namespace Org.OpenAPITools.Model /// unsignedLong /// uuid [JsonConstructor] - public FormatTest(System.IO.Stream binary, byte[] varByte, DateTime date, DateTime dateTime, decimal varDecimal, double varDouble, float varFloat, int int32, long int64, int integer, decimal number, string password, string patternWithBackslash, string patternWithDigits, string patternWithDigitsAndDelimiter, string varString, uint unsignedInteger, ulong unsignedLong, Guid uuid) + 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) { - Binary = binary; VarByte = varByte; Date = date; - DateTime = dateTime; - VarDecimal = varDecimal; - VarDouble = varDouble; - VarFloat = varFloat; - Int32 = int32; - Int64 = int64; - Integer = integer; Number = number; Password = password; - PatternWithBackslash = patternWithBackslash; - PatternWithDigits = patternWithDigits; - PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - VarString = varString; - UnsignedInteger = unsignedInteger; - UnsignedLong = unsignedLong; - Uuid = uuid; + BinaryOption = binary; + DateTimeOption = dateTime; + VarDecimalOption = varDecimal; + VarDoubleOption = varDouble; + VarFloatOption = varFloat; + Int32Option = int32; + Int64Option = int64; + IntegerOption = integer; + PatternWithBackslashOption = patternWithBackslash; + PatternWithDigitsOption = patternWithDigits; + PatternWithDigitsAndDelimiterOption = patternWithDigitsAndDelimiter; + VarStringOption = varString; + UnsignedIntegerOption = unsignedInteger; + UnsignedLongOption = unsignedLong; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); - /// - /// Gets or Sets Binary - /// - [JsonPropertyName("binary")] - public System.IO.Stream Binary { get; set; } - /// /// Gets or Sets VarByte /// @@ -96,49 +91,6 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("date")] public DateTime Date { get; set; } - /// - /// Gets or Sets DateTime - /// - /// 2007-12-03T10:15:30+01:00 - [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } - - /// - /// Gets or Sets VarDecimal - /// - [JsonPropertyName("decimal")] - public decimal VarDecimal { get; set; } - - /// - /// Gets or Sets VarDouble - /// - [JsonPropertyName("double")] - public double VarDouble { get; set; } - - /// - /// Gets or Sets VarFloat - /// - [JsonPropertyName("float")] - public float VarFloat { get; set; } - - /// - /// Gets or Sets Int32 - /// - [JsonPropertyName("int32")] - public int Int32 { get; set; } - - /// - /// Gets or Sets Int64 - /// - [JsonPropertyName("int64")] - public long Int64 { get; set; } - - /// - /// Gets or Sets Integer - /// - [JsonPropertyName("integer")] - public int Integer { get; set; } - /// /// Gets or Sets Number /// @@ -151,51 +103,205 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("password")] public string Password { get; set; } + /// + /// Used to track the state of Binary + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BinaryOption { get; private set; } + + /// + /// Gets or Sets Binary + /// + [JsonPropertyName("binary")] + public System.IO.Stream Binary { get { return this. BinaryOption; } set { this.BinaryOption = new(value); } } + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + /// 2007-12-03T10:15:30+01:00 + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } } + + /// + /// Used to track the state of VarDecimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDecimalOption { get; private set; } + + /// + /// Gets or Sets VarDecimal + /// + [JsonPropertyName("decimal")] + public decimal? VarDecimal { get { return this. VarDecimalOption; } set { this.VarDecimalOption = new(value); } } + + /// + /// Used to track the state of VarDouble + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDoubleOption { get; private set; } + + /// + /// Gets or Sets VarDouble + /// + [JsonPropertyName("double")] + public double? VarDouble { get { return this. VarDoubleOption; } set { this.VarDoubleOption = new(value); } } + + /// + /// Used to track the state of VarFloat + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarFloatOption { get; private set; } + + /// + /// Gets or Sets VarFloat + /// + [JsonPropertyName("float")] + public float? VarFloat { get { return this. VarFloatOption; } set { this.VarFloatOption = new(value); } } + + /// + /// Used to track the state of Int32 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int32Option { get; private set; } + + /// + /// Gets or Sets Int32 + /// + [JsonPropertyName("int32")] + public int? Int32 { get { return this. Int32Option; } set { this.Int32Option = new(value); } } + + /// + /// Used to track the state of Int64 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int64Option { get; private set; } + + /// + /// Gets or Sets Int64 + /// + [JsonPropertyName("int64")] + public long? Int64 { get { return this. Int64Option; } set { this.Int64Option = new(value); } } + + /// + /// Used to track the state of Integer + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerOption { get; private set; } + + /// + /// Gets or Sets Integer + /// + [JsonPropertyName("integer")] + public int? Integer { get { return this. IntegerOption; } set { this.IntegerOption = new(value); } } + + /// + /// Used to track the state of PatternWithBackslash + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithBackslashOption { get; private set; } + /// /// None /// /// None [JsonPropertyName("pattern_with_backslash")] - public string PatternWithBackslash { get; set; } + public string PatternWithBackslash { get { return this. PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new(value); } } + + /// + /// Used to track the state of PatternWithDigits + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsOption { get; private set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. [JsonPropertyName("pattern_with_digits")] - public string PatternWithDigits { get; set; } + public string PatternWithDigits { get { return this. PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new(value); } } + + /// + /// Used to track the state of PatternWithDigitsAndDelimiter + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsAndDelimiterOption { get; private set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. [JsonPropertyName("pattern_with_digits_and_delimiter")] - public string PatternWithDigitsAndDelimiter { get; set; } + public string PatternWithDigitsAndDelimiter { get { return this. PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new(value); } } + + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public string VarString { get; set; } + public string VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } } + + /// + /// Used to track the state of UnsignedInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedIntegerOption { get; private set; } /// /// Gets or Sets UnsignedInteger /// [JsonPropertyName("unsigned_integer")] - public uint UnsignedInteger { get; set; } + public uint? UnsignedInteger { get { return this. UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new(value); } } + + /// + /// Used to track the state of UnsignedLong + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedLongOption { get; private set; } /// /// Gets or Sets UnsignedLong /// [JsonPropertyName("unsigned_long")] - public ulong UnsignedLong { get; set; } + public ulong? UnsignedLong { get { return this. UnsignedLongOption; } set { this.UnsignedLongOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -211,9 +317,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class FormatTest {\n"); - sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" VarByte: ").Append(VarByte).Append("\n"); sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" DateTime: ").Append(DateTime).Append("\n"); sb.Append(" VarDecimal: ").Append(VarDecimal).Append("\n"); sb.Append(" VarDouble: ").Append(VarDouble).Append("\n"); @@ -221,8 +329,6 @@ namespace Org.OpenAPITools.Model sb.Append(" Int32: ").Append(Int32).Append("\n"); sb.Append(" Int64: ").Append(Int64).Append("\n"); sb.Append(" Integer: ").Append(Integer).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" PatternWithBackslash: ").Append(PatternWithBackslash).Append("\n"); sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); @@ -242,54 +348,6 @@ namespace Org.OpenAPITools.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - // VarDouble (double) maximum - if (this.VarDouble > (double)123.4) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); - } - - // VarDouble (double) minimum - if (this.VarDouble < (double)67.8) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); - } - - // VarFloat (float) maximum - if (this.VarFloat > (float)987.6) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); - } - - // VarFloat (float) minimum - if (this.VarFloat < (float)54.3) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); - } - - // Int32 (int) maximum - if (this.Int32 > (int)200) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); - } - - // Int32 (int) minimum - if (this.Int32 < (int)20) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); - } - - // Integer (int) maximum - if (this.Integer > (int)100) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); - } - - // Integer (int) minimum - if (this.Integer < (int)10) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); - } - // Number (decimal) maximum if (this.Number > (decimal)543.2) { @@ -314,50 +372,102 @@ namespace Org.OpenAPITools.Model yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); } - if (this.PatternWithBackslash != null) { + // VarDouble (double) maximum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value > (double)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); + } + + // VarDouble (double) minimum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value < (double)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); + } + + // VarFloat (float) maximum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value > (float)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); + } + + // VarFloat (float) minimum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value < (float)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); + } + + // Int32 (int) maximum + if (this.Int32Option.IsSet && this.Int32Option.Value > (int)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int) minimum + if (this.Int32Option.IsSet && this.Int32Option.Value < (int)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Integer (int) maximum + if (this.IntegerOption.IsSet && this.IntegerOption.Value > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int) minimum + if (this.IntegerOption.IsSet && this.IntegerOption.Value < (int)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + if (this.PatternWithBackslashOption.Value != null) { // PatternWithBackslash (string) pattern Regex regexPatternWithBackslash = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$", RegexOptions.CultureInvariant); - if (!regexPatternWithBackslash.Match(this.PatternWithBackslash).Success) + + if (this.PatternWithBackslashOption.Value != null &&!regexPatternWithBackslash.Match(this.PatternWithBackslashOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithBackslash, must match a pattern of " + regexPatternWithBackslash, new [] { "PatternWithBackslash" }); } } - if (this.PatternWithDigits != null) { + if (this.PatternWithDigitsOption.Value != null) { // PatternWithDigits (string) pattern Regex regexPatternWithDigits = new Regex(@"^\d{10}$", RegexOptions.CultureInvariant); - if (!regexPatternWithDigits.Match(this.PatternWithDigits).Success) + + if (this.PatternWithDigitsOption.Value != null &&!regexPatternWithDigits.Match(this.PatternWithDigitsOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigits, must match a pattern of " + regexPatternWithDigits, new [] { "PatternWithDigits" }); } } - if (this.PatternWithDigitsAndDelimiter != null) { + if (this.PatternWithDigitsAndDelimiterOption.Value != null) { // PatternWithDigitsAndDelimiter (string) pattern Regex regexPatternWithDigitsAndDelimiter = new Regex(@"^image_\d{1,3}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiter).Success) + + if (this.PatternWithDigitsAndDelimiterOption.Value != null &&!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiterOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigitsAndDelimiter, must match a pattern of " + regexPatternWithDigitsAndDelimiter, new [] { "PatternWithDigitsAndDelimiter" }); } } - if (this.VarString != null) { + if (this.VarStringOption.Value != null) { // VarString (string) pattern Regex regexVarString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexVarString.Match(this.VarString).Success) + + if (this.VarStringOption.Value != null &&!regexVarString.Match(this.VarStringOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarString, must match a pattern of " + regexVarString, new [] { "VarString" }); } } // UnsignedInteger (uint) maximum - if (this.UnsignedInteger > (uint)200) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value > (uint)200) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value less than or equal to 200.", new [] { "UnsignedInteger" }); } // UnsignedInteger (uint) minimum - if (this.UnsignedInteger < (uint)20) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value < (uint)20) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value greater than or equal to 20.", new [] { "UnsignedInteger" }); } @@ -398,25 +508,25 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - System.IO.Stream binary = default; - byte[] varByte = default; - DateTime? date = default; - DateTime? dateTime = default; - decimal? varDecimal = default; - double? varDouble = default; - float? varFloat = default; - int? int32 = default; - long? int64 = default; - int? integer = default; - decimal? number = default; - string password = default; - string patternWithBackslash = default; - string patternWithDigits = default; - string patternWithDigitsAndDelimiter = default; - string varString = default; - uint? unsignedInteger = default; - ulong? unsignedLong = default; - Guid? uuid = default; + Option varByte = default; + Option date = default; + Option number = default; + Option password = default; + 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; while (utf8JsonReader.Read()) { @@ -433,76 +543,76 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "binary": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - binary = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; case "byte": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varByte = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varByte = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "date": if (utf8JsonReader.TokenType != JsonTokenType.Null) - date = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "dateTime": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "decimal": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDecimal = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "double": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDouble = utf8JsonReader.GetDouble(); - break; - case "float": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varFloat = (float)utf8JsonReader.GetDouble(); - break; - case "int32": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int32 = utf8JsonReader.GetInt32(); - break; - case "int64": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int64 = utf8JsonReader.GetInt64(); - break; - case "integer": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - integer = utf8JsonReader.GetInt32(); + date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - number = utf8JsonReader.GetDecimal(); + number = new Option(utf8JsonReader.GetDecimal()); break; case "password": - password = utf8JsonReader.GetString(); + password = new Option(utf8JsonReader.GetString()); + break; + case "binary": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + binary = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "decimal": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDecimal = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "double": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDouble = new Option(utf8JsonReader.GetDouble()); + break; + case "float": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varFloat = new Option((float)utf8JsonReader.GetDouble()); + break; + case "int32": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int32 = new Option(utf8JsonReader.GetInt32()); + break; + case "int64": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int64 = new Option(utf8JsonReader.GetInt64()); + break; + case "integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integer = new Option(utf8JsonReader.GetInt32()); break; case "pattern_with_backslash": - patternWithBackslash = utf8JsonReader.GetString(); + patternWithBackslash = new Option(utf8JsonReader.GetString()); break; case "pattern_with_digits": - patternWithDigits = utf8JsonReader.GetString(); + patternWithDigits = new Option(utf8JsonReader.GetString()); break; case "pattern_with_digits_and_delimiter": - patternWithDigitsAndDelimiter = utf8JsonReader.GetString(); + patternWithDigitsAndDelimiter = new Option(utf8JsonReader.GetString()); break; case "string": - varString = utf8JsonReader.GetString(); + varString = new Option(utf8JsonReader.GetString()); break; case "unsigned_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedInteger = utf8JsonReader.GetUInt32(); + unsignedInteger = new Option(utf8JsonReader.GetUInt32()); break; case "unsigned_long": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedLong = utf8JsonReader.GetUInt64(); + unsignedLong = new Option(utf8JsonReader.GetUInt64()); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -510,64 +620,76 @@ namespace Org.OpenAPITools.Model } } - if (binary == null) - throw new ArgumentNullException(nameof(binary), "Property is required for class FormatTest."); + if (!varByte.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(varByte)); - if (varByte == null) - throw new ArgumentNullException(nameof(varByte), "Property is required for class FormatTest."); + if (!date.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(date)); - if (date == null) - throw new ArgumentNullException(nameof(date), "Property is required for class FormatTest."); + if (!number.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(number)); - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class FormatTest."); + if (!password.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(password)); - if (varDecimal == null) - throw new ArgumentNullException(nameof(varDecimal), "Property is required for class FormatTest."); + if (varByte.IsSet && varByte.Value == null) + throw new ArgumentNullException(nameof(varByte), "Property is not nullable for class FormatTest."); - if (varDouble == null) - throw new ArgumentNullException(nameof(varDouble), "Property is required for class FormatTest."); + if (date.IsSet && date.Value == null) + throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest."); - if (varFloat == null) - throw new ArgumentNullException(nameof(varFloat), "Property is required for class FormatTest."); + if (number.IsSet && number.Value == null) + throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest."); - if (int32 == null) - throw new ArgumentNullException(nameof(int32), "Property is required for class FormatTest."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class FormatTest."); - if (int64 == null) - throw new ArgumentNullException(nameof(int64), "Property is required for class FormatTest."); + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest."); - if (integer == null) - throw new ArgumentNullException(nameof(integer), "Property is required for class FormatTest."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest."); - if (number == null) - throw new ArgumentNullException(nameof(number), "Property is required for class FormatTest."); + if (varDecimal.IsSet && varDecimal.Value == null) + throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class FormatTest."); + if (varDouble.IsSet && varDouble.Value == null) + throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest."); - if (patternWithBackslash == null) - throw new ArgumentNullException(nameof(patternWithBackslash), "Property is required for class FormatTest."); + if (varFloat.IsSet && varFloat.Value == null) + throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest."); - if (patternWithDigits == null) - throw new ArgumentNullException(nameof(patternWithDigits), "Property is required for class FormatTest."); + if (int32.IsSet && int32.Value == null) + throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest."); - if (patternWithDigitsAndDelimiter == null) - throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + if (int64.IsSet && int64.Value == null) + throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest."); - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FormatTest."); + if (integer.IsSet && integer.Value == null) + throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest."); - if (unsignedInteger == null) - throw new ArgumentNullException(nameof(unsignedInteger), "Property is required for class FormatTest."); + if (patternWithBackslash.IsSet && patternWithBackslash.Value == null) + throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest."); - if (unsignedLong == null) - throw new ArgumentNullException(nameof(unsignedLong), "Property is required for class FormatTest."); + if (patternWithDigits.IsSet && patternWithDigits.Value == null) + throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class FormatTest."); + if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null) + throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest."); - return new FormatTest(binary, varByte, date.Value, dateTime.Value, varDecimal.Value, varDouble.Value, varFloat.Value, int32.Value, int64.Value, integer.Value, number.Value, password, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger.Value, unsignedLong.Value, uuid.Value); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest."); + + if (unsignedInteger.IsSet && unsignedInteger.Value == null) + throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest."); + + if (unsignedLong.IsSet && unsignedLong.Value == null) + throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest."); + + 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, int64, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid); } /// @@ -594,28 +716,83 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("binary"); - JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + if (formatTest.VarByte == null) + throw new ArgumentNullException(nameof(formatTest.VarByte), "Property is required for class FormatTest."); + + if (formatTest.Password == null) + throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest."); + + if (formatTest.BinaryOption.IsSet && formatTest.Binary == null) + throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest."); + + if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + + if (formatTest.VarStringOption.IsSet && formatTest.VarString == null) + throw new ArgumentNullException(nameof(formatTest.VarString), "Property is required for class FormatTest."); + writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.VarByte, jsonSerializerOptions); writer.WriteString("date", formatTest.Date.ToString(DateFormat)); - writer.WriteString("dateTime", formatTest.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("decimal"); - JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); - writer.WriteNumber("double", formatTest.VarDouble); - writer.WriteNumber("float", formatTest.VarFloat); - writer.WriteNumber("int32", formatTest.Int32); - writer.WriteNumber("int64", formatTest.Int64); - writer.WriteNumber("integer", formatTest.Integer); + writer.WriteNumber("number", formatTest.Number); + writer.WriteString("password", formatTest.Password); - writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); - writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); - writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); - writer.WriteString("string", formatTest.VarString); - writer.WriteNumber("unsigned_integer", formatTest.UnsignedInteger); - writer.WriteNumber("unsigned_long", formatTest.UnsignedLong); - writer.WriteString("uuid", formatTest.Uuid); + + if (formatTest.BinaryOption.IsSet) + { + writer.WritePropertyName("binary"); + JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + } + if (formatTest.DateTimeOption.IsSet) + writer.WriteString("dateTime", formatTest.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (formatTest.VarDecimalOption.IsSet) + { + writer.WritePropertyName("decimal"); + JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); + } + if (formatTest.VarDoubleOption.IsSet) + writer.WriteNumber("double", formatTest.VarDoubleOption.Value.Value); + + if (formatTest.VarFloatOption.IsSet) + writer.WriteNumber("float", formatTest.VarFloatOption.Value.Value); + + if (formatTest.Int32Option.IsSet) + writer.WriteNumber("int32", formatTest.Int32Option.Value.Value); + + if (formatTest.Int64Option.IsSet) + writer.WriteNumber("int64", formatTest.Int64Option.Value.Value); + + if (formatTest.IntegerOption.IsSet) + writer.WriteNumber("integer", formatTest.IntegerOption.Value.Value); + + if (formatTest.PatternWithBackslashOption.IsSet) + writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); + + if (formatTest.PatternWithDigitsOption.IsSet) + writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet) + writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); + + if (formatTest.VarStringOption.IsSet) + writer.WriteString("string", formatTest.VarString); + + if (formatTest.UnsignedIntegerOption.IsSet) + writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value.Value); + + if (formatTest.UnsignedLongOption.IsSet) + writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value.Value); + + if (formatTest.UuidOption.IsSet) + writer.WriteString("uuid", formatTest.UuidOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs index 2e05ffb958a..ea23d8efc42 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,10 +34,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Apple apple, string color) + public Fruit(Apple apple, Option color = default) { Apple = apple; - Color = color; + ColorOption = color; OnCreated(); } @@ -45,10 +46,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Banana banana, string color) + public Fruit(Banana banana, Option color = default) { Banana = banana; - Color = color; + ColorOption = color; OnCreated(); } @@ -64,11 +65,18 @@ namespace Org.OpenAPITools.Model /// public Banana Banana { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Returns the string presentation of the object @@ -116,7 +124,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string color = default; + Option color = default; Apple apple = default; Banana banana = default; @@ -156,7 +164,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -164,8 +172,8 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Fruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); if (apple != null) return new Fruit(apple, color); @@ -200,7 +208,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", fruit.Color); + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs index aa26d3600c0..75652a1b436 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs index 3c2d1ecefc9..fc6e5a9a457 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,31 +35,52 @@ namespace Org.OpenAPITools.Model /// /// /// color - public GmFruit(Apple apple, Banana banana, string color) + public GmFruit(Option apple, Option banana, Option color = default) { - Apple = apple; - Banana = banana; - Color = color; + AppleOption = apple; + BananaOption = banana; + ColorOption = color; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + /// /// Gets or Sets Apple /// - public Apple Apple { get; set; } + public Apple Apple { get { return this.AppleOption; } set { this.AppleOption = new(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } /// /// Gets or Sets Banana /// - public Banana Banana { get; set; } + public Banana Banana { get { return this.BananaOption; } set { this.BananaOption = new(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Returns the string presentation of the object @@ -106,7 +128,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string color = default; + Option color = default; Apple apple = default; Banana banana = default; @@ -146,7 +168,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -154,10 +176,17 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class GmFruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit."); - return new GmFruit(apple, banana, color); + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new GmFruit(appleParsedValue, bananaParsedValue, color); } /// @@ -171,16 +200,16 @@ namespace Org.OpenAPITools.Model { writer.WriteStartObject(); - if (gmFruit.Apple != null) + if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { - AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Apple.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.Apple, jsonSerializerOptions); + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); } - if (gmFruit.Banana != null) + if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null) { - BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Banana.GetType())); - BananaJsonConverter.WriteProperties(ref writer, gmFruit.Banana, jsonSerializerOptions); + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } WriteProperties(ref writer, gmFruit, jsonSerializerOptions); @@ -196,7 +225,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", gmFruit.Color); + if (gmFruit.ColorOption.IsSet && gmFruit.Color == null) + throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit."); + + if (gmFruit.ColorOption.IsSet) + writer.WriteString("color", gmFruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 7ae4662ed8d..6b7d7ae8da6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -110,7 +111,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -128,7 +129,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -136,10 +137,13 @@ namespace Org.OpenAPITools.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class GrandparentAnimal."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class GrandparentAnimal.", nameof(petType)); - return new GrandparentAnimal(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); + + return new GrandparentAnimal(petType.Value); } /// @@ -166,6 +170,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { + if (grandparentAnimal.PetType == null) + throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); + writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 31360d73f75..9652b767d13 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// bar /// foo [JsonConstructor] - internal HasOnlyReadOnly(string bar, string foo) + internal HasOnlyReadOnly(Option bar = default, Option foo = default) { - Bar = bar; - Foo = foo; + BarOption = bar; + FooOption = foo; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Foo + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FooOption { get; } /// /// Gets or Sets Foo /// [JsonPropertyName("foo")] - public string Foo { get; } + public string Foo { get { return this. FooOption; } } /// /// Gets or Sets additional properties @@ -105,8 +120,12 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); - hashCode = (hashCode * 59) + Foo.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + if (Foo != null) + hashCode = (hashCode * 59) + Foo.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -146,8 +165,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string bar = default; - string foo = default; + Option bar = default; + Option foo = default; while (utf8JsonReader.Read()) { @@ -165,10 +184,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()); break; case "foo": - foo = utf8JsonReader.GetString(); + foo = new Option(utf8JsonReader.GetString()); break; default: break; @@ -176,11 +195,11 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class HasOnlyReadOnly."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly."); - if (foo == null) - throw new ArgumentNullException(nameof(foo), "Property is required for class HasOnlyReadOnly."); + if (foo.IsSet && foo.Value == null) + throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly."); return new HasOnlyReadOnly(bar, foo); } @@ -209,8 +228,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", hasOnlyReadOnly.Bar); - writer.WriteString("foo", hasOnlyReadOnly.Foo); + if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.BarOption.IsSet) + writer.WriteString("bar", hasOnlyReadOnly.Bar); + + if (hasOnlyReadOnly.FooOption.IsSet) + writer.WriteString("foo", hasOnlyReadOnly.Foo); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 8355d97fa09..4931d3d73fe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// nullableMessage [JsonConstructor] - public HealthCheckResult(string nullableMessage = default) + public HealthCheckResult(Option nullableMessage = default) { - NullableMessage = nullableMessage; + NullableMessageOption = nullableMessage; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of NullableMessage + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableMessageOption { get; private set; } + /// /// Gets or Sets NullableMessage /// [JsonPropertyName("NullableMessage")] - public string NullableMessage { get; set; } + public string NullableMessage { get { return this. NullableMessageOption; } set { this.NullableMessageOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string nullableMessage = default; + Option nullableMessage = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "NullableMessage": - nullableMessage = utf8JsonReader.GetString(); + nullableMessage = new Option(utf8JsonReader.GetString()); break; default: break; @@ -153,7 +161,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + if (healthCheckResult.NullableMessageOption.IsSet) + if (healthCheckResult.NullableMessageOption.Value != null) + writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + else + writer.WriteNull("NullableMessage"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 0355613042f..3f4aa3229c4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,8 +103,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; - string triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -121,10 +122,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -132,13 +133,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class IsoscelesTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class IsoscelesTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(triangleType)); - return new IsoscelesTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class IsoscelesTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class IsoscelesTriangle."); + + return new IsoscelesTriangle(shapeType.Value, triangleType.Value); } /// @@ -165,7 +172,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (isoscelesTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle."); + + if (isoscelesTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle."); + writer.WriteString("shapeType", isoscelesTriangle.ShapeType); + writer.WriteString("triangleType", isoscelesTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs index 42b0c9cb2cf..5d0425e7769 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// var123List [JsonConstructor] - public List(string var123List) + public List(Option var123List = default) { - Var123List = var123List; + Var123ListOption = var123List; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Var123List + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123ListOption { get; private set; } + /// /// Gets or Sets Var123List /// [JsonPropertyName("123-list")] - public string Var123List { get; set; } + public string Var123List { get { return this. Var123ListOption; } set { this.Var123ListOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string var123List = default; + Option var123List = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "123-list": - var123List = utf8JsonReader.GetString(); + var123List = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (var123List == null) - throw new ArgumentNullException(nameof(var123List), "Property is required for class List."); + if (var123List.IsSet && var123List.Value == null) + throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List."); return new List(var123List); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("123-list", list.Var123List); + if (list.Var123ListOption.IsSet && list.Var123List == null) + throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List."); + + if (list.Var123ListOption.IsSet) + writer.WriteString("123-list", list.Var123List); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 0ad8832af88..f5e9d77e61c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// escapedLiteralString (default to "C:\\Users\\username") /// unescapedLiteralString (default to "C:\Users\username") [JsonConstructor] - public LiteralStringClass(string escapedLiteralString = @"C:\\Users\\username", string unescapedLiteralString = @"C:\Users\username") + public LiteralStringClass(Option escapedLiteralString = default, Option unescapedLiteralString = default) { - EscapedLiteralString = escapedLiteralString; - UnescapedLiteralString = unescapedLiteralString; + EscapedLiteralStringOption = escapedLiteralString; + UnescapedLiteralStringOption = unescapedLiteralString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of EscapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EscapedLiteralStringOption { get; private set; } + /// /// Gets or Sets EscapedLiteralString /// [JsonPropertyName("escapedLiteralString")] - public string EscapedLiteralString { get; set; } + public string EscapedLiteralString { get { return this. EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new(value); } } + + /// + /// Used to track the state of UnescapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnescapedLiteralStringOption { get; private set; } /// /// Gets or Sets UnescapedLiteralString /// [JsonPropertyName("unescapedLiteralString")] - public string UnescapedLiteralString { get; set; } + public string UnescapedLiteralString { get { return this. UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string escapedLiteralString = default; - string unescapedLiteralString = default; + Option escapedLiteralString = default; + Option unescapedLiteralString = default; while (utf8JsonReader.Read()) { @@ -128,10 +143,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "escapedLiteralString": - escapedLiteralString = utf8JsonReader.GetString(); + escapedLiteralString = new Option(utf8JsonReader.GetString()); break; case "unescapedLiteralString": - unescapedLiteralString = utf8JsonReader.GetString(); + unescapedLiteralString = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,11 +154,11 @@ namespace Org.OpenAPITools.Model } } - if (escapedLiteralString == null) - throw new ArgumentNullException(nameof(escapedLiteralString), "Property is required for class LiteralStringClass."); + if (escapedLiteralString.IsSet && escapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass."); - if (unescapedLiteralString == null) - throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is required for class LiteralStringClass."); + if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass."); return new LiteralStringClass(escapedLiteralString, unescapedLiteralString); } @@ -172,8 +187,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); - writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); + if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.EscapedLiteralStringOption.IsSet) + writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet) + writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs index 92011ad0e1d..1ea0d944f05 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -150,7 +151,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; Pig pig = null; Whale whale = null; @@ -207,7 +208,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -215,17 +216,20 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Mammal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Mammal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className); + return new Mammal(pig, className.Value); if (whale != null) - return new Mammal(whale, className); + return new Mammal(whale, className.Value); if (zebra != null) - return new Mammal(zebra, className); + return new Mammal(zebra, className.Value); throw new JsonException(); } @@ -269,6 +273,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { + if (mammal.ClassName == null) + throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); + writer.WriteString("className", mammal.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs index a4fdf221e93..0459a633acc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,12 +37,12 @@ namespace Org.OpenAPITools.Model /// mapMapOfString /// mapOfEnumString [JsonConstructor] - public MapTest(Dictionary directMap, Dictionary indirectMap, Dictionary> mapMapOfString, Dictionary mapOfEnumString) + public MapTest(Option> directMap = default, Option> indirectMap = default, Option>> mapMapOfString = default, Option> mapOfEnumString = default) { - DirectMap = directMap; - IndirectMap = indirectMap; - MapMapOfString = mapMapOfString; - MapOfEnumString = mapOfEnumString; + DirectMapOption = directMap; + IndirectMapOption = indirectMap; + MapMapOfStringOption = mapMapOfString; + MapOfEnumStringOption = mapOfEnumString; OnCreated(); } @@ -104,7 +105,6 @@ namespace Org.OpenAPITools.Model /// public static string InnerEnumToJsonValue(InnerEnum value) { - if (value == InnerEnum.UPPER) return "UPPER"; @@ -114,29 +114,57 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of DirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> DirectMapOption { get; private set; } + /// /// Gets or Sets DirectMap /// [JsonPropertyName("direct_map")] - public Dictionary DirectMap { get; set; } + public Dictionary DirectMap { get { return this. DirectMapOption; } set { this.DirectMapOption = new(value); } } + + /// + /// Used to track the state of IndirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> IndirectMapOption { get; private set; } /// /// Gets or Sets IndirectMap /// [JsonPropertyName("indirect_map")] - public Dictionary IndirectMap { get; set; } + public Dictionary IndirectMap { get { return this. IndirectMapOption; } set { this.IndirectMapOption = new(value); } } + + /// + /// Used to track the state of MapMapOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapMapOfStringOption { get; private set; } /// /// Gets or Sets MapMapOfString /// [JsonPropertyName("map_map_of_string")] - public Dictionary> MapMapOfString { get; set; } + public Dictionary> MapMapOfString { get { return this. MapMapOfStringOption; } set { this.MapMapOfStringOption = new(value); } } + + /// + /// Used to track the state of MapOfEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOfEnumStringOption { get; private set; } /// /// Gets or Sets MapOfEnumString /// [JsonPropertyName("map_of_enum_string")] - public Dictionary MapOfEnumString { get; set; } + public Dictionary MapOfEnumString { get { return this. MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -194,10 +222,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary directMap = default; - Dictionary indirectMap = default; - Dictionary> mapMapOfString = default; - Dictionary mapOfEnumString = default; + Option> directMap = default; + Option> indirectMap = default; + Option>> mapMapOfString = default; + Option> mapOfEnumString = default; while (utf8JsonReader.Read()) { @@ -216,19 +244,19 @@ namespace Org.OpenAPITools.Model { case "direct_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - directMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + directMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "indirect_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - indirectMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + indirectMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_map_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapMapOfString = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapMapOfString = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_of_enum_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfEnumString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapOfEnumString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -236,17 +264,17 @@ namespace Org.OpenAPITools.Model } } - if (directMap == null) - throw new ArgumentNullException(nameof(directMap), "Property is required for class MapTest."); + if (directMap.IsSet && directMap.Value == null) + throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest."); - if (indirectMap == null) - throw new ArgumentNullException(nameof(indirectMap), "Property is required for class MapTest."); + if (indirectMap.IsSet && indirectMap.Value == null) + throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest."); - if (mapMapOfString == null) - throw new ArgumentNullException(nameof(mapMapOfString), "Property is required for class MapTest."); + if (mapMapOfString.IsSet && mapMapOfString.Value == null) + throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest."); - if (mapOfEnumString == null) - throw new ArgumentNullException(nameof(mapOfEnumString), "Property is required for class MapTest."); + if (mapOfEnumString.IsSet && mapOfEnumString.Value == null) + throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest."); return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString); } @@ -275,14 +303,38 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("direct_map"); - JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); - writer.WritePropertyName("indirect_map"); - JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); - writer.WritePropertyName("map_map_of_string"); - JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); - writer.WritePropertyName("map_of_enum_string"); - JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null) + throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest."); + + if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null) + throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest."); + + if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null) + throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest."); + + if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null) + throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest."); + + if (mapTest.DirectMapOption.IsSet) + { + writer.WritePropertyName("direct_map"); + JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); + } + if (mapTest.IndirectMapOption.IsSet) + { + writer.WritePropertyName("indirect_map"); + JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); + } + if (mapTest.MapMapOfStringOption.IsSet) + { + writer.WritePropertyName("map_map_of_string"); + JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); + } + if (mapTest.MapOfEnumStringOption.IsSet) + { + writer.WritePropertyName("map_of_enum_string"); + JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 0ed70f02c2d..99d8e1c2fff 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,40 +37,68 @@ namespace Org.OpenAPITools.Model /// uuid /// uuidWithPattern [JsonConstructor] - public MixedPropertiesAndAdditionalPropertiesClass(DateTime dateTime, Dictionary map, Guid uuid, Guid uuidWithPattern) + public MixedPropertiesAndAdditionalPropertiesClass(Option dateTime = default, Option> map = default, Option uuid = default, Option uuidWithPattern = default) { - DateTime = dateTime; - Map = map; - Uuid = uuid; - UuidWithPattern = uuidWithPattern; + DateTimeOption = dateTime; + MapOption = map; + UuidOption = uuid; + UuidWithPatternOption = uuidWithPattern; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + /// /// Gets or Sets DateTime /// [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } } + + /// + /// Used to track the state of Map + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOption { get; private set; } /// /// Gets or Sets Map /// [JsonPropertyName("map")] - public Dictionary Map { get; set; } + public Dictionary Map { get { return this. MapOption; } set { this.MapOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// Used to track the state of UuidWithPattern + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidWithPatternOption { get; private set; } /// /// Gets or Sets UuidWithPattern /// [JsonPropertyName("uuid_with_pattern")] - public Guid UuidWithPattern { get; set; } + public Guid? UuidWithPattern { get { return this. UuidWithPatternOption; } set { this.UuidWithPatternOption = new(value); } } /// /// Gets or Sets additional properties @@ -103,7 +132,8 @@ namespace Org.OpenAPITools.Model { // UuidWithPattern (Guid) pattern Regex regexUuidWithPattern = new Regex(@"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", RegexOptions.CultureInvariant); - if (!regexUuidWithPattern.Match(this.UuidWithPattern.ToString()).Success) + + if (this.UuidWithPatternOption.Value != null &&!regexUuidWithPattern.Match(this.UuidWithPatternOption.Value.ToString()).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UuidWithPattern, must match a pattern of " + regexUuidWithPattern, new [] { "UuidWithPattern" }); } @@ -138,10 +168,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateTime = default; - Dictionary map = default; - Guid? uuid = default; - Guid? uuidWithPattern = default; + Option dateTime = default; + Option> map = default; + Option uuid = default; + Option uuidWithPattern = default; while (utf8JsonReader.Read()) { @@ -160,19 +190,19 @@ namespace Org.OpenAPITools.Model { case "dateTime": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - map = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + map = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; case "uuid_with_pattern": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuidWithPattern = utf8JsonReader.GetGuid(); + uuidWithPattern = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -180,19 +210,19 @@ namespace Org.OpenAPITools.Model } } - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (map == null) - throw new ArgumentNullException(nameof(map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (map.IsSet && map.Value == null) + throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuidWithPattern == null) - throw new ArgumentNullException(nameof(uuidWithPattern), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuidWithPattern.IsSet && uuidWithPattern.Value == null) + throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - return new MixedPropertiesAndAdditionalPropertiesClass(dateTime.Value, map, uuid.Value, uuidWithPattern.Value); + return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern); } /// @@ -219,11 +249,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("map"); - JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); - writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.Uuid); - writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern); + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null) + throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet) + writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet) + { + writer.WritePropertyName("map"); + JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); + } + if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet) + writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value.Value); + + if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet) + writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs index 7969b9ae04e..5defbb2c2fd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// varClass /// name [JsonConstructor] - public Model200Response(string varClass, int name) + public Model200Response(Option varClass = default, Option name = default) { - VarClass = varClass; - Name = name; + VarClassOption = varClass; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("class")] - public string VarClass { get; set; } + public string VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public int Name { get; set; } + public int? Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varClass = default; - int? name = default; + Option varClass = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -128,11 +143,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()); break; case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - name = utf8JsonReader.GetInt32(); + name = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -140,13 +155,13 @@ namespace Org.OpenAPITools.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class Model200Response."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Model200Response."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response."); - return new Model200Response(varClass, name.Value); + return new Model200Response(varClass, name); } /// @@ -173,8 +188,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("class", model200Response.VarClass); - writer.WriteNumber("name", model200Response.Name); + if (model200Response.VarClassOption.IsSet && model200Response.VarClass == null) + throw new ArgumentNullException(nameof(model200Response.VarClass), "Property is required for class Model200Response."); + + if (model200Response.VarClassOption.IsSet) + writer.WriteString("class", model200Response.VarClass); + + if (model200Response.NameOption.IsSet) + writer.WriteNumber("name", model200Response.NameOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs index 810a6a01b8e..7a2677d7e7f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varClient [JsonConstructor] - public ModelClient(string varClient) + public ModelClient(Option varClient = default) { - VarClient = varClient; + VarClientOption = varClient; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClient + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClientOption { get; private set; } + /// /// Gets or Sets VarClient /// [JsonPropertyName("client")] - public string VarClient { get; set; } + public string VarClient { get { return this. VarClientOption; } set { this.VarClientOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varClient = default; + Option varClient = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "client": - varClient = utf8JsonReader.GetString(); + varClient = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (varClient == null) - throw new ArgumentNullException(nameof(varClient), "Property is required for class ModelClient."); + if (varClient.IsSet && varClient.Value == null) + throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient."); return new ModelClient(varClient); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("client", modelClient.VarClient); + if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null) + throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient."); + + if (modelClient.VarClientOption.IsSet) + writer.WriteString("client", modelClient.VarClient); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs index edcb6b3403c..4651bf76c2c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,12 +37,12 @@ namespace Org.OpenAPITools.Model /// snakeCase /// var123Number [JsonConstructor] - public Name(int varName, string property, int snakeCase, int var123Number) + public Name(int varName, Option property = default, Option snakeCase = default, Option var123Number = default) { VarName = varName; - Property = property; - SnakeCase = snakeCase; - Var123Number = var123Number; + PropertyOption = property; + SnakeCaseOption = snakeCase; + Var123NumberOption = var123Number; OnCreated(); } @@ -53,23 +54,44 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("name")] public int VarName { get; set; } + /// + /// Used to track the state of Property + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PropertyOption { get; private set; } + /// /// Gets or Sets Property /// [JsonPropertyName("property")] - public string Property { get; set; } + public string Property { get { return this. PropertyOption; } set { this.PropertyOption = new(value); } } + + /// + /// Used to track the state of SnakeCase + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SnakeCaseOption { get; } /// /// Gets or Sets SnakeCase /// [JsonPropertyName("snake_case")] - public int SnakeCase { get; } + public int? SnakeCase { get { return this. SnakeCaseOption; } } + + /// + /// Used to track the state of Var123Number + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123NumberOption { get; } /// /// Gets or Sets Var123Number /// [JsonPropertyName("123Number")] - public int Var123Number { get; } + public int? Var123Number { get { return this. Var123NumberOption; } } /// /// Gets or Sets additional properties @@ -123,8 +145,12 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); - hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + if (SnakeCase != null) + hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); + + if (Var123Number != null) + hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -164,10 +190,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varName = default; - string property = default; - int? snakeCase = default; - int? var123Number = default; + Option varName = default; + Option property = default; + Option snakeCase = default; + Option var123Number = default; while (utf8JsonReader.Read()) { @@ -186,18 +212,18 @@ namespace Org.OpenAPITools.Model { case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varName = utf8JsonReader.GetInt32(); + varName = new Option(utf8JsonReader.GetInt32()); break; case "property": - property = utf8JsonReader.GetString(); + property = new Option(utf8JsonReader.GetString()); break; case "snake_case": if (utf8JsonReader.TokenType != JsonTokenType.Null) - snakeCase = utf8JsonReader.GetInt32(); + snakeCase = new Option(utf8JsonReader.GetInt32()); break; case "123Number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - var123Number = utf8JsonReader.GetInt32(); + var123Number = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -205,19 +231,22 @@ namespace Org.OpenAPITools.Model } } - if (varName == null) - throw new ArgumentNullException(nameof(varName), "Property is required for class Name."); + if (!varName.IsSet) + throw new ArgumentException("Property is required for class Name.", nameof(varName)); - if (property == null) - throw new ArgumentNullException(nameof(property), "Property is required for class Name."); + if (varName.IsSet && varName.Value == null) + throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name."); - if (snakeCase == null) - throw new ArgumentNullException(nameof(snakeCase), "Property is required for class Name."); + if (property.IsSet && property.Value == null) + throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name."); - if (var123Number == null) - throw new ArgumentNullException(nameof(var123Number), "Property is required for class Name."); + if (snakeCase.IsSet && snakeCase.Value == null) + throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name."); - return new Name(varName.Value, property, snakeCase.Value, var123Number.Value); + if (var123Number.IsSet && var123Number.Value == null) + throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name."); + + return new Name(varName.Value.Value, property, snakeCase, var123Number); } /// @@ -244,10 +273,19 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) { + if (name.PropertyOption.IsSet && name.Property == null) + throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name."); + writer.WriteNumber("name", name.VarName); - writer.WriteString("property", name.Property); - writer.WriteNumber("snake_case", name.SnakeCase); - writer.WriteNumber("123Number", name.Var123Number); + + if (name.PropertyOption.IsSet) + writer.WriteString("property", name.Property); + + if (name.SnakeCaseOption.IsSet) + writer.WriteNumber("snake_case", name.SnakeCaseOption.Value.Value); + + if (name.Var123NumberOption.IsSet) + writer.WriteNumber("123Number", name.Var123NumberOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index 83ab7f40b1e..cd1516104e3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List> aObjVariableobject = default; - int? pkiNotificationtestID = default; + Option>> aObjVariableobject = default; + Option pkiNotificationtestID = default; while (utf8JsonReader.Read()) { @@ -129,11 +130,11 @@ namespace Org.OpenAPITools.Model { case "a_objVariableobject": if (utf8JsonReader.TokenType != JsonTokenType.Null) - aObjVariableobject = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + aObjVariableobject = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "pkiNotificationtestID": if (utf8JsonReader.TokenType != JsonTokenType.Null) - pkiNotificationtestID = utf8JsonReader.GetInt32(); + pkiNotificationtestID = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -141,13 +142,19 @@ namespace Org.OpenAPITools.Model } } - if (aObjVariableobject == null) - throw new ArgumentNullException(nameof(aObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!aObjVariableobject.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(aObjVariableobject)); - if (pkiNotificationtestID == null) - throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!pkiNotificationtestID.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(pkiNotificationtestID)); - return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject, pkiNotificationtestID.Value); + if (aObjVariableobject.IsSet && aObjVariableobject.Value == null) + throw new ArgumentNullException(nameof(aObjVariableobject), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + if (pkiNotificationtestID.IsSet && pkiNotificationtestID.Value == null) + throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject.Value, pkiNotificationtestID.Value.Value); } /// @@ -174,6 +181,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) { + if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null) + throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + writer.WritePropertyName("a_objVariableobject"); JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions); writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs index 5d9de18c4a3..12a80a92881 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,9 +32,8 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// arrayItemsNullable - /// objectItemsNullable /// arrayAndItemsNullableProp + /// arrayItemsNullable /// arrayNullableProp /// booleanProp /// dateProp @@ -41,99 +41,184 @@ namespace Org.OpenAPITools.Model /// integerProp /// numberProp /// objectAndItemsNullableProp + /// objectItemsNullable /// objectNullableProp /// stringProp [JsonConstructor] - public NullableClass(List arrayItemsNullable, Dictionary objectItemsNullable, List arrayAndItemsNullableProp = default, List arrayNullableProp = default, bool? booleanProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, int? integerProp = default, decimal? numberProp = default, Dictionary objectAndItemsNullableProp = default, Dictionary objectNullableProp = default, string stringProp = default) : base() + public NullableClass(Option> arrayAndItemsNullableProp = default, Option> arrayItemsNullable = default, Option> arrayNullableProp = default, Option booleanProp = default, Option dateProp = default, Option datetimeProp = default, Option integerProp = default, Option numberProp = default, Option> objectAndItemsNullableProp = default, Option> objectItemsNullable = default, Option> objectNullableProp = default, Option stringProp = default) : base() { - ArrayItemsNullable = arrayItemsNullable; - ObjectItemsNullable = objectItemsNullable; - ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - ArrayNullableProp = arrayNullableProp; - BooleanProp = booleanProp; - DateProp = dateProp; - DatetimeProp = datetimeProp; - IntegerProp = integerProp; - NumberProp = numberProp; - ObjectAndItemsNullableProp = objectAndItemsNullableProp; - ObjectNullableProp = objectNullableProp; - StringProp = stringProp; + ArrayAndItemsNullablePropOption = arrayAndItemsNullableProp; + ArrayItemsNullableOption = arrayItemsNullable; + ArrayNullablePropOption = arrayNullableProp; + BooleanPropOption = booleanProp; + DatePropOption = dateProp; + DatetimePropOption = datetimeProp; + IntegerPropOption = integerProp; + NumberPropOption = numberProp; + ObjectAndItemsNullablePropOption = objectAndItemsNullableProp; + ObjectItemsNullableOption = objectItemsNullable; + ObjectNullablePropOption = objectNullableProp; + StringPropOption = stringProp; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets ArrayItemsNullable + /// Used to track the state of ArrayAndItemsNullableProp /// - [JsonPropertyName("array_items_nullable")] - public List ArrayItemsNullable { get; set; } - - /// - /// Gets or Sets ObjectItemsNullable - /// - [JsonPropertyName("object_items_nullable")] - public Dictionary ObjectItemsNullable { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// [JsonPropertyName("array_and_items_nullable_prop")] - public List ArrayAndItemsNullableProp { get; set; } + public List ArrayAndItemsNullableProp { get { return this. ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new(value); } } + + /// + /// Used to track the state of ArrayItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ArrayItemsNullable + /// + [JsonPropertyName("array_items_nullable")] + public List ArrayItemsNullable { get { return this. ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new(value); } } + + /// + /// Used to track the state of ArrayNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNullablePropOption { get; private set; } /// /// Gets or Sets ArrayNullableProp /// [JsonPropertyName("array_nullable_prop")] - public List ArrayNullableProp { get; set; } + public List ArrayNullableProp { get { return this. ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new(value); } } + + /// + /// Used to track the state of BooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BooleanPropOption { get; private set; } /// /// Gets or Sets BooleanProp /// [JsonPropertyName("boolean_prop")] - public bool? BooleanProp { get; set; } + public bool? BooleanProp { get { return this. BooleanPropOption; } set { this.BooleanPropOption = new(value); } } + + /// + /// Used to track the state of DateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatePropOption { get; private set; } /// /// Gets or Sets DateProp /// [JsonPropertyName("date_prop")] - public DateTime? DateProp { get; set; } + public DateTime? DateProp { get { return this. DatePropOption; } set { this.DatePropOption = new(value); } } + + /// + /// Used to track the state of DatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatetimePropOption { get; private set; } /// /// Gets or Sets DatetimeProp /// [JsonPropertyName("datetime_prop")] - public DateTime? DatetimeProp { get; set; } + public DateTime? DatetimeProp { get { return this. DatetimePropOption; } set { this.DatetimePropOption = new(value); } } + + /// + /// Used to track the state of IntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerPropOption { get; private set; } /// /// Gets or Sets IntegerProp /// [JsonPropertyName("integer_prop")] - public int? IntegerProp { get; set; } + public int? IntegerProp { get { return this. IntegerPropOption; } set { this.IntegerPropOption = new(value); } } + + /// + /// Used to track the state of NumberProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NumberPropOption { get; private set; } /// /// Gets or Sets NumberProp /// [JsonPropertyName("number_prop")] - public decimal? NumberProp { get; set; } + public decimal? NumberProp { get { return this. NumberPropOption; } set { this.NumberPropOption = new(value); } } + + /// + /// Used to track the state of ObjectAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// [JsonPropertyName("object_and_items_nullable_prop")] - public Dictionary ObjectAndItemsNullableProp { get; set; } + public Dictionary ObjectAndItemsNullableProp { get { return this. ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new(value); } } + + /// + /// Used to track the state of ObjectItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ObjectItemsNullable + /// + [JsonPropertyName("object_items_nullable")] + public Dictionary ObjectItemsNullable { get { return this. ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new(value); } } + + /// + /// Used to track the state of ObjectNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectNullablePropOption { get; private set; } /// /// Gets or Sets ObjectNullableProp /// [JsonPropertyName("object_nullable_prop")] - public Dictionary ObjectNullableProp { get; set; } + public Dictionary ObjectNullableProp { get { return this. ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new(value); } } + + /// + /// Used to track the state of StringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringPropOption { get; private set; } /// /// Gets or Sets StringProp /// [JsonPropertyName("string_prop")] - public string StringProp { get; set; } + public string StringProp { get { return this. StringPropOption; } set { this.StringPropOption = new(value); } } /// /// Gets or Sets additional properties @@ -150,9 +235,8 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class NullableClass {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); - sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); - sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); sb.Append(" DateProp: ").Append(DateProp).Append("\n"); @@ -160,6 +244,7 @@ namespace Org.OpenAPITools.Model sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -220,18 +305,18 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List arrayItemsNullable = default; - Dictionary objectItemsNullable = default; - List arrayAndItemsNullableProp = default; - List arrayNullableProp = default; - bool? booleanProp = default; - DateTime? dateProp = default; - DateTime? datetimeProp = default; - int? integerProp = default; - decimal? numberProp = default; - Dictionary objectAndItemsNullableProp = default; - Dictionary objectNullableProp = default; - string stringProp = default; + Option> arrayAndItemsNullableProp = default; + Option> arrayItemsNullable = default; + Option> arrayNullableProp = default; + Option booleanProp = default; + Option dateProp = default; + Option datetimeProp = default; + Option integerProp = default; + Option numberProp = default; + Option> objectAndItemsNullableProp = default; + Option> objectItemsNullable = default; + Option> objectNullableProp = default; + Option stringProp = default; while (utf8JsonReader.Read()) { @@ -248,52 +333,52 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "array_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "object_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; case "array_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "array_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "boolean_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - booleanProp = utf8JsonReader.GetBoolean(); + booleanProp = new Option(utf8JsonReader.GetBoolean()); break; case "date_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "datetime_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - datetimeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + datetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "integer_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - integerProp = utf8JsonReader.GetInt32(); + integerProp = new Option(utf8JsonReader.GetInt32()); break; case "number_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - numberProp = utf8JsonReader.GetDecimal(); + numberProp = new Option(utf8JsonReader.GetDecimal()); break; case "object_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "object_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "string_prop": - stringProp = utf8JsonReader.GetString(); + stringProp = new Option(utf8JsonReader.GetString()); break; default: break; @@ -301,13 +386,13 @@ namespace Org.OpenAPITools.Model } } - if (arrayItemsNullable == null) - throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is required for class NullableClass."); + if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null) + throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass."); - if (objectItemsNullable == null) - throw new ArgumentNullException(nameof(objectItemsNullable), "Property is required for class NullableClass."); + if (objectItemsNullable.IsSet && objectItemsNullable.Value == null) + throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass."); - return new NullableClass(arrayItemsNullable, objectItemsNullable, arrayAndItemsNullableProp, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectNullableProp, stringProp); + return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp); } /// @@ -334,45 +419,89 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("object_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("array_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("array_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.BooleanProp != null) - writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); - else - writer.WriteNull("boolean_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.DateProp != null) - writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(DatePropFormat)); - else - writer.WriteNull("date_prop"); + if (nullableClass.ArrayAndItemsNullablePropOption.IsSet) + if (nullableClass.ArrayAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("array_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_and_items_nullable_prop"); + if (nullableClass.ArrayItemsNullableOption.IsSet) + { + writer.WritePropertyName("array_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ArrayNullablePropOption.IsSet) + if (nullableClass.ArrayNullablePropOption.Value != null) + { + writer.WritePropertyName("array_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_nullable_prop"); + if (nullableClass.BooleanPropOption.IsSet) + if (nullableClass.BooleanPropOption.Value != null) + writer.WriteBoolean("boolean_prop", nullableClass.BooleanPropOption.Value.Value); + else + writer.WriteNull("boolean_prop"); - if (nullableClass.DatetimeProp != null) - writer.WriteString("datetime_prop", nullableClass.DatetimeProp.Value.ToString(DatetimePropFormat)); - else - writer.WriteNull("datetime_prop"); + if (nullableClass.DatePropOption.IsSet) + if (nullableClass.DatePropOption.Value != null) + writer.WriteString("date_prop", nullableClass.DatePropOption.Value.Value.ToString(DatePropFormat)); + else + writer.WriteNull("date_prop"); - if (nullableClass.IntegerProp != null) - writer.WriteNumber("integer_prop", nullableClass.IntegerProp.Value); - else - writer.WriteNull("integer_prop"); + if (nullableClass.DatetimePropOption.IsSet) + if (nullableClass.DatetimePropOption.Value != null) + writer.WriteString("datetime_prop", nullableClass.DatetimePropOption.Value.Value.ToString(DatetimePropFormat)); + else + writer.WriteNull("datetime_prop"); - if (nullableClass.NumberProp != null) - writer.WriteNumber("number_prop", nullableClass.NumberProp.Value); - else - writer.WriteNull("number_prop"); + if (nullableClass.IntegerPropOption.IsSet) + if (nullableClass.IntegerPropOption.Value != null) + writer.WriteNumber("integer_prop", nullableClass.IntegerPropOption.Value.Value); + else + writer.WriteNull("integer_prop"); - writer.WritePropertyName("object_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("object_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); - writer.WriteString("string_prop", nullableClass.StringProp); + if (nullableClass.NumberPropOption.IsSet) + if (nullableClass.NumberPropOption.Value != null) + writer.WriteNumber("number_prop", nullableClass.NumberPropOption.Value.Value); + else + writer.WriteNull("number_prop"); + + if (nullableClass.ObjectAndItemsNullablePropOption.IsSet) + if (nullableClass.ObjectAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("object_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_and_items_nullable_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet) + { + writer.WritePropertyName("object_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ObjectNullablePropOption.IsSet) + if (nullableClass.ObjectNullablePropOption.Value != null) + { + writer.WritePropertyName("object_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_nullable_prop"); + if (nullableClass.StringPropOption.IsSet) + if (nullableClass.StringPropOption.Value != null) + writer.WriteString("string_prop", nullableClass.StringProp); + else + writer.WriteNull("string_prop"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs index 684109acd50..ca650f0cce0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,20 +34,27 @@ namespace Org.OpenAPITools.Model /// /// uuid [JsonConstructor] - public NullableGuidClass(Guid? uuid = default) + public NullableGuidClass(Option uuid = default) { - Uuid = uuid; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid? Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -101,7 +109,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Guid? uuid = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model { case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -155,11 +163,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { - - if (nullableGuidClass.Uuid == null) - writer.WriteNull("uuid"); - else - writer.WriteString("uuid", nullableGuidClass.Uuid.Value); + if (nullableGuidClass.UuidOption.IsSet) + if (nullableGuidClass.UuidOption.Value != null) + writer.WriteString("uuid", nullableGuidClass.UuidOption.Value.Value); + else + writer.WriteNull("uuid"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs index a44c950b81b..1e38640c8af 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; Quadrilateral quadrilateral = null; Triangle triangle = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class NullableShape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class NullableShape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType); + return new NullableShape(quadrilateral, shapeType.Value); if (triangle != null) - return new NullableShape(triangle, shapeType); + return new NullableShape(triangle, shapeType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { + if (nullableShape.ShapeType == null) + throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); + writer.WriteString("shapeType", nullableShape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs index 3f3cbf4c505..6f89d827843 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// justNumber [JsonConstructor] - public NumberOnly(decimal justNumber) + public NumberOnly(Option justNumber = default) { - JustNumber = justNumber; + JustNumberOption = justNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of JustNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustNumberOption { get; private set; } + /// /// Gets or Sets JustNumber /// [JsonPropertyName("JustNumber")] - public decimal JustNumber { get; set; } + public decimal? JustNumber { get { return this. JustNumberOption; } set { this.JustNumberOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? justNumber = default; + Option justNumber = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "JustNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - justNumber = utf8JsonReader.GetDecimal(); + justNumber = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -127,10 +135,10 @@ namespace Org.OpenAPITools.Model } } - if (justNumber == null) - throw new ArgumentNullException(nameof(justNumber), "Property is required for class NumberOnly."); + if (justNumber.IsSet && justNumber.Value == null) + throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly."); - return new NumberOnly(justNumber.Value); + return new NumberOnly(justNumber); } /// @@ -157,7 +165,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("JustNumber", numberOnly.JustNumber); + if (numberOnly.JustNumberOption.IsSet) + writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index 57a1614f29f..4ea953e572f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,43 +37,71 @@ namespace Org.OpenAPITools.Model /// id /// uuid [JsonConstructor] - public ObjectWithDeprecatedFields(List bars, DeprecatedObject deprecatedRef, decimal id, string uuid) + public ObjectWithDeprecatedFields(Option> bars = default, Option deprecatedRef = default, Option id = default, Option uuid = default) { - Bars = bars; - DeprecatedRef = deprecatedRef; - Id = id; - Uuid = uuid; + BarsOption = bars; + DeprecatedRefOption = deprecatedRef; + IdOption = id; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bars + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> BarsOption { get; private set; } + /// /// Gets or Sets Bars /// [JsonPropertyName("bars")] [Obsolete] - public List Bars { get; set; } + public List Bars { get { return this. BarsOption; } set { this.BarsOption = new(value); } } + + /// + /// Used to track the state of DeprecatedRef + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeprecatedRefOption { get; private set; } /// /// Gets or Sets DeprecatedRef /// [JsonPropertyName("deprecatedRef")] [Obsolete] - public DeprecatedObject DeprecatedRef { get; set; } + public DeprecatedObject DeprecatedRef { get { return this. DeprecatedRefOption; } set { this.DeprecatedRefOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] [Obsolete] - public decimal Id { get; set; } + public decimal? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public string Uuid { get; set; } + public string Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -130,10 +159,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List bars = default; - DeprecatedObject deprecatedRef = default; - decimal? id = default; - string uuid = default; + Option> bars = default; + Option deprecatedRef = default; + Option id = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -152,18 +181,18 @@ namespace Org.OpenAPITools.Model { case "bars": if (utf8JsonReader.TokenType != JsonTokenType.Null) - bars = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + bars = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "deprecatedRef": if (utf8JsonReader.TokenType != JsonTokenType.Null) - deprecatedRef = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + deprecatedRef = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetDecimal(); + id = new Option(utf8JsonReader.GetDecimal()); break; case "uuid": - uuid = utf8JsonReader.GetString(); + uuid = new Option(utf8JsonReader.GetString()); break; default: break; @@ -171,19 +200,19 @@ namespace Org.OpenAPITools.Model } } - if (bars == null) - throw new ArgumentNullException(nameof(bars), "Property is required for class ObjectWithDeprecatedFields."); + if (bars.IsSet && bars.Value == null) + throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (deprecatedRef == null) - throw new ArgumentNullException(nameof(deprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + if (deprecatedRef.IsSet && deprecatedRef.Value == null) + throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class ObjectWithDeprecatedFields."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class ObjectWithDeprecatedFields."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields."); - return new ObjectWithDeprecatedFields(bars, deprecatedRef, id.Value, uuid); + return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid); } /// @@ -210,12 +239,30 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("bars"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); - writer.WritePropertyName("deprecatedRef"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); - writer.WriteNumber("id", objectWithDeprecatedFields.Id); - writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); + if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.BarsOption.IsSet) + { + writer.WritePropertyName("bars"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet) + { + writer.WritePropertyName("deprecatedRef"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.IdOption.IsSet) + writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value.Value); + + if (objectWithDeprecatedFields.UuidOption.IsSet) + writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OneOfString.cs index 91dd6763161..660604e3ef1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OneOfString.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs index 3258ff15447..57515c27c5e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,21 +32,21 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// complete (default to false) /// id /// petId /// quantity /// shipDate /// Order Status - /// complete (default to false) [JsonConstructor] - public Order(long id, long petId, int quantity, DateTime shipDate, StatusEnum status, bool complete = false) + public Order(Option complete = default, Option id = default, Option petId = default, Option quantity = default, Option shipDate = default, Option status = default) { - Id = id; - PetId = petId; - Quantity = quantity; - ShipDate = shipDate; - Status = status; - Complete = complete; + CompleteOption = complete; + IdOption = id; + PetIdOption = petId; + QuantityOption = quantity; + ShipDateOption = shipDate; + StatusOption = status; OnCreated(); } @@ -118,9 +119,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Placed) return "placed"; @@ -133,43 +133,85 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// Order Status /// /// Order Status [JsonPropertyName("status")] - public StatusEnum Status { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } } + + /// + /// Used to track the state of Complete + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CompleteOption { get; private set; } + + /// + /// Gets or Sets Complete + /// + [JsonPropertyName("complete")] + public bool? Complete { get { return this. CompleteOption; } set { this.CompleteOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of PetId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PetIdOption { get; private set; } /// /// Gets or Sets PetId /// [JsonPropertyName("petId")] - public long PetId { get; set; } + public long? PetId { get { return this. PetIdOption; } set { this.PetIdOption = new(value); } } + + /// + /// Used to track the state of Quantity + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option QuantityOption { get; private set; } /// /// Gets or Sets Quantity /// [JsonPropertyName("quantity")] - public int Quantity { get; set; } + public int? Quantity { get { return this. QuantityOption; } set { this.QuantityOption = new(value); } } + + /// + /// Used to track the state of ShipDate + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShipDateOption { get; private set; } /// /// Gets or Sets ShipDate /// /// 2020-02-02T20:20:20.000222Z [JsonPropertyName("shipDate")] - public DateTime ShipDate { get; set; } - - /// - /// Gets or Sets Complete - /// - [JsonPropertyName("complete")] - public bool Complete { get; set; } + public DateTime? ShipDate { get { return this. ShipDateOption; } set { this.ShipDateOption = new(value); } } /// /// Gets or Sets additional properties @@ -185,12 +227,12 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Order {\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" PetId: ").Append(PetId).Append("\n"); sb.Append(" Quantity: ").Append(Quantity).Append("\n"); sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -234,12 +276,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - long? petId = default; - int? quantity = default; - DateTime? shipDate = default; - Order.StatusEnum? status = default; - bool? complete = default; + Option complete = default; + Option id = default; + Option petId = default; + Option quantity = default; + Option shipDate = default; + Option status = default; while (utf8JsonReader.Read()) { @@ -256,31 +298,30 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "complete": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + complete = new Option(utf8JsonReader.GetBoolean()); + break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "petId": if (utf8JsonReader.TokenType != JsonTokenType.Null) - petId = utf8JsonReader.GetInt64(); + petId = new Option(utf8JsonReader.GetInt64()); break; case "quantity": if (utf8JsonReader.TokenType != JsonTokenType.Null) - quantity = utf8JsonReader.GetInt32(); + quantity = new Option(utf8JsonReader.GetInt32()); break; case "shipDate": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shipDate = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shipDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "status": string statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Order.StatusEnumFromStringOrDefault(statusRawValue); - break; - case "complete": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - complete = utf8JsonReader.GetBoolean(); + if (statusRawValue != null) + status = new Option(Order.StatusEnumFromStringOrDefault(statusRawValue)); break; default: break; @@ -288,25 +329,25 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Order."); + if (complete.IsSet && complete.Value == null) + throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order."); - if (petId == null) - throw new ArgumentNullException(nameof(petId), "Property is required for class Order."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order."); - if (quantity == null) - throw new ArgumentNullException(nameof(quantity), "Property is required for class Order."); + if (petId.IsSet && petId.Value == null) + throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order."); - if (shipDate == null) - throw new ArgumentNullException(nameof(shipDate), "Property is required for class Order."); + if (quantity.IsSet && quantity.Value == null) + throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Order."); + if (shipDate.IsSet && shipDate.Value == null) + throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order."); - if (complete == null) - throw new ArgumentNullException(nameof(complete), "Property is required for class Order."); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order."); - return new Order(id.Value, petId.Value, quantity.Value, shipDate.Value, status.Value, complete.Value); + return new Order(complete, id, petId, quantity, shipDate, status); } /// @@ -333,18 +374,26 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", order.Id); - writer.WriteNumber("petId", order.PetId); - writer.WriteNumber("quantity", order.Quantity); - writer.WriteString("shipDate", order.ShipDate.ToString(ShipDateFormat)); + if (order.CompleteOption.IsSet) + writer.WriteBoolean("complete", order.CompleteOption.Value.Value); - var statusRawValue = Order.StatusEnumToJsonValue(order.Status); + if (order.IdOption.IsSet) + writer.WriteNumber("id", order.IdOption.Value.Value); + + if (order.PetIdOption.IsSet) + writer.WriteNumber("petId", order.PetIdOption.Value.Value); + + if (order.QuantityOption.IsSet) + writer.WriteNumber("quantity", order.QuantityOption.Value.Value); + + if (order.ShipDateOption.IsSet) + writer.WriteString("shipDate", order.ShipDateOption.Value.Value.ToString(ShipDateFormat)); + + var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - - writer.WriteBoolean("complete", order.Complete); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs index c37883db124..532010be421 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// myNumber /// myString [JsonConstructor] - public OuterComposite(bool myBoolean, decimal myNumber, string myString) + public OuterComposite(Option myBoolean = default, Option myNumber = default, Option myString = default) { - MyBoolean = myBoolean; - MyNumber = myNumber; - MyString = myString; + MyBooleanOption = myBoolean; + MyNumberOption = myNumber; + MyStringOption = myString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MyBoolean + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyBooleanOption { get; private set; } + /// /// Gets or Sets MyBoolean /// [JsonPropertyName("my_boolean")] - public bool MyBoolean { get; set; } + public bool? MyBoolean { get { return this. MyBooleanOption; } set { this.MyBooleanOption = new(value); } } + + /// + /// Used to track the state of MyNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyNumberOption { get; private set; } /// /// Gets or Sets MyNumber /// [JsonPropertyName("my_number")] - public decimal MyNumber { get; set; } + public decimal? MyNumber { get { return this. MyNumberOption; } set { this.MyNumberOption = new(value); } } + + /// + /// Used to track the state of MyString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyStringOption { get; private set; } /// /// Gets or Sets MyString /// [JsonPropertyName("my_string")] - public string MyString { get; set; } + public string MyString { get { return this. MyStringOption; } set { this.MyStringOption = new(value); } } /// /// Gets or Sets additional properties @@ -118,9 +140,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - bool? myBoolean = default; - decimal? myNumber = default; - string myString = default; + Option myBoolean = default; + Option myNumber = default; + Option myString = default; while (utf8JsonReader.Read()) { @@ -139,14 +161,14 @@ namespace Org.OpenAPITools.Model { case "my_boolean": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myBoolean = utf8JsonReader.GetBoolean(); + myBoolean = new Option(utf8JsonReader.GetBoolean()); break; case "my_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myNumber = utf8JsonReader.GetDecimal(); + myNumber = new Option(utf8JsonReader.GetDecimal()); break; case "my_string": - myString = utf8JsonReader.GetString(); + myString = new Option(utf8JsonReader.GetString()); break; default: break; @@ -154,16 +176,16 @@ namespace Org.OpenAPITools.Model } } - if (myBoolean == null) - throw new ArgumentNullException(nameof(myBoolean), "Property is required for class OuterComposite."); + if (myBoolean.IsSet && myBoolean.Value == null) + throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite."); - if (myNumber == null) - throw new ArgumentNullException(nameof(myNumber), "Property is required for class OuterComposite."); + if (myNumber.IsSet && myNumber.Value == null) + throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite."); - if (myString == null) - throw new ArgumentNullException(nameof(myString), "Property is required for class OuterComposite."); + if (myString.IsSet && myString.Value == null) + throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite."); - return new OuterComposite(myBoolean.Value, myNumber.Value, myString); + return new OuterComposite(myBoolean, myNumber, myString); } /// @@ -190,9 +212,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteBoolean("my_boolean", outerComposite.MyBoolean); - writer.WriteNumber("my_number", outerComposite.MyNumber); - writer.WriteString("my_string", outerComposite.MyString); + if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null) + throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite."); + + if (outerComposite.MyBooleanOption.IsSet) + writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value); + + if (outerComposite.MyNumberOption.IsSet) + writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value.Value); + + if (outerComposite.MyStringOption.IsSet) + writer.WriteString("my_string", outerComposite.MyString); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs index a4ec335bb38..47bb6793c6a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index 7c67db5ddca..136fb4c54c4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index 84ea65297ab..2ed4f18a657 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index 983d194a199..c6a470cc64d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs index 51d8bee407e..a2e789f2ede 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs index eb0129c6ce0..c451e1a8991 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -76,7 +77,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -94,7 +95,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -102,10 +103,13 @@ namespace Org.OpenAPITools.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ParentPet."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ParentPet.", nameof(petType)); - return new ParentPet(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); + + return new ParentPet(petType.Value); } /// @@ -132,6 +136,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet.PetType == null) + throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); + writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs index 225a9c5328c..f9e7d0466b2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,21 +32,21 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// category - /// id /// name /// photoUrls + /// category + /// id /// pet status in the store /// tags [JsonConstructor] - public Pet(Category category, long id, string name, List photoUrls, StatusEnum status, List tags) + public Pet(string name, List photoUrls, Option category = default, Option id = default, Option status = default, Option> tags = default) { - Category = category; - Id = id; Name = name; PhotoUrls = photoUrls; - Status = status; - Tags = tags; + CategoryOption = category; + IdOption = id; + StatusOption = status; + TagsOption = tags; OnCreated(); } @@ -118,9 +119,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Available) return "available"; @@ -133,24 +133,19 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// pet status in the store /// /// pet status in the store [JsonPropertyName("status")] - public StatusEnum Status { get; set; } - - /// - /// Gets or Sets Category - /// - [JsonPropertyName("category")] - public Category Category { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } } /// /// Gets or Sets Name @@ -165,11 +160,44 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } + /// + /// Used to track the state of Category + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryOption { get; private set; } + + /// + /// Gets or Sets Category + /// + [JsonPropertyName("category")] + public Category Category { get { return this. CategoryOption; } set { this.CategoryOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Tags + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TagsOption { get; private set; } + /// /// Gets or Sets Tags /// [JsonPropertyName("tags")] - public List Tags { get; set; } + public List Tags { get { return this. TagsOption; } set { this.TagsOption = new(value); } } /// /// Gets or Sets additional properties @@ -185,10 +213,10 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Pet {\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); sb.Append(" Tags: ").Append(Tags).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -229,12 +257,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Category category = default; - long? id = default; - string name = default; - List photoUrls = default; - Pet.StatusEnum? status = default; - List tags = default; + Option name = default; + Option> photoUrls = default; + Option category = default; + Option id = default; + Option status = default; + Option> tags = default; while (utf8JsonReader.Read()) { @@ -251,30 +279,29 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "category": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - category = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; case "photoUrls": if (utf8JsonReader.TokenType != JsonTokenType.Null) - photoUrls = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + photoUrls = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "category": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + category = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); break; case "status": string statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Pet.StatusEnumFromStringOrDefault(statusRawValue); + if (statusRawValue != null) + status = new Option(Pet.StatusEnumFromStringOrDefault(statusRawValue)); break; case "tags": if (utf8JsonReader.TokenType != JsonTokenType.Null) - tags = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + tags = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -282,25 +309,31 @@ namespace Org.OpenAPITools.Model } } - if (category == null) - throw new ArgumentNullException(nameof(category), "Property is required for class Pet."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(name)); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Pet."); + if (!photoUrls.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(photoUrls)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Pet."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Pet."); - if (photoUrls == null) - throw new ArgumentNullException(nameof(photoUrls), "Property is required for class Pet."); + if (photoUrls.IsSet && photoUrls.Value == null) + throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Pet."); + if (category.IsSet && category.Value == null) + throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet."); - if (tags == null) - throw new ArgumentNullException(nameof(tags), "Property is required for class Pet."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet."); - return new Pet(category, id.Value, name, photoUrls, status.Value, tags); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet."); + + if (tags.IsSet && tags.Value == null) + throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet."); + + return new Pet(name.Value, photoUrls.Value, category, id, status, tags); } /// @@ -327,21 +360,41 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("category"); - JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); - writer.WriteNumber("id", pet.Id); + if (pet.Name == null) + throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet."); + + if (pet.PhotoUrls == null) + throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet."); + + if (pet.CategoryOption.IsSet && pet.Category == null) + throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet."); + + if (pet.TagsOption.IsSet && pet.Tags == null) + throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet."); + writer.WriteString("name", pet.Name); + writer.WritePropertyName("photoUrls"); JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions); + if (pet.CategoryOption.IsSet) + { + writer.WritePropertyName("category"); + JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); + } + if (pet.IdOption.IsSet) + writer.WriteNumber("id", pet.IdOption.Value.Value); - var statusRawValue = Pet.StatusEnumToJsonValue(pet.Status); + var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - writer.WritePropertyName("tags"); - JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + if (pet.TagsOption.IsSet) + { + writer.WritePropertyName("tags"); + JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs index 8185d643e79..d3bbeb8ff32 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; BasquePig basquePig = null; DanishPig danishPig = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Pig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Pig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className); + return new Pig(basquePig, className.Value); if (danishPig != null) - return new Pig(danishPig, className); + return new Pig(danishPig, className.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { + if (pig.ClassName == null) + throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); + writer.WriteString("className", pig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 3a89a8716e0..2c2227a2251 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs index 65f7b8b4536..3f4034a1771 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; + Option quadrilateralType = default; ComplexQuadrilateral complexQuadrilateral = null; SimpleQuadrilateral simpleQuadrilateral = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class Quadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class Quadrilateral.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType); + return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType); + return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); + writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index c329eed3266..75b7e516cfc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; + Option quadrilateralType = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class QuadrilateralInterface."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class QuadrilateralInterface.", nameof(quadrilateralType)); - return new QuadrilateralInterface(quadrilateralType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class QuadrilateralInterface."); + + return new QuadrilateralInterface(quadrilateralType.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateralInterface.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface."); + writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 2c8b4fff43d..16f308cad5f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// bar /// baz [JsonConstructor] - public ReadOnlyFirst(string bar, string baz) + public ReadOnlyFirst(Option bar = default, Option baz = default) { - Bar = bar; - Baz = baz; + BarOption = bar; + BazOption = baz; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Baz + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BazOption { get; private set; } /// /// Gets or Sets Baz /// [JsonPropertyName("baz")] - public string Baz { get; set; } + public string Baz { get { return this. BazOption; } set { this.BazOption = new(value); } } /// /// Gets or Sets additional properties @@ -105,7 +120,9 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -145,8 +162,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string bar = default; - string baz = default; + Option bar = default; + Option baz = default; while (utf8JsonReader.Read()) { @@ -164,10 +181,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()); break; case "baz": - baz = utf8JsonReader.GetString(); + baz = new Option(utf8JsonReader.GetString()); break; default: break; @@ -175,11 +192,11 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class ReadOnlyFirst."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst."); - if (baz == null) - throw new ArgumentNullException(nameof(baz), "Property is required for class ReadOnlyFirst."); + if (baz.IsSet && baz.Value == null) + throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst."); return new ReadOnlyFirst(bar, baz); } @@ -208,8 +225,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", readOnlyFirst.Bar); - writer.WriteString("baz", readOnlyFirst.Baz); + if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BarOption.IsSet) + writer.WriteString("bar", readOnlyFirst.Bar); + + if (readOnlyFirst.BazOption.IsSet) + writer.WriteString("baz", readOnlyFirst.Baz); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..a7a41e724c5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,2386 @@ +// +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + public partial class RequiredClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// requiredNotNullableDateProp + /// requiredNotnullableArrayOfString + /// requiredNotnullableBooleanProp + /// requiredNotnullableDatetimeProp + /// requiredNotnullableEnumInteger + /// requiredNotnullableEnumIntegerOnly + /// requiredNotnullableEnumString + /// requiredNotnullableOuterEnumDefaultValue + /// requiredNotnullableStringProp + /// requiredNotnullableUuid + /// requiredNotnullableintegerProp + /// requiredNullableArrayOfString + /// requiredNullableBooleanProp + /// requiredNullableDateProp + /// requiredNullableDatetimeProp + /// requiredNullableEnumInteger + /// requiredNullableEnumIntegerOnly + /// requiredNullableEnumString + /// requiredNullableIntegerProp + /// requiredNullableOuterEnumDefaultValue + /// requiredNullableStringProp + /// requiredNullableUuid + /// notRequiredNotnullableDateProp + /// notRequiredNotnullableintegerProp + /// notRequiredNullableDateProp + /// notRequiredNullableIntegerProp + /// notrequiredNotnullableArrayOfString + /// notrequiredNotnullableBooleanProp + /// notrequiredNotnullableDatetimeProp + /// notrequiredNotnullableEnumInteger + /// notrequiredNotnullableEnumIntegerOnly + /// notrequiredNotnullableEnumString + /// notrequiredNotnullableOuterEnumDefaultValue + /// notrequiredNotnullableStringProp + /// notrequiredNotnullableUuid + /// notrequiredNullableArrayOfString + /// notrequiredNullableBooleanProp + /// notrequiredNullableDatetimeProp + /// notrequiredNullableEnumInteger + /// notrequiredNullableEnumIntegerOnly + /// notrequiredNullableEnumString + /// notrequiredNullableOuterEnumDefaultValue + /// notrequiredNullableStringProp + /// notrequiredNullableUuid + [JsonConstructor] + public RequiredClass(DateTime requiredNotNullableDateProp, List requiredNotnullableArrayOfString, bool requiredNotnullableBooleanProp, DateTime requiredNotnullableDatetimeProp, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue, string requiredNotnullableStringProp, Guid requiredNotnullableUuid, int requiredNotnullableintegerProp, List requiredNullableArrayOfString = default, bool? requiredNullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime? requiredNullableDatetimeProp = default, RequiredNullableEnumIntegerEnum? requiredNullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum? requiredNullableEnumIntegerOnly = default, RequiredNullableEnumStringEnum? requiredNullableEnumString = default, int? requiredNullableIntegerProp = default, OuterEnumDefaultValue? requiredNullableOuterEnumDefaultValue = default, string requiredNullableStringProp = default, Guid? requiredNullableUuid = default, Option notRequiredNotnullableDateProp = default, Option notRequiredNotnullableintegerProp = default, Option notRequiredNullableDateProp = default, Option notRequiredNullableIntegerProp = default, Option> notrequiredNotnullableArrayOfString = default, Option notrequiredNotnullableBooleanProp = default, Option notrequiredNotnullableDatetimeProp = default, Option notrequiredNotnullableEnumInteger = default, Option notrequiredNotnullableEnumIntegerOnly = default, Option notrequiredNotnullableEnumString = default, Option notrequiredNotnullableOuterEnumDefaultValue = default, Option notrequiredNotnullableStringProp = default, Option notrequiredNotnullableUuid = default, Option> notrequiredNullableArrayOfString = default, Option notrequiredNullableBooleanProp = default, Option notrequiredNullableDatetimeProp = default, Option notrequiredNullableEnumInteger = default, Option notrequiredNullableEnumIntegerOnly = default, Option notrequiredNullableEnumString = default, Option notrequiredNullableOuterEnumDefaultValue = default, Option notrequiredNullableStringProp = default, Option notrequiredNullableUuid = default) + { + RequiredNotNullableDateProp = requiredNotNullableDateProp; + RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + RequiredNotnullableEnumString = requiredNotnullableEnumString; + RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + RequiredNotnullableStringProp = requiredNotnullableStringProp; + RequiredNotnullableUuid = requiredNotnullableUuid; + RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + RequiredNullableArrayOfString = requiredNullableArrayOfString; + RequiredNullableBooleanProp = requiredNullableBooleanProp; + RequiredNullableDateProp = requiredNullableDateProp; + RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + RequiredNullableEnumInteger = requiredNullableEnumInteger; + RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + RequiredNullableEnumString = requiredNullableEnumString; + RequiredNullableIntegerProp = requiredNullableIntegerProp; + RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + RequiredNullableStringProp = requiredNullableStringProp; + RequiredNullableUuid = requiredNullableUuid; + NotRequiredNotnullableDatePropOption = notRequiredNotnullableDateProp; + NotRequiredNotnullableintegerPropOption = notRequiredNotnullableintegerProp; + NotRequiredNullableDatePropOption = notRequiredNullableDateProp; + NotRequiredNullableIntegerPropOption = notRequiredNullableIntegerProp; + NotrequiredNotnullableArrayOfStringOption = notrequiredNotnullableArrayOfString; + NotrequiredNotnullableBooleanPropOption = notrequiredNotnullableBooleanProp; + NotrequiredNotnullableDatetimePropOption = notrequiredNotnullableDatetimeProp; + NotrequiredNotnullableEnumIntegerOption = notrequiredNotnullableEnumInteger; + NotrequiredNotnullableEnumIntegerOnlyOption = notrequiredNotnullableEnumIntegerOnly; + NotrequiredNotnullableEnumStringOption = notrequiredNotnullableEnumString; + NotrequiredNotnullableOuterEnumDefaultValueOption = notrequiredNotnullableOuterEnumDefaultValue; + NotrequiredNotnullableStringPropOption = notrequiredNotnullableStringProp; + NotrequiredNotnullableUuidOption = notrequiredNotnullableUuid; + NotrequiredNullableArrayOfStringOption = notrequiredNullableArrayOfString; + NotrequiredNullableBooleanPropOption = notrequiredNullableBooleanProp; + NotrequiredNullableDatetimePropOption = notrequiredNullableDatetimeProp; + NotrequiredNullableEnumIntegerOption = notrequiredNullableEnumInteger; + NotrequiredNullableEnumIntegerOnlyOption = notrequiredNullableEnumIntegerOnly; + NotrequiredNullableEnumStringOption = notrequiredNullableEnumString; + NotrequiredNullableOuterEnumDefaultValueOption = notrequiredNullableOuterEnumDefaultValue; + NotrequiredNullableStringPropOption = notrequiredNullableStringProp; + NotrequiredNullableUuidOption = notrequiredNullableUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum? RequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerEnumToJsonValue(RequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [JsonPropertyName("required_notnullable_enum_integer")] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum? RequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(RequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("required_notnullable_enum_integer_only")] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNotnullableEnumString + /// + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumStringEnum RequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumStringEnum? RequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNotnullableEnumStringEnumToJsonValue(RequiredNotnullableEnumStringEnum value) + { + if (value == RequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [JsonPropertyName("required_notnullable_enum_string")] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerEnum RequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerEnum? RequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerEnumToJsonValue(RequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [JsonPropertyName("required_nullable_enum_integer")] + public RequiredNullableEnumIntegerEnum? RequiredNullableEnumInteger { get; set; } + + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerOnlyEnumToJsonValue(RequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("required_nullable_enum_integer_only")] + public RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNullableEnumString + /// + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumStringEnum RequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumStringEnum? RequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == RequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [JsonPropertyName("required_nullable_enum_string")] + public RequiredNullableEnumStringEnum? RequiredNullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum NotrequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerEnumToJsonValue(NotrequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [JsonPropertyName("notrequired_notnullable_enum_integer")] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get { return this.NotrequiredNotnullableEnumIntegerOption; } set { this.NotrequiredNotnullableEnumIntegerOption = new(value); } } + + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum NotrequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_notnullable_enum_integer_only")] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get { return this.NotrequiredNotnullableEnumIntegerOnlyOption; } set { this.NotrequiredNotnullableEnumIntegerOnlyOption = new(value); } } + + /// + /// Defines NotrequiredNotnullableEnumString + /// + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum NotrequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNotnullableEnumStringEnumToJsonValue(NotrequiredNotnullableEnumStringEnum? value) + { + if (value == NotrequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [JsonPropertyName("notrequired_notnullable_enum_string")] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get { return this.NotrequiredNotnullableEnumStringOption; } set { this.NotrequiredNotnullableEnumStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get { return this.NotrequiredNotnullableOuterEnumDefaultValueOption; } set { this.NotrequiredNotnullableOuterEnumDefaultValueOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum NotrequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerEnumToJsonValue(NotrequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [JsonPropertyName("notrequired_nullable_enum_integer")] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get { return this.NotrequiredNullableEnumIntegerOption; } set { this.NotrequiredNullableEnumIntegerOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum NotrequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_nullable_enum_integer_only")] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get { return this.NotrequiredNullableEnumIntegerOnlyOption; } set { this.NotrequiredNullableEnumIntegerOnlyOption = new(value); } } + + /// + /// Defines NotrequiredNullableEnumString + /// + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumStringEnum NotrequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == NotrequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [JsonPropertyName("notrequired_nullable_enum_string")] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get { return this.NotrequiredNullableEnumStringOption; } set { this.NotrequiredNullableEnumStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get { return this.NotrequiredNullableOuterEnumDefaultValueOption; } set { this.NotrequiredNullableOuterEnumDefaultValueOption = new(value); } } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonPropertyName("required_not_nullable_date_prop")] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [JsonPropertyName("required_notnullable_array_of_string")] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [JsonPropertyName("required_notnullable_boolean_prop")] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [JsonPropertyName("required_notnullable_datetime_prop")] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [JsonPropertyName("required_notnullable_string_prop")] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_notnullable_uuid")] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [JsonPropertyName("required_notnullableinteger_prop")] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [JsonPropertyName("required_nullable_array_of_string")] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [JsonPropertyName("required_nullable_boolean_prop")] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonPropertyName("required_nullable_date_prop")] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [JsonPropertyName("required_nullable_datetime_prop")] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [JsonPropertyName("required_nullable_integer_prop")] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [JsonPropertyName("required_nullable_string_prop")] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_nullable_uuid")] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Used to track the state of NotRequiredNotnullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonPropertyName("not_required_notnullable_date_prop")] + public DateTime? NotRequiredNotnullableDateProp { get { return this. NotRequiredNotnullableDatePropOption; } set { this.NotRequiredNotnullableDatePropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNotnullableintegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableintegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [JsonPropertyName("not_required_notnullableinteger_prop")] + public int? NotRequiredNotnullableintegerProp { get { return this. NotRequiredNotnullableintegerPropOption; } set { this.NotRequiredNotnullableintegerPropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonPropertyName("not_required_nullable_date_prop")] + public DateTime? NotRequiredNullableDateProp { get { return this. NotRequiredNullableDatePropOption; } set { this.NotRequiredNullableDatePropOption = new(value); } } + + /// + /// Used to track the state of NotRequiredNullableIntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableIntegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [JsonPropertyName("not_required_nullable_integer_prop")] + public int? NotRequiredNullableIntegerProp { get { return this. NotRequiredNullableIntegerPropOption; } set { this.NotRequiredNullableIntegerPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNotnullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [JsonPropertyName("notrequired_notnullable_array_of_string")] + public List NotrequiredNotnullableArrayOfString { get { return this. NotrequiredNotnullableArrayOfStringOption; } set { this.NotrequiredNotnullableArrayOfStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [JsonPropertyName("notrequired_notnullable_boolean_prop")] + public bool? NotrequiredNotnullableBooleanProp { get { return this. NotrequiredNotnullableBooleanPropOption; } set { this.NotrequiredNotnullableBooleanPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [JsonPropertyName("notrequired_notnullable_datetime_prop")] + public DateTime? NotrequiredNotnullableDatetimeProp { get { return this. NotrequiredNotnullableDatetimePropOption; } set { this.NotrequiredNotnullableDatetimePropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [JsonPropertyName("notrequired_notnullable_string_prop")] + public string NotrequiredNotnullableStringProp { get { return this. NotrequiredNotnullableStringPropOption; } set { this.NotrequiredNotnullableStringPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_notnullable_uuid")] + public Guid? NotrequiredNotnullableUuid { get { return this. NotrequiredNotnullableUuidOption; } set { this.NotrequiredNotnullableUuidOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [JsonPropertyName("notrequired_nullable_array_of_string")] + public List NotrequiredNullableArrayOfString { get { return this. NotrequiredNullableArrayOfStringOption; } set { this.NotrequiredNullableArrayOfStringOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [JsonPropertyName("notrequired_nullable_boolean_prop")] + public bool? NotrequiredNullableBooleanProp { get { return this. NotrequiredNullableBooleanPropOption; } set { this.NotrequiredNullableBooleanPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [JsonPropertyName("notrequired_nullable_datetime_prop")] + public DateTime? NotrequiredNullableDatetimeProp { get { return this. NotrequiredNullableDatetimePropOption; } set { this.NotrequiredNullableDatetimePropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [JsonPropertyName("notrequired_nullable_string_prop")] + public string NotrequiredNullableStringProp { get { return this. NotrequiredNullableStringPropOption; } set { this.NotrequiredNullableStringPropOption = new(value); } } + + /// + /// Used to track the state of NotrequiredNullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_nullable_uuid")] + public Guid? NotrequiredNullableUuid { get { return this. NotrequiredNullableUuidOption; } set { this.NotrequiredNullableUuidOption = new(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize RequiredNotNullableDateProp + /// + public static string RequiredNotNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNotnullableDatetimeProp + /// + public static string RequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize RequiredNullableDateProp + /// + public static string RequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNullableDatetimeProp + /// + public static string RequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotRequiredNotnullableDateProp + /// + public static string NotRequiredNotnullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotRequiredNullableDateProp + /// + public static string NotRequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotrequiredNotnullableDatetimeProp + /// + public static string NotrequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotrequiredNullableDatetimeProp + /// + public static string NotrequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option requiredNotNullableDateProp = default; + Option> requiredNotnullableArrayOfString = default; + Option requiredNotnullableBooleanProp = default; + Option requiredNotnullableDatetimeProp = default; + Option requiredNotnullableEnumInteger = default; + Option requiredNotnullableEnumIntegerOnly = default; + Option requiredNotnullableEnumString = default; + Option requiredNotnullableOuterEnumDefaultValue = default; + Option requiredNotnullableStringProp = default; + Option requiredNotnullableUuid = default; + Option requiredNotnullableintegerProp = default; + Option> requiredNullableArrayOfString = default; + Option requiredNullableBooleanProp = default; + Option requiredNullableDateProp = default; + Option requiredNullableDatetimeProp = default; + Option requiredNullableEnumInteger = default; + Option requiredNullableEnumIntegerOnly = default; + Option requiredNullableEnumString = default; + Option requiredNullableIntegerProp = default; + Option requiredNullableOuterEnumDefaultValue = default; + Option requiredNullableStringProp = default; + Option requiredNullableUuid = default; + Option notRequiredNotnullableDateProp = default; + Option notRequiredNotnullableintegerProp = default; + Option notRequiredNullableDateProp = default; + Option notRequiredNullableIntegerProp = default; + Option> notrequiredNotnullableArrayOfString = default; + Option notrequiredNotnullableBooleanProp = default; + Option notrequiredNotnullableDatetimeProp = default; + Option notrequiredNotnullableEnumInteger = default; + Option notrequiredNotnullableEnumIntegerOnly = default; + Option notrequiredNotnullableEnumString = default; + Option notrequiredNotnullableOuterEnumDefaultValue = default; + Option notrequiredNotnullableStringProp = default; + Option notrequiredNotnullableUuid = default; + Option> notrequiredNullableArrayOfString = default; + Option notrequiredNullableBooleanProp = default; + Option notrequiredNullableDatetimeProp = default; + Option notrequiredNullableEnumInteger = default; + Option notrequiredNullableEnumIntegerOnly = default; + Option notrequiredNullableEnumString = default; + Option notrequiredNullableOuterEnumDefaultValue = default; + Option notrequiredNullableStringProp = default; + Option notrequiredNullableUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "required_not_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumInteger = new Option((RequiredClass.RequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumIntegerOnly = new Option((RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_string": + string requiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumStringRawValue != null) + requiredNotnullableEnumString = new Option(RequiredClass.RequiredNotnullableEnumStringEnumFromStringOrDefault(requiredNotnullableEnumStringRawValue)); + break; + case "required_notnullable_outerEnumDefaultValue": + string requiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableOuterEnumDefaultValueRawValue != null) + requiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "required_notnullable_string_prop": + requiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumInteger = new Option((RequiredClass.RequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumIntegerOnly = new Option((RequiredClass.RequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_string": + string requiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumStringRawValue != null) + requiredNullableEnumString = new Option(RequiredClass.RequiredNullableEnumStringEnumFromStringOrDefault(requiredNullableEnumStringRawValue)); + break; + case "required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_outerEnumDefaultValue": + string requiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + requiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNullableOuterEnumDefaultValueRawValue)); + break; + case "required_nullable_string_prop": + requiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "not_required_notnullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumInteger = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_string": + string notrequiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumStringRawValue != null) + notrequiredNotnullableEnumString = new Option(RequiredClass.NotrequiredNotnullableEnumStringEnumFromStringOrDefault(notrequiredNotnullableEnumStringRawValue)); + break; + case "notrequired_notnullable_outerEnumDefaultValue": + string notrequiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableOuterEnumDefaultValueRawValue != null) + notrequiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_notnullable_string_prop": + notrequiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "notrequired_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumInteger = new Option((RequiredClass.NotrequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_string": + string notrequiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumStringRawValue != null) + notrequiredNullableEnumString = new Option(RequiredClass.NotrequiredNullableEnumStringEnumFromStringOrDefault(notrequiredNullableEnumStringRawValue)); + break; + case "notrequired_nullable_outerEnumDefaultValue": + string notrequiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableOuterEnumDefaultValueRawValue != null) + notrequiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_nullable_string_prop": + notrequiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!requiredNotNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotNullableDateProp)); + + if (!requiredNotnullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableArrayOfString)); + + if (!requiredNotnullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableBooleanProp)); + + if (!requiredNotnullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableDatetimeProp)); + + if (!requiredNotnullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumInteger)); + + if (!requiredNotnullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumIntegerOnly)); + + if (!requiredNotnullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumString)); + + if (!requiredNotnullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableOuterEnumDefaultValue)); + + if (!requiredNotnullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableStringProp)); + + if (!requiredNotnullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableUuid)); + + if (!requiredNotnullableintegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableintegerProp)); + + if (!requiredNullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableArrayOfString)); + + if (!requiredNullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableBooleanProp)); + + if (!requiredNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDateProp)); + + if (!requiredNullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDatetimeProp)); + + if (!requiredNullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumInteger)); + + if (!requiredNullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumIntegerOnly)); + + if (!requiredNullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumString)); + + if (!requiredNullableIntegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableIntegerProp)); + + if (!requiredNullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableOuterEnumDefaultValue)); + + if (!requiredNullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableStringProp)); + + if (!requiredNullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableUuid)); + + if (requiredNotNullableDateProp.IsSet && requiredNotNullableDateProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotNullableDateProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableArrayOfString.IsSet && requiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableBooleanProp.IsSet && requiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableDatetimeProp.IsSet && requiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumInteger.IsSet && requiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumIntegerOnly.IsSet && requiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumString.IsSet && requiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableOuterEnumDefaultValue.IsSet && requiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableStringProp.IsSet && requiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableUuid.IsSet && requiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + return new RequiredClass(requiredNotNullableDateProp.Value.Value, requiredNotnullableArrayOfString.Value, requiredNotnullableBooleanProp.Value.Value, requiredNotnullableDatetimeProp.Value.Value, requiredNotnullableEnumInteger.Value.Value, requiredNotnullableEnumIntegerOnly.Value.Value, requiredNotnullableEnumString.Value.Value, requiredNotnullableOuterEnumDefaultValue.Value.Value, requiredNotnullableStringProp.Value, requiredNotnullableUuid.Value.Value, requiredNotnullableintegerProp.Value.Value, requiredNullableArrayOfString.Value, requiredNullableBooleanProp.Value, requiredNullableDateProp.Value, requiredNullableDatetimeProp.Value, requiredNullableEnumInteger.Value, requiredNullableEnumIntegerOnly.Value, requiredNullableEnumString.Value, requiredNullableIntegerProp.Value, requiredNullableOuterEnumDefaultValue.Value, requiredNullableStringProp.Value, requiredNullableUuid.Value, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + if (requiredClass.RequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.RequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat)); + + writer.WritePropertyName("required_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNotnullableArrayOfString, jsonSerializerOptions); + writer.WriteBoolean("required_notnullable_boolean_prop", requiredClass.RequiredNotnullableBooleanProp); + + writer.WriteString("required_notnullable_datetime_prop", requiredClass.RequiredNotnullableDatetimeProp.ToString(RequiredNotnullableDatetimePropFormat)); + + writer.WriteNumber("required_notnullable_enum_integer", RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNotnullableEnumInteger)); + + writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly)); + + var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString); + if (requiredNotnullableEnumStringRawValue != null) + writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue); + else + writer.WriteNull("required_notnullable_enum_string"); + + var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue); + writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue); + + writer.WriteString("required_notnullable_string_prop", requiredClass.RequiredNotnullableStringProp); + + writer.WriteString("required_notnullable_uuid", requiredClass.RequiredNotnullableUuid); + + writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp); + + if (requiredClass.RequiredNullableArrayOfString != null) + { + writer.WritePropertyName("required_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("required_nullable_array_of_string"); + if (requiredClass.RequiredNullableBooleanProp != null) + writer.WriteBoolean("required_nullable_boolean_prop", requiredClass.RequiredNullableBooleanProp.Value); + else + writer.WriteNull("required_nullable_boolean_prop"); + + if (requiredClass.RequiredNullableDateProp != null) + writer.WriteString("required_nullable_date_prop", requiredClass.RequiredNullableDateProp.Value.ToString(RequiredNullableDatePropFormat)); + else + writer.WriteNull("required_nullable_date_prop"); + + if (requiredClass.RequiredNullableDatetimeProp != null) + writer.WriteString("required_nullable_datetime_prop", requiredClass.RequiredNullableDatetimeProp.Value.ToString(RequiredNullableDatetimePropFormat)); + else + writer.WriteNull("required_nullable_datetime_prop"); + + if (requiredClass.RequiredNullableEnumInteger != null) + writer.WriteNumber("required_nullable_enum_integer", RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNullableEnumInteger.Value)); + else + writer.WriteNull("required_nullable_enum_integer"); + + if (requiredClass.RequiredNullableEnumIntegerOnly != null) + writer.WriteNumber("required_nullable_enum_integer_only", RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNullableEnumIntegerOnly.Value)); + else + writer.WriteNull("required_nullable_enum_integer_only"); + + var requiredNullableEnumStringRawValue = RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClass.RequiredNullableEnumString.Value); + if (requiredNullableEnumStringRawValue != null) + writer.WriteString("required_nullable_enum_string", requiredNullableEnumStringRawValue); + else + writer.WriteNull("required_nullable_enum_string"); + + if (requiredClass.RequiredNullableIntegerProp != null) + writer.WriteNumber("required_nullable_integer_prop", requiredClass.RequiredNullableIntegerProp.Value); + else + writer.WriteNull("required_nullable_integer_prop"); + + if (requiredClass.RequiredNullableOuterEnumDefaultValue == null) + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + else + { + var requiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNullableOuterEnumDefaultValue.Value); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + writer.WriteString("required_nullable_outerEnumDefaultValue", requiredNullableOuterEnumDefaultValueRawValue); + else + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + } + + if (requiredClass.RequiredNullableStringProp != null) + writer.WriteString("required_nullable_string_prop", requiredClass.RequiredNullableStringProp); + else + writer.WriteNull("required_nullable_string_prop"); + + if (requiredClass.RequiredNullableUuid != null) + writer.WriteString("required_nullable_uuid", requiredClass.RequiredNullableUuid.Value); + else + writer.WriteNull("required_nullable_uuid"); + + if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet) + writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value.Value.ToString(NotRequiredNotnullableDatePropFormat)); + + if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet) + writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value.Value); + + if (requiredClass.NotRequiredNullableDatePropOption.IsSet) + if (requiredClass.NotRequiredNullableDatePropOption.Value != null) + writer.WriteString("not_required_nullable_date_prop", requiredClass.NotRequiredNullableDatePropOption.Value.Value.ToString(NotRequiredNullableDatePropFormat)); + else + writer.WriteNull("not_required_nullable_date_prop"); + + if (requiredClass.NotRequiredNullableIntegerPropOption.IsSet) + if (requiredClass.NotRequiredNullableIntegerPropOption.Value != null) + writer.WriteNumber("not_required_nullable_integer_prop", requiredClass.NotRequiredNullableIntegerPropOption.Value.Value); + else + writer.WriteNull("not_required_nullable_integer_prop"); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet) + { + writer.WritePropertyName("notrequired_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions); + } + if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet) + writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value.Value); + + if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet) + writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value.Value.ToString(NotrequiredNotnullableDatetimePropFormat)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value.Value)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value.Value)); + + var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value.Value); + if (notrequiredNotnullableEnumStringRawValue != null) + writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue); + else + writer.WriteNull("notrequired_notnullable_enum_string"); + + if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet) + { + var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue.Value); + writer.WriteString("notrequired_notnullable_outerEnumDefaultValue", notrequiredNotnullableOuterEnumDefaultValueRawValue); + } + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet) + writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp); + + if (requiredClass.NotrequiredNotnullableUuidOption.IsSet) + writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value.Value); + + if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet) + if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null) + { + writer.WritePropertyName("notrequired_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("notrequired_nullable_array_of_string"); + if (requiredClass.NotrequiredNullableBooleanPropOption.IsSet) + if (requiredClass.NotrequiredNullableBooleanPropOption.Value != null) + writer.WriteBoolean("notrequired_nullable_boolean_prop", requiredClass.NotrequiredNullableBooleanPropOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_boolean_prop"); + + if (requiredClass.NotrequiredNullableDatetimePropOption.IsSet) + if (requiredClass.NotrequiredNullableDatetimePropOption.Value != null) + writer.WriteString("notrequired_nullable_datetime_prop", requiredClass.NotrequiredNullableDatetimePropOption.Value.Value.ToString(NotrequiredNullableDatetimePropFormat)); + else + writer.WriteNull("notrequired_nullable_datetime_prop"); + + if (requiredClass.NotrequiredNullableEnumIntegerOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer", RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOption.Value.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer"); + + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer_only", RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer_only"); + + var notrequiredNullableEnumStringRawValue = RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNullableEnumStringOption.Value.Value); + if (notrequiredNullableEnumStringRawValue != null) + writer.WriteString("notrequired_nullable_enum_string", notrequiredNullableEnumStringRawValue); + else + writer.WriteNull("notrequired_nullable_enum_string"); + + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.IsSet) + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value != null) + { + var notrequiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value.Value); + writer.WriteString("notrequired_nullable_outerEnumDefaultValue", notrequiredNullableOuterEnumDefaultValueRawValue); + } + else + writer.WriteNull("notrequired_nullable_outerEnumDefaultValue"); + if (requiredClass.NotrequiredNullableStringPropOption.IsSet) + if (requiredClass.NotrequiredNullableStringPropOption.Value != null) + writer.WriteString("notrequired_nullable_string_prop", requiredClass.NotrequiredNullableStringProp); + else + writer.WriteNull("notrequired_nullable_string_prop"); + + if (requiredClass.NotrequiredNullableUuidOption.IsSet) + if (requiredClass.NotrequiredNullableUuidOption.Value != null) + writer.WriteString("notrequired_nullable_uuid", requiredClass.NotrequiredNullableUuidOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs index 86e7223ee95..604c4abd4e0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varReturn [JsonConstructor] - public Return(int varReturn) + public Return(Option varReturn = default) { - VarReturn = varReturn; + VarReturnOption = varReturn; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarReturn + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarReturnOption { get; private set; } + /// /// Gets or Sets VarReturn /// [JsonPropertyName("return")] - public int VarReturn { get; set; } + public int? VarReturn { get { return this. VarReturnOption; } set { this.VarReturnOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varReturn = default; + Option varReturn = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "return": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varReturn = utf8JsonReader.GetInt32(); + varReturn = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -127,10 +135,10 @@ namespace Org.OpenAPITools.Model } } - if (varReturn == null) - throw new ArgumentNullException(nameof(varReturn), "Property is required for class Return."); + if (varReturn.IsSet && varReturn.Value == null) + throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return."); - return new Return(varReturn.Value); + return new Return(varReturn); } /// @@ -157,7 +165,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("return", varReturn.VarReturn); + if (varReturn.VarReturnOption.IsSet) + writer.WriteNumber("return", varReturn.VarReturnOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 86effcebe7a..b5b205f6991 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// role /// roleUuid [JsonConstructor] - public RolesReportsHash(RolesReportsHashRole role, Guid roleUuid) + public RolesReportsHash(Option role = default, Option roleUuid = default) { - Role = role; - RoleUuid = roleUuid; + RoleOption = role; + RoleUuidOption = roleUuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Role + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleOption { get; private set; } + /// /// Gets or Sets Role /// [JsonPropertyName("role")] - public RolesReportsHashRole Role { get; set; } + public RolesReportsHashRole Role { get { return this. RoleOption; } set { this.RoleOption = new(value); } } + + /// + /// Used to track the state of RoleUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleUuidOption { get; private set; } /// /// Gets or Sets RoleUuid /// [JsonPropertyName("role_uuid")] - public Guid RoleUuid { get; set; } + public Guid? RoleUuid { get { return this. RoleUuidOption; } set { this.RoleUuidOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - RolesReportsHashRole role = default; - Guid? roleUuid = default; + Option role = default; + Option roleUuid = default; while (utf8JsonReader.Read()) { @@ -129,11 +144,11 @@ namespace Org.OpenAPITools.Model { case "role": if (utf8JsonReader.TokenType != JsonTokenType.Null) - role = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + role = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "role_uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - roleUuid = utf8JsonReader.GetGuid(); + roleUuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -141,13 +156,13 @@ namespace Org.OpenAPITools.Model } } - if (role == null) - throw new ArgumentNullException(nameof(role), "Property is required for class RolesReportsHash."); + if (role.IsSet && role.Value == null) + throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash."); - if (roleUuid == null) - throw new ArgumentNullException(nameof(roleUuid), "Property is required for class RolesReportsHash."); + if (roleUuid.IsSet && roleUuid.Value == null) + throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash."); - return new RolesReportsHash(role, roleUuid.Value); + return new RolesReportsHash(role, roleUuid); } /// @@ -174,9 +189,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("role"); - JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); - writer.WriteString("role_uuid", rolesReportsHash.RoleUuid); + if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null) + throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash."); + + if (rolesReportsHash.RoleOption.IsSet) + { + writer.WritePropertyName("role"); + JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); + } + if (rolesReportsHash.RoleUuidOption.IsSet) + writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index c7002b77b2e..7fa32c72ce2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// name [JsonConstructor] - public RolesReportsHashRole(string name) + public RolesReportsHashRole(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class RolesReportsHashRole."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole."); return new RolesReportsHashRole(name); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", rolesReportsHashRole.Name); + if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null) + throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole."); + + if (rolesReportsHashRole.NameOption.IsSet) + writer.WriteString("name", rolesReportsHashRole.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 4151ead57df..52a8e0d69c6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; - string triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ScaleneTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class ScaleneTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(triangleType)); - return new ScaleneTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ScaleneTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class ScaleneTriangle."); + + return new ScaleneTriangle(shapeType.Value, triangleType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (scaleneTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle."); + + if (scaleneTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle."); + writer.WriteString("shapeType", scaleneTriangle.ShapeType); + writer.WriteString("triangleType", scaleneTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs index dae0ef02f96..575069f242e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; Quadrilateral quadrilateral = null; Triangle triangle = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class Shape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class Shape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType); + return new Shape(quadrilateral, shapeType.Value); if (triangle != null) - return new Shape(triangle, shapeType); + return new Shape(triangle, shapeType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { + if (shape.ShapeType == null) + throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); + writer.WriteString("shapeType", shape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs index de32fa535ae..5bd364cc6a4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeInterface."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeInterface.", nameof(shapeType)); - return new ShapeInterface(shapeType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeInterface."); + + return new ShapeInterface(shapeType.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) { + if (shapeInterface.ShapeType == null) + throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface."); + writer.WriteString("shapeType", shapeInterface.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 955461e1202..a26dab03423 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; Quadrilateral quadrilateral = null; Triangle triangle = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeOrNull."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType); + return new ShapeOrNull(quadrilateral, shapeType.Value); if (triangle != null) - return new ShapeOrNull(triangle, shapeType); + return new ShapeOrNull(triangle, shapeType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { + if (shapeOrNull.ShapeType == null) + throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); + writer.WriteString("shapeType", shapeOrNull.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 7f0b8a306f8..a00a87e2efa 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; - string shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class SimpleQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class SimpleQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(shapeType)); - return new SimpleQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class SimpleQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class SimpleQuadrilateral."); + + return new SimpleQuadrilateral(quadrilateralType.Value, shapeType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (simpleQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral."); + + if (simpleQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral."); + writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", simpleQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs index 8328ad3ee12..419b6a022a8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// varSpecialModelName /// specialPropertyName [JsonConstructor] - public SpecialModelName(string varSpecialModelName, long specialPropertyName) + public SpecialModelName(Option varSpecialModelName = default, Option specialPropertyName = default) { - VarSpecialModelName = varSpecialModelName; - SpecialPropertyName = specialPropertyName; + VarSpecialModelNameOption = varSpecialModelName; + SpecialPropertyNameOption = specialPropertyName; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarSpecialModelName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarSpecialModelNameOption { get; private set; } + /// /// Gets or Sets VarSpecialModelName /// [JsonPropertyName("_special_model.name_")] - public string VarSpecialModelName { get; set; } + public string VarSpecialModelName { get { return this. VarSpecialModelNameOption; } set { this.VarSpecialModelNameOption = new(value); } } + + /// + /// Used to track the state of SpecialPropertyName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SpecialPropertyNameOption { get; private set; } /// /// Gets or Sets SpecialPropertyName /// [JsonPropertyName("$special[property.name]")] - public long SpecialPropertyName { get; set; } + public long? SpecialPropertyName { get { return this. SpecialPropertyNameOption; } set { this.SpecialPropertyNameOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varSpecialModelName = default; - long? specialPropertyName = default; + Option varSpecialModelName = default; + Option specialPropertyName = default; while (utf8JsonReader.Read()) { @@ -128,11 +143,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "_special_model.name_": - varSpecialModelName = utf8JsonReader.GetString(); + varSpecialModelName = new Option(utf8JsonReader.GetString()); break; case "$special[property.name]": if (utf8JsonReader.TokenType != JsonTokenType.Null) - specialPropertyName = utf8JsonReader.GetInt64(); + specialPropertyName = new Option(utf8JsonReader.GetInt64()); break; default: break; @@ -140,13 +155,13 @@ namespace Org.OpenAPITools.Model } } - if (varSpecialModelName == null) - throw new ArgumentNullException(nameof(varSpecialModelName), "Property is required for class SpecialModelName."); + if (varSpecialModelName.IsSet && varSpecialModelName.Value == null) + throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName."); - if (specialPropertyName == null) - throw new ArgumentNullException(nameof(specialPropertyName), "Property is required for class SpecialModelName."); + if (specialPropertyName.IsSet && specialPropertyName.Value == null) + throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName."); - return new SpecialModelName(varSpecialModelName, specialPropertyName.Value); + return new SpecialModelName(varSpecialModelName, specialPropertyName); } /// @@ -173,8 +188,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); - writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyName); + if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null) + throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName."); + + if (specialModelName.VarSpecialModelNameOption.IsSet) + writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); + + if (specialModelName.SpecialPropertyNameOption.IsSet) + writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs index 6524d75edcf..418d24e6f1c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// id /// name [JsonConstructor] - public Tag(long id, string name) + public Tag(Option id = default, Option name = default) { - Id = id; - Name = name; + IdOption = id; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -129,10 +144,10 @@ namespace Org.OpenAPITools.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -140,13 +155,13 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Tag."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Tag."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag."); - return new Tag(id.Value, name); + return new Tag(id, name); } /// @@ -173,8 +188,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", tag.Id); - writer.WriteString("name", tag.Name); + if (tag.NameOption.IsSet && tag.Name == null) + throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag."); + + if (tag.IdOption.IsSet) + writer.WriteNumber("id", tag.IdOption.Value.Value); + + if (tag.NameOption.IsSet) + writer.WriteString("name", tag.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index b2e110e79f6..4a89db3e4ee 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// value [JsonConstructor] - public TestCollectionEndingWithWordList(string value) + public TestCollectionEndingWithWordList(Option value = default) { - Value = value; + ValueOption = value; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Value + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ValueOption { get; private set; } + /// /// Gets or Sets Value /// [JsonPropertyName("value")] - public string Value { get; set; } + public string Value { get { return this. ValueOption; } set { this.ValueOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string value = default; + Option value = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "value": - value = utf8JsonReader.GetString(); + value = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (value == null) - throw new ArgumentNullException(nameof(value), "Property is required for class TestCollectionEndingWithWordList."); + if (value.IsSet && value.Value == null) + throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList."); return new TestCollectionEndingWithWordList(value); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("value", testCollectionEndingWithWordList.Value); + if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList."); + + if (testCollectionEndingWithWordList.ValueOption.IsSet) + writer.WriteString("value", testCollectionEndingWithWordList.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 8753edfd9f3..7479f313811 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// testCollectionEndingWithWordList [JsonConstructor] - public TestCollectionEndingWithWordListObject(List testCollectionEndingWithWordList) + public TestCollectionEndingWithWordListObject(Option> testCollectionEndingWithWordList = default) { - TestCollectionEndingWithWordList = testCollectionEndingWithWordList; + TestCollectionEndingWithWordListOption = testCollectionEndingWithWordList; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of TestCollectionEndingWithWordList + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TestCollectionEndingWithWordListOption { get; private set; } + /// /// Gets or Sets TestCollectionEndingWithWordList /// [JsonPropertyName("TestCollectionEndingWithWordList")] - public List TestCollectionEndingWithWordList { get; set; } + public List TestCollectionEndingWithWordList { get { return this. TestCollectionEndingWithWordListOption; } set { this.TestCollectionEndingWithWordListOption = new(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List testCollectionEndingWithWordList = default; + Option> testCollectionEndingWithWordList = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "TestCollectionEndingWithWordList": if (utf8JsonReader.TokenType != JsonTokenType.Null) - testCollectionEndingWithWordList = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + testCollectionEndingWithWordList = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (testCollectionEndingWithWordList == null) - throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject."); return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("TestCollectionEndingWithWordList"); - JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet) + { + writer.WritePropertyName("TestCollectionEndingWithWordList"); + JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index 139e92b4c6a..60971454262 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// someProperty [JsonConstructor] - public TestInlineFreeformAdditionalPropertiesRequest(string someProperty) : base() + public TestInlineFreeformAdditionalPropertiesRequest(Option someProperty = default) : base() { - SomeProperty = someProperty; + SomePropertyOption = someProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SomeProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomePropertyOption { get; private set; } + /// /// Gets or Sets SomeProperty /// [JsonPropertyName("someProperty")] - public string SomeProperty { get; set; } + public string SomeProperty { get { return this. SomePropertyOption; } set { this.SomePropertyOption = new(value); } } /// /// Gets or Sets additional properties @@ -111,7 +119,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string someProperty = default; + Option someProperty = default; while (utf8JsonReader.Read()) { @@ -129,7 +137,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "someProperty": - someProperty = utf8JsonReader.GetString(); + someProperty = new Option(utf8JsonReader.GetString()); break; default: break; @@ -137,8 +145,8 @@ namespace Org.OpenAPITools.Model } } - if (someProperty == null) - throw new ArgumentNullException(nameof(someProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + if (someProperty.IsSet && someProperty.Value == null) + throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest."); return new TestInlineFreeformAdditionalPropertiesRequest(someProperty); } @@ -167,7 +175,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet) + writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs index 814316961f9..737124e080b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -150,7 +151,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string triangleType = default; + Option triangleType = default; EquilateralTriangle equilateralTriangle = null; IsoscelesTriangle isoscelesTriangle = null; @@ -207,7 +208,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -215,17 +216,20 @@ namespace Org.OpenAPITools.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class Triangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class Triangle.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType); + return new Triangle(equilateralTriangle, triangleType.Value); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType); + return new Triangle(isoscelesTriangle, triangleType.Value); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType); + return new Triangle(scaleneTriangle, triangleType.Value); throw new JsonException(); } @@ -269,6 +273,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { + if (triangle.TriangleType == null) + throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); + writer.WriteString("triangleType", triangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs index 6bd1e4303a7..270c598de61 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string triangleType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class TriangleInterface."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class TriangleInterface.", nameof(triangleType)); - return new TriangleInterface(triangleType); + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class TriangleInterface."); + + return new TriangleInterface(triangleType.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) { + if (triangleInterface.TriangleType == null) + throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface."); + writer.WriteString("triangleType", triangleInterface.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs index ea527b94ec0..b0991a50e48 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,114 +32,198 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// email /// firstName /// id /// lastName /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// password /// phone /// User Status /// username - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonConstructor] - public User(string email, string firstName, long id, string lastName, Object objectWithNoDeclaredProps, string password, string phone, int userStatus, string username, Object anyTypeProp = default, Object anyTypePropNullable = default, Object objectWithNoDeclaredPropsNullable = default) + public User(Option anyTypeProp = default, Option anyTypePropNullable = default, Option email = default, Option firstName = default, Option id = default, Option lastName = default, Option objectWithNoDeclaredProps = default, Option objectWithNoDeclaredPropsNullable = default, Option password = default, Option phone = default, Option userStatus = default, Option username = default) { - Email = email; - FirstName = firstName; - Id = id; - LastName = lastName; - ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - Password = password; - Phone = phone; - UserStatus = userStatus; - Username = username; - AnyTypeProp = anyTypeProp; - AnyTypePropNullable = anyTypePropNullable; - ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypePropOption = anyTypeProp; + AnyTypePropNullableOption = anyTypePropNullable; + EmailOption = email; + FirstNameOption = firstName; + IdOption = id; + LastNameOption = lastName; + ObjectWithNoDeclaredPropsOption = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullableOption = objectWithNoDeclaredPropsNullable; + PasswordOption = password; + PhoneOption = phone; + UserStatusOption = userStatus; + UsernameOption = username; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets Email + /// Used to track the state of AnyTypeProp /// - [JsonPropertyName("email")] - public string Email { get; set; } - - /// - /// Gets or Sets FirstName - /// - [JsonPropertyName("firstName")] - public string FirstName { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } - - /// - /// Gets or Sets LastName - /// - [JsonPropertyName("lastName")] - public string LastName { get; set; } - - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [JsonPropertyName("objectWithNoDeclaredProps")] - public Object ObjectWithNoDeclaredProps { get; set; } - - /// - /// Gets or Sets Password - /// - [JsonPropertyName("password")] - public string Password { get; set; } - - /// - /// Gets or Sets Phone - /// - [JsonPropertyName("phone")] - public string Phone { get; set; } - - /// - /// User Status - /// - /// User Status - [JsonPropertyName("userStatus")] - public int UserStatus { get; set; } - - /// - /// Gets or Sets Username - /// - [JsonPropertyName("username")] - public string Username { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 [JsonPropertyName("anyTypeProp")] - public Object AnyTypeProp { get; set; } + public Object AnyTypeProp { get { return this. AnyTypePropOption; } set { this.AnyTypePropOption = new(value); } } + + /// + /// Used to track the state of AnyTypePropNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropNullableOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. [JsonPropertyName("anyTypePropNullable")] - public Object AnyTypePropNullable { get; set; } + public Object AnyTypePropNullable { get { return this. AnyTypePropNullableOption; } set { this.AnyTypePropNullableOption = new(value); } } + + /// + /// Used to track the state of Email + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmailOption { get; private set; } + + /// + /// Gets or Sets Email + /// + [JsonPropertyName("email")] + public string Email { get { return this. EmailOption; } set { this.EmailOption = new(value); } } + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string FirstName { get { return this. FirstNameOption; } set { this.FirstNameOption = new(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string LastName { get { return this. LastNameOption; } set { this.LastNameOption = new(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredProps + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsOption { get; private set; } + + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + [JsonPropertyName("objectWithNoDeclaredProps")] + public Object ObjectWithNoDeclaredProps { get { return this. ObjectWithNoDeclaredPropsOption; } set { this.ObjectWithNoDeclaredPropsOption = new(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredPropsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsNullableOption { get; private set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonPropertyName("objectWithNoDeclaredPropsNullable")] - public Object ObjectWithNoDeclaredPropsNullable { get; set; } + public Object ObjectWithNoDeclaredPropsNullable { get { return this. ObjectWithNoDeclaredPropsNullableOption; } set { this.ObjectWithNoDeclaredPropsNullableOption = new(value); } } + + /// + /// Used to track the state of Password + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PasswordOption { get; private set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string Password { get { return this. PasswordOption; } set { this.PasswordOption = new(value); } } + + /// + /// Used to track the state of Phone + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PhoneOption { get; private set; } + + /// + /// Gets or Sets Phone + /// + [JsonPropertyName("phone")] + public string Phone { get { return this. PhoneOption; } set { this.PhoneOption = new(value); } } + + /// + /// Used to track the state of UserStatus + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UserStatusOption { get; private set; } + + /// + /// User Status + /// + /// User Status + [JsonPropertyName("userStatus")] + public int? UserStatus { get { return this. UserStatusOption; } set { this.UserStatusOption = new(value); } } + + /// + /// Used to track the state of Username + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UsernameOption { get; private set; } + + /// + /// Gets or Sets Username + /// + [JsonPropertyName("username")] + public string Username { get { return this. UsernameOption; } set { this.UsernameOption = new(value); } } /// /// Gets or Sets additional properties @@ -154,18 +239,18 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class User {\n"); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); sb.Append(" Email: ").Append(Email).Append("\n"); sb.Append(" FirstName: ").Append(FirstName).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" LastName: ").Append(LastName).Append("\n"); sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" Phone: ").Append(Phone).Append("\n"); sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); sb.Append(" Username: ").Append(Username).Append("\n"); - sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); - sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); - sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -204,18 +289,18 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string email = default; - string firstName = default; - long? id = default; - string lastName = default; - Object objectWithNoDeclaredProps = default; - string password = default; - string phone = default; - int? userStatus = default; - string username = default; - Object anyTypeProp = default; - Object anyTypePropNullable = default; - Object objectWithNoDeclaredPropsNullable = default; + Option anyTypeProp = default; + Option anyTypePropNullable = default; + Option email = default; + Option firstName = default; + Option id = default; + Option lastName = default; + Option objectWithNoDeclaredProps = default; + Option objectWithNoDeclaredPropsNullable = default; + Option password = default; + Option phone = default; + Option userStatus = default; + Option username = default; while (utf8JsonReader.Read()) { @@ -232,47 +317,47 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "email": - email = utf8JsonReader.GetString(); - break; - case "firstName": - firstName = utf8JsonReader.GetString(); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; - case "lastName": - lastName = utf8JsonReader.GetString(); - break; - case "objectWithNoDeclaredProps": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredProps = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "password": - password = utf8JsonReader.GetString(); - break; - case "phone": - phone = utf8JsonReader.GetString(); - break; - case "userStatus": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - userStatus = utf8JsonReader.GetInt32(); - break; - case "username": - username = utf8JsonReader.GetString(); - break; case "anyTypeProp": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "anyTypePropNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypePropNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypePropNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "email": + email = new Option(utf8JsonReader.GetString()); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "objectWithNoDeclaredProps": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredProps = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "objectWithNoDeclaredPropsNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredPropsNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + objectWithNoDeclaredPropsNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "password": + password = new Option(utf8JsonReader.GetString()); + break; + case "phone": + phone = new Option(utf8JsonReader.GetString()); + break; + case "userStatus": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + userStatus = new Option(utf8JsonReader.GetInt32()); + break; + case "username": + username = new Option(utf8JsonReader.GetString()); break; default: break; @@ -280,34 +365,34 @@ namespace Org.OpenAPITools.Model } } - if (email == null) - throw new ArgumentNullException(nameof(email), "Property is required for class User."); + if (email.IsSet && email.Value == null) + throw new ArgumentNullException(nameof(email), "Property is not nullable for class User."); - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class User."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class User."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class User."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class User."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User."); - if (objectWithNoDeclaredProps == null) - throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is required for class User."); + if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null) + throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class User."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class User."); - if (phone == null) - throw new ArgumentNullException(nameof(phone), "Property is required for class User."); + if (phone.IsSet && phone.Value == null) + throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User."); - if (userStatus == null) - throw new ArgumentNullException(nameof(userStatus), "Property is required for class User."); + if (userStatus.IsSet && userStatus.Value == null) + throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User."); - if (username == null) - throw new ArgumentNullException(nameof(username), "Property is required for class User."); + if (username.IsSet && username.Value == null) + throw new ArgumentNullException(nameof(username), "Property is not nullable for class User."); - return new User(email, firstName, id.Value, lastName, objectWithNoDeclaredProps, password, phone, userStatus.Value, username, anyTypeProp, anyTypePropNullable, objectWithNoDeclaredPropsNullable); + return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username); } /// @@ -334,22 +419,79 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("email", user.Email); - writer.WriteString("firstName", user.FirstName); - writer.WriteNumber("id", user.Id); - writer.WriteString("lastName", user.LastName); - writer.WritePropertyName("objectWithNoDeclaredProps"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); - writer.WriteString("password", user.Password); - writer.WriteString("phone", user.Phone); - writer.WriteNumber("userStatus", user.UserStatus); - writer.WriteString("username", user.Username); - writer.WritePropertyName("anyTypeProp"); - JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); - writer.WritePropertyName("anyTypePropNullable"); - JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); - writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + if (user.EmailOption.IsSet && user.Email == null) + throw new ArgumentNullException(nameof(user.Email), "Property is required for class User."); + + if (user.FirstNameOption.IsSet && user.FirstName == null) + throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User."); + + if (user.LastNameOption.IsSet && user.LastName == null) + throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User."); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null) + throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User."); + + if (user.PasswordOption.IsSet && user.Password == null) + throw new ArgumentNullException(nameof(user.Password), "Property is required for class User."); + + if (user.PhoneOption.IsSet && user.Phone == null) + throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User."); + + if (user.UsernameOption.IsSet && user.Username == null) + throw new ArgumentNullException(nameof(user.Username), "Property is required for class User."); + + if (user.AnyTypePropOption.IsSet) + if (user.AnyTypePropOption.Value != null) + { + writer.WritePropertyName("anyTypeProp"); + JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypeProp"); + if (user.AnyTypePropNullableOption.IsSet) + if (user.AnyTypePropNullableOption.Value != null) + { + writer.WritePropertyName("anyTypePropNullable"); + JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypePropNullable"); + if (user.EmailOption.IsSet) + writer.WriteString("email", user.Email); + + if (user.FirstNameOption.IsSet) + writer.WriteString("firstName", user.FirstName); + + if (user.IdOption.IsSet) + writer.WriteNumber("id", user.IdOption.Value.Value); + + if (user.LastNameOption.IsSet) + writer.WriteString("lastName", user.LastName); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet) + { + writer.WritePropertyName("objectWithNoDeclaredProps"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); + } + if (user.ObjectWithNoDeclaredPropsNullableOption.IsSet) + if (user.ObjectWithNoDeclaredPropsNullableOption.Value != null) + { + writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + } + else + writer.WriteNull("objectWithNoDeclaredPropsNullable"); + if (user.PasswordOption.IsSet) + writer.WriteString("password", user.Password); + + if (user.PhoneOption.IsSet) + writer.WriteString("phone", user.Phone); + + if (user.UserStatusOption.IsSet) + writer.WriteNumber("userStatus", user.UserStatusOption.Value.Value); + + if (user.UsernameOption.IsSet) + writer.WriteString("username", user.Username); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs index e633a5c92cf..1759ab6d1cc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,11 +36,11 @@ namespace Org.OpenAPITools.Model /// hasBaleen /// hasTeeth [JsonConstructor] - public Whale(string className, bool hasBaleen, bool hasTeeth) + public Whale(string className, Option hasBaleen = default, Option hasTeeth = default) { ClassName = className; - HasBaleen = hasBaleen; - HasTeeth = hasTeeth; + HasBaleenOption = hasBaleen; + HasTeethOption = hasTeeth; OnCreated(); } @@ -51,17 +52,31 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of HasBaleen + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasBaleenOption { get; private set; } + /// /// Gets or Sets HasBaleen /// [JsonPropertyName("hasBaleen")] - public bool HasBaleen { get; set; } + public bool? HasBaleen { get { return this. HasBaleenOption; } set { this.HasBaleenOption = new(value); } } + + /// + /// Used to track the state of HasTeeth + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasTeethOption { get; private set; } /// /// Gets or Sets HasTeeth /// [JsonPropertyName("hasTeeth")] - public bool HasTeeth { get; set; } + public bool? HasTeeth { get { return this. HasTeethOption; } set { this.HasTeethOption = new(value); } } /// /// Gets or Sets additional properties @@ -118,9 +133,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - bool? hasBaleen = default; - bool? hasTeeth = default; + Option className = default; + Option hasBaleen = default; + Option hasTeeth = default; while (utf8JsonReader.Read()) { @@ -138,15 +153,15 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; case "hasBaleen": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasBaleen = utf8JsonReader.GetBoolean(); + hasBaleen = new Option(utf8JsonReader.GetBoolean()); break; case "hasTeeth": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasTeeth = utf8JsonReader.GetBoolean(); + hasTeeth = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -154,16 +169,19 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Whale."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Whale.", nameof(className)); - if (hasBaleen == null) - throw new ArgumentNullException(nameof(hasBaleen), "Property is required for class Whale."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale."); - if (hasTeeth == null) - throw new ArgumentNullException(nameof(hasTeeth), "Property is required for class Whale."); + if (hasBaleen.IsSet && hasBaleen.Value == null) + throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale."); - return new Whale(className, hasBaleen.Value, hasTeeth.Value); + if (hasTeeth.IsSet && hasTeeth.Value == null) + throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale."); + + return new Whale(className.Value, hasBaleen, hasTeeth); } /// @@ -190,9 +208,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) { + if (whale.ClassName == null) + throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale."); + writer.WriteString("className", whale.ClassName); - writer.WriteBoolean("hasBaleen", whale.HasBaleen); - writer.WriteBoolean("hasTeeth", whale.HasTeeth); + + if (whale.HasBaleenOption.IsSet) + writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value.Value); + + if (whale.HasTeethOption.IsSet) + writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs index 52135d8a3c5..01397462445 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// className /// type [JsonConstructor] - public Zebra(string className, TypeEnum type) : base() + public Zebra(string className, Option type = default) : base() { ClassName = className; - Type = type; + TypeOption = type; OnCreated(); } @@ -109,9 +110,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string TypeEnumToJsonValue(TypeEnum value) + public static string TypeEnumToJsonValue(TypeEnum? value) { - if (value == TypeEnum.Plains) return "plains"; @@ -124,11 +124,18 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public TypeEnum Type { get; set; } + public TypeEnum? Type { get { return this.TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets ClassName @@ -201,8 +208,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - Zebra.TypeEnum? type = default; + Option className = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -220,13 +227,12 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; case "type": string typeRawValue = utf8JsonReader.GetString(); - type = typeRawValue == null - ? null - : Zebra.TypeEnumFromStringOrDefault(typeRawValue); + if (typeRawValue != null) + type = new Option(Zebra.TypeEnumFromStringOrDefault(typeRawValue)); break; default: break; @@ -234,13 +240,16 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Zebra."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Zebra.", nameof(className)); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Zebra."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra."); - return new Zebra(className, type.Value); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra."); + + return new Zebra(className.Value, type); } /// @@ -267,9 +276,12 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) { + if (zebra.ClassName == null) + throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra."); + writer.WriteString("className", zebra.ClassName); - var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.Type); + var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value.Value); if (typeRawValue != null) writer.WriteString("type", typeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs index 20e184f02b2..34a044fb8b1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 7e5f3cdafcc..3aa6583fff6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,9 +34,9 @@ namespace Org.OpenAPITools.Model /// /// zeroBasedEnum [JsonConstructor] - public ZeroBasedEnumClass(ZeroBasedEnumEnum zeroBasedEnum) + public ZeroBasedEnumClass(Option zeroBasedEnum = default) { - ZeroBasedEnum = zeroBasedEnum; + ZeroBasedEnumOption = zeroBasedEnum; OnCreated(); } @@ -96,9 +97,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum value) + public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum? value) { - if (value == ZeroBasedEnumEnum.Unknown) return "unknown"; @@ -108,11 +108,18 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of ZeroBasedEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ZeroBasedEnumOption { get; private set; } + /// /// Gets or Sets ZeroBasedEnum /// [JsonPropertyName("ZeroBasedEnum")] - public ZeroBasedEnumEnum ZeroBasedEnum { get; set; } + public ZeroBasedEnumEnum? ZeroBasedEnum { get { return this.ZeroBasedEnumOption; } set { this.ZeroBasedEnumOption = new(value); } } /// /// Gets or Sets additional properties @@ -167,7 +174,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - ZeroBasedEnumClass.ZeroBasedEnumEnum? zeroBasedEnum = default; + Option zeroBasedEnum = default; while (utf8JsonReader.Read()) { @@ -186,9 +193,8 @@ namespace Org.OpenAPITools.Model { case "ZeroBasedEnum": string zeroBasedEnumRawValue = utf8JsonReader.GetString(); - zeroBasedEnum = zeroBasedEnumRawValue == null - ? null - : ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue); + if (zeroBasedEnumRawValue != null) + zeroBasedEnum = new Option(ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue)); break; default: break; @@ -196,10 +202,10 @@ namespace Org.OpenAPITools.Model } } - if (zeroBasedEnum == null) - throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is required for class ZeroBasedEnumClass."); + if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null) + throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass."); - return new ZeroBasedEnumClass(zeroBasedEnum.Value); + return new ZeroBasedEnumClass(zeroBasedEnum); } /// @@ -226,8 +232,7 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) { - - var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnum); + var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value); if (zeroBasedEnumRawValue != null) writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/Option.cs index 663aecff33e..b3419229d65 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/Option.cs @@ -37,5 +37,17 @@ namespace Org.OpenAPITools.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Adult.cs index 93bfff98acc..8367b1a6417 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Adult.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Adult.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,19 +39,26 @@ namespace Org.OpenAPITools.Model /// lastName /// type [JsonConstructor] - public Adult(List children, string firstName, string lastName, string type) : base(firstName, lastName, type) + public Adult(Option?> children = default, Option firstName = default, Option lastName = default, Option type = default) : base(firstName, lastName, type) { - Children = children; + ChildrenOption = children; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Children + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option?> ChildrenOption { get; private set; } + /// /// Gets or Sets Children /// [JsonPropertyName("children")] - public List Children { get; set; } + public List? Children { get { return this. ChildrenOption; } set { this.ChildrenOption = new(value); } } /// /// Returns the string presentation of the object @@ -89,10 +97,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List? children = default; - string? firstName = default; - string? lastName = default; - string? type = default; + Option?> children = default; + Option firstName = default; + Option lastName = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -111,16 +119,16 @@ namespace Org.OpenAPITools.Model { case "children": if (utf8JsonReader.TokenType != JsonTokenType.Null) - children = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + children = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); break; case "firstName": - firstName = utf8JsonReader.GetString(); + firstName = new Option(utf8JsonReader.GetString()!); break; case "lastName": - lastName = utf8JsonReader.GetString(); + lastName = new Option(utf8JsonReader.GetString()!); break; case "$_type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,17 +136,17 @@ namespace Org.OpenAPITools.Model } } - if (children == null) - throw new ArgumentNullException(nameof(children), "Property is required for class Adult."); + if (children.IsSet && children.Value == null) + throw new ArgumentNullException(nameof(children), "Property is not nullable for class Adult."); - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class Adult."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Adult."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class Adult."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Adult."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Adult."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult."); return new Adult(children, firstName, lastName, type); } @@ -167,11 +175,31 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("children"); - JsonSerializer.Serialize(writer, adult.Children, jsonSerializerOptions); - writer.WriteString("firstName", adult.FirstName); - writer.WriteString("lastName", adult.LastName); - writer.WriteString("$_type", adult.Type); + if (adult.ChildrenOption.IsSet && adult.Children == null) + throw new ArgumentNullException(nameof(adult.Children), "Property is required for class Adult."); + + if (adult.FirstNameOption.IsSet && adult.FirstName == null) + throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult."); + + if (adult.LastNameOption.IsSet && adult.LastName == null) + throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult."); + + if (adult.TypeOption.IsSet && adult.Type == null) + throw new ArgumentNullException(nameof(adult.Type), "Property is required for class Adult."); + + if (adult.ChildrenOption.IsSet) + { + writer.WritePropertyName("children"); + JsonSerializer.Serialize(writer, adult.Children, jsonSerializerOptions); + } + if (adult.FirstNameOption.IsSet) + writer.WriteString("firstName", adult.FirstName); + + if (adult.LastNameOption.IsSet) + writer.WriteString("lastName", adult.LastName); + + if (adult.TypeOption.IsSet) + writer.WriteString("$_type", adult.Type); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Child.cs index 0814fec25b7..dc6b12799fb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Child.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Child.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -39,26 +40,40 @@ namespace Org.OpenAPITools.Model /// type /// boosterSeat [JsonConstructor] - public Child(int age, string firstName, string lastName, string type, bool boosterSeat) : base(firstName, lastName, type) + public Child(Option age = default, Option firstName = default, Option lastName = default, Option type = default, Option boosterSeat = default) : base(firstName, lastName, type) { - Age = age; - BoosterSeat = boosterSeat; + AgeOption = age; + BoosterSeatOption = boosterSeat; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Age + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AgeOption { get; private set; } + /// /// Gets or Sets Age /// [JsonPropertyName("age")] - public int Age { get; set; } + public int? Age { get { return this. AgeOption; } set { this.AgeOption = new(value); } } + + /// + /// Used to track the state of BoosterSeat + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoosterSeatOption { get; private set; } /// /// Gets or Sets BoosterSeat /// [JsonPropertyName("boosterSeat")] - public bool BoosterSeat { get; set; } + public bool? BoosterSeat { get { return this. BoosterSeatOption; } set { this.BoosterSeatOption = new(value); } } /// /// Returns the string presentation of the object @@ -98,11 +113,11 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? age = default; - string? firstName = default; - string? lastName = default; - string? type = default; - bool? boosterSeat = default; + Option age = default; + Option firstName = default; + Option lastName = default; + Option type = default; + Option boosterSeat = default; while (utf8JsonReader.Read()) { @@ -121,20 +136,20 @@ namespace Org.OpenAPITools.Model { case "age": if (utf8JsonReader.TokenType != JsonTokenType.Null) - age = utf8JsonReader.GetInt32(); + age = new Option(utf8JsonReader.GetInt32()); break; case "firstName": - firstName = utf8JsonReader.GetString(); + firstName = new Option(utf8JsonReader.GetString()!); break; case "lastName": - lastName = utf8JsonReader.GetString(); + lastName = new Option(utf8JsonReader.GetString()!); break; case "$_type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()!); break; case "boosterSeat": if (utf8JsonReader.TokenType != JsonTokenType.Null) - boosterSeat = utf8JsonReader.GetBoolean(); + boosterSeat = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -142,22 +157,22 @@ namespace Org.OpenAPITools.Model } } - if (age == null) - throw new ArgumentNullException(nameof(age), "Property is required for class Child."); + if (age.IsSet && age.Value == null) + throw new ArgumentNullException(nameof(age), "Property is not nullable for class Child."); - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class Child."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Child."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class Child."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Child."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Child."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Child."); - if (boosterSeat == null) - throw new ArgumentNullException(nameof(boosterSeat), "Property is required for class Child."); + if (boosterSeat.IsSet && boosterSeat.Value == null) + throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child."); - return new Child(age.Value, firstName, lastName, type, boosterSeat.Value); + return new Child(age, firstName, lastName, type, boosterSeat); } /// @@ -184,11 +199,29 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("age", child.Age); - writer.WriteString("firstName", child.FirstName); - writer.WriteString("lastName", child.LastName); - writer.WriteString("$_type", child.Type); - writer.WriteBoolean("boosterSeat", child.BoosterSeat); + if (child.FirstNameOption.IsSet && child.FirstName == null) + throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child."); + + if (child.LastNameOption.IsSet && child.LastName == null) + throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child."); + + if (child.TypeOption.IsSet && child.Type == null) + throw new ArgumentNullException(nameof(child.Type), "Property is required for class Child."); + + if (child.AgeOption.IsSet) + writer.WriteNumber("age", child.AgeOption.Value!.Value); + + if (child.FirstNameOption.IsSet) + writer.WriteString("firstName", child.FirstName); + + if (child.LastNameOption.IsSet) + writer.WriteString("lastName", child.LastName); + + if (child.TypeOption.IsSet) + writer.WriteString("$_type", child.Type); + + if (child.BoosterSeatOption.IsSet) + writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Person.cs index 150e974367e..c45a0eb62d1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Person.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Model/Person.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -37,33 +38,54 @@ namespace Org.OpenAPITools.Model /// lastName /// type [JsonConstructor] - public Person(string firstName, string lastName, string type) + public Person(Option firstName = default, Option lastName = default, Option type = default) { - FirstName = firstName; - LastName = lastName; - Type = type; + FirstNameOption = firstName; + LastNameOption = lastName; + TypeOption = type; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + /// /// Gets or Sets FirstName /// [JsonPropertyName("firstName")] - public string FirstName { get; set; } + public string? FirstName { get { return this. FirstNameOption; } set { this.FirstNameOption = new(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } /// /// Gets or Sets LastName /// [JsonPropertyName("lastName")] - public string LastName { get; set; } + public string? LastName { get { return this. LastNameOption; } set { this.LastNameOption = new(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } /// /// Gets or Sets Type /// [JsonPropertyName("$_type")] - public string Type { get; set; } + public string? Type { get { return this. TypeOption; } set { this.TypeOption = new(value); } } /// /// Gets or Sets additional properties @@ -130,9 +152,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? firstName = default; - string? lastName = default; - string? type = default; + Option firstName = default; + Option lastName = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -150,13 +172,13 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "firstName": - firstName = utf8JsonReader.GetString(); + firstName = new Option(utf8JsonReader.GetString()!); break; case "lastName": - lastName = utf8JsonReader.GetString(); + lastName = new Option(utf8JsonReader.GetString()!); break; case "$_type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -164,14 +186,14 @@ namespace Org.OpenAPITools.Model } } - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class Person."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Person."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class Person."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Person."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Person."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person."); return new Person(firstName, lastName, type); } @@ -200,9 +222,23 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("firstName", person.FirstName); - writer.WriteString("lastName", person.LastName); - writer.WriteString("$_type", person.Type); + if (person.FirstNameOption.IsSet && person.FirstName == null) + throw new ArgumentNullException(nameof(person.FirstName), "Property is required for class Person."); + + if (person.LastNameOption.IsSet && person.LastName == null) + throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person."); + + if (person.TypeOption.IsSet && person.Type == null) + throw new ArgumentNullException(nameof(person.Type), "Property is required for class Person."); + + if (person.FirstNameOption.IsSet) + writer.WriteString("firstName", person.FirstName); + + if (person.LastNameOption.IsSet) + writer.WriteString("lastName", person.LastName); + + if (person.TypeOption.IsSet) + writer.WriteString("$_type", person.Type); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/Option.cs index 3c370b043a5..6f4db75a445 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/Option.cs @@ -37,5 +37,17 @@ namespace Org.OpenAPITools.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Apple.cs index 37658134083..22cf086e0e3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Apple.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// kind [JsonConstructor] - public Apple(string kind) + public Apple(Option kind = default) { - Kind = kind; + KindOption = kind; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Kind + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option KindOption { get; private set; } + /// /// Gets or Sets Kind /// [JsonPropertyName("kind")] - public string Kind { get; set; } + public string? Kind { get { return this. KindOption; } set { this.KindOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? kind = default; + Option kind = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "kind": - kind = utf8JsonReader.GetString(); + kind = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (kind == null) - throw new ArgumentNullException(nameof(kind), "Property is required for class Apple."); + if (kind.IsSet && kind.Value == null) + throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple."); return new Apple(kind); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("kind", apple.Kind); + if (apple.KindOption.IsSet && apple.Kind == null) + throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple."); + + if (apple.KindOption.IsSet) + writer.WriteString("kind", apple.Kind); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Banana.cs index 003d499475e..9d81d60d111 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Banana.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// count [JsonConstructor] - public Banana(decimal count) + public Banana(Option count = default) { - Count = count; + CountOption = count; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Count + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountOption { get; private set; } + /// /// Gets or Sets Count /// [JsonPropertyName("count")] - public decimal Count { get; set; } + public decimal? Count { get { return this. CountOption; } set { this.CountOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? count = default; + Option count = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "count": if (utf8JsonReader.TokenType != JsonTokenType.Null) - count = utf8JsonReader.GetDecimal(); + count = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model } } - if (count == null) - throw new ArgumentNullException(nameof(count), "Property is required for class Banana."); + if (count.IsSet && count.Value == null) + throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana."); - return new Banana(count.Value); + return new Banana(count); } /// @@ -159,7 +167,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("count", banana.Count); + if (banana.CountOption.IsSet) + writer.WriteNumber("count", banana.CountOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Fruit.cs index 7cd885961b7..a0f5762ac11 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Model/Fruit.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,31 +37,52 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Apple? apple, Banana? banana, string color) + public Fruit(Option apple, Option banana, Option color = default) { - Apple = apple; - Banana = banana; - Color = color; + AppleOption = apple; + BananaOption = banana; + ColorOption = color; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + /// /// Gets or Sets Apple /// - public Apple? Apple { get; set; } + public Apple? Apple { get { return this.AppleOption; } set { this.AppleOption = new(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } /// /// Gets or Sets Banana /// - public Banana? Banana { get; set; } + public Banana? Banana { get { return this.BananaOption; } set { this.BananaOption = new(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Gets or Sets additional properties @@ -115,7 +137,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? color = default; + Option color = default; Apple? apple = default; Banana? banana = default; @@ -155,7 +177,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -163,10 +185,17 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Fruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); - return new Fruit(apple, banana, color); + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new Fruit(appleParsedValue, bananaParsedValue, color); } /// @@ -180,16 +209,16 @@ namespace Org.OpenAPITools.Model { writer.WriteStartObject(); - if (fruit.Apple != null) + if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null) { - AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.Apple.GetType())); - AppleJsonConverter.WriteProperties(ref writer, fruit.Apple, jsonSerializerOptions); + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(ref writer, fruit.AppleOption.Value, jsonSerializerOptions); } - if (fruit.Banana != null) + if (fruit.BananaOption.IsSet && fruit.BananaOption.Value != null) { - BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.Banana.GetType())); - BananaJsonConverter.WriteProperties(ref writer, fruit.Banana, jsonSerializerOptions); + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(ref writer, fruit.BananaOption.Value, jsonSerializerOptions); } WriteProperties(ref writer, fruit, jsonSerializerOptions); @@ -205,7 +234,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", fruit.Color); + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/Option.cs index 3c370b043a5..6f4db75a445 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/Option.cs @@ -37,5 +37,17 @@ namespace Org.OpenAPITools.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Apple.cs index 37658134083..22cf086e0e3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Apple.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// kind [JsonConstructor] - public Apple(string kind) + public Apple(Option kind = default) { - Kind = kind; + KindOption = kind; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Kind + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option KindOption { get; private set; } + /// /// Gets or Sets Kind /// [JsonPropertyName("kind")] - public string Kind { get; set; } + public string? Kind { get { return this. KindOption; } set { this.KindOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? kind = default; + Option kind = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "kind": - kind = utf8JsonReader.GetString(); + kind = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -128,8 +136,8 @@ namespace Org.OpenAPITools.Model } } - if (kind == null) - throw new ArgumentNullException(nameof(kind), "Property is required for class Apple."); + if (kind.IsSet && kind.Value == null) + throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple."); return new Apple(kind); } @@ -158,7 +166,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("kind", apple.Kind); + if (apple.KindOption.IsSet && apple.Kind == null) + throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple."); + + if (apple.KindOption.IsSet) + writer.WriteString("kind", apple.Kind); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Banana.cs index 003d499475e..9d81d60d111 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Banana.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,19 +36,26 @@ namespace Org.OpenAPITools.Model /// /// count [JsonConstructor] - public Banana(decimal count) + public Banana(Option count = default) { - Count = count; + CountOption = count; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Count + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountOption { get; private set; } + /// /// Gets or Sets Count /// [JsonPropertyName("count")] - public decimal Count { get; set; } + public decimal? Count { get { return this. CountOption; } set { this.CountOption = new(value); } } /// /// Gets or Sets additional properties @@ -102,7 +110,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? count = default; + Option count = default; while (utf8JsonReader.Read()) { @@ -121,7 +129,7 @@ namespace Org.OpenAPITools.Model { case "count": if (utf8JsonReader.TokenType != JsonTokenType.Null) - count = utf8JsonReader.GetDecimal(); + count = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model } } - if (count == null) - throw new ArgumentNullException(nameof(count), "Property is required for class Banana."); + if (count.IsSet && count.Value == null) + throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana."); - return new Banana(count.Value); + return new Banana(count); } /// @@ -159,7 +167,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("count", banana.Count); + if (banana.CountOption.IsSet) + writer.WriteNumber("count", banana.CountOption.Value!.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Fruit.cs index 4310e800fe9..78554584979 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Model/Fruit.cs @@ -22,6 +22,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,10 +36,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Apple apple, string color) + public Fruit(Apple apple, Option color = default) { Apple = apple; - Color = color; + ColorOption = color; OnCreated(); } @@ -47,10 +48,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Banana banana, string color) + public Fruit(Banana banana, Option color = default) { Banana = banana; - Color = color; + ColorOption = color; OnCreated(); } @@ -66,11 +67,18 @@ namespace Org.OpenAPITools.Model /// public Banana? Banana { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } } /// /// Gets or Sets additional properties @@ -125,7 +133,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string? color = default; + Option color = default; Apple? apple = default; Banana? banana = default; @@ -165,7 +173,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()!); break; default: break; @@ -173,8 +181,8 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Fruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); if (apple != null) return new Fruit(apple, color); @@ -209,7 +217,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", fruit.Color); + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES index 1179de6767b..05049077c2a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES @@ -79,6 +79,7 @@ docs/models/PolymorphicProperty.md docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md +docs/models/RequiredClass.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -206,6 +207,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/AdditionalPropertiesClass.md index f79869f95a7..2bbe882fcfc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/AdditionalPropertiesClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/AdditionalPropertiesClass.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Anytype1** | **Object** | | [optional] **EmptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] **MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] **MapProperty** | **Dictionary<string, string>** | | [optional] @@ -11,7 +12,6 @@ Name | Type | Description | Notes **MapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional] **MapWithUndeclaredPropertiesAnytype3** | **Dictionary<string, Object>** | | [optional] **MapWithUndeclaredPropertiesString** | **Dictionary<string, string>** | | [optional] -**Anytype1** | **Object** | | [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-netstandard2.0/docs/models/Drawing.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Drawing.md index 215793515f6..95f49b2ed60 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Drawing.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Drawing.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **MainShape** | [**Shape**](Shape.md) | | [optional] -**Shapes** | [**List<Shape>**](Shape.md) | | [optional] **NullableShape** | [**NullableShape**](NullableShape.md) | | [optional] **ShapeOrNull** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] +**Shapes** | [**List<Shape>**](Shape.md) | | [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-netstandard2.0/docs/models/EnumTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/EnumTest.md index 53bbfe31e77..ebd7ccf2c86 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/EnumTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/EnumTest.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**EnumStringRequired** | **string** | | **EnumInteger** | **int** | | [optional] **EnumIntegerOnly** | **int** | | [optional] **EnumNumber** | **double** | | [optional] **EnumString** | **string** | | [optional] -**EnumStringRequired** | **string** | | +**OuterEnum** | **OuterEnum** | | [optional] **OuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] **OuterEnumInteger** | **OuterEnumInteger** | | [optional] **OuterEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional] -**OuterEnum** | **OuterEnum** | | [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-netstandard2.0/docs/models/FormatTest.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/FormatTest.md index 28f1a809358..ab628ed7bc0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/FormatTest.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/FormatTest.md @@ -4,9 +4,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Binary** | **System.IO.Stream** | | [optional] **VarByte** | **byte[]** | | **Date** | **DateTime** | | +**Number** | **decimal** | | +**Password** | **string** | | +**Binary** | **System.IO.Stream** | | [optional] **DateTime** | **DateTime** | | [optional] **VarDecimal** | **decimal** | | [optional] **VarDouble** | **double** | | [optional] @@ -14,8 +16,6 @@ Name | Type | Description | Notes **Int32** | **int** | | [optional] **Int64** | **long** | | [optional] **Integer** | **int** | | [optional] -**Number** | **decimal** | | -**Password** | **string** | | **PatternWithBackslash** | **string** | None | [optional] **PatternWithDigits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional] **PatternWithDigitsAndDelimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableClass.md index 394feef77db..5d9965f55c0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableClass.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableClass.md @@ -4,9 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ArrayItemsNullable** | **List<Object>** | | [optional] -**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ArrayAndItemsNullableProp** | **List<Object>** | | [optional] +**ArrayItemsNullable** | **List<Object>** | | [optional] **ArrayNullableProp** | **List<Object>** | | [optional] **BooleanProp** | **bool** | | [optional] **DateProp** | **DateTime** | | [optional] @@ -14,6 +13,7 @@ Name | Type | Description | Notes **IntegerProp** | **int** | | [optional] **NumberProp** | **decimal** | | [optional] **ObjectAndItemsNullableProp** | **Dictionary<string, Object>** | | [optional] +**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] **ObjectNullableProp** | **Dictionary<string, Object>** | | [optional] **StringProp** | **string** | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Order.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Order.md index ca5d8992a51..f7d6827ed5c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Order.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Order.md @@ -4,12 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**Complete** | **bool** | | [optional] [default to false] **Id** | **long** | | [optional] **PetId** | **long** | | [optional] **Quantity** | **int** | | [optional] **ShipDate** | **DateTime** | | [optional] **Status** | **string** | Order Status | [optional] -**Complete** | **bool** | | [optional] [default to false] [[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-netstandard2.0/docs/models/Pet.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Pet.md index b13bb576b45..4f019b613bd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Pet.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/Pet.md @@ -4,10 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Category** | [**Category**](Category.md) | | [optional] -**Id** | **long** | | [optional] **Name** | **string** | | **PhotoUrls** | **List<string>** | | +**Category** | [**Category**](Category.md) | | [optional] +**Id** | **long** | | [optional] **Status** | **string** | pet status in the store | [optional] **Tags** | [**List<Tag>**](Tag.md) | | [optional] diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/RequiredClass.md new file mode 100644 index 00000000000..8f148be840b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNotNullableDateProp** | **DateTime** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNotnullableEnumInteger** | **int** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**RequiredNotnullableEnumString** | **string** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableStringProp** | **string** | | +**RequiredNotnullableUuid** | **Guid** | | +**RequiredNotnullableintegerProp** | **int** | | +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNullableBooleanProp** | **bool** | | +**RequiredNullableDateProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime** | | +**RequiredNullableEnumInteger** | **int** | | +**RequiredNullableEnumIntegerOnly** | **int** | | +**RequiredNullableEnumString** | **string** | | +**RequiredNullableIntegerProp** | **int** | | +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNullableStringProp** | **string** | | +**RequiredNullableUuid** | **Guid** | | +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**NotRequiredNullableDateProp** | **DateTime** | | [optional] +**NotRequiredNullableIntegerProp** | **int** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNullableBooleanProp** | **bool** | | [optional] +**NotrequiredNullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNullableEnumInteger** | **int** | | [optional] +**NotrequiredNullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNullableUuid** | **Guid** | | [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-netstandard2.0/docs/models/User.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/User.md index 455f031674d..b5700f1c75d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/User.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/User.md @@ -4,18 +4,18 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] +**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] **Email** | **string** | | [optional] **FirstName** | **string** | | [optional] **Id** | **long** | | [optional] **LastName** | **string** | | [optional] **ObjectWithNoDeclaredProps** | **Object** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional] +**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] **Password** | **string** | | [optional] **Phone** | **string** | | [optional] **UserStatus** | **int** | User Status | [optional] **Username** | **string** | | [optional] -**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] -**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] -**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [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-netstandard2.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..6e8958b1b74 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,452 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs index 485ee4c9a08..99e27fdfa16 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -141,6 +141,8 @@ namespace Org.OpenAPITools.Client return EnumArrays.JustSymbolEnumToJsonValue(enumArraysJustSymbolEnum); if (obj is EnumClass enumClass) return EnumClassValueConverter.ToJsonValue(enumClass); + if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) + return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is EnumTest.EnumIntegerEnum enumTestEnumIntegerEnum) return EnumTest.EnumIntegerEnumToJsonValue(enumTestEnumIntegerEnum).ToString(); if (obj is EnumTest.EnumIntegerOnlyEnum enumTestEnumIntegerOnlyEnum) @@ -149,8 +151,6 @@ namespace Org.OpenAPITools.Client return EnumTest.EnumNumberEnumToJsonValue(enumTestEnumNumberEnum).ToString(); if (obj is EnumTest.EnumStringEnum enumTestEnumStringEnum) return EnumTest.EnumStringEnumToJsonValue(enumTestEnumStringEnum); - if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) - return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); if (obj is MapTest.InnerEnum mapTestInnerEnum) return MapTest.InnerEnumToJsonValue(mapTestInnerEnum); if (obj is Order.StatusEnum orderStatusEnum) @@ -167,6 +167,30 @@ namespace Org.OpenAPITools.Client return OuterEnumTestValueConverter.ToJsonValue(outerEnumTest); if (obj is Pet.StatusEnum petStatusEnum) return Pet.StatusEnumToJsonValue(petStatusEnum); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerEnum requiredClassRequiredNotnullableEnumIntegerEnum) + return RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum requiredClassRequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumStringEnum requiredClassRequiredNotnullableEnumStringEnum) + return RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClassRequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.RequiredNullableEnumIntegerEnum requiredClassRequiredNullableEnumIntegerEnum) + return RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClassRequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumIntegerOnlyEnum requiredClassRequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) + return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerEnum requiredClassNotrequiredNotnullableEnumIntegerEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumStringEnum requiredClassNotrequiredNotnullableEnumStringEnum) + return RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClassNotrequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerEnum requiredClassNotrequiredNullableEnumIntegerEnum) + return RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum requiredClassNotrequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumStringEnum requiredClassNotrequiredNullableEnumStringEnum) + return RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClassNotrequiredNullableEnumStringEnum); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs index 964d9c24a14..903a95cb48a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -114,6 +114,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/Option.cs index 70f41078bb6..8cf79a713b7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/Option.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/Option.cs @@ -35,5 +35,17 @@ namespace Org.OpenAPITools.Client IsSet = true; Value = value; } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs index 42747dee35e..306058f38c3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Activity.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// activityOutputs [JsonConstructor] - public Activity(Dictionary> activityOutputs) + public Activity(Option>> activityOutputs = default) { - ActivityOutputs = activityOutputs; + ActivityOutputsOption = activityOutputs; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ActivityOutputs + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ActivityOutputsOption { get; private set; } + /// /// Gets or Sets ActivityOutputs /// [JsonPropertyName("activity_outputs")] - public Dictionary> ActivityOutputs { get; set; } + public Dictionary> ActivityOutputs { get { return this. ActivityOutputsOption; } set { this.ActivityOutputsOption = new Option>>(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary> activityOutputs = default; + Option>> activityOutputs = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "activity_outputs": if (utf8JsonReader.TokenType != JsonTokenType.Null) - activityOutputs = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + activityOutputs = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (activityOutputs == null) - throw new ArgumentNullException(nameof(activityOutputs), "Property is required for class Activity."); + if (activityOutputs.IsSet && activityOutputs.Value == null) + throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity."); return new Activity(activityOutputs); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("activity_outputs"); - JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null) + throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity."); + + if (activity.ActivityOutputsOption.IsSet) + { + writer.WritePropertyName("activity_outputs"); + JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index 233d362f51e..70b907a2f5c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// prop1 /// prop2 [JsonConstructor] - public ActivityOutputElementRepresentation(string prop1, Object prop2) + public ActivityOutputElementRepresentation(Option prop1 = default, Option prop2 = default) { - Prop1 = prop1; - Prop2 = prop2; + Prop1Option = prop1; + Prop2Option = prop2; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Prop1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop1Option { get; private set; } + /// /// Gets or Sets Prop1 /// [JsonPropertyName("prop1")] - public string Prop1 { get; set; } + public string Prop1 { get { return this. Prop1Option; } set { this.Prop1Option = new Option(value); } } + + /// + /// Used to track the state of Prop2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop2Option { get; private set; } /// /// Gets or Sets Prop2 /// [JsonPropertyName("prop2")] - public Object Prop2 { get; set; } + public Object Prop2 { get { return this. Prop2Option; } set { this.Prop2Option = new Option(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string prop1 = default; - Object prop2 = default; + Option prop1 = default; + Option prop2 = default; while (utf8JsonReader.Read()) { @@ -128,11 +143,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "prop1": - prop1 = utf8JsonReader.GetString(); + prop1 = new Option(utf8JsonReader.GetString()); break; case "prop2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - prop2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + prop2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -140,11 +155,11 @@ namespace Org.OpenAPITools.Model } } - if (prop1 == null) - throw new ArgumentNullException(nameof(prop1), "Property is required for class ActivityOutputElementRepresentation."); + if (prop1.IsSet && prop1.Value == null) + throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation."); - if (prop2 == null) - throw new ArgumentNullException(nameof(prop2), "Property is required for class ActivityOutputElementRepresentation."); + if (prop2.IsSet && prop2.Value == null) + throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation."); return new ActivityOutputElementRepresentation(prop1, prop2); } @@ -173,9 +188,20 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); - writer.WritePropertyName("prop2"); - JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop1Option.IsSet) + writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); + + if (activityOutputElementRepresentation.Prop2Option.IsSet) + { + writer.WritePropertyName("prop2"); + JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index ed15d711b7a..e723f090a2d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,6 +32,7 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// anytype1 /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// mapOfMapProperty /// mapProperty @@ -38,71 +40,126 @@ namespace Org.OpenAPITools.Model /// mapWithUndeclaredPropertiesAnytype2 /// mapWithUndeclaredPropertiesAnytype3 /// mapWithUndeclaredPropertiesString - /// anytype1 [JsonConstructor] - public AdditionalPropertiesClass(Object emptyMap, Dictionary> mapOfMapProperty, Dictionary mapProperty, Object mapWithUndeclaredPropertiesAnytype1, Object mapWithUndeclaredPropertiesAnytype2, Dictionary mapWithUndeclaredPropertiesAnytype3, Dictionary mapWithUndeclaredPropertiesString, Object anytype1 = default) + public AdditionalPropertiesClass(Option anytype1 = default, Option emptyMap = default, Option>> mapOfMapProperty = default, Option> mapProperty = default, Option mapWithUndeclaredPropertiesAnytype1 = default, Option mapWithUndeclaredPropertiesAnytype2 = default, Option> mapWithUndeclaredPropertiesAnytype3 = default, Option> mapWithUndeclaredPropertiesString = default) { - EmptyMap = emptyMap; - MapOfMapProperty = mapOfMapProperty; - MapProperty = mapProperty; - MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - Anytype1 = anytype1; + Anytype1Option = anytype1; + EmptyMapOption = emptyMap; + MapOfMapPropertyOption = mapOfMapProperty; + MapPropertyOption = mapProperty; + MapWithUndeclaredPropertiesAnytype1Option = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2Option = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3Option = mapWithUndeclaredPropertiesAnytype3; + MapWithUndeclaredPropertiesStringOption = mapWithUndeclaredPropertiesString; OnCreated(); } partial void OnCreated(); /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// Used to track the state of Anytype1 /// - /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [JsonPropertyName("empty_map")] - public Object EmptyMap { get; set; } - - /// - /// Gets or Sets MapOfMapProperty - /// - [JsonPropertyName("map_of_map_property")] - public Dictionary> MapOfMapProperty { get; set; } - - /// - /// Gets or Sets MapProperty - /// - [JsonPropertyName("map_property")] - public Dictionary MapProperty { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_1")] - public Object MapWithUndeclaredPropertiesAnytype1 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_2")] - public Object MapWithUndeclaredPropertiesAnytype2 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 - /// - [JsonPropertyName("map_with_undeclared_properties_anytype_3")] - public Dictionary MapWithUndeclaredPropertiesAnytype3 { get; set; } - - /// - /// Gets or Sets MapWithUndeclaredPropertiesString - /// - [JsonPropertyName("map_with_undeclared_properties_string")] - public Dictionary MapWithUndeclaredPropertiesString { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Anytype1Option { get; private set; } /// /// Gets or Sets Anytype1 /// [JsonPropertyName("anytype_1")] - public Object Anytype1 { get; set; } + public Object Anytype1 { get { return this. Anytype1Option; } set { this.Anytype1Option = new Option(value); } } + + /// + /// Used to track the state of EmptyMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmptyMapOption { get; private set; } + + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + [JsonPropertyName("empty_map")] + public Object EmptyMap { get { return this. EmptyMapOption; } set { this.EmptyMapOption = new Option(value); } } + + /// + /// Used to track the state of MapOfMapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapOfMapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [JsonPropertyName("map_of_map_property")] + public Dictionary> MapOfMapProperty { get { return this. MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new Option>>(value); } } + + /// + /// Used to track the state of MapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapProperty + /// + [JsonPropertyName("map_property")] + public Dictionary MapProperty { get { return this. MapPropertyOption; } set { this.MapPropertyOption = new Option>(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype1Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] + public Object MapWithUndeclaredPropertiesAnytype1 { get { return this. MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new Option(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype2Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] + public Object MapWithUndeclaredPropertiesAnytype2 { get { return this. MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new Option(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype3 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesAnytype3Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] + public Dictionary MapWithUndeclaredPropertiesAnytype3 { get { return this. MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new Option>(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesStringOption { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesString + /// + [JsonPropertyName("map_with_undeclared_properties_string")] + public Dictionary MapWithUndeclaredPropertiesString { get { return this. MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -118,6 +175,7 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); @@ -125,7 +183,6 @@ namespace Org.OpenAPITools.Model sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); - sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -164,14 +221,14 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Object emptyMap = default; - Dictionary> mapOfMapProperty = default; - Dictionary mapProperty = default; - Object mapWithUndeclaredPropertiesAnytype1 = default; - Object mapWithUndeclaredPropertiesAnytype2 = default; - Dictionary mapWithUndeclaredPropertiesAnytype3 = default; - Dictionary mapWithUndeclaredPropertiesString = default; - Object anytype1 = default; + Option anytype1 = default; + Option emptyMap = default; + Option>> mapOfMapProperty = default; + Option> mapProperty = default; + Option mapWithUndeclaredPropertiesAnytype1 = default; + Option mapWithUndeclaredPropertiesAnytype2 = default; + Option> mapWithUndeclaredPropertiesAnytype3 = default; + Option> mapWithUndeclaredPropertiesString = default; while (utf8JsonReader.Read()) { @@ -188,37 +245,37 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; case "empty_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - emptyMap = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + emptyMap = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_of_map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfMapProperty = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapOfMapProperty = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_property": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapProperty = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapProperty = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_anytype_1": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_anytype_2": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype2 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_anytype_3": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesAnytype3 = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesAnytype3 = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_with_undeclared_properties_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapWithUndeclaredPropertiesString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "anytype_1": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - anytype1 = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + mapWithUndeclaredPropertiesString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -226,28 +283,28 @@ namespace Org.OpenAPITools.Model } } - if (emptyMap == null) - throw new ArgumentNullException(nameof(emptyMap), "Property is required for class AdditionalPropertiesClass."); + if (emptyMap.IsSet && emptyMap.Value == null) + throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapOfMapProperty == null) - throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null) + throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapProperty == null) - throw new ArgumentNullException(nameof(mapProperty), "Property is required for class AdditionalPropertiesClass."); + if (mapProperty.IsSet && mapProperty.Value == null) + throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype1 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype2 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesAnytype3 == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass."); - if (mapWithUndeclaredPropertiesString == null) - throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass."); - return new AdditionalPropertiesClass(emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString, anytype1); + return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString); } /// @@ -274,22 +331,70 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("empty_map"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); - writer.WritePropertyName("map_of_map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_property"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); - writer.WritePropertyName("map_with_undeclared_properties_string"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); - writer.WritePropertyName("anytype_1"); - JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.Anytype1Option.IsSet) + if (additionalPropertiesClass.Anytype1Option.Value != null) + { + writer.WritePropertyName("anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + } + else + writer.WriteNull("anytype_1"); + if (additionalPropertiesClass.EmptyMapOption.IsSet) + { + writer.WritePropertyName("empty_map"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet) + { + writer.WritePropertyName("map_of_map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapPropertyOption.IsSet) + { + writer.WritePropertyName("map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_string"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs index 460543ebf0d..017eb4dc94b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, string color = @"red") + public Animal(string className, Option color = default) { ClassName = className; - Color = color; + ColorOption = color; OnCreated(); } @@ -49,11 +50,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get { return this. ColorOption; } set { this.ColorOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -119,8 +127,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - string color = default; + Option className = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -138,10 +146,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -149,13 +157,16 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Animal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Animal.", nameof(className)); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Animal."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal."); - return new Animal(className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); + + return new Animal(className.Value, color); } /// @@ -182,8 +193,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { + if (animal.ClassName == null) + throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); + + if (animal.ColorOption.IsSet && animal.Color == null) + throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); + writer.WriteString("className", animal.ClassName); - writer.WriteString("color", animal.Color); + + if (animal.ColorOption.IsSet) + writer.WriteString("color", animal.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs index 5a7be95495c..51008671a47 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// message /// type [JsonConstructor] - public ApiResponse(int code, string message, string type) + public ApiResponse(Option code = default, Option message = default, Option type = default) { - Code = code; - Message = message; - Type = type; + CodeOption = code; + MessageOption = message; + TypeOption = type; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + /// /// Gets or Sets Code /// [JsonPropertyName("code")] - public int Code { get; set; } + public int? Code { get { return this. CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Message + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MessageOption { get; private set; } /// /// Gets or Sets Message /// [JsonPropertyName("message")] - public string Message { get; set; } + public string Message { get { return this. MessageOption; } set { this.MessageOption = new Option(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public string Type { get; set; } + public string Type { get { return this. TypeOption; } set { this.TypeOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -118,9 +140,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? code = default; - string message = default; - string type = default; + Option code = default; + Option message = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -139,13 +161,13 @@ namespace Org.OpenAPITools.Model { case "code": if (utf8JsonReader.TokenType != JsonTokenType.Null) - code = utf8JsonReader.GetInt32(); + code = new Option(utf8JsonReader.GetInt32()); break; case "message": - message = utf8JsonReader.GetString(); + message = new Option(utf8JsonReader.GetString()); break; case "type": - type = utf8JsonReader.GetString(); + type = new Option(utf8JsonReader.GetString()); break; default: break; @@ -153,16 +175,16 @@ namespace Org.OpenAPITools.Model } } - if (code == null) - throw new ArgumentNullException(nameof(code), "Property is required for class ApiResponse."); + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse."); - if (message == null) - throw new ArgumentNullException(nameof(message), "Property is required for class ApiResponse."); + if (message.IsSet && message.Value == null) + throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse."); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class ApiResponse."); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse."); - return new ApiResponse(code.Value, message, type); + return new ApiResponse(code, message, type); } /// @@ -189,9 +211,20 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("code", apiResponse.Code); - writer.WriteString("message", apiResponse.Message); - writer.WriteString("type", apiResponse.Type); + if (apiResponse.MessageOption.IsSet && apiResponse.Message == null) + throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse."); + + if (apiResponse.TypeOption.IsSet && apiResponse.Type == null) + throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse."); + + if (apiResponse.CodeOption.IsSet) + writer.WriteNumber("code", apiResponse.CodeOption.Value.Value); + + if (apiResponse.MessageOption.IsSet) + writer.WriteString("message", apiResponse.Message); + + if (apiResponse.TypeOption.IsSet) + writer.WriteString("type", apiResponse.Type); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs index 31246df0422..e193be63a22 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// cultivar /// origin [JsonConstructor] - public Apple(string colorCode, string cultivar, string origin) + public Apple(Option colorCode = default, Option cultivar = default, Option origin = default) { - ColorCode = colorCode; - Cultivar = cultivar; - Origin = origin; + ColorCodeOption = colorCode; + CultivarOption = cultivar; + OriginOption = origin; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ColorCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorCodeOption { get; private set; } + /// /// Gets or Sets ColorCode /// [JsonPropertyName("color_code")] - public string ColorCode { get; set; } + public string ColorCode { get { return this. ColorCodeOption; } set { this.ColorCodeOption = new Option(value); } } + + /// + /// Used to track the state of Cultivar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CultivarOption { get; private set; } /// /// Gets or Sets Cultivar /// [JsonPropertyName("cultivar")] - public string Cultivar { get; set; } + public string Cultivar { get { return this. CultivarOption; } set { this.CultivarOption = new Option(value); } } + + /// + /// Used to track the state of Origin + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OriginOption { get; private set; } /// /// Gets or Sets Origin /// [JsonPropertyName("origin")] - public string Origin { get; set; } + public string Origin { get { return this. OriginOption; } set { this.OriginOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -92,28 +114,31 @@ namespace Org.OpenAPITools.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - if (this.ColorCode != null) { + if (this.ColorCodeOption.Value != null) { // ColorCode (string) pattern Regex regexColorCode = new Regex(@"^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$", RegexOptions.CultureInvariant); - if (!regexColorCode.Match(this.ColorCode).Success) + + if (this.ColorCodeOption.Value != null &&!regexColorCode.Match(this.ColorCodeOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ColorCode, must match a pattern of " + regexColorCode, new [] { "ColorCode" }); } } - if (this.Cultivar != null) { + if (this.CultivarOption.Value != null) { // Cultivar (string) pattern Regex regexCultivar = new Regex(@"^[a-zA-Z\s]*$", RegexOptions.CultureInvariant); - if (!regexCultivar.Match(this.Cultivar).Success) + + if (this.CultivarOption.Value != null &&!regexCultivar.Match(this.CultivarOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Cultivar, must match a pattern of " + regexCultivar, new [] { "Cultivar" }); } } - if (this.Origin != null) { + if (this.OriginOption.Value != null) { // Origin (string) pattern Regex regexOrigin = new Regex(@"^[A-Z\s]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexOrigin.Match(this.Origin).Success) + + if (this.OriginOption.Value != null &&!regexOrigin.Match(this.OriginOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Origin, must match a pattern of " + regexOrigin, new [] { "Origin" }); } @@ -145,9 +170,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string colorCode = default; - string cultivar = default; - string origin = default; + Option colorCode = default; + Option cultivar = default; + Option origin = default; while (utf8JsonReader.Read()) { @@ -165,13 +190,13 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color_code": - colorCode = utf8JsonReader.GetString(); + colorCode = new Option(utf8JsonReader.GetString()); break; case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()); break; case "origin": - origin = utf8JsonReader.GetString(); + origin = new Option(utf8JsonReader.GetString()); break; default: break; @@ -179,14 +204,14 @@ namespace Org.OpenAPITools.Model } } - if (colorCode == null) - throw new ArgumentNullException(nameof(colorCode), "Property is required for class Apple."); + if (colorCode.IsSet && colorCode.Value == null) + throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple."); - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class Apple."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple."); - if (origin == null) - throw new ArgumentNullException(nameof(origin), "Property is required for class Apple."); + if (origin.IsSet && origin.Value == null) + throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple."); return new Apple(colorCode, cultivar, origin); } @@ -215,9 +240,23 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color_code", apple.ColorCode); - writer.WriteString("cultivar", apple.Cultivar); - writer.WriteString("origin", apple.Origin); + if (apple.ColorCodeOption.IsSet && apple.ColorCode == null) + throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple."); + + if (apple.CultivarOption.IsSet && apple.Cultivar == null) + throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple."); + + if (apple.OriginOption.IsSet && apple.Origin == null) + throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple."); + + if (apple.ColorCodeOption.IsSet) + writer.WriteString("color_code", apple.ColorCode); + + if (apple.CultivarOption.IsSet) + writer.WriteString("cultivar", apple.Cultivar); + + if (apple.OriginOption.IsSet) + writer.WriteString("origin", apple.Origin); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs index e0882d925c5..b4551174f52 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// cultivar /// mealy [JsonConstructor] - public AppleReq(string cultivar, bool mealy) + public AppleReq(string cultivar, Option mealy = default) { Cultivar = cultivar; - Mealy = mealy; + MealyOption = mealy; OnCreated(); } @@ -49,11 +50,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("cultivar")] public string Cultivar { get; set; } + /// + /// Used to track the state of Mealy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MealyOption { get; private set; } + /// /// Gets or Sets Mealy /// [JsonPropertyName("mealy")] - public bool Mealy { get; set; } + public bool? Mealy { get { return this. MealyOption; } set { this.MealyOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -102,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string cultivar = default; - bool? mealy = default; + Option cultivar = default; + Option mealy = default; while (utf8JsonReader.Read()) { @@ -121,11 +129,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "cultivar": - cultivar = utf8JsonReader.GetString(); + cultivar = new Option(utf8JsonReader.GetString()); break; case "mealy": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mealy = utf8JsonReader.GetBoolean(); + mealy = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -133,13 +141,16 @@ namespace Org.OpenAPITools.Model } } - if (cultivar == null) - throw new ArgumentNullException(nameof(cultivar), "Property is required for class AppleReq."); + if (!cultivar.IsSet) + throw new ArgumentException("Property is required for class AppleReq.", nameof(cultivar)); - if (mealy == null) - throw new ArgumentNullException(nameof(mealy), "Property is required for class AppleReq."); + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq."); - return new AppleReq(cultivar, mealy.Value); + if (mealy.IsSet && mealy.Value == null) + throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq."); + + return new AppleReq(cultivar.Value, mealy); } /// @@ -166,8 +177,13 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) { + if (appleReq.Cultivar == null) + throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq."); + writer.WriteString("cultivar", appleReq.Cultivar); - writer.WriteBoolean("mealy", appleReq.Mealy); + + if (appleReq.MealyOption.IsSet) + writer.WriteBoolean("mealy", appleReq.MealyOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 6fc0afdbc30..5eed5f32014 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// arrayArrayNumber [JsonConstructor] - public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber) + public ArrayOfArrayOfNumberOnly(Option>> arrayArrayNumber = default) { - ArrayArrayNumber = arrayArrayNumber; + ArrayArrayNumberOption = arrayArrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayArrayNumber /// [JsonPropertyName("ArrayArrayNumber")] - public List> ArrayArrayNumber { get; set; } + public List> ArrayArrayNumber { get { return this. ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new Option>>(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List> arrayArrayNumber = default; + Option>> arrayArrayNumber = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "ArrayArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayNumber = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayNumber = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (arrayArrayNumber == null) - throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly."); return new ArrayOfArrayOfNumberOnly(arrayArrayNumber); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 0715a3fdf65..5336a5b2dbb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// arrayNumber [JsonConstructor] - public ArrayOfNumberOnly(List arrayNumber) + public ArrayOfNumberOnly(Option> arrayNumber = default) { - ArrayNumber = arrayNumber; + ArrayNumberOption = arrayNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNumberOption { get; private set; } + /// /// Gets or Sets ArrayNumber /// [JsonPropertyName("ArrayNumber")] - public List ArrayNumber { get; set; } + public List ArrayNumber { get { return this. ArrayNumberOption; } set { this.ArrayNumberOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List arrayNumber = default; + Option> arrayNumber = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "ArrayNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNumber = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNumber = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (arrayNumber == null) - throw new ArgumentNullException(nameof(arrayNumber), "Property is required for class ArrayOfNumberOnly."); + if (arrayNumber.IsSet && arrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly."); return new ArrayOfNumberOnly(arrayNumber); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("ArrayNumber"); - JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly."); + + if (arrayOfNumberOnly.ArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs index 43088ca1d97..9ec2bd39bfe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// arrayArrayOfModel /// arrayOfString [JsonConstructor] - public ArrayTest(List> arrayArrayOfInteger, List> arrayArrayOfModel, List arrayOfString) + public ArrayTest(Option>> arrayArrayOfInteger = default, Option>> arrayArrayOfModel = default, Option> arrayOfString = default) { - ArrayArrayOfInteger = arrayArrayOfInteger; - ArrayArrayOfModel = arrayArrayOfModel; - ArrayOfString = arrayOfString; + ArrayArrayOfIntegerOption = arrayArrayOfInteger; + ArrayArrayOfModelOption = arrayArrayOfModel; + ArrayOfStringOption = arrayOfString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ArrayArrayOfInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfIntegerOption { get; private set; } + /// /// Gets or Sets ArrayArrayOfInteger /// [JsonPropertyName("array_array_of_integer")] - public List> ArrayArrayOfInteger { get; set; } + public List> ArrayArrayOfInteger { get { return this. ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new Option>>(value); } } + + /// + /// Used to track the state of ArrayArrayOfModel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfModelOption { get; private set; } /// /// Gets or Sets ArrayArrayOfModel /// [JsonPropertyName("array_array_of_model")] - public List> ArrayArrayOfModel { get; set; } + public List> ArrayArrayOfModel { get { return this. ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new Option>>(value); } } + + /// + /// Used to track the state of ArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayOfStringOption { get; private set; } /// /// Gets or Sets ArrayOfString /// [JsonPropertyName("array_of_string")] - public List ArrayOfString { get; set; } + public List ArrayOfString { get { return this. ArrayOfStringOption; } set { this.ArrayOfStringOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -118,9 +140,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List> arrayArrayOfInteger = default; - List> arrayArrayOfModel = default; - List arrayOfString = default; + Option>> arrayArrayOfInteger = default; + Option>> arrayArrayOfModel = default; + Option> arrayOfString = default; while (utf8JsonReader.Read()) { @@ -139,15 +161,15 @@ namespace Org.OpenAPITools.Model { case "array_array_of_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfInteger = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfInteger = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "array_array_of_model": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayArrayOfModel = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + arrayArrayOfModel = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "array_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayOfString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -155,14 +177,14 @@ namespace Org.OpenAPITools.Model } } - if (arrayArrayOfInteger == null) - throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is required for class ArrayTest."); + if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest."); - if (arrayArrayOfModel == null) - throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is required for class ArrayTest."); + if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest."); - if (arrayOfString == null) - throw new ArgumentNullException(nameof(arrayOfString), "Property is required for class ArrayTest."); + if (arrayOfString.IsSet && arrayOfString.Value == null) + throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest."); return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString); } @@ -191,12 +213,30 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_array_of_integer"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); - writer.WritePropertyName("array_array_of_model"); - JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); - writer.WritePropertyName("array_of_string"); - JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfIntegerOption.IsSet) + { + writer.WritePropertyName("array_array_of_integer"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); + } + if (arrayTest.ArrayArrayOfModelOption.IsSet) + { + writer.WritePropertyName("array_array_of_model"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); + } + if (arrayTest.ArrayOfStringOption.IsSet) + { + writer.WritePropertyName("array_of_string"); + JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs index 75bab7a8d05..bab9e17b824 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// lengthCm [JsonConstructor] - public Banana(decimal lengthCm) + public Banana(Option lengthCm = default) { - LengthCm = lengthCm; + LengthCmOption = lengthCm; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of LengthCm + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LengthCmOption { get; private set; } + /// /// Gets or Sets LengthCm /// [JsonPropertyName("lengthCm")] - public decimal LengthCm { get; set; } + public decimal? LengthCm { get { return this. LengthCmOption; } set { this.LengthCmOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; + Option lengthCm = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -127,10 +135,10 @@ namespace Org.OpenAPITools.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class Banana."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana."); - return new Banana(lengthCm.Value); + return new Banana(lengthCm); } /// @@ -157,7 +165,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("lengthCm", banana.LengthCm); + if (banana.LengthCmOption.IsSet) + writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs index 61e5cf312cc..82a047319d3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// lengthCm /// sweet [JsonConstructor] - public BananaReq(decimal lengthCm, bool sweet) + public BananaReq(decimal lengthCm, Option sweet = default) { LengthCm = lengthCm; - Sweet = sweet; + SweetOption = sweet; OnCreated(); } @@ -49,11 +50,18 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } + /// + /// Used to track the state of Sweet + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SweetOption { get; private set; } + /// /// Gets or Sets Sweet /// [JsonPropertyName("sweet")] - public bool Sweet { get; set; } + public bool? Sweet { get { return this. SweetOption; } set { this.SweetOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -102,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? lengthCm = default; - bool? sweet = default; + Option lengthCm = default; + Option sweet = default; while (utf8JsonReader.Read()) { @@ -122,11 +130,11 @@ namespace Org.OpenAPITools.Model { case "lengthCm": if (utf8JsonReader.TokenType != JsonTokenType.Null) - lengthCm = utf8JsonReader.GetDecimal(); + lengthCm = new Option(utf8JsonReader.GetDecimal()); break; case "sweet": if (utf8JsonReader.TokenType != JsonTokenType.Null) - sweet = utf8JsonReader.GetBoolean(); + sweet = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -134,13 +142,16 @@ namespace Org.OpenAPITools.Model } } - if (lengthCm == null) - throw new ArgumentNullException(nameof(lengthCm), "Property is required for class BananaReq."); + if (!lengthCm.IsSet) + throw new ArgumentException("Property is required for class BananaReq.", nameof(lengthCm)); - if (sweet == null) - throw new ArgumentNullException(nameof(sweet), "Property is required for class BananaReq."); + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq."); - return new BananaReq(lengthCm.Value, sweet.Value); + if (sweet.IsSet && sweet.Value == null) + throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq."); + + return new BananaReq(lengthCm.Value.Value, sweet); } /// @@ -168,7 +179,9 @@ namespace Org.OpenAPITools.Model public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); - writer.WriteBoolean("sweet", bananaReq.Sweet); + + if (bananaReq.SweetOption.IsSet) + writer.WriteBoolean("sweet", bananaReq.SweetOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs index c9e4a8bc712..53c20a25cd1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class BasquePig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class BasquePig.", nameof(className)); - return new BasquePig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class BasquePig."); + + return new BasquePig(className.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) { + if (basquePig.ClassName == null) + throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig."); + writer.WriteString("className", basquePig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs index ca7eb413c65..b038e95b9c0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -38,55 +39,97 @@ namespace Org.OpenAPITools.Model /// smallCamel /// smallSnake [JsonConstructor] - public Capitalization(string aTTNAME, string capitalCamel, string capitalSnake, string sCAETHFlowPoints, string smallCamel, string smallSnake) + public Capitalization(Option aTTNAME = default, Option capitalCamel = default, Option capitalSnake = default, Option sCAETHFlowPoints = default, Option smallCamel = default, Option smallSnake = default) { - ATT_NAME = aTTNAME; - CapitalCamel = capitalCamel; - CapitalSnake = capitalSnake; - SCAETHFlowPoints = sCAETHFlowPoints; - SmallCamel = smallCamel; - SmallSnake = smallSnake; + ATT_NAMEOption = aTTNAME; + CapitalCamelOption = capitalCamel; + CapitalSnakeOption = capitalSnake; + SCAETHFlowPointsOption = sCAETHFlowPoints; + SmallCamelOption = smallCamel; + SmallSnakeOption = smallSnake; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of ATT_NAME + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ATT_NAMEOption { get; private set; } + /// /// Name of the pet /// /// Name of the pet [JsonPropertyName("ATT_NAME")] - public string ATT_NAME { get; set; } + public string ATT_NAME { get { return this. ATT_NAMEOption; } set { this.ATT_NAMEOption = new Option(value); } } + + /// + /// Used to track the state of CapitalCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalCamelOption { get; private set; } /// /// Gets or Sets CapitalCamel /// [JsonPropertyName("CapitalCamel")] - public string CapitalCamel { get; set; } + public string CapitalCamel { get { return this. CapitalCamelOption; } set { this.CapitalCamelOption = new Option(value); } } + + /// + /// Used to track the state of CapitalSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalSnakeOption { get; private set; } /// /// Gets or Sets CapitalSnake /// [JsonPropertyName("Capital_Snake")] - public string CapitalSnake { get; set; } + public string CapitalSnake { get { return this. CapitalSnakeOption; } set { this.CapitalSnakeOption = new Option(value); } } + + /// + /// Used to track the state of SCAETHFlowPoints + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SCAETHFlowPointsOption { get; private set; } /// /// Gets or Sets SCAETHFlowPoints /// [JsonPropertyName("SCA_ETH_Flow_Points")] - public string SCAETHFlowPoints { get; set; } + public string SCAETHFlowPoints { get { return this. SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new Option(value); } } + + /// + /// Used to track the state of SmallCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallCamelOption { get; private set; } /// /// Gets or Sets SmallCamel /// [JsonPropertyName("smallCamel")] - public string SmallCamel { get; set; } + public string SmallCamel { get { return this. SmallCamelOption; } set { this.SmallCamelOption = new Option(value); } } + + /// + /// Used to track the state of SmallSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallSnakeOption { get; private set; } /// /// Gets or Sets SmallSnake /// [JsonPropertyName("small_Snake")] - public string SmallSnake { get; set; } + public string SmallSnake { get { return this. SmallSnakeOption; } set { this.SmallSnakeOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -146,12 +189,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string aTTNAME = default; - string capitalCamel = default; - string capitalSnake = default; - string sCAETHFlowPoints = default; - string smallCamel = default; - string smallSnake = default; + Option aTTNAME = default; + Option capitalCamel = default; + Option capitalSnake = default; + Option sCAETHFlowPoints = default; + Option smallCamel = default; + Option smallSnake = default; while (utf8JsonReader.Read()) { @@ -169,22 +212,22 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "ATT_NAME": - aTTNAME = utf8JsonReader.GetString(); + aTTNAME = new Option(utf8JsonReader.GetString()); break; case "CapitalCamel": - capitalCamel = utf8JsonReader.GetString(); + capitalCamel = new Option(utf8JsonReader.GetString()); break; case "Capital_Snake": - capitalSnake = utf8JsonReader.GetString(); + capitalSnake = new Option(utf8JsonReader.GetString()); break; case "SCA_ETH_Flow_Points": - sCAETHFlowPoints = utf8JsonReader.GetString(); + sCAETHFlowPoints = new Option(utf8JsonReader.GetString()); break; case "smallCamel": - smallCamel = utf8JsonReader.GetString(); + smallCamel = new Option(utf8JsonReader.GetString()); break; case "small_Snake": - smallSnake = utf8JsonReader.GetString(); + smallSnake = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,23 +235,23 @@ namespace Org.OpenAPITools.Model } } - if (aTTNAME == null) - throw new ArgumentNullException(nameof(aTTNAME), "Property is required for class Capitalization."); + if (aTTNAME.IsSet && aTTNAME.Value == null) + throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization."); - if (capitalCamel == null) - throw new ArgumentNullException(nameof(capitalCamel), "Property is required for class Capitalization."); + if (capitalCamel.IsSet && capitalCamel.Value == null) + throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization."); - if (capitalSnake == null) - throw new ArgumentNullException(nameof(capitalSnake), "Property is required for class Capitalization."); + if (capitalSnake.IsSet && capitalSnake.Value == null) + throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization."); - if (sCAETHFlowPoints == null) - throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is required for class Capitalization."); + if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null) + throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization."); - if (smallCamel == null) - throw new ArgumentNullException(nameof(smallCamel), "Property is required for class Capitalization."); + if (smallCamel.IsSet && smallCamel.Value == null) + throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization."); - if (smallSnake == null) - throw new ArgumentNullException(nameof(smallSnake), "Property is required for class Capitalization."); + if (smallSnake.IsSet && smallSnake.Value == null) + throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization."); return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake); } @@ -237,12 +280,41 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("ATT_NAME", capitalization.ATT_NAME); - writer.WriteString("CapitalCamel", capitalization.CapitalCamel); - writer.WriteString("Capital_Snake", capitalization.CapitalSnake); - writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); - writer.WriteString("smallCamel", capitalization.SmallCamel); - writer.WriteString("small_Snake", capitalization.SmallSnake); + if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null) + throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization."); + + if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null) + throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization."); + + if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null) + throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization."); + + if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null) + throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization."); + + if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null) + throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization."); + + if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null) + throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization."); + + if (capitalization.ATT_NAMEOption.IsSet) + writer.WriteString("ATT_NAME", capitalization.ATT_NAME); + + if (capitalization.CapitalCamelOption.IsSet) + writer.WriteString("CapitalCamel", capitalization.CapitalCamel); + + if (capitalization.CapitalSnakeOption.IsSet) + writer.WriteString("Capital_Snake", capitalization.CapitalSnake); + + if (capitalization.SCAETHFlowPointsOption.IsSet) + writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); + + if (capitalization.SmallCamelOption.IsSet) + writer.WriteString("smallCamel", capitalization.SmallCamel); + + if (capitalization.SmallSnakeOption.IsSet) + writer.WriteString("small_Snake", capitalization.SmallSnake); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs index 619fc52ce11..d032e72761d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -32,22 +33,29 @@ namespace Org.OpenAPITools.Model /// Initializes a new instance of the class. /// /// className - /// declawed /// color (default to "red") + /// declawed [JsonConstructor] - public Cat(string className, bool declawed, string color = @"red") : base(className, color) + public Cat(string className, Option color = default, Option declawed = default) : base(className, color) { - Declawed = declawed; + DeclawedOption = declawed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Declawed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeclawedOption { get; private set; } + /// /// Gets or Sets Declawed /// [JsonPropertyName("declawed")] - public bool Declawed { get; set; } + public bool? Declawed { get { return this. DeclawedOption; } set { this.DeclawedOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -86,9 +94,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - bool? declawed = default; - string color = default; + Option className = default; + Option color = default; + Option declawed = default; while (utf8JsonReader.Read()) { @@ -106,14 +114,14 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); break; case "declawed": if (utf8JsonReader.TokenType != JsonTokenType.Null) - declawed = utf8JsonReader.GetBoolean(); - break; - case "color": - color = utf8JsonReader.GetString(); + declawed = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -121,16 +129,19 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Cat."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Cat.", nameof(className)); - if (declawed == null) - throw new ArgumentNullException(nameof(declawed), "Property is required for class Cat."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Cat."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat."); - return new Cat(className, declawed.Value, color); + if (declawed.IsSet && declawed.Value == null) + throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); + + return new Cat(className.Value, color, declawed); } /// @@ -157,9 +168,19 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { + if (cat.ClassName == null) + throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); + + if (cat.ColorOption.IsSet && cat.Color == null) + throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); + writer.WriteString("className", cat.ClassName); - writer.WriteBoolean("declawed", cat.Declawed); - writer.WriteString("color", cat.Color); + + if (cat.ColorOption.IsSet) + writer.WriteString("color", cat.Color); + + if (cat.DeclawedOption.IsSet) + writer.WriteBoolean("declawed", cat.DeclawedOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs index 6139c304839..315dd17bd31 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,20 +35,27 @@ namespace Org.OpenAPITools.Model /// id /// name (default to "default-name") [JsonConstructor] - public Category(long id, string name = @"default-name") + public Category(Option id = default, string name = @"default-name") { - Id = id; + IdOption = id; Name = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new Option(value); } } /// /// Gets or Sets Name @@ -109,8 +117,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -129,10 +137,10 @@ namespace Org.OpenAPITools.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -140,13 +148,16 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Category."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Category.", nameof(name)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Category."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category."); - return new Category(id.Value, name); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category."); + + return new Category(id, name.Value); } /// @@ -173,7 +184,12 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", category.Id); + if (category.Name == null) + throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category."); + + if (category.IdOption.IsSet) + writer.WriteNumber("id", category.IdOption.Value.Value); + writer.WriteString("name", category.Name); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs index a3282125986..52579d16971 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// name /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(string name, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value)) { - Name = name; - PetType = petType; + NameOption = name; + PetTypeOption = petType; OnCreated(); } @@ -87,26 +88,39 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string PetTypeEnumToJsonValue(PetTypeEnum value) + public static string PetTypeEnumToJsonValue(PetTypeEnum? value) { - if (value == PetTypeEnum.ChildCat) return "ChildCat"; throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of PetType + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new Option PetTypeOption { get; private set; } + /// /// Gets or Sets PetType /// [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } + public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -146,8 +160,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string name = default; - ChildCat.PetTypeEnum? petType = default; + Option name = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -165,13 +179,12 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; case "pet_type": string petTypeRawValue = utf8JsonReader.GetString(); - petType = petTypeRawValue == null - ? null - : ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue); + if (petTypeRawValue != null) + petType = new Option(ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue)); break; default: break; @@ -179,13 +192,13 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class ChildCat."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ChildCat."); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value); + return new ChildCat(name, petType); } /// @@ -212,9 +225,13 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", childCat.Name); + if (childCat.NameOption.IsSet && childCat.Name == null) + throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat."); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); + if (childCat.NameOption.IsSet) + writer.WriteString("name", childCat.Name); + + var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value.Value); if (petTypeRawValue != null) writer.WriteString("pet_type", petTypeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs index d1c65d36819..b7ef5105c6a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varClass [JsonConstructor] - public ClassModel(string varClass) + public ClassModel(Option varClass = default) { - VarClass = varClass; + VarClassOption = varClass; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("_class")] - public string VarClass { get; set; } + public string VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varClass = default; + Option varClass = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "_class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class ClassModel."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel."); return new ClassModel(varClass); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_class", classModel.VarClass); + if (classModel.VarClassOption.IsSet && classModel.VarClass == null) + throw new ArgumentNullException(nameof(classModel.VarClass), "Property is required for class ClassModel."); + + if (classModel.VarClassOption.IsSet) + writer.WriteString("_class", classModel.VarClass); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 79579247f7e..747b36ec65b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; - string shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class ComplexQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ComplexQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(shapeType)); - return new ComplexQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class ComplexQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ComplexQuadrilateral."); + + return new ComplexQuadrilateral(quadrilateralType.Value, shapeType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (complexQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral."); + + if (complexQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral."); + writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", complexQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs index 84439210bcf..c28634e4e13 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class DanishPig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class DanishPig.", nameof(className)); - return new DanishPig(className); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class DanishPig."); + + return new DanishPig(className.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) { + if (danishPig.ClassName == null) + throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig."); + writer.WriteString("className", danishPig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 4420630af34..9bfd36317da 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,20 +34,27 @@ namespace Org.OpenAPITools.Model /// /// dateOnlyProperty [JsonConstructor] - public DateOnlyClass(DateTime dateOnlyProperty) + public DateOnlyClass(Option dateOnlyProperty = default) { - DateOnlyProperty = dateOnlyProperty; + DateOnlyPropertyOption = dateOnlyProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateOnlyProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateOnlyPropertyOption { get; private set; } + /// /// Gets or Sets DateOnlyProperty /// /// Fri Jul 21 00:00:00 UTC 2017 [JsonPropertyName("dateOnlyProperty")] - public DateTime DateOnlyProperty { get; set; } + public DateTime? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -106,7 +114,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateOnlyProperty = default; + Option dateOnlyProperty = default; while (utf8JsonReader.Read()) { @@ -125,7 +133,7 @@ namespace Org.OpenAPITools.Model { case "dateOnlyProperty": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -133,10 +141,10 @@ namespace Org.OpenAPITools.Model } } - if (dateOnlyProperty == null) - throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is required for class DateOnlyClass."); + if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null) + throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass."); - return new DateOnlyClass(dateOnlyProperty.Value); + return new DateOnlyClass(dateOnlyProperty); } /// @@ -163,7 +171,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(DateOnlyPropertyFormat)); + if (dateOnlyClass.DateOnlyPropertyOption.IsSet) + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat)); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 16e3dfe57fa..1ef8301d0c3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// name [JsonConstructor] - public DeprecatedObject(string name) + public DeprecatedObject(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class DeprecatedObject."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject."); return new DeprecatedObject(name); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", deprecatedObject.Name); + if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null) + throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject."); + + if (deprecatedObject.NameOption.IsSet) + writer.WriteString("name", deprecatedObject.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs index 810934b95ef..933668a9426 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,23 +32,30 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// breed /// className + /// breed /// color (default to "red") [JsonConstructor] - public Dog(string breed, string className, string color = @"red") : base(className, color) + public Dog(string className, Option breed = default, Option color = default) : base(className, color) { - Breed = breed; + BreedOption = breed; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Breed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BreedOption { get; private set; } + /// /// Gets or Sets Breed /// [JsonPropertyName("breed")] - public string Breed { get; set; } + public string Breed { get { return this. BreedOption; } set { this.BreedOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -86,9 +94,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string breed = default; - string className = default; - string color = default; + Option className = default; + Option breed = default; + Option color = default; while (utf8JsonReader.Read()) { @@ -105,14 +113,14 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "breed": - breed = utf8JsonReader.GetString(); - break; case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); + break; + case "breed": + breed = new Option(utf8JsonReader.GetString()); break; case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -120,16 +128,19 @@ namespace Org.OpenAPITools.Model } } - if (breed == null) - throw new ArgumentNullException(nameof(breed), "Property is required for class Dog."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Dog.", nameof(className)); - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Dog."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog."); - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Dog."); + if (breed.IsSet && breed.Value == null) + throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog."); - return new Dog(breed, className, color); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); + + return new Dog(className.Value, breed, color); } /// @@ -156,9 +167,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("breed", dog.Breed); + if (dog.ClassName == null) + throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); + + if (dog.BreedOption.IsSet && dog.Breed == null) + throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); + + if (dog.ColorOption.IsSet && dog.Color == null) + throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog."); + writer.WriteString("className", dog.ClassName); - writer.WriteString("color", dog.Color); + + if (dog.BreedOption.IsSet) + writer.WriteString("breed", dog.Breed); + + if (dog.ColorOption.IsSet) + writer.WriteString("color", dog.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs index 68f7676ff91..63a985af8fc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -32,44 +33,72 @@ namespace Org.OpenAPITools.Model /// Initializes a new instance of the class. /// /// mainShape - /// shapes /// nullableShape /// shapeOrNull + /// shapes [JsonConstructor] - public Drawing(Shape mainShape, List shapes, NullableShape nullableShape = default, ShapeOrNull shapeOrNull = default) : base() + public Drawing(Option mainShape = default, Option nullableShape = default, Option shapeOrNull = default, Option> shapes = default) : base() { - MainShape = mainShape; - Shapes = shapes; - NullableShape = nullableShape; - ShapeOrNull = shapeOrNull; + MainShapeOption = mainShape; + NullableShapeOption = nullableShape; + ShapeOrNullOption = shapeOrNull; + ShapesOption = shapes; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MainShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MainShapeOption { get; private set; } + /// /// Gets or Sets MainShape /// [JsonPropertyName("mainShape")] - public Shape MainShape { get; set; } + public Shape MainShape { get { return this. MainShapeOption; } set { this.MainShapeOption = new Option(value); } } /// - /// Gets or Sets Shapes + /// Used to track the state of NullableShape /// - [JsonPropertyName("shapes")] - public List Shapes { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableShapeOption { get; private set; } /// /// Gets or Sets NullableShape /// [JsonPropertyName("nullableShape")] - public NullableShape NullableShape { get; set; } + public NullableShape NullableShape { get { return this. NullableShapeOption; } set { this.NullableShapeOption = new Option(value); } } + + /// + /// Used to track the state of ShapeOrNull + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShapeOrNullOption { get; private set; } /// /// Gets or Sets ShapeOrNull /// [JsonPropertyName("shapeOrNull")] - public ShapeOrNull ShapeOrNull { get; set; } + public ShapeOrNull ShapeOrNull { get { return this. ShapeOrNullOption; } set { this.ShapeOrNullOption = new Option(value); } } + + /// + /// Used to track the state of Shapes + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ShapesOption { get; private set; } + + /// + /// Gets or Sets Shapes + /// + [JsonPropertyName("shapes")] + public List Shapes { get { return this. ShapesOption; } set { this.ShapesOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -87,9 +116,9 @@ namespace Org.OpenAPITools.Model sb.Append("class Drawing {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" MainShape: ").Append(MainShape).Append("\n"); - sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -138,10 +167,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Shape mainShape = default; - List shapes = default; - NullableShape nullableShape = default; - ShapeOrNull shapeOrNull = default; + Option mainShape = default; + Option nullableShape = default; + Option shapeOrNull = default; + Option> shapes = default; while (utf8JsonReader.Read()) { @@ -160,19 +189,19 @@ namespace Org.OpenAPITools.Model { case "mainShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mainShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "shapes": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapes = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mainShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "nullableShape": if (utf8JsonReader.TokenType != JsonTokenType.Null) - nullableShape = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shapeOrNull = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapes": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapes = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -180,13 +209,13 @@ namespace Org.OpenAPITools.Model } } - if (mainShape == null) - throw new ArgumentNullException(nameof(mainShape), "Property is required for class Drawing."); + if (mainShape.IsSet && mainShape.Value == null) + throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapes == null) - throw new ArgumentNullException(nameof(shapes), "Property is required for class Drawing."); + if (shapes.IsSet && shapes.Value == null) + throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); - return new Drawing(mainShape, shapes, nullableShape, shapeOrNull); + return new Drawing(mainShape, nullableShape, shapeOrNull, shapes); } /// @@ -213,14 +242,38 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("mainShape"); - JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); - writer.WritePropertyName("shapes"); - JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); - writer.WritePropertyName("nullableShape"); - JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) + throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) + throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); + + if (drawing.MainShapeOption.IsSet) + { + writer.WritePropertyName("mainShape"); + JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); + } + if (drawing.NullableShapeOption.IsSet) + if (drawing.NullableShapeOption.Value != null) + { + writer.WritePropertyName("nullableShape"); + JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); + } + else + writer.WriteNull("nullableShape"); + if (drawing.ShapeOrNullOption.IsSet) + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); + if (drawing.ShapesOption.IsSet) + { + writer.WritePropertyName("shapes"); + JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs index 58cf3e310f8..4780ffd6faf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// arrayEnum /// justSymbol [JsonConstructor] - public EnumArrays(List arrayEnum, JustSymbolEnum justSymbol) + public EnumArrays(Option> arrayEnum = default, Option justSymbol = default) { - ArrayEnum = arrayEnum; - JustSymbol = justSymbol; + ArrayEnumOption = arrayEnum; + JustSymbolOption = justSymbol; OnCreated(); } @@ -100,7 +101,6 @@ namespace Org.OpenAPITools.Model /// public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum value) { - if (value == ArrayEnumEnum.Fish) return "fish"; @@ -165,9 +165,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string JustSymbolEnumToJsonValue(JustSymbolEnum value) + public static string JustSymbolEnumToJsonValue(JustSymbolEnum? value) { - if (value == JustSymbolEnum.GreaterThanOrEqualTo) return ">="; @@ -177,17 +176,31 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of JustSymbol + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustSymbolOption { get; private set; } + /// /// Gets or Sets JustSymbol /// [JsonPropertyName("just_symbol")] - public JustSymbolEnum JustSymbol { get; set; } + public JustSymbolEnum? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new Option(value); } } + + /// + /// Used to track the state of ArrayEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayEnumOption { get; private set; } /// /// Gets or Sets ArrayEnum /// [JsonPropertyName("array_enum")] - public List ArrayEnum { get; set; } + public List ArrayEnum { get { return this. ArrayEnumOption; } set { this.ArrayEnumOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -243,8 +256,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List arrayEnum = default; - EnumArrays.JustSymbolEnum? justSymbol = default; + Option> arrayEnum = default; + Option justSymbol = default; while (utf8JsonReader.Read()) { @@ -263,13 +276,12 @@ namespace Org.OpenAPITools.Model { case "array_enum": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayEnum = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayEnum = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "just_symbol": string justSymbolRawValue = utf8JsonReader.GetString(); - justSymbol = justSymbolRawValue == null - ? null - : EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue); + if (justSymbolRawValue != null) + justSymbol = new Option(EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue)); break; default: break; @@ -277,13 +289,13 @@ namespace Org.OpenAPITools.Model } } - if (arrayEnum == null) - throw new ArgumentNullException(nameof(arrayEnum), "Property is required for class EnumArrays."); + if (arrayEnum.IsSet && arrayEnum.Value == null) + throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays."); - if (justSymbol == null) - throw new ArgumentNullException(nameof(justSymbol), "Property is required for class EnumArrays."); + if (justSymbol.IsSet && justSymbol.Value == null) + throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays."); - return new EnumArrays(arrayEnum, justSymbol.Value); + return new EnumArrays(arrayEnum, justSymbol); } /// @@ -310,10 +322,15 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_enum"); - JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null) + throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays."); - var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbol); + if (enumArrays.ArrayEnumOption.IsSet) + { + writer.WritePropertyName("array_enum"); + JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + } + var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value.Value); if (justSymbolRawValue != null) writer.WriteString("just_symbol", justSymbolRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs index 94c2361c881..b1aff0adf0d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs index f3310c22a12..0a730df5230 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,392 +32,32 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// enumStringRequired /// enumInteger /// enumIntegerOnly /// enumNumber /// enumString - /// enumStringRequired + /// outerEnum /// outerEnumDefaultValue /// outerEnumInteger /// outerEnumIntegerDefaultValue - /// outerEnum [JsonConstructor] - public EnumTest(EnumIntegerEnum enumInteger, EnumIntegerOnlyEnum enumIntegerOnly, EnumNumberEnum enumNumber, EnumStringEnum enumString, EnumStringRequiredEnum enumStringRequired, OuterEnumDefaultValue outerEnumDefaultValue, OuterEnumInteger outerEnumInteger, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue, OuterEnum? outerEnum = default) + public EnumTest(EnumStringRequiredEnum enumStringRequired, Option enumInteger = default, Option enumIntegerOnly = default, Option enumNumber = default, Option enumString = default, Option outerEnum = default, Option outerEnumDefaultValue = default, Option outerEnumInteger = default, Option outerEnumIntegerDefaultValue = default) { - EnumInteger = enumInteger; - EnumIntegerOnly = enumIntegerOnly; - EnumNumber = enumNumber; - EnumString = enumString; EnumStringRequired = enumStringRequired; - OuterEnumDefaultValue = outerEnumDefaultValue; - OuterEnumInteger = outerEnumInteger; - OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - OuterEnum = outerEnum; + EnumIntegerOption = enumInteger; + EnumIntegerOnlyOption = enumIntegerOnly; + EnumNumberOption = enumNumber; + EnumStringOption = enumString; + OuterEnumOption = outerEnum; + OuterEnumDefaultValueOption = outerEnumDefaultValue; + OuterEnumIntegerOption = outerEnumInteger; + OuterEnumIntegerDefaultValueOption = outerEnumIntegerDefaultValue; OnCreated(); } partial void OnCreated(); - /// - /// Defines EnumInteger - /// - public enum EnumIntegerEnum - { - /// - /// Enum NUMBER_1 for value: 1 - /// - NUMBER_1 = 1, - - /// - /// Enum NUMBER_MINUS_1 for value: -1 - /// - NUMBER_MINUS_1 = -1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerEnum EnumIntegerEnumFromString(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) - { - if (value.Equals((1).ToString())) - return EnumIntegerEnum.NUMBER_1; - - if (value.Equals((-1).ToString())) - return EnumIntegerEnum.NUMBER_MINUS_1; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumInteger - /// - [JsonPropertyName("enum_integer")] - public EnumIntegerEnum EnumInteger { get; set; } - - /// - /// Defines EnumIntegerOnly - /// - public enum EnumIntegerOnlyEnum - { - /// - /// Enum NUMBER_2 for value: 2 - /// - NUMBER_2 = 2, - - /// - /// Enum NUMBER_MINUS_2 for value: -2 - /// - NUMBER_MINUS_2 = -2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) - { - if (value.Equals((2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_2; - - if (value.Equals((-2).ToString())) - return EnumIntegerOnlyEnum.NUMBER_MINUS_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) - { - return (int) value; - } - - /// - /// Gets or Sets EnumIntegerOnly - /// - [JsonPropertyName("enum_integer_only")] - public EnumIntegerOnlyEnum EnumIntegerOnly { get; set; } - - /// - /// Defines EnumNumber - /// - public enum EnumNumberEnum - { - /// - /// Enum NUMBER_1_DOT_1 for value: 1.1 - /// - NUMBER_1_DOT_1 = 1, - - /// - /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 - /// - NUMBER_MINUS_1_DOT_2 = 2 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumNumberEnum EnumNumberEnumFromString(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) - { - if (value.Equals("1.1")) - return EnumNumberEnum.NUMBER_1_DOT_1; - - if (value.Equals("-1.2")) - return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static double EnumNumberEnumToJsonValue(EnumNumberEnum value) - { - - if (value == EnumNumberEnum.NUMBER_1_DOT_1) - return 1.1; - - if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) - return -1.2; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumNumber - /// - [JsonPropertyName("enum_number")] - public EnumNumberEnum EnumNumber { get; set; } - - /// - /// Defines EnumString - /// - public enum EnumStringEnum - { - /// - /// Enum UPPER for value: UPPER - /// - UPPER = 1, - - /// - /// Enum Lower for value: lower - /// - Lower = 2, - - /// - /// Enum Empty for value: - /// - Empty = 3, - - /// - /// Enum ValuewithTab for value: Value\twith tab - /// - ValuewithTab = 4, - - /// - /// Enum ValueWithQuote for value: Value with \" quote - /// - ValueWithQuote = 5, - - /// - /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote - /// - ValueWithEscapedQuote = 6, - - /// - /// Enum Duplicatevalue for value: Duplicate\nvalue - /// - Duplicatevalue = 7, - - /// - /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue - /// - Duplicatevalue2 = 8 - } - - /// - /// Returns a - /// - /// - /// - /// - public static EnumStringEnum EnumStringEnumFromString(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) - { - if (value.Equals("UPPER")) - return EnumStringEnum.UPPER; - - if (value.Equals("lower")) - return EnumStringEnum.Lower; - - if (value.Equals("")) - return EnumStringEnum.Empty; - - if (value.Equals("Value\twith tab")) - return EnumStringEnum.ValuewithTab; - - if (value.Equals("Value with \" quote")) - return EnumStringEnum.ValueWithQuote; - - if (value.Equals("Value with escaped \" quote")) - return EnumStringEnum.ValueWithEscapedQuote; - - if (value.Equals("Duplicate\nvalue")) - return EnumStringEnum.Duplicatevalue; - - if (value.Equals("Duplicate\r\nvalue")) - return EnumStringEnum.Duplicatevalue2; - - return null; - } - - /// - /// Converts the to the json value - /// - /// - /// - /// - public static string EnumStringEnumToJsonValue(EnumStringEnum value) - { - - if (value == EnumStringEnum.UPPER) - return "UPPER"; - - if (value == EnumStringEnum.Lower) - return "lower"; - - if (value == EnumStringEnum.Empty) - return ""; - - if (value == EnumStringEnum.ValuewithTab) - return "Value\twith tab"; - - if (value == EnumStringEnum.ValueWithQuote) - return "Value with \" quote"; - - if (value == EnumStringEnum.ValueWithEscapedQuote) - return "Value with escaped \" quote"; - - if (value == EnumStringEnum.Duplicatevalue) - return "Duplicate\nvalue"; - - if (value == EnumStringEnum.Duplicatevalue2) - return "Duplicate\r\nvalue"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } - - /// - /// Gets or Sets EnumString - /// - [JsonPropertyName("enum_string")] - public EnumStringEnum EnumString { get; set; } - /// /// Defines EnumStringRequired /// @@ -540,7 +181,6 @@ namespace Org.OpenAPITools.Model /// public static string EnumStringRequiredEnumToJsonValue(EnumStringRequiredEnum value) { - if (value == EnumStringRequiredEnum.UPPER) return "UPPER"; @@ -575,28 +215,442 @@ namespace Org.OpenAPITools.Model public EnumStringRequiredEnum EnumStringRequired { get; set; } /// - /// Gets or Sets OuterEnumDefaultValue + /// Defines EnumInteger /// - [JsonPropertyName("outerEnumDefaultValue")] - public OuterEnumDefaultValue OuterEnumDefaultValue { get; set; } + public enum EnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } /// - /// Gets or Sets OuterEnumInteger + /// Returns a /// - [JsonPropertyName("outerEnumInteger")] - public OuterEnumInteger OuterEnumInteger { get; set; } + /// + /// + /// + public static EnumIntegerEnum EnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); + } /// - /// Gets or Sets OuterEnumIntegerDefaultValue + /// Returns a /// - [JsonPropertyName("outerEnumIntegerDefaultValue")] - public OuterEnumIntegerDefaultValue OuterEnumIntegerDefaultValue { get; set; } + /// + /// + public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOption { get; private set; } + + /// + /// Gets or Sets EnumInteger + /// + [JsonPropertyName("enum_integer")] + public EnumIntegerEnum? EnumInteger { get { return this.EnumIntegerOption; } set { this.EnumIntegerOption = new Option(value); } } + + /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets EnumIntegerOnly + /// + [JsonPropertyName("enum_integer_only")] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get { return this.EnumIntegerOnlyOption; } set { this.EnumIntegerOnlyOption = new Option(value); } } + + /// + /// Defines EnumNumber + /// + public enum EnumNumberEnum + { + /// + /// Enum NUMBER_1_DOT_1 for value: 1.1 + /// + NUMBER_1_DOT_1 = 1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 + /// + NUMBER_MINUS_1_DOT_2 = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumNumberEnum EnumNumberEnumFromString(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static double EnumNumberEnumToJsonValue(EnumNumberEnum? value) + { + if (value == EnumNumberEnum.NUMBER_1_DOT_1) + return 1.1; + + if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) + return -1.2; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumNumberOption { get; private set; } + + /// + /// Gets or Sets EnumNumber + /// + [JsonPropertyName("enum_number")] + public EnumNumberEnum? EnumNumber { get { return this.EnumNumberOption; } set { this.EnumNumberOption = new Option(value); } } + + /// + /// Defines EnumString + /// + public enum EnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumStringEnum EnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string EnumStringEnumToJsonValue(EnumStringEnum? value) + { + if (value == EnumStringEnum.UPPER) + return "UPPER"; + + if (value == EnumStringEnum.Lower) + return "lower"; + + if (value == EnumStringEnum.Empty) + return ""; + + if (value == EnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumStringOption { get; private set; } + + /// + /// Gets or Sets EnumString + /// + [JsonPropertyName("enum_string")] + public EnumStringEnum? EnumString { get { return this.EnumStringOption; } set { this.EnumStringOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumOption { get; private set; } /// /// Gets or Sets OuterEnum /// [JsonPropertyName("outerEnum")] - public OuterEnum? OuterEnum { get; set; } + public OuterEnum? OuterEnum { get { return this.OuterEnumOption; } set { this.OuterEnumOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumDefaultValue + /// + [JsonPropertyName("outerEnumDefaultValue")] + public OuterEnumDefaultValue? OuterEnumDefaultValue { get { return this.OuterEnumDefaultValueOption; } set { this.OuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets OuterEnumInteger + /// + [JsonPropertyName("outerEnumInteger")] + public OuterEnumInteger? OuterEnumInteger { get { return this.OuterEnumIntegerOption; } set { this.OuterEnumIntegerOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumIntegerDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumIntegerDefaultValue + /// + [JsonPropertyName("outerEnumIntegerDefaultValue")] + public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get { return this.OuterEnumIntegerDefaultValueOption; } set { this.OuterEnumIntegerDefaultValueOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -612,15 +666,15 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EnumTest {\n"); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); sb.Append(" EnumString: ").Append(EnumString).Append("\n"); - sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); - sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -659,15 +713,15 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - EnumTest.EnumIntegerEnum? enumInteger = default; - EnumTest.EnumIntegerOnlyEnum? enumIntegerOnly = default; - EnumTest.EnumNumberEnum? enumNumber = default; - EnumTest.EnumStringEnum? enumString = default; - EnumTest.EnumStringRequiredEnum? enumStringRequired = default; - OuterEnumDefaultValue? outerEnumDefaultValue = default; - OuterEnumInteger? outerEnumInteger = default; - OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default; - OuterEnum? outerEnum = default; + Option enumStringRequired = default; + Option enumInteger = default; + Option enumIntegerOnly = default; + Option enumNumber = default; + Option enumString = default; + Option outerEnum = default; + Option outerEnumDefaultValue = default; + Option outerEnumInteger = default; + Option outerEnumIntegerDefaultValue = default; while (utf8JsonReader.Read()) { @@ -684,53 +738,47 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "enum_string_required": + string enumStringRequiredRawValue = utf8JsonReader.GetString(); + if (enumStringRequiredRawValue != null) + enumStringRequired = new Option(EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue)); + break; case "enum_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumInteger = (EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32(); + enumInteger = new Option((EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32()); break; case "enum_integer_only": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumIntegerOnly = (EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32(); + enumIntegerOnly = new Option((EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); break; case "enum_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - enumNumber = (EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32(); + enumNumber = new Option((EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32()); break; case "enum_string": string enumStringRawValue = utf8JsonReader.GetString(); - enumString = enumStringRawValue == null - ? null - : EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue); - break; - case "enum_string_required": - string enumStringRequiredRawValue = utf8JsonReader.GetString(); - enumStringRequired = enumStringRequiredRawValue == null - ? null - : EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue); - break; - case "outerEnumDefaultValue": - string outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumDefaultValue = outerEnumDefaultValueRawValue == null - ? null - : OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue); - break; - case "outerEnumInteger": - string outerEnumIntegerRawValue = utf8JsonReader.GetString(); - outerEnumInteger = outerEnumIntegerRawValue == null - ? null - : OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue); - break; - case "outerEnumIntegerDefaultValue": - string outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); - outerEnumIntegerDefaultValue = outerEnumIntegerDefaultValueRawValue == null - ? null - : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue); + if (enumStringRawValue != null) + enumString = new Option(EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue)); break; case "outerEnum": string outerEnumRawValue = utf8JsonReader.GetString(); - outerEnum = outerEnumRawValue == null - ? null - : OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue); + if (outerEnumRawValue != null) + outerEnum = new Option(OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue)); + break; + case "outerEnumDefaultValue": + string outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumDefaultValueRawValue != null) + outerEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue)); + break; + case "outerEnumInteger": + string outerEnumIntegerRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerRawValue != null) + outerEnumInteger = new Option(OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue)); + break; + case "outerEnumIntegerDefaultValue": + string outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerDefaultValueRawValue != null) + outerEnumIntegerDefaultValue = new Option(OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue)); break; default: break; @@ -738,31 +786,34 @@ namespace Org.OpenAPITools.Model } } - if (enumInteger == null) - throw new ArgumentNullException(nameof(enumInteger), "Property is required for class EnumTest."); + if (!enumStringRequired.IsSet) + throw new ArgumentException("Property is required for class EnumTest.", nameof(enumStringRequired)); - if (enumIntegerOnly == null) - throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is required for class EnumTest."); + if (enumStringRequired.IsSet && enumStringRequired.Value == null) + throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest."); - if (enumNumber == null) - throw new ArgumentNullException(nameof(enumNumber), "Property is required for class EnumTest."); + if (enumInteger.IsSet && enumInteger.Value == null) + throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest."); - if (enumString == null) - throw new ArgumentNullException(nameof(enumString), "Property is required for class EnumTest."); + if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest."); - if (enumStringRequired == null) - throw new ArgumentNullException(nameof(enumStringRequired), "Property is required for class EnumTest."); + if (enumNumber.IsSet && enumNumber.Value == null) + throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest."); - if (outerEnumDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is required for class EnumTest."); + if (enumString.IsSet && enumString.Value == null) + throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest."); - if (outerEnumInteger == null) - throw new ArgumentNullException(nameof(outerEnumInteger), "Property is required for class EnumTest."); + if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest."); - if (outerEnumIntegerDefaultValue == null) - throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is required for class EnumTest."); + if (outerEnumInteger.IsSet && outerEnumInteger.Value == null) + throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest."); - return new EnumTest(enumInteger.Value, enumIntegerOnly.Value, enumNumber.Value, enumString.Value, enumStringRequired.Value, outerEnumDefaultValue.Value, outerEnumInteger.Value, outerEnumIntegerDefaultValue.Value, outerEnum); + if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest."); + + return new EnumTest(enumStringRequired.Value.Value, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue); } /// @@ -789,43 +840,49 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumInteger)); - writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnly)); - writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumber)); - - var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumString); - if (enumStringRawValue != null) - writer.WriteString("enum_string", enumStringRawValue); - else - writer.WriteNull("enum_string"); - var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); if (enumStringRequiredRawValue != null) writer.WriteString("enum_string_required", enumStringRequiredRawValue); else writer.WriteNull("enum_string_required"); - var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue); + if (enumTest.EnumIntegerOption.IsSet) + writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value.Value)); - if (outerEnumDefaultValueRawValue != null) - writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + if (enumTest.EnumIntegerOnlyOption.IsSet) + writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value.Value)); + + if (enumTest.EnumNumberOption.IsSet) + writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value.Value)); + + var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value.Value); + if (enumStringRawValue != null) + writer.WriteString("enum_string", enumStringRawValue); else - writer.WriteNull("outerEnumDefaultValue"); + writer.WriteNull("enum_string"); - var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger); - writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); - var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue); - writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); - - if (enumTest.OuterEnum == null) - writer.WriteNull("outerEnum"); - else - { - var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnum.Value); - if (outerEnumRawValue != null) + if (enumTest.OuterEnumOption.IsSet) + if (enumTest.OuterEnumOption.Value != null) + { + var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnumOption.Value.Value); writer.WriteString("outerEnum", outerEnumRawValue); + } else writer.WriteNull("outerEnum"); + if (enumTest.OuterEnumDefaultValueOption.IsSet) + { + var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue.Value); + writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + } + if (enumTest.OuterEnumIntegerOption.IsSet) + { + var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger.Value); + writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); + } + if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet) + { + var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue.Value); + writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 626748ff209..bbf4bf8f8e0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; - string triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class EquilateralTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class EquilateralTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(triangleType)); - return new EquilateralTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class EquilateralTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class EquilateralTriangle."); + + return new EquilateralTriangle(shapeType.Value, triangleType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (equilateralTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle."); + + if (equilateralTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle."); + writer.WriteString("shapeType", equilateralTriangle.ShapeType); + writer.WriteString("triangleType", equilateralTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs index 905e5452f7c..213451addd4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,20 +34,27 @@ namespace Org.OpenAPITools.Model /// /// Test capitalization [JsonConstructor] - public File(string sourceURI) + public File(Option sourceURI = default) { - SourceURI = sourceURI; + SourceURIOption = sourceURI; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SourceURI + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SourceURIOption { get; private set; } + /// /// Test capitalization /// /// Test capitalization [JsonPropertyName("sourceURI")] - public string SourceURI { get; set; } + public string SourceURI { get { return this. SourceURIOption; } set { this.SourceURIOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -101,7 +109,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string sourceURI = default; + Option sourceURI = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "sourceURI": - sourceURI = utf8JsonReader.GetString(); + sourceURI = new Option(utf8JsonReader.GetString()); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (sourceURI == null) - throw new ArgumentNullException(nameof(sourceURI), "Property is required for class File."); + if (sourceURI.IsSet && sourceURI.Value == null) + throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File."); return new File(sourceURI); } @@ -157,7 +165,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("sourceURI", file.SourceURI); + if (file.SourceURIOption.IsSet && file.SourceURI == null) + throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File."); + + if (file.SourceURIOption.IsSet) + writer.WriteString("sourceURI", file.SourceURI); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 722ba3b949f..525183c27c9 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// file /// files [JsonConstructor] - public FileSchemaTestClass(File file, List files) + public FileSchemaTestClass(Option file = default, Option> files = default) { - File = file; - Files = files; + FileOption = file; + FilesOption = files; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of File + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FileOption { get; private set; } + /// /// Gets or Sets File /// [JsonPropertyName("file")] - public File File { get; set; } + public File File { get { return this. FileOption; } set { this.FileOption = new Option(value); } } + + /// + /// Used to track the state of Files + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> FilesOption { get; private set; } /// /// Gets or Sets Files /// [JsonPropertyName("files")] - public List Files { get; set; } + public List Files { get { return this. FilesOption; } set { this.FilesOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - File file = default; - List files = default; + Option file = default; + Option> files = default; while (utf8JsonReader.Read()) { @@ -129,11 +144,11 @@ namespace Org.OpenAPITools.Model { case "file": if (utf8JsonReader.TokenType != JsonTokenType.Null) - file = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + file = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "files": if (utf8JsonReader.TokenType != JsonTokenType.Null) - files = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + files = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -141,11 +156,11 @@ namespace Org.OpenAPITools.Model } } - if (file == null) - throw new ArgumentNullException(nameof(file), "Property is required for class FileSchemaTestClass."); + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass."); - if (files == null) - throw new ArgumentNullException(nameof(files), "Property is required for class FileSchemaTestClass."); + if (files.IsSet && files.Value == null) + throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass."); return new FileSchemaTestClass(file, files); } @@ -174,10 +189,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("file"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); - writer.WritePropertyName("files"); - JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FileOption.IsSet) + { + writer.WritePropertyName("file"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); + } + if (fileSchemaTestClass.FilesOption.IsSet) + { + writer.WritePropertyName("files"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs index 9cfe3b508fe..f4b99d158e8 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// bar (default to "bar") [JsonConstructor] - public Foo(string bar = @"bar") + public Foo(Option bar = default) { - Bar = bar; + BarOption = bar; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; private set; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; set; } + public string Bar { get { return this. BarOption; } set { this.BarOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string bar = default; + Option bar = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class Foo."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo."); return new Foo(bar); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", foo.Bar); + if (foo.BarOption.IsSet && foo.Bar == null) + throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo."); + + if (foo.BarOption.IsSet) + writer.WriteString("bar", foo.Bar); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index c8291e8eae5..7e6890ba3bf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varString [JsonConstructor] - public FooGetDefaultResponse(Foo varString) + public FooGetDefaultResponse(Option varString = default) { - VarString = varString; + VarStringOption = varString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } + /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public Foo VarString { get; set; } + public Foo VarString { get { return this. VarStringOption; } set { this.VarStringOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Foo varString = default; + Option varString = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varString = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varString = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FooGetDefaultResponse."); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse."); return new FooGetDefaultResponse(varString); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("string"); - JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + if (fooGetDefaultResponse.VarStringOption.IsSet && fooGetDefaultResponse.VarString == null) + throw new ArgumentNullException(nameof(fooGetDefaultResponse.VarString), "Property is required for class FooGetDefaultResponse."); + + if (fooGetDefaultResponse.VarStringOption.IsSet) + { + writer.WritePropertyName("string"); + JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs index 30a9b189932..29eff0cd769 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,9 +32,11 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// binary /// varByte /// date + /// number + /// password + /// binary /// dateTime /// varDecimal /// varDouble @@ -41,8 +44,6 @@ namespace Org.OpenAPITools.Model /// int32 /// int64 /// integer - /// number - /// password /// None /// A string that is a 10 digit number. Can have leading zeros. /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. @@ -51,38 +52,32 @@ namespace Org.OpenAPITools.Model /// unsignedLong /// uuid [JsonConstructor] - public FormatTest(System.IO.Stream binary, byte[] varByte, DateTime date, DateTime dateTime, decimal varDecimal, double varDouble, float varFloat, int int32, long int64, int integer, decimal number, string password, string patternWithBackslash, string patternWithDigits, string patternWithDigitsAndDelimiter, string varString, uint unsignedInteger, ulong unsignedLong, Guid uuid) + 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) { - Binary = binary; VarByte = varByte; Date = date; - DateTime = dateTime; - VarDecimal = varDecimal; - VarDouble = varDouble; - VarFloat = varFloat; - Int32 = int32; - Int64 = int64; - Integer = integer; Number = number; Password = password; - PatternWithBackslash = patternWithBackslash; - PatternWithDigits = patternWithDigits; - PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - VarString = varString; - UnsignedInteger = unsignedInteger; - UnsignedLong = unsignedLong; - Uuid = uuid; + BinaryOption = binary; + DateTimeOption = dateTime; + VarDecimalOption = varDecimal; + VarDoubleOption = varDouble; + VarFloatOption = varFloat; + Int32Option = int32; + Int64Option = int64; + IntegerOption = integer; + PatternWithBackslashOption = patternWithBackslash; + PatternWithDigitsOption = patternWithDigits; + PatternWithDigitsAndDelimiterOption = patternWithDigitsAndDelimiter; + VarStringOption = varString; + UnsignedIntegerOption = unsignedInteger; + UnsignedLongOption = unsignedLong; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); - /// - /// Gets or Sets Binary - /// - [JsonPropertyName("binary")] - public System.IO.Stream Binary { get; set; } - /// /// Gets or Sets VarByte /// @@ -96,49 +91,6 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("date")] public DateTime Date { get; set; } - /// - /// Gets or Sets DateTime - /// - /// 2007-12-03T10:15:30+01:00 - [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } - - /// - /// Gets or Sets VarDecimal - /// - [JsonPropertyName("decimal")] - public decimal VarDecimal { get; set; } - - /// - /// Gets or Sets VarDouble - /// - [JsonPropertyName("double")] - public double VarDouble { get; set; } - - /// - /// Gets or Sets VarFloat - /// - [JsonPropertyName("float")] - public float VarFloat { get; set; } - - /// - /// Gets or Sets Int32 - /// - [JsonPropertyName("int32")] - public int Int32 { get; set; } - - /// - /// Gets or Sets Int64 - /// - [JsonPropertyName("int64")] - public long Int64 { get; set; } - - /// - /// Gets or Sets Integer - /// - [JsonPropertyName("integer")] - public int Integer { get; set; } - /// /// Gets or Sets Number /// @@ -151,51 +103,205 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("password")] public string Password { get; set; } + /// + /// Used to track the state of Binary + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BinaryOption { get; private set; } + + /// + /// Gets or Sets Binary + /// + [JsonPropertyName("binary")] + public System.IO.Stream Binary { get { return this. BinaryOption; } set { this.BinaryOption = new Option(value); } } + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + /// 2007-12-03T10:15:30+01:00 + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new Option(value); } } + + /// + /// Used to track the state of VarDecimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDecimalOption { get; private set; } + + /// + /// Gets or Sets VarDecimal + /// + [JsonPropertyName("decimal")] + public decimal? VarDecimal { get { return this. VarDecimalOption; } set { this.VarDecimalOption = new Option(value); } } + + /// + /// Used to track the state of VarDouble + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarDoubleOption { get; private set; } + + /// + /// Gets or Sets VarDouble + /// + [JsonPropertyName("double")] + public double? VarDouble { get { return this. VarDoubleOption; } set { this.VarDoubleOption = new Option(value); } } + + /// + /// Used to track the state of VarFloat + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarFloatOption { get; private set; } + + /// + /// Gets or Sets VarFloat + /// + [JsonPropertyName("float")] + public float? VarFloat { get { return this. VarFloatOption; } set { this.VarFloatOption = new Option(value); } } + + /// + /// Used to track the state of Int32 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int32Option { get; private set; } + + /// + /// Gets or Sets Int32 + /// + [JsonPropertyName("int32")] + public int? Int32 { get { return this. Int32Option; } set { this.Int32Option = new Option(value); } } + + /// + /// Used to track the state of Int64 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int64Option { get; private set; } + + /// + /// Gets or Sets Int64 + /// + [JsonPropertyName("int64")] + public long? Int64 { get { return this. Int64Option; } set { this.Int64Option = new Option(value); } } + + /// + /// Used to track the state of Integer + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerOption { get; private set; } + + /// + /// Gets or Sets Integer + /// + [JsonPropertyName("integer")] + public int? Integer { get { return this. IntegerOption; } set { this.IntegerOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithBackslash + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithBackslashOption { get; private set; } + /// /// None /// /// None [JsonPropertyName("pattern_with_backslash")] - public string PatternWithBackslash { get; set; } + public string PatternWithBackslash { get { return this. PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithDigits + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsOption { get; private set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. [JsonPropertyName("pattern_with_digits")] - public string PatternWithDigits { get; set; } + public string PatternWithDigits { get { return this. PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithDigitsAndDelimiter + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsAndDelimiterOption { get; private set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. [JsonPropertyName("pattern_with_digits_and_delimiter")] - public string PatternWithDigitsAndDelimiter { get; set; } + public string PatternWithDigitsAndDelimiter { get { return this. PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new Option(value); } } + + /// + /// Used to track the state of VarString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarStringOption { get; private set; } /// /// Gets or Sets VarString /// [JsonPropertyName("string")] - public string VarString { get; set; } + public string VarString { get { return this. VarStringOption; } set { this.VarStringOption = new Option(value); } } + + /// + /// Used to track the state of UnsignedInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedIntegerOption { get; private set; } /// /// Gets or Sets UnsignedInteger /// [JsonPropertyName("unsigned_integer")] - public uint UnsignedInteger { get; set; } + public uint? UnsignedInteger { get { return this. UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new Option(value); } } + + /// + /// Used to track the state of UnsignedLong + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedLongOption { get; private set; } /// /// Gets or Sets UnsignedLong /// [JsonPropertyName("unsigned_long")] - public ulong UnsignedLong { get; set; } + public ulong? UnsignedLong { get { return this. UnsignedLongOption; } set { this.UnsignedLongOption = new Option(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -211,9 +317,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class FormatTest {\n"); - sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" VarByte: ").Append(VarByte).Append("\n"); sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" DateTime: ").Append(DateTime).Append("\n"); sb.Append(" VarDecimal: ").Append(VarDecimal).Append("\n"); sb.Append(" VarDouble: ").Append(VarDouble).Append("\n"); @@ -221,8 +329,6 @@ namespace Org.OpenAPITools.Model sb.Append(" Int32: ").Append(Int32).Append("\n"); sb.Append(" Int64: ").Append(Int64).Append("\n"); sb.Append(" Integer: ").Append(Integer).Append("\n"); - sb.Append(" Number: ").Append(Number).Append("\n"); - sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" PatternWithBackslash: ").Append(PatternWithBackslash).Append("\n"); sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); @@ -242,54 +348,6 @@ namespace Org.OpenAPITools.Model /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { - // VarDouble (double) maximum - if (this.VarDouble > (double)123.4) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); - } - - // VarDouble (double) minimum - if (this.VarDouble < (double)67.8) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); - } - - // VarFloat (float) maximum - if (this.VarFloat > (float)987.6) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); - } - - // VarFloat (float) minimum - if (this.VarFloat < (float)54.3) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); - } - - // Int32 (int) maximum - if (this.Int32 > (int)200) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); - } - - // Int32 (int) minimum - if (this.Int32 < (int)20) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); - } - - // Integer (int) maximum - if (this.Integer > (int)100) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); - } - - // Integer (int) minimum - if (this.Integer < (int)10) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); - } - // Number (decimal) maximum if (this.Number > (decimal)543.2) { @@ -314,50 +372,102 @@ namespace Org.OpenAPITools.Model yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); } - if (this.PatternWithBackslash != null) { + // VarDouble (double) maximum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value > (double)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value less than or equal to 123.4.", new [] { "VarDouble" }); + } + + // VarDouble (double) minimum + if (this.VarDoubleOption.IsSet && this.VarDoubleOption.Value < (double)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarDouble, must be a value greater than or equal to 67.8.", new [] { "VarDouble" }); + } + + // VarFloat (float) maximum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value > (float)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value less than or equal to 987.6.", new [] { "VarFloat" }); + } + + // VarFloat (float) minimum + if (this.VarFloatOption.IsSet && this.VarFloatOption.Value < (float)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarFloat, must be a value greater than or equal to 54.3.", new [] { "VarFloat" }); + } + + // Int32 (int) maximum + if (this.Int32Option.IsSet && this.Int32Option.Value > (int)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int) minimum + if (this.Int32Option.IsSet && this.Int32Option.Value < (int)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Integer (int) maximum + if (this.IntegerOption.IsSet && this.IntegerOption.Value > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int) minimum + if (this.IntegerOption.IsSet && this.IntegerOption.Value < (int)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + if (this.PatternWithBackslashOption.Value != null) { // PatternWithBackslash (string) pattern Regex regexPatternWithBackslash = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$", RegexOptions.CultureInvariant); - if (!regexPatternWithBackslash.Match(this.PatternWithBackslash).Success) + + if (this.PatternWithBackslashOption.Value != null &&!regexPatternWithBackslash.Match(this.PatternWithBackslashOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithBackslash, must match a pattern of " + regexPatternWithBackslash, new [] { "PatternWithBackslash" }); } } - if (this.PatternWithDigits != null) { + if (this.PatternWithDigitsOption.Value != null) { // PatternWithDigits (string) pattern Regex regexPatternWithDigits = new Regex(@"^\d{10}$", RegexOptions.CultureInvariant); - if (!regexPatternWithDigits.Match(this.PatternWithDigits).Success) + + if (this.PatternWithDigitsOption.Value != null &&!regexPatternWithDigits.Match(this.PatternWithDigitsOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigits, must match a pattern of " + regexPatternWithDigits, new [] { "PatternWithDigits" }); } } - if (this.PatternWithDigitsAndDelimiter != null) { + if (this.PatternWithDigitsAndDelimiterOption.Value != null) { // PatternWithDigitsAndDelimiter (string) pattern Regex regexPatternWithDigitsAndDelimiter = new Regex(@"^image_\d{1,3}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiter).Success) + + if (this.PatternWithDigitsAndDelimiterOption.Value != null &&!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiterOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigitsAndDelimiter, must match a pattern of " + regexPatternWithDigitsAndDelimiter, new [] { "PatternWithDigitsAndDelimiter" }); } } - if (this.VarString != null) { + if (this.VarStringOption.Value != null) { // VarString (string) pattern Regex regexVarString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); - if (!regexVarString.Match(this.VarString).Success) + + if (this.VarStringOption.Value != null &&!regexVarString.Match(this.VarStringOption.Value).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for VarString, must match a pattern of " + regexVarString, new [] { "VarString" }); } } // UnsignedInteger (uint) maximum - if (this.UnsignedInteger > (uint)200) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value > (uint)200) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value less than or equal to 200.", new [] { "UnsignedInteger" }); } // UnsignedInteger (uint) minimum - if (this.UnsignedInteger < (uint)20) + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value < (uint)20) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value greater than or equal to 20.", new [] { "UnsignedInteger" }); } @@ -398,25 +508,25 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - System.IO.Stream binary = default; - byte[] varByte = default; - DateTime? date = default; - DateTime? dateTime = default; - decimal? varDecimal = default; - double? varDouble = default; - float? varFloat = default; - int? int32 = default; - long? int64 = default; - int? integer = default; - decimal? number = default; - string password = default; - string patternWithBackslash = default; - string patternWithDigits = default; - string patternWithDigitsAndDelimiter = default; - string varString = default; - uint? unsignedInteger = default; - ulong? unsignedLong = default; - Guid? uuid = default; + Option varByte = default; + Option date = default; + Option number = default; + Option password = default; + 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; while (utf8JsonReader.Read()) { @@ -433,76 +543,76 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "binary": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - binary = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; case "byte": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varByte = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + varByte = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "date": if (utf8JsonReader.TokenType != JsonTokenType.Null) - date = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "dateTime": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "decimal": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDecimal = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "double": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varDouble = utf8JsonReader.GetDouble(); - break; - case "float": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - varFloat = (float)utf8JsonReader.GetDouble(); - break; - case "int32": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int32 = utf8JsonReader.GetInt32(); - break; - case "int64": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - int64 = utf8JsonReader.GetInt64(); - break; - case "integer": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - integer = utf8JsonReader.GetInt32(); + date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - number = utf8JsonReader.GetDecimal(); + number = new Option(utf8JsonReader.GetDecimal()); break; case "password": - password = utf8JsonReader.GetString(); + password = new Option(utf8JsonReader.GetString()); + break; + case "binary": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + binary = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "decimal": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDecimal = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "double": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDouble = new Option(utf8JsonReader.GetDouble()); + break; + case "float": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varFloat = new Option((float)utf8JsonReader.GetDouble()); + break; + case "int32": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int32 = new Option(utf8JsonReader.GetInt32()); + break; + case "int64": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int64 = new Option(utf8JsonReader.GetInt64()); + break; + case "integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integer = new Option(utf8JsonReader.GetInt32()); break; case "pattern_with_backslash": - patternWithBackslash = utf8JsonReader.GetString(); + patternWithBackslash = new Option(utf8JsonReader.GetString()); break; case "pattern_with_digits": - patternWithDigits = utf8JsonReader.GetString(); + patternWithDigits = new Option(utf8JsonReader.GetString()); break; case "pattern_with_digits_and_delimiter": - patternWithDigitsAndDelimiter = utf8JsonReader.GetString(); + patternWithDigitsAndDelimiter = new Option(utf8JsonReader.GetString()); break; case "string": - varString = utf8JsonReader.GetString(); + varString = new Option(utf8JsonReader.GetString()); break; case "unsigned_integer": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedInteger = utf8JsonReader.GetUInt32(); + unsignedInteger = new Option(utf8JsonReader.GetUInt32()); break; case "unsigned_long": if (utf8JsonReader.TokenType != JsonTokenType.Null) - unsignedLong = utf8JsonReader.GetUInt64(); + unsignedLong = new Option(utf8JsonReader.GetUInt64()); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -510,64 +620,76 @@ namespace Org.OpenAPITools.Model } } - if (binary == null) - throw new ArgumentNullException(nameof(binary), "Property is required for class FormatTest."); + if (!varByte.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(varByte)); - if (varByte == null) - throw new ArgumentNullException(nameof(varByte), "Property is required for class FormatTest."); + if (!date.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(date)); - if (date == null) - throw new ArgumentNullException(nameof(date), "Property is required for class FormatTest."); + if (!number.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(number)); - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class FormatTest."); + if (!password.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(password)); - if (varDecimal == null) - throw new ArgumentNullException(nameof(varDecimal), "Property is required for class FormatTest."); + if (varByte.IsSet && varByte.Value == null) + throw new ArgumentNullException(nameof(varByte), "Property is not nullable for class FormatTest."); - if (varDouble == null) - throw new ArgumentNullException(nameof(varDouble), "Property is required for class FormatTest."); + if (date.IsSet && date.Value == null) + throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest."); - if (varFloat == null) - throw new ArgumentNullException(nameof(varFloat), "Property is required for class FormatTest."); + if (number.IsSet && number.Value == null) + throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest."); - if (int32 == null) - throw new ArgumentNullException(nameof(int32), "Property is required for class FormatTest."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class FormatTest."); - if (int64 == null) - throw new ArgumentNullException(nameof(int64), "Property is required for class FormatTest."); + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest."); - if (integer == null) - throw new ArgumentNullException(nameof(integer), "Property is required for class FormatTest."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest."); - if (number == null) - throw new ArgumentNullException(nameof(number), "Property is required for class FormatTest."); + if (varDecimal.IsSet && varDecimal.Value == null) + throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class FormatTest."); + if (varDouble.IsSet && varDouble.Value == null) + throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest."); - if (patternWithBackslash == null) - throw new ArgumentNullException(nameof(patternWithBackslash), "Property is required for class FormatTest."); + if (varFloat.IsSet && varFloat.Value == null) + throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest."); - if (patternWithDigits == null) - throw new ArgumentNullException(nameof(patternWithDigits), "Property is required for class FormatTest."); + if (int32.IsSet && int32.Value == null) + throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest."); - if (patternWithDigitsAndDelimiter == null) - throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + if (int64.IsSet && int64.Value == null) + throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest."); - if (varString == null) - throw new ArgumentNullException(nameof(varString), "Property is required for class FormatTest."); + if (integer.IsSet && integer.Value == null) + throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest."); - if (unsignedInteger == null) - throw new ArgumentNullException(nameof(unsignedInteger), "Property is required for class FormatTest."); + if (patternWithBackslash.IsSet && patternWithBackslash.Value == null) + throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest."); - if (unsignedLong == null) - throw new ArgumentNullException(nameof(unsignedLong), "Property is required for class FormatTest."); + if (patternWithDigits.IsSet && patternWithDigits.Value == null) + throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class FormatTest."); + if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null) + throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest."); - return new FormatTest(binary, varByte, date.Value, dateTime.Value, varDecimal.Value, varDouble.Value, varFloat.Value, int32.Value, int64.Value, integer.Value, number.Value, password, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger.Value, unsignedLong.Value, uuid.Value); + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest."); + + if (unsignedInteger.IsSet && unsignedInteger.Value == null) + throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest."); + + if (unsignedLong.IsSet && unsignedLong.Value == null) + throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest."); + + 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, int64, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid); } /// @@ -594,28 +716,83 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("binary"); - JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + if (formatTest.VarByte == null) + throw new ArgumentNullException(nameof(formatTest.VarByte), "Property is required for class FormatTest."); + + if (formatTest.Password == null) + throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest."); + + if (formatTest.BinaryOption.IsSet && formatTest.Binary == null) + throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest."); + + if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + + if (formatTest.VarStringOption.IsSet && formatTest.VarString == null) + throw new ArgumentNullException(nameof(formatTest.VarString), "Property is required for class FormatTest."); + writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.VarByte, jsonSerializerOptions); writer.WriteString("date", formatTest.Date.ToString(DateFormat)); - writer.WriteString("dateTime", formatTest.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("decimal"); - JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); - writer.WriteNumber("double", formatTest.VarDouble); - writer.WriteNumber("float", formatTest.VarFloat); - writer.WriteNumber("int32", formatTest.Int32); - writer.WriteNumber("int64", formatTest.Int64); - writer.WriteNumber("integer", formatTest.Integer); + writer.WriteNumber("number", formatTest.Number); + writer.WriteString("password", formatTest.Password); - writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); - writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); - writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); - writer.WriteString("string", formatTest.VarString); - writer.WriteNumber("unsigned_integer", formatTest.UnsignedInteger); - writer.WriteNumber("unsigned_long", formatTest.UnsignedLong); - writer.WriteString("uuid", formatTest.Uuid); + + if (formatTest.BinaryOption.IsSet) + { + writer.WritePropertyName("binary"); + JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + } + if (formatTest.DateTimeOption.IsSet) + writer.WriteString("dateTime", formatTest.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (formatTest.VarDecimalOption.IsSet) + { + writer.WritePropertyName("decimal"); + JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); + } + if (formatTest.VarDoubleOption.IsSet) + writer.WriteNumber("double", formatTest.VarDoubleOption.Value.Value); + + if (formatTest.VarFloatOption.IsSet) + writer.WriteNumber("float", formatTest.VarFloatOption.Value.Value); + + if (formatTest.Int32Option.IsSet) + writer.WriteNumber("int32", formatTest.Int32Option.Value.Value); + + if (formatTest.Int64Option.IsSet) + writer.WriteNumber("int64", formatTest.Int64Option.Value.Value); + + if (formatTest.IntegerOption.IsSet) + writer.WriteNumber("integer", formatTest.IntegerOption.Value.Value); + + if (formatTest.PatternWithBackslashOption.IsSet) + writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); + + if (formatTest.PatternWithDigitsOption.IsSet) + writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet) + writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); + + if (formatTest.VarStringOption.IsSet) + writer.WriteString("string", formatTest.VarString); + + if (formatTest.UnsignedIntegerOption.IsSet) + writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value.Value); + + if (formatTest.UnsignedLongOption.IsSet) + writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value.Value); + + if (formatTest.UuidOption.IsSet) + writer.WriteString("uuid", formatTest.UuidOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs index 2e05ffb958a..efc98a08e71 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,10 +34,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Apple apple, string color) + public Fruit(Apple apple, Option color = default) { Apple = apple; - Color = color; + ColorOption = color; OnCreated(); } @@ -45,10 +46,10 @@ namespace Org.OpenAPITools.Model /// /// /// color - public Fruit(Banana banana, string color) + public Fruit(Banana banana, Option color = default) { Banana = banana; - Color = color; + ColorOption = color; OnCreated(); } @@ -64,11 +65,18 @@ namespace Org.OpenAPITools.Model /// public Banana Banana { get; set; } + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get { return this. ColorOption; } set { this.ColorOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -116,7 +124,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string color = default; + Option color = default; Apple apple = default; Banana banana = default; @@ -156,7 +164,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -164,8 +172,8 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class Fruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); if (apple != null) return new Fruit(apple, color); @@ -200,7 +208,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", fruit.Color); + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs index aa26d3600c0..75652a1b436 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs index 3c2d1ecefc9..b9f6c12dea7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,31 +35,52 @@ namespace Org.OpenAPITools.Model /// /// /// color - public GmFruit(Apple apple, Banana banana, string color) + public GmFruit(Option apple, Option banana, Option color = default) { - Apple = apple; - Banana = banana; - Color = color; + AppleOption = apple; + BananaOption = banana; + ColorOption = color; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + /// /// Gets or Sets Apple /// - public Apple Apple { get; set; } + public Apple Apple { get { return this.AppleOption; } set { this.AppleOption = new Option(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } /// /// Gets or Sets Banana /// - public Banana Banana { get; set; } + public Banana Banana { get { return this.BananaOption; } set { this.BananaOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } /// /// Gets or Sets Color /// [JsonPropertyName("color")] - public string Color { get; set; } + public string Color { get { return this. ColorOption; } set { this.ColorOption = new Option(value); } } /// /// Returns the string presentation of the object @@ -106,7 +128,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string color = default; + Option color = default; Apple apple = default; Banana banana = default; @@ -146,7 +168,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "color": - color = utf8JsonReader.GetString(); + color = new Option(utf8JsonReader.GetString()); break; default: break; @@ -154,10 +176,17 @@ namespace Org.OpenAPITools.Model } } - if (color == null) - throw new ArgumentNullException(nameof(color), "Property is required for class GmFruit."); + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit."); - return new GmFruit(apple, banana, color); + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new GmFruit(appleParsedValue, bananaParsedValue, color); } /// @@ -171,16 +200,16 @@ namespace Org.OpenAPITools.Model { writer.WriteStartObject(); - if (gmFruit.Apple != null) + if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { - AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Apple.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.Apple, jsonSerializerOptions); + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); } - if (gmFruit.Banana != null) + if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null) { - BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Banana.GetType())); - BananaJsonConverter.WriteProperties(ref writer, gmFruit.Banana, jsonSerializerOptions); + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } WriteProperties(ref writer, gmFruit, jsonSerializerOptions); @@ -196,7 +225,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("color", gmFruit.Color); + if (gmFruit.ColorOption.IsSet && gmFruit.Color == null) + throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit."); + + if (gmFruit.ColorOption.IsSet) + writer.WriteString("color", gmFruit.Color); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 7ae4662ed8d..6b7d7ae8da6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -110,7 +111,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -128,7 +129,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -136,10 +137,13 @@ namespace Org.OpenAPITools.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class GrandparentAnimal."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class GrandparentAnimal.", nameof(petType)); - return new GrandparentAnimal(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); + + return new GrandparentAnimal(petType.Value); } /// @@ -166,6 +170,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { + if (grandparentAnimal.PetType == null) + throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); + writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 31360d73f75..9652b767d13 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// bar /// foo [JsonConstructor] - internal HasOnlyReadOnly(string bar, string foo) + internal HasOnlyReadOnly(Option bar = default, Option foo = default) { - Bar = bar; - Foo = foo; + BarOption = bar; + FooOption = foo; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Foo + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FooOption { get; } /// /// Gets or Sets Foo /// [JsonPropertyName("foo")] - public string Foo { get; } + public string Foo { get { return this. FooOption; } } /// /// Gets or Sets additional properties @@ -105,8 +120,12 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); - hashCode = (hashCode * 59) + Foo.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + if (Foo != null) + hashCode = (hashCode * 59) + Foo.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -146,8 +165,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string bar = default; - string foo = default; + Option bar = default; + Option foo = default; while (utf8JsonReader.Read()) { @@ -165,10 +184,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()); break; case "foo": - foo = utf8JsonReader.GetString(); + foo = new Option(utf8JsonReader.GetString()); break; default: break; @@ -176,11 +195,11 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class HasOnlyReadOnly."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly."); - if (foo == null) - throw new ArgumentNullException(nameof(foo), "Property is required for class HasOnlyReadOnly."); + if (foo.IsSet && foo.Value == null) + throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly."); return new HasOnlyReadOnly(bar, foo); } @@ -209,8 +228,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", hasOnlyReadOnly.Bar); - writer.WriteString("foo", hasOnlyReadOnly.Foo); + if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.BarOption.IsSet) + writer.WriteString("bar", hasOnlyReadOnly.Bar); + + if (hasOnlyReadOnly.FooOption.IsSet) + writer.WriteString("foo", hasOnlyReadOnly.Foo); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 8355d97fa09..568712d2708 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// nullableMessage [JsonConstructor] - public HealthCheckResult(string nullableMessage = default) + public HealthCheckResult(Option nullableMessage = default) { - NullableMessage = nullableMessage; + NullableMessageOption = nullableMessage; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of NullableMessage + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableMessageOption { get; private set; } + /// /// Gets or Sets NullableMessage /// [JsonPropertyName("NullableMessage")] - public string NullableMessage { get; set; } + public string NullableMessage { get { return this. NullableMessageOption; } set { this.NullableMessageOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string nullableMessage = default; + Option nullableMessage = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "NullableMessage": - nullableMessage = utf8JsonReader.GetString(); + nullableMessage = new Option(utf8JsonReader.GetString()); break; default: break; @@ -153,7 +161,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + if (healthCheckResult.NullableMessageOption.IsSet) + if (healthCheckResult.NullableMessageOption.Value != null) + writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + else + writer.WriteNull("NullableMessage"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 0355613042f..3f4aa3229c4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -102,8 +103,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; - string triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -121,10 +122,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -132,13 +133,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class IsoscelesTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class IsoscelesTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(triangleType)); - return new IsoscelesTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class IsoscelesTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class IsoscelesTriangle."); + + return new IsoscelesTriangle(shapeType.Value, triangleType.Value); } /// @@ -165,7 +172,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (isoscelesTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle."); + + if (isoscelesTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle."); + writer.WriteString("shapeType", isoscelesTriangle.ShapeType); + writer.WriteString("triangleType", isoscelesTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs index 42b0c9cb2cf..f21994c3523 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// var123List [JsonConstructor] - public List(string var123List) + public List(Option var123List = default) { - Var123List = var123List; + Var123ListOption = var123List; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Var123List + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123ListOption { get; private set; } + /// /// Gets or Sets Var123List /// [JsonPropertyName("123-list")] - public string Var123List { get; set; } + public string Var123List { get { return this. Var123ListOption; } set { this.Var123ListOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string var123List = default; + Option var123List = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "123-list": - var123List = utf8JsonReader.GetString(); + var123List = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (var123List == null) - throw new ArgumentNullException(nameof(var123List), "Property is required for class List."); + if (var123List.IsSet && var123List.Value == null) + throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List."); return new List(var123List); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("123-list", list.Var123List); + if (list.Var123ListOption.IsSet && list.Var123List == null) + throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List."); + + if (list.Var123ListOption.IsSet) + writer.WriteString("123-list", list.Var123List); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 0ad8832af88..cfc824d8f5a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// escapedLiteralString (default to "C:\\Users\\username") /// unescapedLiteralString (default to "C:\Users\username") [JsonConstructor] - public LiteralStringClass(string escapedLiteralString = @"C:\\Users\\username", string unescapedLiteralString = @"C:\Users\username") + public LiteralStringClass(Option escapedLiteralString = default, Option unescapedLiteralString = default) { - EscapedLiteralString = escapedLiteralString; - UnescapedLiteralString = unescapedLiteralString; + EscapedLiteralStringOption = escapedLiteralString; + UnescapedLiteralStringOption = unescapedLiteralString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of EscapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EscapedLiteralStringOption { get; private set; } + /// /// Gets or Sets EscapedLiteralString /// [JsonPropertyName("escapedLiteralString")] - public string EscapedLiteralString { get; set; } + public string EscapedLiteralString { get { return this. EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new Option(value); } } + + /// + /// Used to track the state of UnescapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnescapedLiteralStringOption { get; private set; } /// /// Gets or Sets UnescapedLiteralString /// [JsonPropertyName("unescapedLiteralString")] - public string UnescapedLiteralString { get; set; } + public string UnescapedLiteralString { get { return this. UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string escapedLiteralString = default; - string unescapedLiteralString = default; + Option escapedLiteralString = default; + Option unescapedLiteralString = default; while (utf8JsonReader.Read()) { @@ -128,10 +143,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "escapedLiteralString": - escapedLiteralString = utf8JsonReader.GetString(); + escapedLiteralString = new Option(utf8JsonReader.GetString()); break; case "unescapedLiteralString": - unescapedLiteralString = utf8JsonReader.GetString(); + unescapedLiteralString = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,11 +154,11 @@ namespace Org.OpenAPITools.Model } } - if (escapedLiteralString == null) - throw new ArgumentNullException(nameof(escapedLiteralString), "Property is required for class LiteralStringClass."); + if (escapedLiteralString.IsSet && escapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass."); - if (unescapedLiteralString == null) - throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is required for class LiteralStringClass."); + if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass."); return new LiteralStringClass(escapedLiteralString, unescapedLiteralString); } @@ -172,8 +187,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); - writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); + if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.EscapedLiteralStringOption.IsSet) + writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet) + writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs index 92011ad0e1d..1ea0d944f05 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -150,7 +151,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; Pig pig = null; Whale whale = null; @@ -207,7 +208,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -215,17 +216,20 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Mammal."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Mammal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className); + return new Mammal(pig, className.Value); if (whale != null) - return new Mammal(whale, className); + return new Mammal(whale, className.Value); if (zebra != null) - return new Mammal(zebra, className); + return new Mammal(zebra, className.Value); throw new JsonException(); } @@ -269,6 +273,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { + if (mammal.ClassName == null) + throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); + writer.WriteString("className", mammal.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs index a4fdf221e93..b620db4b59d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,12 +37,12 @@ namespace Org.OpenAPITools.Model /// mapMapOfString /// mapOfEnumString [JsonConstructor] - public MapTest(Dictionary directMap, Dictionary indirectMap, Dictionary> mapMapOfString, Dictionary mapOfEnumString) + public MapTest(Option> directMap = default, Option> indirectMap = default, Option>> mapMapOfString = default, Option> mapOfEnumString = default) { - DirectMap = directMap; - IndirectMap = indirectMap; - MapMapOfString = mapMapOfString; - MapOfEnumString = mapOfEnumString; + DirectMapOption = directMap; + IndirectMapOption = indirectMap; + MapMapOfStringOption = mapMapOfString; + MapOfEnumStringOption = mapOfEnumString; OnCreated(); } @@ -104,7 +105,6 @@ namespace Org.OpenAPITools.Model /// public static string InnerEnumToJsonValue(InnerEnum value) { - if (value == InnerEnum.UPPER) return "UPPER"; @@ -114,29 +114,57 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of DirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> DirectMapOption { get; private set; } + /// /// Gets or Sets DirectMap /// [JsonPropertyName("direct_map")] - public Dictionary DirectMap { get; set; } + public Dictionary DirectMap { get { return this. DirectMapOption; } set { this.DirectMapOption = new Option>(value); } } + + /// + /// Used to track the state of IndirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> IndirectMapOption { get; private set; } /// /// Gets or Sets IndirectMap /// [JsonPropertyName("indirect_map")] - public Dictionary IndirectMap { get; set; } + public Dictionary IndirectMap { get { return this. IndirectMapOption; } set { this.IndirectMapOption = new Option>(value); } } + + /// + /// Used to track the state of MapMapOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapMapOfStringOption { get; private set; } /// /// Gets or Sets MapMapOfString /// [JsonPropertyName("map_map_of_string")] - public Dictionary> MapMapOfString { get; set; } + public Dictionary> MapMapOfString { get { return this. MapMapOfStringOption; } set { this.MapMapOfStringOption = new Option>>(value); } } + + /// + /// Used to track the state of MapOfEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOfEnumStringOption { get; private set; } /// /// Gets or Sets MapOfEnumString /// [JsonPropertyName("map_of_enum_string")] - public Dictionary MapOfEnumString { get; set; } + public Dictionary MapOfEnumString { get { return this. MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -194,10 +222,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Dictionary directMap = default; - Dictionary indirectMap = default; - Dictionary> mapMapOfString = default; - Dictionary mapOfEnumString = default; + Option> directMap = default; + Option> indirectMap = default; + Option>> mapMapOfString = default; + Option> mapOfEnumString = default; while (utf8JsonReader.Read()) { @@ -216,19 +244,19 @@ namespace Org.OpenAPITools.Model { case "direct_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - directMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + directMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "indirect_map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - indirectMap = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + indirectMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_map_of_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapMapOfString = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + mapMapOfString = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "map_of_enum_string": if (utf8JsonReader.TokenType != JsonTokenType.Null) - mapOfEnumString = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + mapOfEnumString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -236,17 +264,17 @@ namespace Org.OpenAPITools.Model } } - if (directMap == null) - throw new ArgumentNullException(nameof(directMap), "Property is required for class MapTest."); + if (directMap.IsSet && directMap.Value == null) + throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest."); - if (indirectMap == null) - throw new ArgumentNullException(nameof(indirectMap), "Property is required for class MapTest."); + if (indirectMap.IsSet && indirectMap.Value == null) + throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest."); - if (mapMapOfString == null) - throw new ArgumentNullException(nameof(mapMapOfString), "Property is required for class MapTest."); + if (mapMapOfString.IsSet && mapMapOfString.Value == null) + throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest."); - if (mapOfEnumString == null) - throw new ArgumentNullException(nameof(mapOfEnumString), "Property is required for class MapTest."); + if (mapOfEnumString.IsSet && mapOfEnumString.Value == null) + throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest."); return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString); } @@ -275,14 +303,38 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("direct_map"); - JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); - writer.WritePropertyName("indirect_map"); - JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); - writer.WritePropertyName("map_map_of_string"); - JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); - writer.WritePropertyName("map_of_enum_string"); - JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null) + throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest."); + + if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null) + throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest."); + + if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null) + throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest."); + + if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null) + throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest."); + + if (mapTest.DirectMapOption.IsSet) + { + writer.WritePropertyName("direct_map"); + JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); + } + if (mapTest.IndirectMapOption.IsSet) + { + writer.WritePropertyName("indirect_map"); + JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); + } + if (mapTest.MapMapOfStringOption.IsSet) + { + writer.WritePropertyName("map_map_of_string"); + JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); + } + if (mapTest.MapOfEnumStringOption.IsSet) + { + writer.WritePropertyName("map_of_enum_string"); + JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 0ed70f02c2d..b75b184b9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,40 +37,68 @@ namespace Org.OpenAPITools.Model /// uuid /// uuidWithPattern [JsonConstructor] - public MixedPropertiesAndAdditionalPropertiesClass(DateTime dateTime, Dictionary map, Guid uuid, Guid uuidWithPattern) + public MixedPropertiesAndAdditionalPropertiesClass(Option dateTime = default, Option> map = default, Option uuid = default, Option uuidWithPattern = default) { - DateTime = dateTime; - Map = map; - Uuid = uuid; - UuidWithPattern = uuidWithPattern; + DateTimeOption = dateTime; + MapOption = map; + UuidOption = uuid; + UuidWithPatternOption = uuidWithPattern; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + /// /// Gets or Sets DateTime /// [JsonPropertyName("dateTime")] - public DateTime DateTime { get; set; } + public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new Option(value); } } + + /// + /// Used to track the state of Map + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOption { get; private set; } /// /// Gets or Sets Map /// [JsonPropertyName("map")] - public Dictionary Map { get; set; } + public Dictionary Map { get { return this. MapOption; } set { this.MapOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Used to track the state of UuidWithPattern + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidWithPatternOption { get; private set; } /// /// Gets or Sets UuidWithPattern /// [JsonPropertyName("uuid_with_pattern")] - public Guid UuidWithPattern { get; set; } + public Guid? UuidWithPattern { get { return this. UuidWithPatternOption; } set { this.UuidWithPatternOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -103,7 +132,8 @@ namespace Org.OpenAPITools.Model { // UuidWithPattern (Guid) pattern Regex regexUuidWithPattern = new Regex(@"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", RegexOptions.CultureInvariant); - if (!regexUuidWithPattern.Match(this.UuidWithPattern.ToString()).Success) + + if (this.UuidWithPatternOption.Value != null &&!regexUuidWithPattern.Match(this.UuidWithPatternOption.Value.ToString()).Success) { yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UuidWithPattern, must match a pattern of " + regexUuidWithPattern, new [] { "UuidWithPattern" }); } @@ -138,10 +168,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - DateTime? dateTime = default; - Dictionary map = default; - Guid? uuid = default; - Guid? uuidWithPattern = default; + Option dateTime = default; + Option> map = default; + Option uuid = default; + Option uuidWithPattern = default; while (utf8JsonReader.Read()) { @@ -160,19 +190,19 @@ namespace Org.OpenAPITools.Model { case "dateTime": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateTime = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "map": if (utf8JsonReader.TokenType != JsonTokenType.Null) - map = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + map = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; case "uuid_with_pattern": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuidWithPattern = utf8JsonReader.GetGuid(); + uuidWithPattern = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -180,19 +210,19 @@ namespace Org.OpenAPITools.Model } } - if (dateTime == null) - throw new ArgumentNullException(nameof(dateTime), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (map == null) - throw new ArgumentNullException(nameof(map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (map.IsSet && map.Value == null) + throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - if (uuidWithPattern == null) - throw new ArgumentNullException(nameof(uuidWithPattern), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + if (uuidWithPattern.IsSet && uuidWithPattern.Value == null) + throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); - return new MixedPropertiesAndAdditionalPropertiesClass(dateTime.Value, map, uuid.Value, uuidWithPattern.Value); + return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern); } /// @@ -219,11 +249,22 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTime.ToString(DateTimeFormat)); - writer.WritePropertyName("map"); - JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); - writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.Uuid); - writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern); + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null) + throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet) + writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet) + { + writer.WritePropertyName("map"); + JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); + } + if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet) + writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value.Value); + + if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet) + writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs index 7969b9ae04e..ba4afe20a01 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// varClass /// name [JsonConstructor] - public Model200Response(string varClass, int name) + public Model200Response(Option varClass = default, Option name = default) { - VarClass = varClass; - Name = name; + VarClassOption = varClass; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClass + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClassOption { get; private set; } + /// /// Gets or Sets VarClass /// [JsonPropertyName("class")] - public string VarClass { get; set; } + public string VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public int Name { get; set; } + public int? Name { get { return this. NameOption; } set { this.NameOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varClass = default; - int? name = default; + Option varClass = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -128,11 +143,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "class": - varClass = utf8JsonReader.GetString(); + varClass = new Option(utf8JsonReader.GetString()); break; case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - name = utf8JsonReader.GetInt32(); + name = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -140,13 +155,13 @@ namespace Org.OpenAPITools.Model } } - if (varClass == null) - throw new ArgumentNullException(nameof(varClass), "Property is required for class Model200Response."); + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Model200Response."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response."); - return new Model200Response(varClass, name.Value); + return new Model200Response(varClass, name); } /// @@ -173,8 +188,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("class", model200Response.VarClass); - writer.WriteNumber("name", model200Response.Name); + if (model200Response.VarClassOption.IsSet && model200Response.VarClass == null) + throw new ArgumentNullException(nameof(model200Response.VarClass), "Property is required for class Model200Response."); + + if (model200Response.VarClassOption.IsSet) + writer.WriteString("class", model200Response.VarClass); + + if (model200Response.NameOption.IsSet) + writer.WriteNumber("name", model200Response.NameOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs index 810a6a01b8e..2830a1d5135 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varClient [JsonConstructor] - public ModelClient(string varClient) + public ModelClient(Option varClient = default) { - VarClient = varClient; + VarClientOption = varClient; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarClient + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClientOption { get; private set; } + /// /// Gets or Sets VarClient /// [JsonPropertyName("client")] - public string VarClient { get; set; } + public string VarClient { get { return this. VarClientOption; } set { this.VarClientOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varClient = default; + Option varClient = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "client": - varClient = utf8JsonReader.GetString(); + varClient = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (varClient == null) - throw new ArgumentNullException(nameof(varClient), "Property is required for class ModelClient."); + if (varClient.IsSet && varClient.Value == null) + throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient."); return new ModelClient(varClient); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("client", modelClient.VarClient); + if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null) + throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient."); + + if (modelClient.VarClientOption.IsSet) + writer.WriteString("client", modelClient.VarClient); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs index edcb6b3403c..7403eda73f2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,12 +37,12 @@ namespace Org.OpenAPITools.Model /// snakeCase /// var123Number [JsonConstructor] - public Name(int varName, string property, int snakeCase, int var123Number) + public Name(int varName, Option property = default, Option snakeCase = default, Option var123Number = default) { VarName = varName; - Property = property; - SnakeCase = snakeCase; - Var123Number = var123Number; + PropertyOption = property; + SnakeCaseOption = snakeCase; + Var123NumberOption = var123Number; OnCreated(); } @@ -53,23 +54,44 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("name")] public int VarName { get; set; } + /// + /// Used to track the state of Property + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PropertyOption { get; private set; } + /// /// Gets or Sets Property /// [JsonPropertyName("property")] - public string Property { get; set; } + public string Property { get { return this. PropertyOption; } set { this.PropertyOption = new Option(value); } } + + /// + /// Used to track the state of SnakeCase + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SnakeCaseOption { get; } /// /// Gets or Sets SnakeCase /// [JsonPropertyName("snake_case")] - public int SnakeCase { get; } + public int? SnakeCase { get { return this. SnakeCaseOption; } } + + /// + /// Used to track the state of Var123Number + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123NumberOption { get; } /// /// Gets or Sets Var123Number /// [JsonPropertyName("123Number")] - public int Var123Number { get; } + public int? Var123Number { get { return this. Var123NumberOption; } } /// /// Gets or Sets additional properties @@ -123,8 +145,12 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); - hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + if (SnakeCase != null) + hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); + + if (Var123Number != null) + hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -164,10 +190,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varName = default; - string property = default; - int? snakeCase = default; - int? var123Number = default; + Option varName = default; + Option property = default; + Option snakeCase = default; + Option var123Number = default; while (utf8JsonReader.Read()) { @@ -186,18 +212,18 @@ namespace Org.OpenAPITools.Model { case "name": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varName = utf8JsonReader.GetInt32(); + varName = new Option(utf8JsonReader.GetInt32()); break; case "property": - property = utf8JsonReader.GetString(); + property = new Option(utf8JsonReader.GetString()); break; case "snake_case": if (utf8JsonReader.TokenType != JsonTokenType.Null) - snakeCase = utf8JsonReader.GetInt32(); + snakeCase = new Option(utf8JsonReader.GetInt32()); break; case "123Number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - var123Number = utf8JsonReader.GetInt32(); + var123Number = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -205,19 +231,22 @@ namespace Org.OpenAPITools.Model } } - if (varName == null) - throw new ArgumentNullException(nameof(varName), "Property is required for class Name."); + if (!varName.IsSet) + throw new ArgumentException("Property is required for class Name.", nameof(varName)); - if (property == null) - throw new ArgumentNullException(nameof(property), "Property is required for class Name."); + if (varName.IsSet && varName.Value == null) + throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name."); - if (snakeCase == null) - throw new ArgumentNullException(nameof(snakeCase), "Property is required for class Name."); + if (property.IsSet && property.Value == null) + throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name."); - if (var123Number == null) - throw new ArgumentNullException(nameof(var123Number), "Property is required for class Name."); + if (snakeCase.IsSet && snakeCase.Value == null) + throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name."); - return new Name(varName.Value, property, snakeCase.Value, var123Number.Value); + if (var123Number.IsSet && var123Number.Value == null) + throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name."); + + return new Name(varName.Value.Value, property, snakeCase, var123Number); } /// @@ -244,10 +273,19 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) { + if (name.PropertyOption.IsSet && name.Property == null) + throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name."); + writer.WriteNumber("name", name.VarName); - writer.WriteString("property", name.Property); - writer.WriteNumber("snake_case", name.SnakeCase); - writer.WriteNumber("123Number", name.Var123Number); + + if (name.PropertyOption.IsSet) + writer.WriteString("property", name.Property); + + if (name.SnakeCaseOption.IsSet) + writer.WriteNumber("snake_case", name.SnakeCaseOption.Value.Value); + + if (name.Var123NumberOption.IsSet) + writer.WriteNumber("123Number", name.Var123NumberOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index 83ab7f40b1e..cd1516104e3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List> aObjVariableobject = default; - int? pkiNotificationtestID = default; + Option>> aObjVariableobject = default; + Option pkiNotificationtestID = default; while (utf8JsonReader.Read()) { @@ -129,11 +130,11 @@ namespace Org.OpenAPITools.Model { case "a_objVariableobject": if (utf8JsonReader.TokenType != JsonTokenType.Null) - aObjVariableobject = JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions); + aObjVariableobject = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); break; case "pkiNotificationtestID": if (utf8JsonReader.TokenType != JsonTokenType.Null) - pkiNotificationtestID = utf8JsonReader.GetInt32(); + pkiNotificationtestID = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -141,13 +142,19 @@ namespace Org.OpenAPITools.Model } } - if (aObjVariableobject == null) - throw new ArgumentNullException(nameof(aObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!aObjVariableobject.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(aObjVariableobject)); - if (pkiNotificationtestID == null) - throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + if (!pkiNotificationtestID.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(pkiNotificationtestID)); - return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject, pkiNotificationtestID.Value); + if (aObjVariableobject.IsSet && aObjVariableobject.Value == null) + throw new ArgumentNullException(nameof(aObjVariableobject), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + if (pkiNotificationtestID.IsSet && pkiNotificationtestID.Value == null) + throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject.Value, pkiNotificationtestID.Value.Value); } /// @@ -174,6 +181,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) { + if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null) + throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + writer.WritePropertyName("a_objVariableobject"); JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions); writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs index 5d9de18c4a3..205ed5a2f20 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,9 +32,8 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// arrayItemsNullable - /// objectItemsNullable /// arrayAndItemsNullableProp + /// arrayItemsNullable /// arrayNullableProp /// booleanProp /// dateProp @@ -41,99 +41,184 @@ namespace Org.OpenAPITools.Model /// integerProp /// numberProp /// objectAndItemsNullableProp + /// objectItemsNullable /// objectNullableProp /// stringProp [JsonConstructor] - public NullableClass(List arrayItemsNullable, Dictionary objectItemsNullable, List arrayAndItemsNullableProp = default, List arrayNullableProp = default, bool? booleanProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, int? integerProp = default, decimal? numberProp = default, Dictionary objectAndItemsNullableProp = default, Dictionary objectNullableProp = default, string stringProp = default) : base() + public NullableClass(Option> arrayAndItemsNullableProp = default, Option> arrayItemsNullable = default, Option> arrayNullableProp = default, Option booleanProp = default, Option dateProp = default, Option datetimeProp = default, Option integerProp = default, Option numberProp = default, Option> objectAndItemsNullableProp = default, Option> objectItemsNullable = default, Option> objectNullableProp = default, Option stringProp = default) : base() { - ArrayItemsNullable = arrayItemsNullable; - ObjectItemsNullable = objectItemsNullable; - ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - ArrayNullableProp = arrayNullableProp; - BooleanProp = booleanProp; - DateProp = dateProp; - DatetimeProp = datetimeProp; - IntegerProp = integerProp; - NumberProp = numberProp; - ObjectAndItemsNullableProp = objectAndItemsNullableProp; - ObjectNullableProp = objectNullableProp; - StringProp = stringProp; + ArrayAndItemsNullablePropOption = arrayAndItemsNullableProp; + ArrayItemsNullableOption = arrayItemsNullable; + ArrayNullablePropOption = arrayNullableProp; + BooleanPropOption = booleanProp; + DatePropOption = dateProp; + DatetimePropOption = datetimeProp; + IntegerPropOption = integerProp; + NumberPropOption = numberProp; + ObjectAndItemsNullablePropOption = objectAndItemsNullableProp; + ObjectItemsNullableOption = objectItemsNullable; + ObjectNullablePropOption = objectNullableProp; + StringPropOption = stringProp; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets ArrayItemsNullable + /// Used to track the state of ArrayAndItemsNullableProp /// - [JsonPropertyName("array_items_nullable")] - public List ArrayItemsNullable { get; set; } - - /// - /// Gets or Sets ObjectItemsNullable - /// - [JsonPropertyName("object_items_nullable")] - public Dictionary ObjectItemsNullable { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// [JsonPropertyName("array_and_items_nullable_prop")] - public List ArrayAndItemsNullableProp { get; set; } + public List ArrayAndItemsNullableProp { get { return this. ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of ArrayItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ArrayItemsNullable + /// + [JsonPropertyName("array_items_nullable")] + public List ArrayItemsNullable { get { return this. ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new Option>(value); } } + + /// + /// Used to track the state of ArrayNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNullablePropOption { get; private set; } /// /// Gets or Sets ArrayNullableProp /// [JsonPropertyName("array_nullable_prop")] - public List ArrayNullableProp { get; set; } + public List ArrayNullableProp { get { return this. ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of BooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BooleanPropOption { get; private set; } /// /// Gets or Sets BooleanProp /// [JsonPropertyName("boolean_prop")] - public bool? BooleanProp { get; set; } + public bool? BooleanProp { get { return this. BooleanPropOption; } set { this.BooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of DateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatePropOption { get; private set; } /// /// Gets or Sets DateProp /// [JsonPropertyName("date_prop")] - public DateTime? DateProp { get; set; } + public DateTime? DateProp { get { return this. DatePropOption; } set { this.DatePropOption = new Option(value); } } + + /// + /// Used to track the state of DatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatetimePropOption { get; private set; } /// /// Gets or Sets DatetimeProp /// [JsonPropertyName("datetime_prop")] - public DateTime? DatetimeProp { get; set; } + public DateTime? DatetimeProp { get { return this. DatetimePropOption; } set { this.DatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of IntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerPropOption { get; private set; } /// /// Gets or Sets IntegerProp /// [JsonPropertyName("integer_prop")] - public int? IntegerProp { get; set; } + public int? IntegerProp { get { return this. IntegerPropOption; } set { this.IntegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NumberProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NumberPropOption { get; private set; } /// /// Gets or Sets NumberProp /// [JsonPropertyName("number_prop")] - public decimal? NumberProp { get; set; } + public decimal? NumberProp { get { return this. NumberPropOption; } set { this.NumberPropOption = new Option(value); } } + + /// + /// Used to track the state of ObjectAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectAndItemsNullablePropOption { get; private set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// [JsonPropertyName("object_and_items_nullable_prop")] - public Dictionary ObjectAndItemsNullableProp { get; set; } + public Dictionary ObjectAndItemsNullableProp { get { return this. ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of ObjectItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ObjectItemsNullable + /// + [JsonPropertyName("object_items_nullable")] + public Dictionary ObjectItemsNullable { get { return this. ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new Option>(value); } } + + /// + /// Used to track the state of ObjectNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectNullablePropOption { get; private set; } /// /// Gets or Sets ObjectNullableProp /// [JsonPropertyName("object_nullable_prop")] - public Dictionary ObjectNullableProp { get; set; } + public Dictionary ObjectNullableProp { get { return this. ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of StringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringPropOption { get; private set; } /// /// Gets or Sets StringProp /// [JsonPropertyName("string_prop")] - public string StringProp { get; set; } + public string StringProp { get { return this. StringPropOption; } set { this.StringPropOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -150,9 +235,8 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class NullableClass {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); - sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); - sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); sb.Append(" DateProp: ").Append(DateProp).Append("\n"); @@ -160,6 +244,7 @@ namespace Org.OpenAPITools.Model sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -220,18 +305,18 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List arrayItemsNullable = default; - Dictionary objectItemsNullable = default; - List arrayAndItemsNullableProp = default; - List arrayNullableProp = default; - bool? booleanProp = default; - DateTime? dateProp = default; - DateTime? datetimeProp = default; - int? integerProp = default; - decimal? numberProp = default; - Dictionary objectAndItemsNullableProp = default; - Dictionary objectNullableProp = default; - string stringProp = default; + Option> arrayAndItemsNullableProp = default; + Option> arrayItemsNullable = default; + Option> arrayNullableProp = default; + Option booleanProp = default; + Option dateProp = default; + Option datetimeProp = default; + Option integerProp = default; + Option numberProp = default; + Option> objectAndItemsNullableProp = default; + Option> objectItemsNullable = default; + Option> objectNullableProp = default; + Option stringProp = default; while (utf8JsonReader.Read()) { @@ -248,52 +333,52 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "array_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; - case "object_items_nullable": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectItemsNullable = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); - break; case "array_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "array_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - arrayNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + arrayNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "boolean_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - booleanProp = utf8JsonReader.GetBoolean(); + booleanProp = new Option(utf8JsonReader.GetBoolean()); break; case "date_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - dateProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + dateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "datetime_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - datetimeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + datetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "integer_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - integerProp = utf8JsonReader.GetInt32(); + integerProp = new Option(utf8JsonReader.GetInt32()); break; case "number_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - numberProp = utf8JsonReader.GetDecimal(); + numberProp = new Option(utf8JsonReader.GetDecimal()); break; case "object_and_items_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectAndItemsNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "object_nullable_prop": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectNullableProp = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + objectNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "string_prop": - stringProp = utf8JsonReader.GetString(); + stringProp = new Option(utf8JsonReader.GetString()); break; default: break; @@ -301,13 +386,13 @@ namespace Org.OpenAPITools.Model } } - if (arrayItemsNullable == null) - throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is required for class NullableClass."); + if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null) + throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass."); - if (objectItemsNullable == null) - throw new ArgumentNullException(nameof(objectItemsNullable), "Property is required for class NullableClass."); + if (objectItemsNullable.IsSet && objectItemsNullable.Value == null) + throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass."); - return new NullableClass(arrayItemsNullable, objectItemsNullable, arrayAndItemsNullableProp, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectNullableProp, stringProp); + return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp); } /// @@ -334,45 +419,89 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("array_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("object_items_nullable"); - JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); - writer.WritePropertyName("array_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("array_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.BooleanProp != null) - writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); - else - writer.WriteNull("boolean_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass."); - if (nullableClass.DateProp != null) - writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(DatePropFormat)); - else - writer.WriteNull("date_prop"); + if (nullableClass.ArrayAndItemsNullablePropOption.IsSet) + if (nullableClass.ArrayAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("array_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_and_items_nullable_prop"); + if (nullableClass.ArrayItemsNullableOption.IsSet) + { + writer.WritePropertyName("array_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ArrayNullablePropOption.IsSet) + if (nullableClass.ArrayNullablePropOption.Value != null) + { + writer.WritePropertyName("array_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_nullable_prop"); + if (nullableClass.BooleanPropOption.IsSet) + if (nullableClass.BooleanPropOption.Value != null) + writer.WriteBoolean("boolean_prop", nullableClass.BooleanPropOption.Value.Value); + else + writer.WriteNull("boolean_prop"); - if (nullableClass.DatetimeProp != null) - writer.WriteString("datetime_prop", nullableClass.DatetimeProp.Value.ToString(DatetimePropFormat)); - else - writer.WriteNull("datetime_prop"); + if (nullableClass.DatePropOption.IsSet) + if (nullableClass.DatePropOption.Value != null) + writer.WriteString("date_prop", nullableClass.DatePropOption.Value.Value.ToString(DatePropFormat)); + else + writer.WriteNull("date_prop"); - if (nullableClass.IntegerProp != null) - writer.WriteNumber("integer_prop", nullableClass.IntegerProp.Value); - else - writer.WriteNull("integer_prop"); + if (nullableClass.DatetimePropOption.IsSet) + if (nullableClass.DatetimePropOption.Value != null) + writer.WriteString("datetime_prop", nullableClass.DatetimePropOption.Value.Value.ToString(DatetimePropFormat)); + else + writer.WriteNull("datetime_prop"); - if (nullableClass.NumberProp != null) - writer.WriteNumber("number_prop", nullableClass.NumberProp.Value); - else - writer.WriteNull("number_prop"); + if (nullableClass.IntegerPropOption.IsSet) + if (nullableClass.IntegerPropOption.Value != null) + writer.WriteNumber("integer_prop", nullableClass.IntegerPropOption.Value.Value); + else + writer.WriteNull("integer_prop"); - writer.WritePropertyName("object_and_items_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); - writer.WritePropertyName("object_nullable_prop"); - JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); - writer.WriteString("string_prop", nullableClass.StringProp); + if (nullableClass.NumberPropOption.IsSet) + if (nullableClass.NumberPropOption.Value != null) + writer.WriteNumber("number_prop", nullableClass.NumberPropOption.Value.Value); + else + writer.WriteNull("number_prop"); + + if (nullableClass.ObjectAndItemsNullablePropOption.IsSet) + if (nullableClass.ObjectAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("object_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_and_items_nullable_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet) + { + writer.WritePropertyName("object_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ObjectNullablePropOption.IsSet) + if (nullableClass.ObjectNullablePropOption.Value != null) + { + writer.WritePropertyName("object_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_nullable_prop"); + if (nullableClass.StringPropOption.IsSet) + if (nullableClass.StringPropOption.Value != null) + writer.WriteString("string_prop", nullableClass.StringProp); + else + writer.WriteNull("string_prop"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs index 684109acd50..415b5b58a97 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,20 +34,27 @@ namespace Org.OpenAPITools.Model /// /// uuid [JsonConstructor] - public NullableGuidClass(Guid? uuid = default) + public NullableGuidClass(Option uuid = default) { - Uuid = uuid; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + /// /// Gets or Sets Uuid /// /// 72f98069-206d-4f12-9f12-3d1e525a8e84 [JsonPropertyName("uuid")] - public Guid? Uuid { get; set; } + public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -101,7 +109,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Guid? uuid = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -120,7 +128,7 @@ namespace Org.OpenAPITools.Model { case "uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - uuid = utf8JsonReader.GetGuid(); + uuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -155,11 +163,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { - - if (nullableGuidClass.Uuid == null) - writer.WriteNull("uuid"); - else - writer.WriteString("uuid", nullableGuidClass.Uuid.Value); + if (nullableGuidClass.UuidOption.IsSet) + if (nullableGuidClass.UuidOption.Value != null) + writer.WriteString("uuid", nullableGuidClass.UuidOption.Value.Value); + else + writer.WriteNull("uuid"); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs index a44c950b81b..1e38640c8af 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; Quadrilateral quadrilateral = null; Triangle triangle = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class NullableShape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class NullableShape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType); + return new NullableShape(quadrilateral, shapeType.Value); if (triangle != null) - return new NullableShape(triangle, shapeType); + return new NullableShape(triangle, shapeType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { + if (nullableShape.ShapeType == null) + throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); + writer.WriteString("shapeType", nullableShape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs index 3f3cbf4c505..dff14aaba02 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// justNumber [JsonConstructor] - public NumberOnly(decimal justNumber) + public NumberOnly(Option justNumber = default) { - JustNumber = justNumber; + JustNumberOption = justNumber; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of JustNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustNumberOption { get; private set; } + /// /// Gets or Sets JustNumber /// [JsonPropertyName("JustNumber")] - public decimal JustNumber { get; set; } + public decimal? JustNumber { get { return this. JustNumberOption; } set { this.JustNumberOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - decimal? justNumber = default; + Option justNumber = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "JustNumber": if (utf8JsonReader.TokenType != JsonTokenType.Null) - justNumber = utf8JsonReader.GetDecimal(); + justNumber = new Option(utf8JsonReader.GetDecimal()); break; default: break; @@ -127,10 +135,10 @@ namespace Org.OpenAPITools.Model } } - if (justNumber == null) - throw new ArgumentNullException(nameof(justNumber), "Property is required for class NumberOnly."); + if (justNumber.IsSet && justNumber.Value == null) + throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly."); - return new NumberOnly(justNumber.Value); + return new NumberOnly(justNumber); } /// @@ -157,7 +165,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("JustNumber", numberOnly.JustNumber); + if (numberOnly.JustNumberOption.IsSet) + writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index 57a1614f29f..a11aee11212 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -36,43 +37,71 @@ namespace Org.OpenAPITools.Model /// id /// uuid [JsonConstructor] - public ObjectWithDeprecatedFields(List bars, DeprecatedObject deprecatedRef, decimal id, string uuid) + public ObjectWithDeprecatedFields(Option> bars = default, Option deprecatedRef = default, Option id = default, Option uuid = default) { - Bars = bars; - DeprecatedRef = deprecatedRef; - Id = id; - Uuid = uuid; + BarsOption = bars; + DeprecatedRefOption = deprecatedRef; + IdOption = id; + UuidOption = uuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bars + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> BarsOption { get; private set; } + /// /// Gets or Sets Bars /// [JsonPropertyName("bars")] [Obsolete] - public List Bars { get; set; } + public List Bars { get { return this. BarsOption; } set { this.BarsOption = new Option>(value); } } + + /// + /// Used to track the state of DeprecatedRef + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeprecatedRefOption { get; private set; } /// /// Gets or Sets DeprecatedRef /// [JsonPropertyName("deprecatedRef")] [Obsolete] - public DeprecatedObject DeprecatedRef { get; set; } + public DeprecatedObject DeprecatedRef { get { return this. DeprecatedRefOption; } set { this.DeprecatedRefOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] [Obsolete] - public decimal Id { get; set; } + public decimal? Id { get { return this. IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } /// /// Gets or Sets Uuid /// [JsonPropertyName("uuid")] - public string Uuid { get; set; } + public string Uuid { get { return this. UuidOption; } set { this.UuidOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -130,10 +159,10 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List bars = default; - DeprecatedObject deprecatedRef = default; - decimal? id = default; - string uuid = default; + Option> bars = default; + Option deprecatedRef = default; + Option id = default; + Option uuid = default; while (utf8JsonReader.Read()) { @@ -152,18 +181,18 @@ namespace Org.OpenAPITools.Model { case "bars": if (utf8JsonReader.TokenType != JsonTokenType.Null) - bars = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + bars = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; case "deprecatedRef": if (utf8JsonReader.TokenType != JsonTokenType.Null) - deprecatedRef = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + deprecatedRef = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetDecimal(); + id = new Option(utf8JsonReader.GetDecimal()); break; case "uuid": - uuid = utf8JsonReader.GetString(); + uuid = new Option(utf8JsonReader.GetString()); break; default: break; @@ -171,19 +200,19 @@ namespace Org.OpenAPITools.Model } } - if (bars == null) - throw new ArgumentNullException(nameof(bars), "Property is required for class ObjectWithDeprecatedFields."); + if (bars.IsSet && bars.Value == null) + throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (deprecatedRef == null) - throw new ArgumentNullException(nameof(deprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + if (deprecatedRef.IsSet && deprecatedRef.Value == null) + throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class ObjectWithDeprecatedFields."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields."); - if (uuid == null) - throw new ArgumentNullException(nameof(uuid), "Property is required for class ObjectWithDeprecatedFields."); + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields."); - return new ObjectWithDeprecatedFields(bars, deprecatedRef, id.Value, uuid); + return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid); } /// @@ -210,12 +239,30 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("bars"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); - writer.WritePropertyName("deprecatedRef"); - JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); - writer.WriteNumber("id", objectWithDeprecatedFields.Id); - writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); + if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.BarsOption.IsSet) + { + writer.WritePropertyName("bars"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet) + { + writer.WritePropertyName("deprecatedRef"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.IdOption.IsSet) + writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value.Value); + + if (objectWithDeprecatedFields.UuidOption.IsSet) + writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OneOfString.cs index 91dd6763161..660604e3ef1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OneOfString.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs index 3258ff15447..3c64766aa74 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,21 +32,21 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// complete (default to false) /// id /// petId /// quantity /// shipDate /// Order Status - /// complete (default to false) [JsonConstructor] - public Order(long id, long petId, int quantity, DateTime shipDate, StatusEnum status, bool complete = false) + public Order(Option complete = default, Option id = default, Option petId = default, Option quantity = default, Option shipDate = default, Option status = default) { - Id = id; - PetId = petId; - Quantity = quantity; - ShipDate = shipDate; - Status = status; - Complete = complete; + CompleteOption = complete; + IdOption = id; + PetIdOption = petId; + QuantityOption = quantity; + ShipDateOption = shipDate; + StatusOption = status; OnCreated(); } @@ -118,9 +119,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Placed) return "placed"; @@ -133,43 +133,85 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// Order Status /// /// Order Status [JsonPropertyName("status")] - public StatusEnum Status { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new Option(value); } } + + /// + /// Used to track the state of Complete + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CompleteOption { get; private set; } + + /// + /// Gets or Sets Complete + /// + [JsonPropertyName("complete")] + public bool? Complete { get { return this. CompleteOption; } set { this.CompleteOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of PetId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PetIdOption { get; private set; } /// /// Gets or Sets PetId /// [JsonPropertyName("petId")] - public long PetId { get; set; } + public long? PetId { get { return this. PetIdOption; } set { this.PetIdOption = new Option(value); } } + + /// + /// Used to track the state of Quantity + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option QuantityOption { get; private set; } /// /// Gets or Sets Quantity /// [JsonPropertyName("quantity")] - public int Quantity { get; set; } + public int? Quantity { get { return this. QuantityOption; } set { this.QuantityOption = new Option(value); } } + + /// + /// Used to track the state of ShipDate + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShipDateOption { get; private set; } /// /// Gets or Sets ShipDate /// /// 2020-02-02T20:20:20.000222Z [JsonPropertyName("shipDate")] - public DateTime ShipDate { get; set; } - - /// - /// Gets or Sets Complete - /// - [JsonPropertyName("complete")] - public bool Complete { get; set; } + public DateTime? ShipDate { get { return this. ShipDateOption; } set { this.ShipDateOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -185,12 +227,12 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Order {\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" PetId: ").Append(PetId).Append("\n"); sb.Append(" Quantity: ").Append(Quantity).Append("\n"); sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Complete: ").Append(Complete).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -234,12 +276,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - long? petId = default; - int? quantity = default; - DateTime? shipDate = default; - Order.StatusEnum? status = default; - bool? complete = default; + Option complete = default; + Option id = default; + Option petId = default; + Option quantity = default; + Option shipDate = default; + Option status = default; while (utf8JsonReader.Read()) { @@ -256,31 +298,30 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { + case "complete": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + complete = new Option(utf8JsonReader.GetBoolean()); + break; case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "petId": if (utf8JsonReader.TokenType != JsonTokenType.Null) - petId = utf8JsonReader.GetInt64(); + petId = new Option(utf8JsonReader.GetInt64()); break; case "quantity": if (utf8JsonReader.TokenType != JsonTokenType.Null) - quantity = utf8JsonReader.GetInt32(); + quantity = new Option(utf8JsonReader.GetInt32()); break; case "shipDate": if (utf8JsonReader.TokenType != JsonTokenType.Null) - shipDate = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + shipDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "status": string statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Order.StatusEnumFromStringOrDefault(statusRawValue); - break; - case "complete": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - complete = utf8JsonReader.GetBoolean(); + if (statusRawValue != null) + status = new Option(Order.StatusEnumFromStringOrDefault(statusRawValue)); break; default: break; @@ -288,25 +329,25 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Order."); + if (complete.IsSet && complete.Value == null) + throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order."); - if (petId == null) - throw new ArgumentNullException(nameof(petId), "Property is required for class Order."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order."); - if (quantity == null) - throw new ArgumentNullException(nameof(quantity), "Property is required for class Order."); + if (petId.IsSet && petId.Value == null) + throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order."); - if (shipDate == null) - throw new ArgumentNullException(nameof(shipDate), "Property is required for class Order."); + if (quantity.IsSet && quantity.Value == null) + throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Order."); + if (shipDate.IsSet && shipDate.Value == null) + throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order."); - if (complete == null) - throw new ArgumentNullException(nameof(complete), "Property is required for class Order."); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order."); - return new Order(id.Value, petId.Value, quantity.Value, shipDate.Value, status.Value, complete.Value); + return new Order(complete, id, petId, quantity, shipDate, status); } /// @@ -333,18 +374,26 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", order.Id); - writer.WriteNumber("petId", order.PetId); - writer.WriteNumber("quantity", order.Quantity); - writer.WriteString("shipDate", order.ShipDate.ToString(ShipDateFormat)); + if (order.CompleteOption.IsSet) + writer.WriteBoolean("complete", order.CompleteOption.Value.Value); - var statusRawValue = Order.StatusEnumToJsonValue(order.Status); + if (order.IdOption.IsSet) + writer.WriteNumber("id", order.IdOption.Value.Value); + + if (order.PetIdOption.IsSet) + writer.WriteNumber("petId", order.PetIdOption.Value.Value); + + if (order.QuantityOption.IsSet) + writer.WriteNumber("quantity", order.QuantityOption.Value.Value); + + if (order.ShipDateOption.IsSet) + writer.WriteString("shipDate", order.ShipDateOption.Value.Value.ToString(ShipDateFormat)); + + var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - - writer.WriteBoolean("complete", order.Complete); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs index c37883db124..42665b8a066 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,33 +36,54 @@ namespace Org.OpenAPITools.Model /// myNumber /// myString [JsonConstructor] - public OuterComposite(bool myBoolean, decimal myNumber, string myString) + public OuterComposite(Option myBoolean = default, Option myNumber = default, Option myString = default) { - MyBoolean = myBoolean; - MyNumber = myNumber; - MyString = myString; + MyBooleanOption = myBoolean; + MyNumberOption = myNumber; + MyStringOption = myString; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of MyBoolean + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyBooleanOption { get; private set; } + /// /// Gets or Sets MyBoolean /// [JsonPropertyName("my_boolean")] - public bool MyBoolean { get; set; } + public bool? MyBoolean { get { return this. MyBooleanOption; } set { this.MyBooleanOption = new Option(value); } } + + /// + /// Used to track the state of MyNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyNumberOption { get; private set; } /// /// Gets or Sets MyNumber /// [JsonPropertyName("my_number")] - public decimal MyNumber { get; set; } + public decimal? MyNumber { get { return this. MyNumberOption; } set { this.MyNumberOption = new Option(value); } } + + /// + /// Used to track the state of MyString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyStringOption { get; private set; } /// /// Gets or Sets MyString /// [JsonPropertyName("my_string")] - public string MyString { get; set; } + public string MyString { get { return this. MyStringOption; } set { this.MyStringOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -118,9 +140,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - bool? myBoolean = default; - decimal? myNumber = default; - string myString = default; + Option myBoolean = default; + Option myNumber = default; + Option myString = default; while (utf8JsonReader.Read()) { @@ -139,14 +161,14 @@ namespace Org.OpenAPITools.Model { case "my_boolean": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myBoolean = utf8JsonReader.GetBoolean(); + myBoolean = new Option(utf8JsonReader.GetBoolean()); break; case "my_number": if (utf8JsonReader.TokenType != JsonTokenType.Null) - myNumber = utf8JsonReader.GetDecimal(); + myNumber = new Option(utf8JsonReader.GetDecimal()); break; case "my_string": - myString = utf8JsonReader.GetString(); + myString = new Option(utf8JsonReader.GetString()); break; default: break; @@ -154,16 +176,16 @@ namespace Org.OpenAPITools.Model } } - if (myBoolean == null) - throw new ArgumentNullException(nameof(myBoolean), "Property is required for class OuterComposite."); + if (myBoolean.IsSet && myBoolean.Value == null) + throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite."); - if (myNumber == null) - throw new ArgumentNullException(nameof(myNumber), "Property is required for class OuterComposite."); + if (myNumber.IsSet && myNumber.Value == null) + throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite."); - if (myString == null) - throw new ArgumentNullException(nameof(myString), "Property is required for class OuterComposite."); + if (myString.IsSet && myString.Value == null) + throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite."); - return new OuterComposite(myBoolean.Value, myNumber.Value, myString); + return new OuterComposite(myBoolean, myNumber, myString); } /// @@ -190,9 +212,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteBoolean("my_boolean", outerComposite.MyBoolean); - writer.WriteNumber("my_number", outerComposite.MyNumber); - writer.WriteString("my_string", outerComposite.MyString); + if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null) + throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite."); + + if (outerComposite.MyBooleanOption.IsSet) + writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value); + + if (outerComposite.MyNumberOption.IsSet) + writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value.Value); + + if (outerComposite.MyStringOption.IsSet) + writer.WriteString("my_string", outerComposite.MyString); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs index a4ec335bb38..47bb6793c6a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index 7c67db5ddca..136fb4c54c4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index 84ea65297ab..2ed4f18a657 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index 983d194a199..c6a470cc64d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs index 51d8bee407e..a2e789f2ede 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumTest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs index eb0129c6ce0..c451e1a8991 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -76,7 +77,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string petType = default; + Option petType = default; while (utf8JsonReader.Read()) { @@ -94,7 +95,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "pet_type": - petType = utf8JsonReader.GetString(); + petType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -102,10 +103,13 @@ namespace Org.OpenAPITools.Model } } - if (petType == null) - throw new ArgumentNullException(nameof(petType), "Property is required for class ParentPet."); + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ParentPet.", nameof(petType)); - return new ParentPet(petType); + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); + + return new ParentPet(petType.Value); } /// @@ -132,6 +136,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet.PetType == null) + throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); + writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs index 225a9c5328c..992e25a8486 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,21 +32,21 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// - /// category - /// id /// name /// photoUrls + /// category + /// id /// pet status in the store /// tags [JsonConstructor] - public Pet(Category category, long id, string name, List photoUrls, StatusEnum status, List tags) + public Pet(string name, List photoUrls, Option category = default, Option id = default, Option status = default, Option> tags = default) { - Category = category; - Id = id; Name = name; PhotoUrls = photoUrls; - Status = status; - Tags = tags; + CategoryOption = category; + IdOption = id; + StatusOption = status; + TagsOption = tags; OnCreated(); } @@ -118,9 +119,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string StatusEnumToJsonValue(StatusEnum value) + public static string StatusEnumToJsonValue(StatusEnum? value) { - if (value == StatusEnum.Available) return "available"; @@ -133,24 +133,19 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + /// /// pet status in the store /// /// pet status in the store [JsonPropertyName("status")] - public StatusEnum Status { get; set; } - - /// - /// Gets or Sets Category - /// - [JsonPropertyName("category")] - public Category Category { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new Option(value); } } /// /// Gets or Sets Name @@ -165,11 +160,44 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } + /// + /// Used to track the state of Category + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryOption { get; private set; } + + /// + /// Gets or Sets Category + /// + [JsonPropertyName("category")] + public Category Category { get { return this. CategoryOption; } set { this.CategoryOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Tags + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TagsOption { get; private set; } + /// /// Gets or Sets Tags /// [JsonPropertyName("tags")] - public List Tags { get; set; } + public List Tags { get { return this. TagsOption; } set { this.TagsOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -185,10 +213,10 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Pet {\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" Status: ").Append(Status).Append("\n"); sb.Append(" Tags: ").Append(Tags).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); @@ -229,12 +257,12 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Category category = default; - long? id = default; - string name = default; - List photoUrls = default; - Pet.StatusEnum? status = default; - List tags = default; + Option name = default; + Option> photoUrls = default; + Option category = default; + Option id = default; + Option status = default; + Option> tags = default; while (utf8JsonReader.Read()) { @@ -251,30 +279,29 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "category": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - category = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; case "photoUrls": if (utf8JsonReader.TokenType != JsonTokenType.Null) - photoUrls = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + photoUrls = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "category": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + category = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); break; case "status": string statusRawValue = utf8JsonReader.GetString(); - status = statusRawValue == null - ? null - : Pet.StatusEnumFromStringOrDefault(statusRawValue); + if (statusRawValue != null) + status = new Option(Pet.StatusEnumFromStringOrDefault(statusRawValue)); break; case "tags": if (utf8JsonReader.TokenType != JsonTokenType.Null) - tags = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + tags = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -282,25 +309,31 @@ namespace Org.OpenAPITools.Model } } - if (category == null) - throw new ArgumentNullException(nameof(category), "Property is required for class Pet."); + if (!name.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(name)); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Pet."); + if (!photoUrls.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(photoUrls)); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Pet."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Pet."); - if (photoUrls == null) - throw new ArgumentNullException(nameof(photoUrls), "Property is required for class Pet."); + if (photoUrls.IsSet && photoUrls.Value == null) + throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet."); - if (status == null) - throw new ArgumentNullException(nameof(status), "Property is required for class Pet."); + if (category.IsSet && category.Value == null) + throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet."); - if (tags == null) - throw new ArgumentNullException(nameof(tags), "Property is required for class Pet."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet."); - return new Pet(category, id.Value, name, photoUrls, status.Value, tags); + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet."); + + if (tags.IsSet && tags.Value == null) + throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet."); + + return new Pet(name.Value, photoUrls.Value, category, id, status, tags); } /// @@ -327,21 +360,41 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("category"); - JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); - writer.WriteNumber("id", pet.Id); + if (pet.Name == null) + throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet."); + + if (pet.PhotoUrls == null) + throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet."); + + if (pet.CategoryOption.IsSet && pet.Category == null) + throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet."); + + if (pet.TagsOption.IsSet && pet.Tags == null) + throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet."); + writer.WriteString("name", pet.Name); + writer.WritePropertyName("photoUrls"); JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions); + if (pet.CategoryOption.IsSet) + { + writer.WritePropertyName("category"); + JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); + } + if (pet.IdOption.IsSet) + writer.WriteNumber("id", pet.IdOption.Value.Value); - var statusRawValue = Pet.StatusEnumToJsonValue(pet.Status); + var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value.Value); if (statusRawValue != null) writer.WriteString("status", statusRawValue); else writer.WriteNull("status"); - writer.WritePropertyName("tags"); - JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + if (pet.TagsOption.IsSet) + { + writer.WritePropertyName("tags"); + JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs index 8185d643e79..d3bbeb8ff32 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; + Option className = default; BasquePig basquePig = null; DanishPig danishPig = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Pig."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Pig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className); + return new Pig(basquePig, className.Value); if (danishPig != null) - return new Pig(danishPig, className); + return new Pig(danishPig, className.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { + if (pig.ClassName == null) + throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); + writer.WriteString("className", pig.ClassName); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 3a89a8716e0..2c2227a2251 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs index 65f7b8b4536..3f4034a1771 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; + Option quadrilateralType = default; ComplexQuadrilateral complexQuadrilateral = null; SimpleQuadrilateral simpleQuadrilateral = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class Quadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class Quadrilateral.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType); + return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType); + return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); + writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index c329eed3266..75b7e516cfc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; + Option quadrilateralType = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class QuadrilateralInterface."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class QuadrilateralInterface.", nameof(quadrilateralType)); - return new QuadrilateralInterface(quadrilateralType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class QuadrilateralInterface."); + + return new QuadrilateralInterface(quadrilateralType.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) { + if (quadrilateralInterface.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface."); + writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 2c8b4fff43d..d5b7e21838d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// bar /// baz [JsonConstructor] - public ReadOnlyFirst(string bar, string baz) + public ReadOnlyFirst(Option bar = default, Option baz = default) { - Bar = bar; - Baz = baz; + BarOption = bar; + BazOption = baz; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + /// /// Gets or Sets Bar /// [JsonPropertyName("bar")] - public string Bar { get; } + public string Bar { get { return this. BarOption; } } + + /// + /// Used to track the state of Baz + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BazOption { get; private set; } /// /// Gets or Sets Baz /// [JsonPropertyName("baz")] - public string Baz { get; set; } + public string Baz { get { return this. BazOption; } set { this.BazOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -105,7 +120,9 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + Bar.GetHashCode(); + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); return hashCode; @@ -145,8 +162,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string bar = default; - string baz = default; + Option bar = default; + Option baz = default; while (utf8JsonReader.Read()) { @@ -164,10 +181,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "bar": - bar = utf8JsonReader.GetString(); + bar = new Option(utf8JsonReader.GetString()); break; case "baz": - baz = utf8JsonReader.GetString(); + baz = new Option(utf8JsonReader.GetString()); break; default: break; @@ -175,11 +192,11 @@ namespace Org.OpenAPITools.Model } } - if (bar == null) - throw new ArgumentNullException(nameof(bar), "Property is required for class ReadOnlyFirst."); + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst."); - if (baz == null) - throw new ArgumentNullException(nameof(baz), "Property is required for class ReadOnlyFirst."); + if (baz.IsSet && baz.Value == null) + throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst."); return new ReadOnlyFirst(bar, baz); } @@ -208,8 +225,17 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("bar", readOnlyFirst.Bar); - writer.WriteString("baz", readOnlyFirst.Baz); + if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BarOption.IsSet) + writer.WriteString("bar", readOnlyFirst.Bar); + + if (readOnlyFirst.BazOption.IsSet) + writer.WriteString("baz", readOnlyFirst.Baz); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..f72773b3ffc --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,2386 @@ +// +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + public partial class RequiredClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// requiredNotNullableDateProp + /// requiredNotnullableArrayOfString + /// requiredNotnullableBooleanProp + /// requiredNotnullableDatetimeProp + /// requiredNotnullableEnumInteger + /// requiredNotnullableEnumIntegerOnly + /// requiredNotnullableEnumString + /// requiredNotnullableOuterEnumDefaultValue + /// requiredNotnullableStringProp + /// requiredNotnullableUuid + /// requiredNotnullableintegerProp + /// requiredNullableArrayOfString + /// requiredNullableBooleanProp + /// requiredNullableDateProp + /// requiredNullableDatetimeProp + /// requiredNullableEnumInteger + /// requiredNullableEnumIntegerOnly + /// requiredNullableEnumString + /// requiredNullableIntegerProp + /// requiredNullableOuterEnumDefaultValue + /// requiredNullableStringProp + /// requiredNullableUuid + /// notRequiredNotnullableDateProp + /// notRequiredNotnullableintegerProp + /// notRequiredNullableDateProp + /// notRequiredNullableIntegerProp + /// notrequiredNotnullableArrayOfString + /// notrequiredNotnullableBooleanProp + /// notrequiredNotnullableDatetimeProp + /// notrequiredNotnullableEnumInteger + /// notrequiredNotnullableEnumIntegerOnly + /// notrequiredNotnullableEnumString + /// notrequiredNotnullableOuterEnumDefaultValue + /// notrequiredNotnullableStringProp + /// notrequiredNotnullableUuid + /// notrequiredNullableArrayOfString + /// notrequiredNullableBooleanProp + /// notrequiredNullableDatetimeProp + /// notrequiredNullableEnumInteger + /// notrequiredNullableEnumIntegerOnly + /// notrequiredNullableEnumString + /// notrequiredNullableOuterEnumDefaultValue + /// notrequiredNullableStringProp + /// notrequiredNullableUuid + [JsonConstructor] + public RequiredClass(DateTime requiredNotNullableDateProp, List requiredNotnullableArrayOfString, bool requiredNotnullableBooleanProp, DateTime requiredNotnullableDatetimeProp, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue, string requiredNotnullableStringProp, Guid requiredNotnullableUuid, int requiredNotnullableintegerProp, List requiredNullableArrayOfString = default, bool? requiredNullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime? requiredNullableDatetimeProp = default, RequiredNullableEnumIntegerEnum? requiredNullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum? requiredNullableEnumIntegerOnly = default, RequiredNullableEnumStringEnum? requiredNullableEnumString = default, int? requiredNullableIntegerProp = default, OuterEnumDefaultValue? requiredNullableOuterEnumDefaultValue = default, string requiredNullableStringProp = default, Guid? requiredNullableUuid = default, Option notRequiredNotnullableDateProp = default, Option notRequiredNotnullableintegerProp = default, Option notRequiredNullableDateProp = default, Option notRequiredNullableIntegerProp = default, Option> notrequiredNotnullableArrayOfString = default, Option notrequiredNotnullableBooleanProp = default, Option notrequiredNotnullableDatetimeProp = default, Option notrequiredNotnullableEnumInteger = default, Option notrequiredNotnullableEnumIntegerOnly = default, Option notrequiredNotnullableEnumString = default, Option notrequiredNotnullableOuterEnumDefaultValue = default, Option notrequiredNotnullableStringProp = default, Option notrequiredNotnullableUuid = default, Option> notrequiredNullableArrayOfString = default, Option notrequiredNullableBooleanProp = default, Option notrequiredNullableDatetimeProp = default, Option notrequiredNullableEnumInteger = default, Option notrequiredNullableEnumIntegerOnly = default, Option notrequiredNullableEnumString = default, Option notrequiredNullableOuterEnumDefaultValue = default, Option notrequiredNullableStringProp = default, Option notrequiredNullableUuid = default) + { + RequiredNotNullableDateProp = requiredNotNullableDateProp; + RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + RequiredNotnullableEnumString = requiredNotnullableEnumString; + RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + RequiredNotnullableStringProp = requiredNotnullableStringProp; + RequiredNotnullableUuid = requiredNotnullableUuid; + RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + RequiredNullableArrayOfString = requiredNullableArrayOfString; + RequiredNullableBooleanProp = requiredNullableBooleanProp; + RequiredNullableDateProp = requiredNullableDateProp; + RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + RequiredNullableEnumInteger = requiredNullableEnumInteger; + RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + RequiredNullableEnumString = requiredNullableEnumString; + RequiredNullableIntegerProp = requiredNullableIntegerProp; + RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + RequiredNullableStringProp = requiredNullableStringProp; + RequiredNullableUuid = requiredNullableUuid; + NotRequiredNotnullableDatePropOption = notRequiredNotnullableDateProp; + NotRequiredNotnullableintegerPropOption = notRequiredNotnullableintegerProp; + NotRequiredNullableDatePropOption = notRequiredNullableDateProp; + NotRequiredNullableIntegerPropOption = notRequiredNullableIntegerProp; + NotrequiredNotnullableArrayOfStringOption = notrequiredNotnullableArrayOfString; + NotrequiredNotnullableBooleanPropOption = notrequiredNotnullableBooleanProp; + NotrequiredNotnullableDatetimePropOption = notrequiredNotnullableDatetimeProp; + NotrequiredNotnullableEnumIntegerOption = notrequiredNotnullableEnumInteger; + NotrequiredNotnullableEnumIntegerOnlyOption = notrequiredNotnullableEnumIntegerOnly; + NotrequiredNotnullableEnumStringOption = notrequiredNotnullableEnumString; + NotrequiredNotnullableOuterEnumDefaultValueOption = notrequiredNotnullableOuterEnumDefaultValue; + NotrequiredNotnullableStringPropOption = notrequiredNotnullableStringProp; + NotrequiredNotnullableUuidOption = notrequiredNotnullableUuid; + NotrequiredNullableArrayOfStringOption = notrequiredNullableArrayOfString; + NotrequiredNullableBooleanPropOption = notrequiredNullableBooleanProp; + NotrequiredNullableDatetimePropOption = notrequiredNullableDatetimeProp; + NotrequiredNullableEnumIntegerOption = notrequiredNullableEnumInteger; + NotrequiredNullableEnumIntegerOnlyOption = notrequiredNullableEnumIntegerOnly; + NotrequiredNullableEnumStringOption = notrequiredNullableEnumString; + NotrequiredNullableOuterEnumDefaultValueOption = notrequiredNullableOuterEnumDefaultValue; + NotrequiredNullableStringPropOption = notrequiredNullableStringProp; + NotrequiredNullableUuidOption = notrequiredNullableUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum? RequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerEnumToJsonValue(RequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [JsonPropertyName("required_notnullable_enum_integer")] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum? RequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(RequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("required_notnullable_enum_integer_only")] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNotnullableEnumString + /// + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumStringEnum RequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumStringEnum? RequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNotnullableEnumStringEnumToJsonValue(RequiredNotnullableEnumStringEnum value) + { + if (value == RequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [JsonPropertyName("required_notnullable_enum_string")] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerEnum RequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerEnum? RequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerEnumToJsonValue(RequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [JsonPropertyName("required_nullable_enum_integer")] + public RequiredNullableEnumIntegerEnum? RequiredNullableEnumInteger { get; set; } + + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerOnlyEnumToJsonValue(RequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("required_nullable_enum_integer_only")] + public RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNullableEnumString + /// + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumStringEnum RequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumStringEnum? RequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == RequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [JsonPropertyName("required_nullable_enum_string")] + public RequiredNullableEnumStringEnum? RequiredNullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum NotrequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerEnumToJsonValue(NotrequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [JsonPropertyName("notrequired_notnullable_enum_integer")] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get { return this.NotrequiredNotnullableEnumIntegerOption; } set { this.NotrequiredNotnullableEnumIntegerOption = new Option(value); } } + + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum NotrequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_notnullable_enum_integer_only")] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get { return this.NotrequiredNotnullableEnumIntegerOnlyOption; } set { this.NotrequiredNotnullableEnumIntegerOnlyOption = new Option(value); } } + + /// + /// Defines NotrequiredNotnullableEnumString + /// + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum NotrequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNotnullableEnumStringEnumToJsonValue(NotrequiredNotnullableEnumStringEnum? value) + { + if (value == NotrequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [JsonPropertyName("notrequired_notnullable_enum_string")] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get { return this.NotrequiredNotnullableEnumStringOption; } set { this.NotrequiredNotnullableEnumStringOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get { return this.NotrequiredNotnullableOuterEnumDefaultValueOption; } set { this.NotrequiredNotnullableOuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum NotrequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerEnumToJsonValue(NotrequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [JsonPropertyName("notrequired_nullable_enum_integer")] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get { return this.NotrequiredNullableEnumIntegerOption; } set { this.NotrequiredNullableEnumIntegerOption = new Option(value); } } + + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum NotrequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_nullable_enum_integer_only")] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get { return this.NotrequiredNullableEnumIntegerOnlyOption; } set { this.NotrequiredNullableEnumIntegerOnlyOption = new Option(value); } } + + /// + /// Defines NotrequiredNullableEnumString + /// + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumStringEnum NotrequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == NotrequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [JsonPropertyName("notrequired_nullable_enum_string")] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get { return this.NotrequiredNullableEnumStringOption; } set { this.NotrequiredNullableEnumStringOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get { return this.NotrequiredNullableOuterEnumDefaultValueOption; } set { this.NotrequiredNullableOuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonPropertyName("required_not_nullable_date_prop")] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [JsonPropertyName("required_notnullable_array_of_string")] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [JsonPropertyName("required_notnullable_boolean_prop")] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [JsonPropertyName("required_notnullable_datetime_prop")] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [JsonPropertyName("required_notnullable_string_prop")] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_notnullable_uuid")] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [JsonPropertyName("required_notnullableinteger_prop")] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [JsonPropertyName("required_nullable_array_of_string")] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [JsonPropertyName("required_nullable_boolean_prop")] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonPropertyName("required_nullable_date_prop")] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [JsonPropertyName("required_nullable_datetime_prop")] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [JsonPropertyName("required_nullable_integer_prop")] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [JsonPropertyName("required_nullable_string_prop")] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_nullable_uuid")] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Used to track the state of NotRequiredNotnullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonPropertyName("not_required_notnullable_date_prop")] + public DateTime? NotRequiredNotnullableDateProp { get { return this. NotRequiredNotnullableDatePropOption; } set { this.NotRequiredNotnullableDatePropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNotnullableintegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableintegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [JsonPropertyName("not_required_notnullableinteger_prop")] + public int? NotRequiredNotnullableintegerProp { get { return this. NotRequiredNotnullableintegerPropOption; } set { this.NotRequiredNotnullableintegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonPropertyName("not_required_nullable_date_prop")] + public DateTime? NotRequiredNullableDateProp { get { return this. NotRequiredNullableDatePropOption; } set { this.NotRequiredNullableDatePropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNullableIntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableIntegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [JsonPropertyName("not_required_nullable_integer_prop")] + public int? NotRequiredNullableIntegerProp { get { return this. NotRequiredNullableIntegerPropOption; } set { this.NotRequiredNullableIntegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNotnullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [JsonPropertyName("notrequired_notnullable_array_of_string")] + public List NotrequiredNotnullableArrayOfString { get { return this. NotrequiredNotnullableArrayOfStringOption; } set { this.NotrequiredNotnullableArrayOfStringOption = new Option>(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [JsonPropertyName("notrequired_notnullable_boolean_prop")] + public bool? NotrequiredNotnullableBooleanProp { get { return this. NotrequiredNotnullableBooleanPropOption; } set { this.NotrequiredNotnullableBooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [JsonPropertyName("notrequired_notnullable_datetime_prop")] + public DateTime? NotrequiredNotnullableDatetimeProp { get { return this. NotrequiredNotnullableDatetimePropOption; } set { this.NotrequiredNotnullableDatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [JsonPropertyName("notrequired_notnullable_string_prop")] + public string NotrequiredNotnullableStringProp { get { return this. NotrequiredNotnullableStringPropOption; } set { this.NotrequiredNotnullableStringPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_notnullable_uuid")] + public Guid? NotrequiredNotnullableUuid { get { return this. NotrequiredNotnullableUuidOption; } set { this.NotrequiredNotnullableUuidOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [JsonPropertyName("notrequired_nullable_array_of_string")] + public List NotrequiredNullableArrayOfString { get { return this. NotrequiredNullableArrayOfStringOption; } set { this.NotrequiredNullableArrayOfStringOption = new Option>(value); } } + + /// + /// Used to track the state of NotrequiredNullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [JsonPropertyName("notrequired_nullable_boolean_prop")] + public bool? NotrequiredNullableBooleanProp { get { return this. NotrequiredNullableBooleanPropOption; } set { this.NotrequiredNullableBooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [JsonPropertyName("notrequired_nullable_datetime_prop")] + public DateTime? NotrequiredNullableDatetimeProp { get { return this. NotrequiredNullableDatetimePropOption; } set { this.NotrequiredNullableDatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [JsonPropertyName("notrequired_nullable_string_prop")] + public string NotrequiredNullableStringProp { get { return this. NotrequiredNullableStringPropOption; } set { this.NotrequiredNullableStringPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_nullable_uuid")] + public Guid? NotrequiredNullableUuid { get { return this. NotrequiredNullableUuidOption; } set { this.NotrequiredNullableUuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize RequiredNotNullableDateProp + /// + public static string RequiredNotNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNotnullableDatetimeProp + /// + public static string RequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize RequiredNullableDateProp + /// + public static string RequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNullableDatetimeProp + /// + public static string RequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotRequiredNotnullableDateProp + /// + public static string NotRequiredNotnullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotRequiredNullableDateProp + /// + public static string NotRequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotrequiredNotnullableDatetimeProp + /// + public static string NotrequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotrequiredNullableDatetimeProp + /// + public static string NotrequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option requiredNotNullableDateProp = default; + Option> requiredNotnullableArrayOfString = default; + Option requiredNotnullableBooleanProp = default; + Option requiredNotnullableDatetimeProp = default; + Option requiredNotnullableEnumInteger = default; + Option requiredNotnullableEnumIntegerOnly = default; + Option requiredNotnullableEnumString = default; + Option requiredNotnullableOuterEnumDefaultValue = default; + Option requiredNotnullableStringProp = default; + Option requiredNotnullableUuid = default; + Option requiredNotnullableintegerProp = default; + Option> requiredNullableArrayOfString = default; + Option requiredNullableBooleanProp = default; + Option requiredNullableDateProp = default; + Option requiredNullableDatetimeProp = default; + Option requiredNullableEnumInteger = default; + Option requiredNullableEnumIntegerOnly = default; + Option requiredNullableEnumString = default; + Option requiredNullableIntegerProp = default; + Option requiredNullableOuterEnumDefaultValue = default; + Option requiredNullableStringProp = default; + Option requiredNullableUuid = default; + Option notRequiredNotnullableDateProp = default; + Option notRequiredNotnullableintegerProp = default; + Option notRequiredNullableDateProp = default; + Option notRequiredNullableIntegerProp = default; + Option> notrequiredNotnullableArrayOfString = default; + Option notrequiredNotnullableBooleanProp = default; + Option notrequiredNotnullableDatetimeProp = default; + Option notrequiredNotnullableEnumInteger = default; + Option notrequiredNotnullableEnumIntegerOnly = default; + Option notrequiredNotnullableEnumString = default; + Option notrequiredNotnullableOuterEnumDefaultValue = default; + Option notrequiredNotnullableStringProp = default; + Option notrequiredNotnullableUuid = default; + Option> notrequiredNullableArrayOfString = default; + Option notrequiredNullableBooleanProp = default; + Option notrequiredNullableDatetimeProp = default; + Option notrequiredNullableEnumInteger = default; + Option notrequiredNullableEnumIntegerOnly = default; + Option notrequiredNullableEnumString = default; + Option notrequiredNullableOuterEnumDefaultValue = default; + Option notrequiredNullableStringProp = default; + Option notrequiredNullableUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "required_not_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumInteger = new Option((RequiredClass.RequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumIntegerOnly = new Option((RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_string": + string requiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumStringRawValue != null) + requiredNotnullableEnumString = new Option(RequiredClass.RequiredNotnullableEnumStringEnumFromStringOrDefault(requiredNotnullableEnumStringRawValue)); + break; + case "required_notnullable_outerEnumDefaultValue": + string requiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableOuterEnumDefaultValueRawValue != null) + requiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "required_notnullable_string_prop": + requiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumInteger = new Option((RequiredClass.RequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumIntegerOnly = new Option((RequiredClass.RequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_string": + string requiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumStringRawValue != null) + requiredNullableEnumString = new Option(RequiredClass.RequiredNullableEnumStringEnumFromStringOrDefault(requiredNullableEnumStringRawValue)); + break; + case "required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_outerEnumDefaultValue": + string requiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + requiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNullableOuterEnumDefaultValueRawValue)); + break; + case "required_nullable_string_prop": + requiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "not_required_notnullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumInteger = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_string": + string notrequiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumStringRawValue != null) + notrequiredNotnullableEnumString = new Option(RequiredClass.NotrequiredNotnullableEnumStringEnumFromStringOrDefault(notrequiredNotnullableEnumStringRawValue)); + break; + case "notrequired_notnullable_outerEnumDefaultValue": + string notrequiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableOuterEnumDefaultValueRawValue != null) + notrequiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_notnullable_string_prop": + notrequiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "notrequired_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumInteger = new Option((RequiredClass.NotrequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_string": + string notrequiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumStringRawValue != null) + notrequiredNullableEnumString = new Option(RequiredClass.NotrequiredNullableEnumStringEnumFromStringOrDefault(notrequiredNullableEnumStringRawValue)); + break; + case "notrequired_nullable_outerEnumDefaultValue": + string notrequiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableOuterEnumDefaultValueRawValue != null) + notrequiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_nullable_string_prop": + notrequiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!requiredNotNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotNullableDateProp)); + + if (!requiredNotnullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableArrayOfString)); + + if (!requiredNotnullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableBooleanProp)); + + if (!requiredNotnullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableDatetimeProp)); + + if (!requiredNotnullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumInteger)); + + if (!requiredNotnullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumIntegerOnly)); + + if (!requiredNotnullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumString)); + + if (!requiredNotnullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableOuterEnumDefaultValue)); + + if (!requiredNotnullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableStringProp)); + + if (!requiredNotnullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableUuid)); + + if (!requiredNotnullableintegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableintegerProp)); + + if (!requiredNullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableArrayOfString)); + + if (!requiredNullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableBooleanProp)); + + if (!requiredNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDateProp)); + + if (!requiredNullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDatetimeProp)); + + if (!requiredNullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumInteger)); + + if (!requiredNullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumIntegerOnly)); + + if (!requiredNullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumString)); + + if (!requiredNullableIntegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableIntegerProp)); + + if (!requiredNullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableOuterEnumDefaultValue)); + + if (!requiredNullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableStringProp)); + + if (!requiredNullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableUuid)); + + if (requiredNotNullableDateProp.IsSet && requiredNotNullableDateProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotNullableDateProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableArrayOfString.IsSet && requiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableBooleanProp.IsSet && requiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableDatetimeProp.IsSet && requiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumInteger.IsSet && requiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumIntegerOnly.IsSet && requiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumString.IsSet && requiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableOuterEnumDefaultValue.IsSet && requiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableStringProp.IsSet && requiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableUuid.IsSet && requiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + return new RequiredClass(requiredNotNullableDateProp.Value.Value, requiredNotnullableArrayOfString.Value, requiredNotnullableBooleanProp.Value.Value, requiredNotnullableDatetimeProp.Value.Value, requiredNotnullableEnumInteger.Value.Value, requiredNotnullableEnumIntegerOnly.Value.Value, requiredNotnullableEnumString.Value.Value, requiredNotnullableOuterEnumDefaultValue.Value.Value, requiredNotnullableStringProp.Value, requiredNotnullableUuid.Value.Value, requiredNotnullableintegerProp.Value.Value, requiredNullableArrayOfString.Value, requiredNullableBooleanProp.Value, requiredNullableDateProp.Value, requiredNullableDatetimeProp.Value, requiredNullableEnumInteger.Value, requiredNullableEnumIntegerOnly.Value, requiredNullableEnumString.Value, requiredNullableIntegerProp.Value, requiredNullableOuterEnumDefaultValue.Value, requiredNullableStringProp.Value, requiredNullableUuid.Value, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + if (requiredClass.RequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.RequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat)); + + writer.WritePropertyName("required_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNotnullableArrayOfString, jsonSerializerOptions); + writer.WriteBoolean("required_notnullable_boolean_prop", requiredClass.RequiredNotnullableBooleanProp); + + writer.WriteString("required_notnullable_datetime_prop", requiredClass.RequiredNotnullableDatetimeProp.ToString(RequiredNotnullableDatetimePropFormat)); + + writer.WriteNumber("required_notnullable_enum_integer", RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNotnullableEnumInteger)); + + writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly)); + + var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString); + if (requiredNotnullableEnumStringRawValue != null) + writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue); + else + writer.WriteNull("required_notnullable_enum_string"); + + var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue); + writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue); + + writer.WriteString("required_notnullable_string_prop", requiredClass.RequiredNotnullableStringProp); + + writer.WriteString("required_notnullable_uuid", requiredClass.RequiredNotnullableUuid); + + writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp); + + if (requiredClass.RequiredNullableArrayOfString != null) + { + writer.WritePropertyName("required_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("required_nullable_array_of_string"); + if (requiredClass.RequiredNullableBooleanProp != null) + writer.WriteBoolean("required_nullable_boolean_prop", requiredClass.RequiredNullableBooleanProp.Value); + else + writer.WriteNull("required_nullable_boolean_prop"); + + if (requiredClass.RequiredNullableDateProp != null) + writer.WriteString("required_nullable_date_prop", requiredClass.RequiredNullableDateProp.Value.ToString(RequiredNullableDatePropFormat)); + else + writer.WriteNull("required_nullable_date_prop"); + + if (requiredClass.RequiredNullableDatetimeProp != null) + writer.WriteString("required_nullable_datetime_prop", requiredClass.RequiredNullableDatetimeProp.Value.ToString(RequiredNullableDatetimePropFormat)); + else + writer.WriteNull("required_nullable_datetime_prop"); + + if (requiredClass.RequiredNullableEnumInteger != null) + writer.WriteNumber("required_nullable_enum_integer", RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNullableEnumInteger.Value)); + else + writer.WriteNull("required_nullable_enum_integer"); + + if (requiredClass.RequiredNullableEnumIntegerOnly != null) + writer.WriteNumber("required_nullable_enum_integer_only", RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNullableEnumIntegerOnly.Value)); + else + writer.WriteNull("required_nullable_enum_integer_only"); + + var requiredNullableEnumStringRawValue = RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClass.RequiredNullableEnumString.Value); + if (requiredNullableEnumStringRawValue != null) + writer.WriteString("required_nullable_enum_string", requiredNullableEnumStringRawValue); + else + writer.WriteNull("required_nullable_enum_string"); + + if (requiredClass.RequiredNullableIntegerProp != null) + writer.WriteNumber("required_nullable_integer_prop", requiredClass.RequiredNullableIntegerProp.Value); + else + writer.WriteNull("required_nullable_integer_prop"); + + if (requiredClass.RequiredNullableOuterEnumDefaultValue == null) + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + else + { + var requiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNullableOuterEnumDefaultValue.Value); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + writer.WriteString("required_nullable_outerEnumDefaultValue", requiredNullableOuterEnumDefaultValueRawValue); + else + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + } + + if (requiredClass.RequiredNullableStringProp != null) + writer.WriteString("required_nullable_string_prop", requiredClass.RequiredNullableStringProp); + else + writer.WriteNull("required_nullable_string_prop"); + + if (requiredClass.RequiredNullableUuid != null) + writer.WriteString("required_nullable_uuid", requiredClass.RequiredNullableUuid.Value); + else + writer.WriteNull("required_nullable_uuid"); + + if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet) + writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value.Value.ToString(NotRequiredNotnullableDatePropFormat)); + + if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet) + writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value.Value); + + if (requiredClass.NotRequiredNullableDatePropOption.IsSet) + if (requiredClass.NotRequiredNullableDatePropOption.Value != null) + writer.WriteString("not_required_nullable_date_prop", requiredClass.NotRequiredNullableDatePropOption.Value.Value.ToString(NotRequiredNullableDatePropFormat)); + else + writer.WriteNull("not_required_nullable_date_prop"); + + if (requiredClass.NotRequiredNullableIntegerPropOption.IsSet) + if (requiredClass.NotRequiredNullableIntegerPropOption.Value != null) + writer.WriteNumber("not_required_nullable_integer_prop", requiredClass.NotRequiredNullableIntegerPropOption.Value.Value); + else + writer.WriteNull("not_required_nullable_integer_prop"); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet) + { + writer.WritePropertyName("notrequired_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions); + } + if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet) + writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value.Value); + + if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet) + writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value.Value.ToString(NotrequiredNotnullableDatetimePropFormat)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value.Value)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value.Value)); + + var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value.Value); + if (notrequiredNotnullableEnumStringRawValue != null) + writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue); + else + writer.WriteNull("notrequired_notnullable_enum_string"); + + if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet) + { + var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue.Value); + writer.WriteString("notrequired_notnullable_outerEnumDefaultValue", notrequiredNotnullableOuterEnumDefaultValueRawValue); + } + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet) + writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp); + + if (requiredClass.NotrequiredNotnullableUuidOption.IsSet) + writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value.Value); + + if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet) + if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null) + { + writer.WritePropertyName("notrequired_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("notrequired_nullable_array_of_string"); + if (requiredClass.NotrequiredNullableBooleanPropOption.IsSet) + if (requiredClass.NotrequiredNullableBooleanPropOption.Value != null) + writer.WriteBoolean("notrequired_nullable_boolean_prop", requiredClass.NotrequiredNullableBooleanPropOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_boolean_prop"); + + if (requiredClass.NotrequiredNullableDatetimePropOption.IsSet) + if (requiredClass.NotrequiredNullableDatetimePropOption.Value != null) + writer.WriteString("notrequired_nullable_datetime_prop", requiredClass.NotrequiredNullableDatetimePropOption.Value.Value.ToString(NotrequiredNullableDatetimePropFormat)); + else + writer.WriteNull("notrequired_nullable_datetime_prop"); + + if (requiredClass.NotrequiredNullableEnumIntegerOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer", RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOption.Value.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer"); + + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer_only", RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer_only"); + + var notrequiredNullableEnumStringRawValue = RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNullableEnumStringOption.Value.Value); + if (notrequiredNullableEnumStringRawValue != null) + writer.WriteString("notrequired_nullable_enum_string", notrequiredNullableEnumStringRawValue); + else + writer.WriteNull("notrequired_nullable_enum_string"); + + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.IsSet) + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value != null) + { + var notrequiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value.Value); + writer.WriteString("notrequired_nullable_outerEnumDefaultValue", notrequiredNullableOuterEnumDefaultValueRawValue); + } + else + writer.WriteNull("notrequired_nullable_outerEnumDefaultValue"); + if (requiredClass.NotrequiredNullableStringPropOption.IsSet) + if (requiredClass.NotrequiredNullableStringPropOption.Value != null) + writer.WriteString("notrequired_nullable_string_prop", requiredClass.NotrequiredNullableStringProp); + else + writer.WriteNull("notrequired_nullable_string_prop"); + + if (requiredClass.NotrequiredNullableUuidOption.IsSet) + if (requiredClass.NotrequiredNullableUuidOption.Value != null) + writer.WriteString("notrequired_nullable_uuid", requiredClass.NotrequiredNullableUuidOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs index 86e7223ee95..7ef17db222f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// varReturn [JsonConstructor] - public Return(int varReturn) + public Return(Option varReturn = default) { - VarReturn = varReturn; + VarReturnOption = varReturn; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarReturn + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarReturnOption { get; private set; } + /// /// Gets or Sets VarReturn /// [JsonPropertyName("return")] - public int VarReturn { get; set; } + public int? VarReturn { get { return this. VarReturnOption; } set { this.VarReturnOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - int? varReturn = default; + Option varReturn = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "return": if (utf8JsonReader.TokenType != JsonTokenType.Null) - varReturn = utf8JsonReader.GetInt32(); + varReturn = new Option(utf8JsonReader.GetInt32()); break; default: break; @@ -127,10 +135,10 @@ namespace Org.OpenAPITools.Model } } - if (varReturn == null) - throw new ArgumentNullException(nameof(varReturn), "Property is required for class Return."); + if (varReturn.IsSet && varReturn.Value == null) + throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return."); - return new Return(varReturn.Value); + return new Return(varReturn); } /// @@ -157,7 +165,8 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("return", varReturn.VarReturn); + if (varReturn.VarReturnOption.IsSet) + writer.WriteNumber("return", varReturn.VarReturnOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 86effcebe7a..f7435144367 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// role /// roleUuid [JsonConstructor] - public RolesReportsHash(RolesReportsHashRole role, Guid roleUuid) + public RolesReportsHash(Option role = default, Option roleUuid = default) { - Role = role; - RoleUuid = roleUuid; + RoleOption = role; + RoleUuidOption = roleUuid; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Role + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleOption { get; private set; } + /// /// Gets or Sets Role /// [JsonPropertyName("role")] - public RolesReportsHashRole Role { get; set; } + public RolesReportsHashRole Role { get { return this. RoleOption; } set { this.RoleOption = new Option(value); } } + + /// + /// Used to track the state of RoleUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleUuidOption { get; private set; } /// /// Gets or Sets RoleUuid /// [JsonPropertyName("role_uuid")] - public Guid RoleUuid { get; set; } + public Guid? RoleUuid { get { return this. RoleUuidOption; } set { this.RoleUuidOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - RolesReportsHashRole role = default; - Guid? roleUuid = default; + Option role = default; + Option roleUuid = default; while (utf8JsonReader.Read()) { @@ -129,11 +144,11 @@ namespace Org.OpenAPITools.Model { case "role": if (utf8JsonReader.TokenType != JsonTokenType.Null) - role = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + role = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "role_uuid": if (utf8JsonReader.TokenType != JsonTokenType.Null) - roleUuid = utf8JsonReader.GetGuid(); + roleUuid = new Option(utf8JsonReader.GetGuid()); break; default: break; @@ -141,13 +156,13 @@ namespace Org.OpenAPITools.Model } } - if (role == null) - throw new ArgumentNullException(nameof(role), "Property is required for class RolesReportsHash."); + if (role.IsSet && role.Value == null) + throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash."); - if (roleUuid == null) - throw new ArgumentNullException(nameof(roleUuid), "Property is required for class RolesReportsHash."); + if (roleUuid.IsSet && roleUuid.Value == null) + throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash."); - return new RolesReportsHash(role, roleUuid.Value); + return new RolesReportsHash(role, roleUuid); } /// @@ -174,9 +189,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("role"); - JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); - writer.WriteString("role_uuid", rolesReportsHash.RoleUuid); + if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null) + throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash."); + + if (rolesReportsHash.RoleOption.IsSet) + { + writer.WritePropertyName("role"); + JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); + } + if (rolesReportsHash.RoleUuidOption.IsSet) + writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index c7002b77b2e..4a29f6ec7b1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// name [JsonConstructor] - public RolesReportsHashRole(string name) + public RolesReportsHashRole(Option name = default) { - Name = name; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string name = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class RolesReportsHashRole."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole."); return new RolesReportsHashRole(name); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("name", rolesReportsHashRole.Name); + if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null) + throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole."); + + if (rolesReportsHashRole.NameOption.IsSet) + writer.WriteString("name", rolesReportsHashRole.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 4151ead57df..52a8e0d69c6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; - string triangleType = default; + Option shapeType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ScaleneTriangle."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(shapeType)); - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class ScaleneTriangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(triangleType)); - return new ScaleneTriangle(shapeType, triangleType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ScaleneTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class ScaleneTriangle."); + + return new ScaleneTriangle(shapeType.Value, triangleType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) { + if (scaleneTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle."); + + if (scaleneTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle."); + writer.WriteString("shapeType", scaleneTriangle.ShapeType); + writer.WriteString("triangleType", scaleneTriangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs index dae0ef02f96..575069f242e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; Quadrilateral quadrilateral = null; Triangle triangle = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class Shape."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class Shape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType); + return new Shape(quadrilateral, shapeType.Value); if (triangle != null) - return new Shape(triangle, shapeType); + return new Shape(triangle, shapeType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { + if (shape.ShapeType == null) + throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); + writer.WriteString("shapeType", shape.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs index de32fa535ae..5bd364cc6a4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeInterface."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeInterface.", nameof(shapeType)); - return new ShapeInterface(shapeType); + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeInterface."); + + return new ShapeInterface(shapeType.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) { + if (shapeInterface.ShapeType == null) + throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface."); + writer.WriteString("shapeType", shapeInterface.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 955461e1202..a26dab03423 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -133,7 +134,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string shapeType = default; + Option shapeType = default; Quadrilateral quadrilateral = null; Triangle triangle = null; @@ -184,7 +185,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -192,14 +193,17 @@ namespace Org.OpenAPITools.Model } } - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeOrNull."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType); + return new ShapeOrNull(quadrilateral, shapeType.Value); if (triangle != null) - return new ShapeOrNull(triangle, shapeType); + return new ShapeOrNull(triangle, shapeType.Value); throw new JsonException(); } @@ -238,6 +242,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { + if (shapeOrNull.ShapeType == null) + throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); + writer.WriteString("shapeType", shapeOrNull.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 7f0b8a306f8..a00a87e2efa 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -109,8 +110,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string quadrilateralType = default; - string shapeType = default; + Option quadrilateralType = default; + Option shapeType = default; while (utf8JsonReader.Read()) { @@ -128,10 +129,10 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "quadrilateralType": - quadrilateralType = utf8JsonReader.GetString(); + quadrilateralType = new Option(utf8JsonReader.GetString()); break; case "shapeType": - shapeType = utf8JsonReader.GetString(); + shapeType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -139,13 +140,19 @@ namespace Org.OpenAPITools.Model } } - if (quadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class SimpleQuadrilateral."); + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(quadrilateralType)); - if (shapeType == null) - throw new ArgumentNullException(nameof(shapeType), "Property is required for class SimpleQuadrilateral."); + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(shapeType)); - return new SimpleQuadrilateral(quadrilateralType, shapeType); + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class SimpleQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class SimpleQuadrilateral."); + + return new SimpleQuadrilateral(quadrilateralType.Value, shapeType.Value); } /// @@ -172,7 +179,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) { + if (simpleQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral."); + + if (simpleQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral."); + writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType); + writer.WriteString("shapeType", simpleQuadrilateral.ShapeType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs index 8328ad3ee12..81bfc146662 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// varSpecialModelName /// specialPropertyName [JsonConstructor] - public SpecialModelName(string varSpecialModelName, long specialPropertyName) + public SpecialModelName(Option varSpecialModelName = default, Option specialPropertyName = default) { - VarSpecialModelName = varSpecialModelName; - SpecialPropertyName = specialPropertyName; + VarSpecialModelNameOption = varSpecialModelName; + SpecialPropertyNameOption = specialPropertyName; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of VarSpecialModelName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarSpecialModelNameOption { get; private set; } + /// /// Gets or Sets VarSpecialModelName /// [JsonPropertyName("_special_model.name_")] - public string VarSpecialModelName { get; set; } + public string VarSpecialModelName { get { return this. VarSpecialModelNameOption; } set { this.VarSpecialModelNameOption = new Option(value); } } + + /// + /// Used to track the state of SpecialPropertyName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SpecialPropertyNameOption { get; private set; } /// /// Gets or Sets SpecialPropertyName /// [JsonPropertyName("$special[property.name]")] - public long SpecialPropertyName { get; set; } + public long? SpecialPropertyName { get { return this. SpecialPropertyNameOption; } set { this.SpecialPropertyNameOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string varSpecialModelName = default; - long? specialPropertyName = default; + Option varSpecialModelName = default; + Option specialPropertyName = default; while (utf8JsonReader.Read()) { @@ -128,11 +143,11 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "_special_model.name_": - varSpecialModelName = utf8JsonReader.GetString(); + varSpecialModelName = new Option(utf8JsonReader.GetString()); break; case "$special[property.name]": if (utf8JsonReader.TokenType != JsonTokenType.Null) - specialPropertyName = utf8JsonReader.GetInt64(); + specialPropertyName = new Option(utf8JsonReader.GetInt64()); break; default: break; @@ -140,13 +155,13 @@ namespace Org.OpenAPITools.Model } } - if (varSpecialModelName == null) - throw new ArgumentNullException(nameof(varSpecialModelName), "Property is required for class SpecialModelName."); + if (varSpecialModelName.IsSet && varSpecialModelName.Value == null) + throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName."); - if (specialPropertyName == null) - throw new ArgumentNullException(nameof(specialPropertyName), "Property is required for class SpecialModelName."); + if (specialPropertyName.IsSet && specialPropertyName.Value == null) + throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName."); - return new SpecialModelName(varSpecialModelName, specialPropertyName.Value); + return new SpecialModelName(varSpecialModelName, specialPropertyName); } /// @@ -173,8 +188,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); - writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyName); + if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null) + throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName."); + + if (specialModelName.VarSpecialModelNameOption.IsSet) + writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); + + if (specialModelName.SpecialPropertyNameOption.IsSet) + writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs index 6524d75edcf..4f4891d049f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,26 +35,40 @@ namespace Org.OpenAPITools.Model /// id /// name [JsonConstructor] - public Tag(long id, string name) + public Tag(Option id = default, Option name = default) { - Id = id; - Name = name; + IdOption = id; + NameOption = name; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + /// /// Gets or Sets Id /// [JsonPropertyName("id")] - public long Id { get; set; } + public long? Id { get { return this. IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } /// /// Gets or Sets Name /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get { return this. NameOption; } set { this.NameOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -109,8 +124,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - long? id = default; - string name = default; + Option id = default; + Option name = default; while (utf8JsonReader.Read()) { @@ -129,10 +144,10 @@ namespace Org.OpenAPITools.Model { case "id": if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); + id = new Option(utf8JsonReader.GetInt64()); break; case "name": - name = utf8JsonReader.GetString(); + name = new Option(utf8JsonReader.GetString()); break; default: break; @@ -140,13 +155,13 @@ namespace Org.OpenAPITools.Model } } - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class Tag."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag."); - if (name == null) - throw new ArgumentNullException(nameof(name), "Property is required for class Tag."); + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag."); - return new Tag(id.Value, name); + return new Tag(id, name); } /// @@ -173,8 +188,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteNumber("id", tag.Id); - writer.WriteString("name", tag.Name); + if (tag.NameOption.IsSet && tag.Name == null) + throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag."); + + if (tag.IdOption.IsSet) + writer.WriteNumber("id", tag.IdOption.Value.Value); + + if (tag.NameOption.IsSet) + writer.WriteString("name", tag.Name); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index b2e110e79f6..47a94630b7d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// value [JsonConstructor] - public TestCollectionEndingWithWordList(string value) + public TestCollectionEndingWithWordList(Option value = default) { - Value = value; + ValueOption = value; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of Value + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ValueOption { get; private set; } + /// /// Gets or Sets Value /// [JsonPropertyName("value")] - public string Value { get; set; } + public string Value { get { return this. ValueOption; } set { this.ValueOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string value = default; + Option value = default; while (utf8JsonReader.Read()) { @@ -118,7 +126,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "value": - value = utf8JsonReader.GetString(); + value = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,8 +134,8 @@ namespace Org.OpenAPITools.Model } } - if (value == null) - throw new ArgumentNullException(nameof(value), "Property is required for class TestCollectionEndingWithWordList."); + if (value.IsSet && value.Value == null) + throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList."); return new TestCollectionEndingWithWordList(value); } @@ -156,7 +164,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("value", testCollectionEndingWithWordList.Value); + if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList."); + + if (testCollectionEndingWithWordList.ValueOption.IsSet) + writer.WriteString("value", testCollectionEndingWithWordList.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 8753edfd9f3..d1b0714cb3c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// testCollectionEndingWithWordList [JsonConstructor] - public TestCollectionEndingWithWordListObject(List testCollectionEndingWithWordList) + public TestCollectionEndingWithWordListObject(Option> testCollectionEndingWithWordList = default) { - TestCollectionEndingWithWordList = testCollectionEndingWithWordList; + TestCollectionEndingWithWordListOption = testCollectionEndingWithWordList; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of TestCollectionEndingWithWordList + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TestCollectionEndingWithWordListOption { get; private set; } + /// /// Gets or Sets TestCollectionEndingWithWordList /// [JsonPropertyName("TestCollectionEndingWithWordList")] - public List TestCollectionEndingWithWordList { get; set; } + public List TestCollectionEndingWithWordList { get { return this. TestCollectionEndingWithWordListOption; } set { this.TestCollectionEndingWithWordListOption = new Option>(value); } } /// /// Gets or Sets additional properties @@ -100,7 +108,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - List testCollectionEndingWithWordList = default; + Option> testCollectionEndingWithWordList = default; while (utf8JsonReader.Read()) { @@ -119,7 +127,7 @@ namespace Org.OpenAPITools.Model { case "TestCollectionEndingWithWordList": if (utf8JsonReader.TokenType != JsonTokenType.Null) - testCollectionEndingWithWordList = JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions); + testCollectionEndingWithWordList = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); break; default: break; @@ -127,8 +135,8 @@ namespace Org.OpenAPITools.Model } } - if (testCollectionEndingWithWordList == null) - throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject."); return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList); } @@ -157,8 +165,14 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) { - writer.WritePropertyName("TestCollectionEndingWithWordList"); - JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet) + { + writer.WritePropertyName("TestCollectionEndingWithWordList"); + JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + } } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index 139e92b4c6a..cac22db5606 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,19 +34,26 @@ namespace Org.OpenAPITools.Model /// /// someProperty [JsonConstructor] - public TestInlineFreeformAdditionalPropertiesRequest(string someProperty) : base() + public TestInlineFreeformAdditionalPropertiesRequest(Option someProperty = default) : base() { - SomeProperty = someProperty; + SomePropertyOption = someProperty; OnCreated(); } partial void OnCreated(); + /// + /// Used to track the state of SomeProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomePropertyOption { get; private set; } + /// /// Gets or Sets SomeProperty /// [JsonPropertyName("someProperty")] - public string SomeProperty { get; set; } + public string SomeProperty { get { return this. SomePropertyOption; } set { this.SomePropertyOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -111,7 +119,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string someProperty = default; + Option someProperty = default; while (utf8JsonReader.Read()) { @@ -129,7 +137,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "someProperty": - someProperty = utf8JsonReader.GetString(); + someProperty = new Option(utf8JsonReader.GetString()); break; default: break; @@ -137,8 +145,8 @@ namespace Org.OpenAPITools.Model } } - if (someProperty == null) - throw new ArgumentNullException(nameof(someProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + if (someProperty.IsSet && someProperty.Value == null) + throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest."); return new TestInlineFreeformAdditionalPropertiesRequest(someProperty); } @@ -167,7 +175,11 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet) + writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs index 814316961f9..737124e080b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -150,7 +151,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string triangleType = default; + Option triangleType = default; EquilateralTriangle equilateralTriangle = null; IsoscelesTriangle isoscelesTriangle = null; @@ -207,7 +208,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -215,17 +216,20 @@ namespace Org.OpenAPITools.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class Triangle."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class Triangle.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType); + return new Triangle(equilateralTriangle, triangleType.Value); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType); + return new Triangle(isoscelesTriangle, triangleType.Value); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType); + return new Triangle(scaleneTriangle, triangleType.Value); throw new JsonException(); } @@ -269,6 +273,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { + if (triangle.TriangleType == null) + throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); + writer.WriteString("triangleType", triangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs index 6bd1e4303a7..270c598de61 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -100,7 +101,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string triangleType = default; + Option triangleType = default; while (utf8JsonReader.Read()) { @@ -118,7 +119,7 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "triangleType": - triangleType = utf8JsonReader.GetString(); + triangleType = new Option(utf8JsonReader.GetString()); break; default: break; @@ -126,10 +127,13 @@ namespace Org.OpenAPITools.Model } } - if (triangleType == null) - throw new ArgumentNullException(nameof(triangleType), "Property is required for class TriangleInterface."); + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class TriangleInterface.", nameof(triangleType)); - return new TriangleInterface(triangleType); + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class TriangleInterface."); + + return new TriangleInterface(triangleType.Value); } /// @@ -156,6 +160,9 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) { + if (triangleInterface.TriangleType == null) + throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface."); + writer.WriteString("triangleType", triangleInterface.TriangleType); } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs index ea527b94ec0..8c8eb5c8434 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -31,114 +32,198 @@ namespace Org.OpenAPITools.Model /// /// Initializes a new instance of the class. /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// email /// firstName /// id /// lastName /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// password /// phone /// User Status /// username - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonConstructor] - public User(string email, string firstName, long id, string lastName, Object objectWithNoDeclaredProps, string password, string phone, int userStatus, string username, Object anyTypeProp = default, Object anyTypePropNullable = default, Object objectWithNoDeclaredPropsNullable = default) + public User(Option anyTypeProp = default, Option anyTypePropNullable = default, Option email = default, Option firstName = default, Option id = default, Option lastName = default, Option objectWithNoDeclaredProps = default, Option objectWithNoDeclaredPropsNullable = default, Option password = default, Option phone = default, Option userStatus = default, Option username = default) { - Email = email; - FirstName = firstName; - Id = id; - LastName = lastName; - ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - Password = password; - Phone = phone; - UserStatus = userStatus; - Username = username; - AnyTypeProp = anyTypeProp; - AnyTypePropNullable = anyTypePropNullable; - ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypePropOption = anyTypeProp; + AnyTypePropNullableOption = anyTypePropNullable; + EmailOption = email; + FirstNameOption = firstName; + IdOption = id; + LastNameOption = lastName; + ObjectWithNoDeclaredPropsOption = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullableOption = objectWithNoDeclaredPropsNullable; + PasswordOption = password; + PhoneOption = phone; + UserStatusOption = userStatus; + UsernameOption = username; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets Email + /// Used to track the state of AnyTypeProp /// - [JsonPropertyName("email")] - public string Email { get; set; } - - /// - /// Gets or Sets FirstName - /// - [JsonPropertyName("firstName")] - public string FirstName { get; set; } - - /// - /// Gets or Sets Id - /// - [JsonPropertyName("id")] - public long Id { get; set; } - - /// - /// Gets or Sets LastName - /// - [JsonPropertyName("lastName")] - public string LastName { get; set; } - - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - /// - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [JsonPropertyName("objectWithNoDeclaredProps")] - public Object ObjectWithNoDeclaredProps { get; set; } - - /// - /// Gets or Sets Password - /// - [JsonPropertyName("password")] - public string Password { get; set; } - - /// - /// Gets or Sets Phone - /// - [JsonPropertyName("phone")] - public string Phone { get; set; } - - /// - /// User Status - /// - /// User Status - [JsonPropertyName("userStatus")] - public int UserStatus { get; set; } - - /// - /// Gets or Sets Username - /// - [JsonPropertyName("username")] - public string Username { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 [JsonPropertyName("anyTypeProp")] - public Object AnyTypeProp { get; set; } + public Object AnyTypeProp { get { return this. AnyTypePropOption; } set { this.AnyTypePropOption = new Option(value); } } + + /// + /// Used to track the state of AnyTypePropNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropNullableOption { get; private set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. [JsonPropertyName("anyTypePropNullable")] - public Object AnyTypePropNullable { get; set; } + public Object AnyTypePropNullable { get { return this. AnyTypePropNullableOption; } set { this.AnyTypePropNullableOption = new Option(value); } } + + /// + /// Used to track the state of Email + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmailOption { get; private set; } + + /// + /// Gets or Sets Email + /// + [JsonPropertyName("email")] + public string Email { get { return this. EmailOption; } set { this.EmailOption = new Option(value); } } + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string FirstName { get { return this. FirstNameOption; } set { this.FirstNameOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this. IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string LastName { get { return this. LastNameOption; } set { this.LastNameOption = new Option(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredProps + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsOption { get; private set; } + + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + [JsonPropertyName("objectWithNoDeclaredProps")] + public Object ObjectWithNoDeclaredProps { get { return this. ObjectWithNoDeclaredPropsOption; } set { this.ObjectWithNoDeclaredPropsOption = new Option(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredPropsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsNullableOption { get; private set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. [JsonPropertyName("objectWithNoDeclaredPropsNullable")] - public Object ObjectWithNoDeclaredPropsNullable { get; set; } + public Object ObjectWithNoDeclaredPropsNullable { get { return this. ObjectWithNoDeclaredPropsNullableOption; } set { this.ObjectWithNoDeclaredPropsNullableOption = new Option(value); } } + + /// + /// Used to track the state of Password + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PasswordOption { get; private set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string Password { get { return this. PasswordOption; } set { this.PasswordOption = new Option(value); } } + + /// + /// Used to track the state of Phone + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PhoneOption { get; private set; } + + /// + /// Gets or Sets Phone + /// + [JsonPropertyName("phone")] + public string Phone { get { return this. PhoneOption; } set { this.PhoneOption = new Option(value); } } + + /// + /// Used to track the state of UserStatus + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UserStatusOption { get; private set; } + + /// + /// User Status + /// + /// User Status + [JsonPropertyName("userStatus")] + public int? UserStatus { get { return this. UserStatusOption; } set { this.UserStatusOption = new Option(value); } } + + /// + /// Used to track the state of Username + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UsernameOption { get; private set; } + + /// + /// Gets or Sets Username + /// + [JsonPropertyName("username")] + public string Username { get { return this. UsernameOption; } set { this.UsernameOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -154,18 +239,18 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class User {\n"); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); sb.Append(" Email: ").Append(Email).Append("\n"); sb.Append(" FirstName: ").Append(FirstName).Append("\n"); sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" LastName: ").Append(LastName).Append("\n"); sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append(" Phone: ").Append(Phone).Append("\n"); sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); sb.Append(" Username: ").Append(Username).Append("\n"); - sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); - sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); - sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -204,18 +289,18 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string email = default; - string firstName = default; - long? id = default; - string lastName = default; - Object objectWithNoDeclaredProps = default; - string password = default; - string phone = default; - int? userStatus = default; - string username = default; - Object anyTypeProp = default; - Object anyTypePropNullable = default; - Object objectWithNoDeclaredPropsNullable = default; + Option anyTypeProp = default; + Option anyTypePropNullable = default; + Option email = default; + Option firstName = default; + Option id = default; + Option lastName = default; + Option objectWithNoDeclaredProps = default; + Option objectWithNoDeclaredPropsNullable = default; + Option password = default; + Option phone = default; + Option userStatus = default; + Option username = default; while (utf8JsonReader.Read()) { @@ -232,47 +317,47 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { - case "email": - email = utf8JsonReader.GetString(); - break; - case "firstName": - firstName = utf8JsonReader.GetString(); - break; - case "id": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - id = utf8JsonReader.GetInt64(); - break; - case "lastName": - lastName = utf8JsonReader.GetString(); - break; - case "objectWithNoDeclaredProps": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredProps = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); - break; - case "password": - password = utf8JsonReader.GetString(); - break; - case "phone": - phone = utf8JsonReader.GetString(); - break; - case "userStatus": - if (utf8JsonReader.TokenType != JsonTokenType.Null) - userStatus = utf8JsonReader.GetInt32(); - break; - case "username": - username = utf8JsonReader.GetString(); - break; case "anyTypeProp": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypeProp = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "anyTypePropNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - anyTypePropNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + anyTypePropNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "email": + email = new Option(utf8JsonReader.GetString()); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "objectWithNoDeclaredProps": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredProps = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "objectWithNoDeclaredPropsNullable": if (utf8JsonReader.TokenType != JsonTokenType.Null) - objectWithNoDeclaredPropsNullable = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + objectWithNoDeclaredPropsNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "password": + password = new Option(utf8JsonReader.GetString()); + break; + case "phone": + phone = new Option(utf8JsonReader.GetString()); + break; + case "userStatus": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + userStatus = new Option(utf8JsonReader.GetInt32()); + break; + case "username": + username = new Option(utf8JsonReader.GetString()); break; default: break; @@ -280,34 +365,34 @@ namespace Org.OpenAPITools.Model } } - if (email == null) - throw new ArgumentNullException(nameof(email), "Property is required for class User."); + if (email.IsSet && email.Value == null) + throw new ArgumentNullException(nameof(email), "Property is not nullable for class User."); - if (firstName == null) - throw new ArgumentNullException(nameof(firstName), "Property is required for class User."); + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User."); - if (id == null) - throw new ArgumentNullException(nameof(id), "Property is required for class User."); + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class User."); - if (lastName == null) - throw new ArgumentNullException(nameof(lastName), "Property is required for class User."); + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User."); - if (objectWithNoDeclaredProps == null) - throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is required for class User."); + if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null) + throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User."); - if (password == null) - throw new ArgumentNullException(nameof(password), "Property is required for class User."); + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class User."); - if (phone == null) - throw new ArgumentNullException(nameof(phone), "Property is required for class User."); + if (phone.IsSet && phone.Value == null) + throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User."); - if (userStatus == null) - throw new ArgumentNullException(nameof(userStatus), "Property is required for class User."); + if (userStatus.IsSet && userStatus.Value == null) + throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User."); - if (username == null) - throw new ArgumentNullException(nameof(username), "Property is required for class User."); + if (username.IsSet && username.Value == null) + throw new ArgumentNullException(nameof(username), "Property is not nullable for class User."); - return new User(email, firstName, id.Value, lastName, objectWithNoDeclaredProps, password, phone, userStatus.Value, username, anyTypeProp, anyTypePropNullable, objectWithNoDeclaredPropsNullable); + return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username); } /// @@ -334,22 +419,79 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) { - writer.WriteString("email", user.Email); - writer.WriteString("firstName", user.FirstName); - writer.WriteNumber("id", user.Id); - writer.WriteString("lastName", user.LastName); - writer.WritePropertyName("objectWithNoDeclaredProps"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); - writer.WriteString("password", user.Password); - writer.WriteString("phone", user.Phone); - writer.WriteNumber("userStatus", user.UserStatus); - writer.WriteString("username", user.Username); - writer.WritePropertyName("anyTypeProp"); - JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); - writer.WritePropertyName("anyTypePropNullable"); - JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); - writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); - JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + if (user.EmailOption.IsSet && user.Email == null) + throw new ArgumentNullException(nameof(user.Email), "Property is required for class User."); + + if (user.FirstNameOption.IsSet && user.FirstName == null) + throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User."); + + if (user.LastNameOption.IsSet && user.LastName == null) + throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User."); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null) + throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User."); + + if (user.PasswordOption.IsSet && user.Password == null) + throw new ArgumentNullException(nameof(user.Password), "Property is required for class User."); + + if (user.PhoneOption.IsSet && user.Phone == null) + throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User."); + + if (user.UsernameOption.IsSet && user.Username == null) + throw new ArgumentNullException(nameof(user.Username), "Property is required for class User."); + + if (user.AnyTypePropOption.IsSet) + if (user.AnyTypePropOption.Value != null) + { + writer.WritePropertyName("anyTypeProp"); + JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypeProp"); + if (user.AnyTypePropNullableOption.IsSet) + if (user.AnyTypePropNullableOption.Value != null) + { + writer.WritePropertyName("anyTypePropNullable"); + JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypePropNullable"); + if (user.EmailOption.IsSet) + writer.WriteString("email", user.Email); + + if (user.FirstNameOption.IsSet) + writer.WriteString("firstName", user.FirstName); + + if (user.IdOption.IsSet) + writer.WriteNumber("id", user.IdOption.Value.Value); + + if (user.LastNameOption.IsSet) + writer.WriteString("lastName", user.LastName); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet) + { + writer.WritePropertyName("objectWithNoDeclaredProps"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); + } + if (user.ObjectWithNoDeclaredPropsNullableOption.IsSet) + if (user.ObjectWithNoDeclaredPropsNullableOption.Value != null) + { + writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + } + else + writer.WriteNull("objectWithNoDeclaredPropsNullable"); + if (user.PasswordOption.IsSet) + writer.WriteString("password", user.Password); + + if (user.PhoneOption.IsSet) + writer.WriteString("phone", user.Phone); + + if (user.UserStatusOption.IsSet) + writer.WriteNumber("userStatus", user.UserStatusOption.Value.Value); + + if (user.UsernameOption.IsSet) + writer.WriteString("username", user.Username); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs index e633a5c92cf..de887038530 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -35,11 +36,11 @@ namespace Org.OpenAPITools.Model /// hasBaleen /// hasTeeth [JsonConstructor] - public Whale(string className, bool hasBaleen, bool hasTeeth) + public Whale(string className, Option hasBaleen = default, Option hasTeeth = default) { ClassName = className; - HasBaleen = hasBaleen; - HasTeeth = hasTeeth; + HasBaleenOption = hasBaleen; + HasTeethOption = hasTeeth; OnCreated(); } @@ -51,17 +52,31 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("className")] public string ClassName { get; set; } + /// + /// Used to track the state of HasBaleen + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasBaleenOption { get; private set; } + /// /// Gets or Sets HasBaleen /// [JsonPropertyName("hasBaleen")] - public bool HasBaleen { get; set; } + public bool? HasBaleen { get { return this. HasBaleenOption; } set { this.HasBaleenOption = new Option(value); } } + + /// + /// Used to track the state of HasTeeth + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasTeethOption { get; private set; } /// /// Gets or Sets HasTeeth /// [JsonPropertyName("hasTeeth")] - public bool HasTeeth { get; set; } + public bool? HasTeeth { get { return this. HasTeethOption; } set { this.HasTeethOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -118,9 +133,9 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - bool? hasBaleen = default; - bool? hasTeeth = default; + Option className = default; + Option hasBaleen = default; + Option hasTeeth = default; while (utf8JsonReader.Read()) { @@ -138,15 +153,15 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; case "hasBaleen": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasBaleen = utf8JsonReader.GetBoolean(); + hasBaleen = new Option(utf8JsonReader.GetBoolean()); break; case "hasTeeth": if (utf8JsonReader.TokenType != JsonTokenType.Null) - hasTeeth = utf8JsonReader.GetBoolean(); + hasTeeth = new Option(utf8JsonReader.GetBoolean()); break; default: break; @@ -154,16 +169,19 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Whale."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Whale.", nameof(className)); - if (hasBaleen == null) - throw new ArgumentNullException(nameof(hasBaleen), "Property is required for class Whale."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale."); - if (hasTeeth == null) - throw new ArgumentNullException(nameof(hasTeeth), "Property is required for class Whale."); + if (hasBaleen.IsSet && hasBaleen.Value == null) + throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale."); - return new Whale(className, hasBaleen.Value, hasTeeth.Value); + if (hasTeeth.IsSet && hasTeeth.Value == null) + throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale."); + + return new Whale(className.Value, hasBaleen, hasTeeth); } /// @@ -190,9 +208,16 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) { + if (whale.ClassName == null) + throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale."); + writer.WriteString("className", whale.ClassName); - writer.WriteBoolean("hasBaleen", whale.HasBaleen); - writer.WriteBoolean("hasTeeth", whale.HasTeeth); + + if (whale.HasBaleenOption.IsSet) + writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value.Value); + + if (whale.HasTeethOption.IsSet) + writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value.Value); } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs index 52135d8a3c5..895e2f5553e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -34,10 +35,10 @@ namespace Org.OpenAPITools.Model /// className /// type [JsonConstructor] - public Zebra(string className, TypeEnum type) : base() + public Zebra(string className, Option type = default) : base() { ClassName = className; - Type = type; + TypeOption = type; OnCreated(); } @@ -109,9 +110,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string TypeEnumToJsonValue(TypeEnum value) + public static string TypeEnumToJsonValue(TypeEnum? value) { - if (value == TypeEnum.Plains) return "plains"; @@ -124,11 +124,18 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + /// /// Gets or Sets Type /// [JsonPropertyName("type")] - public TypeEnum Type { get; set; } + public TypeEnum? Type { get { return this.TypeOption; } set { this.TypeOption = new Option(value); } } /// /// Gets or Sets ClassName @@ -201,8 +208,8 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - string className = default; - Zebra.TypeEnum? type = default; + Option className = default; + Option type = default; while (utf8JsonReader.Read()) { @@ -220,13 +227,12 @@ namespace Org.OpenAPITools.Model switch (localVarJsonPropertyName) { case "className": - className = utf8JsonReader.GetString(); + className = new Option(utf8JsonReader.GetString()); break; case "type": string typeRawValue = utf8JsonReader.GetString(); - type = typeRawValue == null - ? null - : Zebra.TypeEnumFromStringOrDefault(typeRawValue); + if (typeRawValue != null) + type = new Option(Zebra.TypeEnumFromStringOrDefault(typeRawValue)); break; default: break; @@ -234,13 +240,16 @@ namespace Org.OpenAPITools.Model } } - if (className == null) - throw new ArgumentNullException(nameof(className), "Property is required for class Zebra."); + if (!className.IsSet) + throw new ArgumentException("Property is required for class Zebra.", nameof(className)); - if (type == null) - throw new ArgumentNullException(nameof(type), "Property is required for class Zebra."); + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra."); - return new Zebra(className, type.Value); + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra."); + + return new Zebra(className.Value, type); } /// @@ -267,9 +276,12 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) { + if (zebra.ClassName == null) + throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra."); + writer.WriteString("className", zebra.ClassName); - var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.Type); + var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value.Value); if (typeRawValue != null) writer.WriteString("type", typeRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs index 20e184f02b2..34a044fb8b1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 7e5f3cdafcc..c052c649769 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -20,6 +20,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; namespace Org.OpenAPITools.Model { @@ -33,9 +34,9 @@ namespace Org.OpenAPITools.Model /// /// zeroBasedEnum [JsonConstructor] - public ZeroBasedEnumClass(ZeroBasedEnumEnum zeroBasedEnum) + public ZeroBasedEnumClass(Option zeroBasedEnum = default) { - ZeroBasedEnum = zeroBasedEnum; + ZeroBasedEnumOption = zeroBasedEnum; OnCreated(); } @@ -96,9 +97,8 @@ namespace Org.OpenAPITools.Model /// /// /// - public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum value) + public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum? value) { - if (value == ZeroBasedEnumEnum.Unknown) return "unknown"; @@ -108,11 +108,18 @@ namespace Org.OpenAPITools.Model throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Used to track the state of ZeroBasedEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ZeroBasedEnumOption { get; private set; } + /// /// Gets or Sets ZeroBasedEnum /// [JsonPropertyName("ZeroBasedEnum")] - public ZeroBasedEnumEnum ZeroBasedEnum { get; set; } + public ZeroBasedEnumEnum? ZeroBasedEnum { get { return this.ZeroBasedEnumOption; } set { this.ZeroBasedEnumOption = new Option(value); } } /// /// Gets or Sets additional properties @@ -167,7 +174,7 @@ namespace Org.OpenAPITools.Model JsonTokenType startingTokenType = utf8JsonReader.TokenType; - ZeroBasedEnumClass.ZeroBasedEnumEnum? zeroBasedEnum = default; + Option zeroBasedEnum = default; while (utf8JsonReader.Read()) { @@ -186,9 +193,8 @@ namespace Org.OpenAPITools.Model { case "ZeroBasedEnum": string zeroBasedEnumRawValue = utf8JsonReader.GetString(); - zeroBasedEnum = zeroBasedEnumRawValue == null - ? null - : ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue); + if (zeroBasedEnumRawValue != null) + zeroBasedEnum = new Option(ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue)); break; default: break; @@ -196,10 +202,10 @@ namespace Org.OpenAPITools.Model } } - if (zeroBasedEnum == null) - throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is required for class ZeroBasedEnumClass."); + if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null) + throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass."); - return new ZeroBasedEnumClass(zeroBasedEnum.Value); + return new ZeroBasedEnumClass(zeroBasedEnum); } /// @@ -226,8 +232,7 @@ namespace Org.OpenAPITools.Model /// public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) { - - var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnum); + var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value); if (zeroBasedEnumRawValue != null) writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue); else diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-httpclient/.openapi-generator/FILES index cfa6edb1db8..3079e1bed81 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -195,6 +196,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/README.md index 18aa6dd26bc..45508dddfc6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/README.md @@ -246,6 +246,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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-httpclient/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..919ae3fc0fe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1043 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES index ddeca89d213..1e54de3472d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -198,6 +199,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/README.md b/samples/client/petstore/csharp/OpenAPIClient-net47/README.md index 2a3e242fe88..b344c43c38b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/README.md @@ -233,6 +233,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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-net47/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..90e0c44b40b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1042 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES index ddeca89d213..1e54de3472d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -198,6 +199,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/README.md b/samples/client/petstore/csharp/OpenAPIClient-net48/README.md index 2a3e242fe88..b344c43c38b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/README.md @@ -233,6 +233,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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-net48/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..90e0c44b40b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1042 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES index ddeca89d213..1e54de3472d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -198,6 +199,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md index 2a3e242fe88..b344c43c38b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md @@ -233,6 +233,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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-net5.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..90e0c44b40b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1042 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/.openapi-generator/FILES index b6dffff4f19..b73f11d50f1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/.openapi-generator/FILES @@ -75,6 +75,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -194,6 +195,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/README.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/README.md index dcfb2967818..7397b3f9816 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/README.md @@ -207,6 +207,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](Quadrilateral.md) - [Model.QuadrilateralInterface](QuadrilateralInterface.md) - [Model.ReadOnlyFirst](ReadOnlyFirst.md) + - [Model.RequiredClass](RequiredClass.md) - [Model.Return](Return.md) - [Model.RolesReportsHash](RolesReportsHash.md) - [Model.RolesReportsHashRole](RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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-unityWebRequest/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..24f5e2325d2 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,410 @@ +/* + * 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.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Test] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Test] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Test] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Test] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Test] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Test] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Test] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Test] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Test] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Test] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Test] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Test] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Test] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Test] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Test] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Test] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Test] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Test] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Test] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Test] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Test] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Test] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Test] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Test] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Test] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Test] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Test] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Test] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Test] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Test] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Test] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Test] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Test] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Test] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Test] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Test] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Test] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + /// + /// Test the property 'RequiredNullableUuid' + /// + [Test] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Test] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Test] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Test] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Test] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Test] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Test] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Test] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..eb89d56999f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1224 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() { } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as RequiredClass); + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + if (input == null) + { + return false; + } + return + ( + this.RequiredNullableIntegerProp == input.RequiredNullableIntegerProp || + (this.RequiredNullableIntegerProp != null && + this.RequiredNullableIntegerProp.Equals(input.RequiredNullableIntegerProp)) + ) && + ( + this.RequiredNotnullableintegerProp == input.RequiredNotnullableintegerProp || + this.RequiredNotnullableintegerProp.Equals(input.RequiredNotnullableintegerProp) + ) && + ( + this.NotRequiredNullableIntegerProp == input.NotRequiredNullableIntegerProp || + (this.NotRequiredNullableIntegerProp != null && + this.NotRequiredNullableIntegerProp.Equals(input.NotRequiredNullableIntegerProp)) + ) && + ( + this.NotRequiredNotnullableintegerProp == input.NotRequiredNotnullableintegerProp || + this.NotRequiredNotnullableintegerProp.Equals(input.NotRequiredNotnullableintegerProp) + ) && + ( + this.RequiredNullableStringProp == input.RequiredNullableStringProp || + (this.RequiredNullableStringProp != null && + this.RequiredNullableStringProp.Equals(input.RequiredNullableStringProp)) + ) && + ( + this.RequiredNotnullableStringProp == input.RequiredNotnullableStringProp || + (this.RequiredNotnullableStringProp != null && + this.RequiredNotnullableStringProp.Equals(input.RequiredNotnullableStringProp)) + ) && + ( + this.NotrequiredNullableStringProp == input.NotrequiredNullableStringProp || + (this.NotrequiredNullableStringProp != null && + this.NotrequiredNullableStringProp.Equals(input.NotrequiredNullableStringProp)) + ) && + ( + this.NotrequiredNotnullableStringProp == input.NotrequiredNotnullableStringProp || + (this.NotrequiredNotnullableStringProp != null && + this.NotrequiredNotnullableStringProp.Equals(input.NotrequiredNotnullableStringProp)) + ) && + ( + this.RequiredNullableBooleanProp == input.RequiredNullableBooleanProp || + (this.RequiredNullableBooleanProp != null && + this.RequiredNullableBooleanProp.Equals(input.RequiredNullableBooleanProp)) + ) && + ( + this.RequiredNotnullableBooleanProp == input.RequiredNotnullableBooleanProp || + this.RequiredNotnullableBooleanProp.Equals(input.RequiredNotnullableBooleanProp) + ) && + ( + this.NotrequiredNullableBooleanProp == input.NotrequiredNullableBooleanProp || + (this.NotrequiredNullableBooleanProp != null && + this.NotrequiredNullableBooleanProp.Equals(input.NotrequiredNullableBooleanProp)) + ) && + ( + this.NotrequiredNotnullableBooleanProp == input.NotrequiredNotnullableBooleanProp || + this.NotrequiredNotnullableBooleanProp.Equals(input.NotrequiredNotnullableBooleanProp) + ) && + ( + this.RequiredNullableDateProp == input.RequiredNullableDateProp || + (this.RequiredNullableDateProp != null && + this.RequiredNullableDateProp.Equals(input.RequiredNullableDateProp)) + ) && + ( + this.RequiredNotNullableDateProp == input.RequiredNotNullableDateProp || + (this.RequiredNotNullableDateProp != null && + this.RequiredNotNullableDateProp.Equals(input.RequiredNotNullableDateProp)) + ) && + ( + this.NotRequiredNullableDateProp == input.NotRequiredNullableDateProp || + (this.NotRequiredNullableDateProp != null && + this.NotRequiredNullableDateProp.Equals(input.NotRequiredNullableDateProp)) + ) && + ( + this.NotRequiredNotnullableDateProp == input.NotRequiredNotnullableDateProp || + (this.NotRequiredNotnullableDateProp != null && + this.NotRequiredNotnullableDateProp.Equals(input.NotRequiredNotnullableDateProp)) + ) && + ( + this.RequiredNotnullableDatetimeProp == input.RequiredNotnullableDatetimeProp || + (this.RequiredNotnullableDatetimeProp != null && + this.RequiredNotnullableDatetimeProp.Equals(input.RequiredNotnullableDatetimeProp)) + ) && + ( + this.RequiredNullableDatetimeProp == input.RequiredNullableDatetimeProp || + (this.RequiredNullableDatetimeProp != null && + this.RequiredNullableDatetimeProp.Equals(input.RequiredNullableDatetimeProp)) + ) && + ( + this.NotrequiredNullableDatetimeProp == input.NotrequiredNullableDatetimeProp || + (this.NotrequiredNullableDatetimeProp != null && + this.NotrequiredNullableDatetimeProp.Equals(input.NotrequiredNullableDatetimeProp)) + ) && + ( + this.NotrequiredNotnullableDatetimeProp == input.NotrequiredNotnullableDatetimeProp || + (this.NotrequiredNotnullableDatetimeProp != null && + this.NotrequiredNotnullableDatetimeProp.Equals(input.NotrequiredNotnullableDatetimeProp)) + ) && + ( + this.RequiredNullableEnumInteger == input.RequiredNullableEnumInteger || + this.RequiredNullableEnumInteger.Equals(input.RequiredNullableEnumInteger) + ) && + ( + this.RequiredNotnullableEnumInteger == input.RequiredNotnullableEnumInteger || + this.RequiredNotnullableEnumInteger.Equals(input.RequiredNotnullableEnumInteger) + ) && + ( + this.NotrequiredNullableEnumInteger == input.NotrequiredNullableEnumInteger || + this.NotrequiredNullableEnumInteger.Equals(input.NotrequiredNullableEnumInteger) + ) && + ( + this.NotrequiredNotnullableEnumInteger == input.NotrequiredNotnullableEnumInteger || + this.NotrequiredNotnullableEnumInteger.Equals(input.NotrequiredNotnullableEnumInteger) + ) && + ( + this.RequiredNullableEnumIntegerOnly == input.RequiredNullableEnumIntegerOnly || + this.RequiredNullableEnumIntegerOnly.Equals(input.RequiredNullableEnumIntegerOnly) + ) && + ( + this.RequiredNotnullableEnumIntegerOnly == input.RequiredNotnullableEnumIntegerOnly || + this.RequiredNotnullableEnumIntegerOnly.Equals(input.RequiredNotnullableEnumIntegerOnly) + ) && + ( + this.NotrequiredNullableEnumIntegerOnly == input.NotrequiredNullableEnumIntegerOnly || + this.NotrequiredNullableEnumIntegerOnly.Equals(input.NotrequiredNullableEnumIntegerOnly) + ) && + ( + this.NotrequiredNotnullableEnumIntegerOnly == input.NotrequiredNotnullableEnumIntegerOnly || + this.NotrequiredNotnullableEnumIntegerOnly.Equals(input.NotrequiredNotnullableEnumIntegerOnly) + ) && + ( + this.RequiredNotnullableEnumString == input.RequiredNotnullableEnumString || + this.RequiredNotnullableEnumString.Equals(input.RequiredNotnullableEnumString) + ) && + ( + this.RequiredNullableEnumString == input.RequiredNullableEnumString || + this.RequiredNullableEnumString.Equals(input.RequiredNullableEnumString) + ) && + ( + this.NotrequiredNullableEnumString == input.NotrequiredNullableEnumString || + this.NotrequiredNullableEnumString.Equals(input.NotrequiredNullableEnumString) + ) && + ( + this.NotrequiredNotnullableEnumString == input.NotrequiredNotnullableEnumString || + this.NotrequiredNotnullableEnumString.Equals(input.NotrequiredNotnullableEnumString) + ) && + ( + this.RequiredNullableOuterEnumDefaultValue == input.RequiredNullableOuterEnumDefaultValue || + this.RequiredNullableOuterEnumDefaultValue.Equals(input.RequiredNullableOuterEnumDefaultValue) + ) && + ( + this.RequiredNotnullableOuterEnumDefaultValue == input.RequiredNotnullableOuterEnumDefaultValue || + this.RequiredNotnullableOuterEnumDefaultValue.Equals(input.RequiredNotnullableOuterEnumDefaultValue) + ) && + ( + this.NotrequiredNullableOuterEnumDefaultValue == input.NotrequiredNullableOuterEnumDefaultValue || + this.NotrequiredNullableOuterEnumDefaultValue.Equals(input.NotrequiredNullableOuterEnumDefaultValue) + ) && + ( + this.NotrequiredNotnullableOuterEnumDefaultValue == input.NotrequiredNotnullableOuterEnumDefaultValue || + this.NotrequiredNotnullableOuterEnumDefaultValue.Equals(input.NotrequiredNotnullableOuterEnumDefaultValue) + ) && + ( + this.RequiredNullableUuid == input.RequiredNullableUuid || + (this.RequiredNullableUuid != null && + this.RequiredNullableUuid.Equals(input.RequiredNullableUuid)) + ) && + ( + this.RequiredNotnullableUuid == input.RequiredNotnullableUuid || + (this.RequiredNotnullableUuid != null && + this.RequiredNotnullableUuid.Equals(input.RequiredNotnullableUuid)) + ) && + ( + this.NotrequiredNullableUuid == input.NotrequiredNullableUuid || + (this.NotrequiredNullableUuid != null && + this.NotrequiredNullableUuid.Equals(input.NotrequiredNullableUuid)) + ) && + ( + this.NotrequiredNotnullableUuid == input.NotrequiredNotnullableUuid || + (this.NotrequiredNotnullableUuid != null && + this.NotrequiredNotnullableUuid.Equals(input.NotrequiredNotnullableUuid)) + ) && + ( + this.RequiredNullableArrayOfString == input.RequiredNullableArrayOfString || + this.RequiredNullableArrayOfString != null && + input.RequiredNullableArrayOfString != null && + this.RequiredNullableArrayOfString.SequenceEqual(input.RequiredNullableArrayOfString) + ) && + ( + this.RequiredNotnullableArrayOfString == input.RequiredNotnullableArrayOfString || + this.RequiredNotnullableArrayOfString != null && + input.RequiredNotnullableArrayOfString != null && + this.RequiredNotnullableArrayOfString.SequenceEqual(input.RequiredNotnullableArrayOfString) + ) && + ( + this.NotrequiredNullableArrayOfString == input.NotrequiredNullableArrayOfString || + this.NotrequiredNullableArrayOfString != null && + input.NotrequiredNullableArrayOfString != null && + this.NotrequiredNullableArrayOfString.SequenceEqual(input.NotrequiredNullableArrayOfString) + ) && + ( + this.NotrequiredNotnullableArrayOfString == input.NotrequiredNotnullableArrayOfString || + this.NotrequiredNotnullableArrayOfString != null && + input.NotrequiredNotnullableArrayOfString != null && + this.NotrequiredNotnullableArrayOfString.SequenceEqual(input.NotrequiredNotnullableArrayOfString) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES index f69e6ba1aba..0af518f942a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -197,6 +198,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient/README.md b/samples/client/petstore/csharp/OpenAPIClient/README.md index af827f28641..c2d5ddeb353 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient/README.md @@ -221,6 +221,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClient/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..90e0c44b40b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1042 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClientCore/.openapi-generator/FILES index f69e6ba1aba..0af518f942a 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClientCore/.openapi-generator/FILES @@ -77,6 +77,7 @@ docs/PolymorphicProperty.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md +docs/RequiredClass.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -197,6 +198,7 @@ src/Org.OpenAPITools/Model/PolymorphicProperty.cs src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/README.md b/samples/client/petstore/csharp/OpenAPIClientCore/README.md index 2a3e242fe88..b344c43c38b 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/README.md +++ b/samples/client/petstore/csharp/OpenAPIClientCore/README.md @@ -233,6 +233,7 @@ Class | Method | HTTP request | Description - [Model.Quadrilateral](docs/Quadrilateral.md) - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Model.RequiredClass](docs/RequiredClass.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml index f6eeaf555f1..70e89968fbe 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml @@ -1946,6 +1946,264 @@ components: nullable: true type: string type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object NullableClass: additionalProperties: nullable: true diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/RequiredClass.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/RequiredClass.md new file mode 100644 index 00000000000..07b6f018f6c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNullableIntegerProp** | **int?** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNullableIntegerProp** | **int?** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**RequiredNullableStringProp** | **string** | | +**RequiredNotnullableStringProp** | **string** | | +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**RequiredNullableBooleanProp** | **bool?** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**NotrequiredNullableBooleanProp** | **bool?** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**RequiredNullableDateProp** | **DateTime?** | | +**RequiredNotNullableDateProp** | **DateTime** | | +**NotRequiredNullableDateProp** | **DateTime?** | | [optional] +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime?** | | +**NotrequiredNullableDatetimeProp** | **DateTime?** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**RequiredNullableEnumInteger** | **int?** | | +**RequiredNotnullableEnumInteger** | **int** | | +**NotrequiredNullableEnumInteger** | **int?** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**RequiredNullableEnumIntegerOnly** | **int?** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**NotrequiredNullableEnumIntegerOnly** | **int?** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**RequiredNotnullableEnumString** | **string** | | +**RequiredNullableEnumString** | **string** | | +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**RequiredNullableUuid** | **Guid?** | | +**RequiredNotnullableUuid** | **Guid** | | +**NotrequiredNullableUuid** | **Guid?** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [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/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 00000000000..17de04feade --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,453 @@ +/* + * 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 Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 00000000000..9e1e2927135 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1027 @@ +/* + * 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.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + [DataContract(Name = "RequiredClass")] + public partial class RequiredClass : IEquatable, IValidatableObject + { + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [DataMember(Name = "required_nullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerEnum RequiredNullableEnumInteger { get; set; } + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [DataMember(Name = "required_notnullable_enum_integer", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [DataMember(Name = "notrequired_nullable_enum_integer", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get; set; } + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [DataMember(Name = "notrequired_notnullable_enum_integer", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get; set; } + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "required_nullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "required_notnullable_enum_integer_only", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_nullable_enum_integer_only", EmitDefaultValue = true)] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get; set; } + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [DataMember(Name = "notrequired_notnullable_enum_integer_only", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get; set; } + /// + /// Defines RequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [DataMember(Name = "required_notnullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + /// + /// Defines RequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [DataMember(Name = "required_nullable_enum_string", IsRequired = true, EmitDefaultValue = true)] + public RequiredNullableEnumStringEnum RequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [DataMember(Name = "notrequired_nullable_enum_string", EmitDefaultValue = true)] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get; set; } + /// + /// Defines NotrequiredNotnullableEnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + [EnumMember(Value = "UPPER")] + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + [EnumMember(Value = "lower")] + Lower = 2, + + /// + /// Enum Empty for value: + /// + [EnumMember(Value = "")] + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + [EnumMember(Value = "Value\twith tab")] + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + [EnumMember(Value = "Value with \" quote")] + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + [EnumMember(Value = "Value with escaped \" quote")] + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + [EnumMember(Value = "Duplicate\nvalue")] + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + [EnumMember(Value = "Duplicate\r\nvalue")] + Duplicatevalue2 = 8 + } + + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [DataMember(Name = "notrequired_notnullable_enum_string", EmitDefaultValue = false)] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_nullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "required_notnullable_outerEnumDefaultValue", IsRequired = true, EmitDefaultValue = true)] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_nullable_outerEnumDefaultValue", EmitDefaultValue = true)] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [DataMember(Name = "notrequired_notnullable_outerEnumDefaultValue", EmitDefaultValue = false)] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected RequiredClass() { } + /// + /// Initializes a new instance of the class. + /// + /// requiredNullableIntegerProp (required). + /// requiredNotnullableintegerProp (required). + /// notRequiredNullableIntegerProp. + /// notRequiredNotnullableintegerProp. + /// requiredNullableStringProp (required). + /// requiredNotnullableStringProp (required). + /// notrequiredNullableStringProp. + /// notrequiredNotnullableStringProp. + /// requiredNullableBooleanProp (required). + /// requiredNotnullableBooleanProp (required). + /// notrequiredNullableBooleanProp. + /// notrequiredNotnullableBooleanProp. + /// requiredNullableDateProp (required). + /// requiredNotNullableDateProp (required). + /// notRequiredNullableDateProp. + /// notRequiredNotnullableDateProp. + /// requiredNotnullableDatetimeProp (required). + /// requiredNullableDatetimeProp (required). + /// notrequiredNullableDatetimeProp. + /// notrequiredNotnullableDatetimeProp. + /// requiredNullableEnumInteger (required). + /// requiredNotnullableEnumInteger (required). + /// notrequiredNullableEnumInteger. + /// notrequiredNotnullableEnumInteger. + /// requiredNullableEnumIntegerOnly (required). + /// requiredNotnullableEnumIntegerOnly (required). + /// notrequiredNullableEnumIntegerOnly. + /// notrequiredNotnullableEnumIntegerOnly. + /// requiredNotnullableEnumString (required). + /// requiredNullableEnumString (required). + /// notrequiredNullableEnumString. + /// notrequiredNotnullableEnumString. + /// requiredNullableOuterEnumDefaultValue (required). + /// requiredNotnullableOuterEnumDefaultValue (required). + /// notrequiredNullableOuterEnumDefaultValue. + /// notrequiredNotnullableOuterEnumDefaultValue. + /// requiredNullableUuid (required). + /// requiredNotnullableUuid (required). + /// notrequiredNullableUuid. + /// notrequiredNotnullableUuid. + /// requiredNullableArrayOfString (required). + /// requiredNotnullableArrayOfString (required). + /// notrequiredNullableArrayOfString. + /// notrequiredNotnullableArrayOfString. + public RequiredClass(int? requiredNullableIntegerProp = default(int?), int requiredNotnullableintegerProp = default(int), int? notRequiredNullableIntegerProp = default(int?), int notRequiredNotnullableintegerProp = default(int), string requiredNullableStringProp = default(string), string requiredNotnullableStringProp = default(string), string notrequiredNullableStringProp = default(string), string notrequiredNotnullableStringProp = default(string), bool? requiredNullableBooleanProp = default(bool?), bool requiredNotnullableBooleanProp = default(bool), bool? notrequiredNullableBooleanProp = default(bool?), bool notrequiredNotnullableBooleanProp = default(bool), DateTime? requiredNullableDateProp = default(DateTime?), DateTime requiredNotNullableDateProp = default(DateTime), DateTime? notRequiredNullableDateProp = default(DateTime?), DateTime notRequiredNotnullableDateProp = default(DateTime), DateTime requiredNotnullableDatetimeProp = default(DateTime), DateTime? requiredNullableDatetimeProp = default(DateTime?), DateTime? notrequiredNullableDatetimeProp = default(DateTime?), DateTime notrequiredNotnullableDatetimeProp = default(DateTime), RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default(RequiredNullableEnumIntegerEnum), RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default(RequiredNotnullableEnumIntegerEnum), NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default(NotrequiredNullableEnumIntegerEnum?), NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default(NotrequiredNotnullableEnumIntegerEnum?), RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default(RequiredNullableEnumIntegerOnlyEnum), RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default(RequiredNotnullableEnumIntegerOnlyEnum), NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default(NotrequiredNullableEnumIntegerOnlyEnum?), NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default(NotrequiredNotnullableEnumIntegerOnlyEnum?), RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default(RequiredNotnullableEnumStringEnum), RequiredNullableEnumStringEnum requiredNullableEnumString = default(RequiredNullableEnumStringEnum), NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default(NotrequiredNullableEnumStringEnum?), NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default(NotrequiredNotnullableEnumStringEnum?), OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue), OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default(OuterEnumDefaultValue?), Guid? requiredNullableUuid = default(Guid?), Guid requiredNotnullableUuid = default(Guid), Guid? notrequiredNullableUuid = default(Guid?), Guid notrequiredNotnullableUuid = default(Guid), List requiredNullableArrayOfString = default(List), List requiredNotnullableArrayOfString = default(List), List notrequiredNullableArrayOfString = default(List), List notrequiredNotnullableArrayOfString = default(List)) + { + // to ensure "requiredNullableIntegerProp" is required (not null) + if (requiredNullableIntegerProp == null) + { + throw new ArgumentNullException("requiredNullableIntegerProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableIntegerProp = requiredNullableIntegerProp; + this.RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + // to ensure "requiredNullableStringProp" is required (not null) + if (requiredNullableStringProp == null) + { + throw new ArgumentNullException("requiredNullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableStringProp = requiredNullableStringProp; + // to ensure "requiredNotnullableStringProp" is required (not null) + if (requiredNotnullableStringProp == null) + { + throw new ArgumentNullException("requiredNotnullableStringProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableStringProp = requiredNotnullableStringProp; + // to ensure "requiredNullableBooleanProp" is required (not null) + if (requiredNullableBooleanProp == null) + { + throw new ArgumentNullException("requiredNullableBooleanProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableBooleanProp = requiredNullableBooleanProp; + this.RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + // to ensure "requiredNullableDateProp" is required (not null) + if (requiredNullableDateProp == null) + { + throw new ArgumentNullException("requiredNullableDateProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDateProp = requiredNullableDateProp; + this.RequiredNotNullableDateProp = requiredNotNullableDateProp; + this.RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + // to ensure "requiredNullableDatetimeProp" is required (not null) + if (requiredNullableDatetimeProp == null) + { + throw new ArgumentNullException("requiredNullableDatetimeProp is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + this.RequiredNullableEnumInteger = requiredNullableEnumInteger; + this.RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + this.RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + this.RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + this.RequiredNotnullableEnumString = requiredNotnullableEnumString; + this.RequiredNullableEnumString = requiredNullableEnumString; + this.RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + this.RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + // to ensure "requiredNullableUuid" is required (not null) + if (requiredNullableUuid == null) + { + throw new ArgumentNullException("requiredNullableUuid is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableUuid = requiredNullableUuid; + this.RequiredNotnullableUuid = requiredNotnullableUuid; + // to ensure "requiredNullableArrayOfString" is required (not null) + if (requiredNullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNullableArrayOfString = requiredNullableArrayOfString; + // to ensure "requiredNotnullableArrayOfString" is required (not null) + if (requiredNotnullableArrayOfString == null) + { + throw new ArgumentNullException("requiredNotnullableArrayOfString is a required property for RequiredClass and cannot be null"); + } + this.RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + this.NotRequiredNullableIntegerProp = notRequiredNullableIntegerProp; + this.NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; + this.NotrequiredNullableStringProp = notrequiredNullableStringProp; + this.NotrequiredNotnullableStringProp = notrequiredNotnullableStringProp; + this.NotrequiredNullableBooleanProp = notrequiredNullableBooleanProp; + this.NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; + this.NotRequiredNullableDateProp = notRequiredNullableDateProp; + this.NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; + this.NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; + this.NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; + this.NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; + this.NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; + this.NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; + this.NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; + this.NotrequiredNullableEnumString = notrequiredNullableEnumString; + this.NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; + this.NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; + this.NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; + this.NotrequiredNullableUuid = notrequiredNullableUuid; + this.NotrequiredNotnullableUuid = notrequiredNotnullableUuid; + this.NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; + this.NotrequiredNotnullableArrayOfString = notrequiredNotnullableArrayOfString; + } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [DataMember(Name = "required_nullable_integer_prop", IsRequired = true, EmitDefaultValue = true)] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [DataMember(Name = "required_notnullableinteger_prop", IsRequired = true, EmitDefaultValue = true)] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [DataMember(Name = "not_required_nullable_integer_prop", EmitDefaultValue = true)] + public int? NotRequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [DataMember(Name = "not_required_notnullableinteger_prop", EmitDefaultValue = false)] + public int NotRequiredNotnullableintegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [DataMember(Name = "required_nullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [DataMember(Name = "required_notnullable_string_prop", IsRequired = true, EmitDefaultValue = true)] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [DataMember(Name = "notrequired_nullable_string_prop", EmitDefaultValue = true)] + public string NotrequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [DataMember(Name = "notrequired_notnullable_string_prop", EmitDefaultValue = false)] + public string NotrequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [DataMember(Name = "required_nullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [DataMember(Name = "required_notnullable_boolean_prop", IsRequired = true, EmitDefaultValue = true)] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [DataMember(Name = "notrequired_nullable_boolean_prop", EmitDefaultValue = true)] + public bool? NotrequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [DataMember(Name = "notrequired_notnullable_boolean_prop", EmitDefaultValue = true)] + public bool NotrequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [DataMember(Name = "required_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [DataMember(Name = "required_not_nullable_date_prop", IsRequired = true, EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [DataMember(Name = "not_required_nullable_date_prop", EmitDefaultValue = true)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime? NotRequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [DataMember(Name = "not_required_notnullable_date_prop", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime NotRequiredNotnullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [DataMember(Name = "required_notnullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [DataMember(Name = "required_nullable_datetime_prop", IsRequired = true, EmitDefaultValue = true)] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [DataMember(Name = "notrequired_nullable_datetime_prop", EmitDefaultValue = true)] + public DateTime? NotrequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [DataMember(Name = "notrequired_notnullable_datetime_prop", EmitDefaultValue = false)] + public DateTime NotrequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_nullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "required_notnullable_uuid", IsRequired = true, EmitDefaultValue = true)] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_nullable_uuid", EmitDefaultValue = true)] + public Guid? NotrequiredNullableUuid { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [DataMember(Name = "notrequired_notnullable_uuid", EmitDefaultValue = false)] + public Guid NotrequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [DataMember(Name = "required_nullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [DataMember(Name = "required_notnullable_array_of_string", IsRequired = true, EmitDefaultValue = true)] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [DataMember(Name = "notrequired_nullable_array_of_string", EmitDefaultValue = true)] + public List NotrequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [DataMember(Name = "notrequired_notnullable_array_of_string", EmitDefaultValue = false)] + public List NotrequiredNotnullableArrayOfString { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as RequiredClass).AreEqual; + } + + /// + /// Returns true if RequiredClass instances are equal + /// + /// Instance of RequiredClass to be compared + /// Boolean + public bool Equals(RequiredClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.RequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableintegerProp.GetHashCode(); + if (this.NotRequiredNullableIntegerProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableIntegerProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotRequiredNotnullableintegerProp.GetHashCode(); + if (this.RequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableStringProp.GetHashCode(); + } + if (this.RequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableStringProp.GetHashCode(); + } + if (this.NotrequiredNullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableStringProp.GetHashCode(); + } + if (this.NotrequiredNotnullableStringProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableStringProp.GetHashCode(); + } + if (this.RequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNotnullableBooleanProp.GetHashCode(); + if (this.NotrequiredNullableBooleanProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableBooleanProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.NotrequiredNotnullableBooleanProp.GetHashCode(); + if (this.RequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDateProp.GetHashCode(); + } + if (this.RequiredNotNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNullableDateProp.GetHashCode(); + } + if (this.NotRequiredNotnullableDateProp != null) + { + hashCode = (hashCode * 59) + this.NotRequiredNotnullableDateProp.GetHashCode(); + } + if (this.RequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableDatetimeProp.GetHashCode(); + } + if (this.RequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableDatetimeProp.GetHashCode(); + } + if (this.NotrequiredNotnullableDatetimeProp != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableDatetimeProp.GetHashCode(); + } + hashCode = (hashCode * 59) + this.RequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumInteger.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumIntegerOnly.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableEnumString.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.RequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNullableOuterEnumDefaultValue.GetHashCode(); + hashCode = (hashCode * 59) + this.NotrequiredNotnullableOuterEnumDefaultValue.GetHashCode(); + if (this.RequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableUuid.GetHashCode(); + } + if (this.RequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableUuid.GetHashCode(); + } + if (this.NotrequiredNullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableUuid.GetHashCode(); + } + if (this.NotrequiredNotnullableUuid != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableUuid.GetHashCode(); + } + if (this.RequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNullableArrayOfString.GetHashCode(); + } + if (this.RequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.RequiredNotnullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNullableArrayOfString.GetHashCode(); + } + if (this.NotrequiredNotnullableArrayOfString != null) + { + hashCode = (hashCode * 59) + this.NotrequiredNotnullableArrayOfString.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +}