forked from loafle/openapi-generator-original
[csharp][generichost] Implement not required nullable properties (#16810)
* init * fixed read and write * completed changes using latest-nrt sample * fixed all samples * add null check on write, change on exception * resolved conflicts * build samples * added backing property for not required properties * more not required and nullable hanlding improvements * revert sample updates for a merge master * revert sample updates for a merge master * sample build is working, need to remove warnings * fixed warnings in .net 7 with nrt * fixed manual tests * fixed all samples * fix npe * removed debugging lines * revert changes to unused file * removed unused lambdas * fix a serialization bug * make option a hidden property * updated documentation * improved parameter ordering
This commit is contained in:
parent
2f655f1a9c
commit
7e529926a6
@ -418,11 +418,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Lambda> 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
|
||||
|
@ -454,14 +454,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
Collections.sort(codegenModel.readWriteVars, propertyComparatorByName);
|
||||
Collections.sort(codegenModel.parentVars, propertyComparatorByName);
|
||||
|
||||
Comparator<CodegenProperty> 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<CodegenProperty> propertyComparatorByDefaultValue = new Comparator<CodegenProperty>() {
|
||||
public static Comparator<CodegenProperty> propertyComparatorByNotNullableRequiredNoDefault = new Comparator<CodegenProperty>() {
|
||||
@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<CodegenProperty> propertyComparatorByNullable = new Comparator<CodegenProperty>() {
|
||||
@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;
|
||||
|
@ -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:
|
||||
* <pre>
|
||||
* additionalProperties.put("copy", new CopyLambda());
|
||||
* </pre>
|
||||
*
|
||||
* Use:
|
||||
* <pre>
|
||||
* {{#copy}}{{name}}{{/copy}}
|
||||
* </pre>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
@ -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:
|
||||
* <pre>
|
||||
* additionalProperties.put("paste", new PasteLambda(copyLambda, true, true, true, false));
|
||||
* </pre>
|
||||
*
|
||||
* Use:
|
||||
* <pre>
|
||||
* {{#paste}}{{/paste}}
|
||||
* </pre>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}}
|
||||
{{#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}}
|
@ -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<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(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}}
|
||||
|
@ -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}}
|
||||
{{#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}}
|
@ -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}}
|
||||
{{#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}}
|
@ -31,5 +31,17 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
IsSet = true;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts this option to the contained type
|
||||
/// </summary>
|
||||
/// <param name="option"></param>
|
||||
public static implicit operator TType(Option<TType> option) => option.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts the provided value to an Option
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public static implicit operator Option<TType>(TType value) => new Option<TType>(value);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
new Option<{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}>(
|
@ -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}}}" });
|
||||
}
|
@ -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}}
|
@ -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}}
|
@ -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}}
|
||||
|
@ -15,19 +15,19 @@
|
||||
{{#allVars}}
|
||||
/// <param name="{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}">{{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}</param>
|
||||
{{/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}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public {{#isNew}}new {{/isNew}}Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
/// </summary>
|
||||
@ -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}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[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}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}{{/description}}
|
||||
/// </summary>{{#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}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public new Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
/// </summary>{{#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}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
/// </summary>{{#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}}
|
||||
|
@ -74,7 +74,7 @@
|
||||
{{#isString}}
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
{{/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}})
|
||||
|
@ -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}}
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing RequiredClass
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
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.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of RequiredClass
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredClassInstanceTest()
|
||||
{
|
||||
// TODO uncomment below to test "IsType" RequiredClass
|
||||
//Assert.IsType<RequiredClass>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableIntegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableIntegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableIntegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableintegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableintegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableintegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNullableIntegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNullableIntegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNullableIntegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNotnullableintegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNotnullableintegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNotnullableintegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotNullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotNullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotNullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNotnullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNotnullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNotnullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableArrayOfString'
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -64,7 +64,7 @@ public class UnitTest1
|
||||
Apple apple = new("#000000", "cultivar", "origin");
|
||||
string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions);
|
||||
Apple? apple2 = JsonSerializer.Deserialize<Apple>(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<Apple>(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<ChildCat>(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<Cat>(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
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Apple>(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<Apple>(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<ChildCat>(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<Cat>(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
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing RequiredClass
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
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.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of RequiredClass
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredClassInstanceTest()
|
||||
{
|
||||
// TODO uncomment below to test "IsType" RequiredClass
|
||||
//Assert.IsType<RequiredClass>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotNullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotNullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotNullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNotnullableintegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNotnullableintegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNotnullableintegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNotnullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNotnullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNotnullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNotnullableintegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNotnullableintegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNotnullableintegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNotnullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNotnullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNotnullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableIntegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableIntegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableIntegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'RequiredNullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RequiredNullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'RequiredNullableUuid'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNullableDateProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNullableDatePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNullableDateProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotRequiredNullableIntegerProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotRequiredNullableIntegerPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotRequiredNullableIntegerProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableArrayOfString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableArrayOfStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableArrayOfString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableBooleanProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableBooleanPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableBooleanProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableDatetimeProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableDatetimePropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableDatetimeProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableEnumInteger'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableEnumIntegerTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableEnumInteger'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableEnumIntegerOnly'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableEnumIntegerOnlyTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableEnumString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableEnumStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableEnumString'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableOuterEnumDefaultValue'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableOuterEnumDefaultValueTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableStringProp'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableStringPropTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableStringProp'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'NotrequiredNullableUuid'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NotrequiredNullableUuidTest()
|
||||
{
|
||||
// TODO unit test for the property 'NotrequiredNullableUuid'
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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(),
|
||||
|
@ -37,5 +37,17 @@ namespace UseSourceGeneration.Client
|
||||
IsSet = true;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts this option to the contained type
|
||||
/// </summary>
|
||||
/// <param name="option"></param>
|
||||
public static implicit operator TType(Option<TType> option) => option.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts the provided value to an Option
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public static implicit operator Option<TType>(TType value) => new Option<TType>(value);
|
||||
}
|
||||
}
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="activityOutputs">activityOutputs</param>
|
||||
[JsonConstructor]
|
||||
public Activity(Dictionary<string, List<ActivityOutputElementRepresentation>> activityOutputs)
|
||||
public Activity(Option<Dictionary<string, List<ActivityOutputElementRepresentation>>?> activityOutputs = default)
|
||||
{
|
||||
ActivityOutputs = activityOutputs;
|
||||
ActivityOutputsOption = activityOutputs;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ActivityOutputs
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, List<ActivityOutputElementRepresentation>>?> ActivityOutputsOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ActivityOutputs
|
||||
/// </summary>
|
||||
[JsonPropertyName("activity_outputs")]
|
||||
public Dictionary<string, List<ActivityOutputElementRepresentation>> ActivityOutputs { get; set; }
|
||||
public Dictionary<string, List<ActivityOutputElementRepresentation>>? ActivityOutputs { get { return this. ActivityOutputsOption; } set { this.ActivityOutputsOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
Dictionary<string, List<ActivityOutputElementRepresentation>>? activityOutputs = default;
|
||||
Option<Dictionary<string, List<ActivityOutputElementRepresentation>>?> activityOutputs = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "activity_outputs":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
activityOutputs = JsonSerializer.Deserialize<Dictionary<string, List<ActivityOutputElementRepresentation>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
activityOutputs = new Option<Dictionary<string, List<ActivityOutputElementRepresentation>>?>(JsonSerializer.Deserialize<Dictionary<string, List<ActivityOutputElementRepresentation>>>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="prop1">prop1</param>
|
||||
/// <param name="prop2">prop2</param>
|
||||
[JsonConstructor]
|
||||
public ActivityOutputElementRepresentation(string prop1, Object prop2)
|
||||
public ActivityOutputElementRepresentation(Option<string?> prop1 = default, Option<Object?> prop2 = default)
|
||||
{
|
||||
Prop1 = prop1;
|
||||
Prop2 = prop2;
|
||||
Prop1Option = prop1;
|
||||
Prop2Option = prop2;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Prop1
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> Prop1Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Prop1
|
||||
/// </summary>
|
||||
[JsonPropertyName("prop1")]
|
||||
public string Prop1 { get; set; }
|
||||
public string? Prop1 { get { return this. Prop1Option; } set { this.Prop1Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Prop2
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Object?> Prop2Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Prop2
|
||||
/// </summary>
|
||||
[JsonPropertyName("prop2")]
|
||||
public Object Prop2 { get; set; }
|
||||
public Object? Prop2 { get { return this. Prop2Option; } set { this.Prop2Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? prop1 = default;
|
||||
Object? prop2 = default;
|
||||
Option<string?> prop1 = default;
|
||||
Option<Object?> prop2 = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -132,11 +146,11 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "prop1":
|
||||
prop1 = utf8JsonReader.GetString();
|
||||
prop1 = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "prop2":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
prop2 = JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
prop2 = new Option<Object?>(JsonSerializer.Deserialize<Object>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ namespace UseSourceGeneration.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AdditionalPropertiesClass" /> class.
|
||||
/// </summary>
|
||||
/// <param name="anytype1">anytype1</param>
|
||||
/// <param name="emptyMap">an object with no declared properties and no undeclared properties, hence it's an empty map.</param>
|
||||
/// <param name="mapOfMapProperty">mapOfMapProperty</param>
|
||||
/// <param name="mapProperty">mapProperty</param>
|
||||
@ -42,71 +43,126 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="mapWithUndeclaredPropertiesAnytype2">mapWithUndeclaredPropertiesAnytype2</param>
|
||||
/// <param name="mapWithUndeclaredPropertiesAnytype3">mapWithUndeclaredPropertiesAnytype3</param>
|
||||
/// <param name="mapWithUndeclaredPropertiesString">mapWithUndeclaredPropertiesString</param>
|
||||
/// <param name="anytype1">anytype1</param>
|
||||
[JsonConstructor]
|
||||
public AdditionalPropertiesClass(Object emptyMap, Dictionary<string, Dictionary<string, string>> mapOfMapProperty, Dictionary<string, string> mapProperty, Object mapWithUndeclaredPropertiesAnytype1, Object mapWithUndeclaredPropertiesAnytype2, Dictionary<string, Object> mapWithUndeclaredPropertiesAnytype3, Dictionary<string, string> mapWithUndeclaredPropertiesString, Object? anytype1 = default)
|
||||
public AdditionalPropertiesClass(Option<Object?> anytype1 = default, Option<Object?> emptyMap = default, Option<Dictionary<string, Dictionary<string, string>>?> mapOfMapProperty = default, Option<Dictionary<string, string>?> mapProperty = default, Option<Object?> mapWithUndeclaredPropertiesAnytype1 = default, Option<Object?> mapWithUndeclaredPropertiesAnytype2 = default, Option<Dictionary<string, Object>?> mapWithUndeclaredPropertiesAnytype3 = default, Option<Dictionary<string, string>?> 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();
|
||||
|
||||
/// <summary>
|
||||
/// an object with no declared properties and no undeclared properties, hence it's an empty map.
|
||||
/// Used to track the state of Anytype1
|
||||
/// </summary>
|
||||
/// <value>an object with no declared properties and no undeclared properties, hence it's an empty map.</value>
|
||||
[JsonPropertyName("empty_map")]
|
||||
public Object EmptyMap { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapOfMapProperty
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_of_map_property")]
|
||||
public Dictionary<string, Dictionary<string, string>> MapOfMapProperty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapProperty
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_property")]
|
||||
public Dictionary<string, string> MapProperty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesAnytype1
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_anytype_1")]
|
||||
public Object MapWithUndeclaredPropertiesAnytype1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesAnytype2
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_anytype_2")]
|
||||
public Object MapWithUndeclaredPropertiesAnytype2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesAnytype3
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_anytype_3")]
|
||||
public Dictionary<string, Object> MapWithUndeclaredPropertiesAnytype3 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesString
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_string")]
|
||||
public Dictionary<string, string> MapWithUndeclaredPropertiesString { get; set; }
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Object?> Anytype1Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Anytype1
|
||||
/// </summary>
|
||||
[JsonPropertyName("anytype_1")]
|
||||
public Object? Anytype1 { get; set; }
|
||||
public Object? Anytype1 { get { return this. Anytype1Option; } set { this.Anytype1Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of EmptyMap
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Object?> EmptyMapOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// an object with no declared properties and no undeclared properties, hence it's an empty map.
|
||||
/// </summary>
|
||||
/// <value>an object with no declared properties and no undeclared properties, hence it's an empty map.</value>
|
||||
[JsonPropertyName("empty_map")]
|
||||
public Object? EmptyMap { get { return this. EmptyMapOption; } set { this.EmptyMapOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapOfMapProperty
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Dictionary<string, string>>?> MapOfMapPropertyOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapOfMapProperty
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_of_map_property")]
|
||||
public Dictionary<string, Dictionary<string, string>>? MapOfMapProperty { get { return this. MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapProperty
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, string>?> MapPropertyOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapProperty
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_property")]
|
||||
public Dictionary<string, string>? MapProperty { get { return this. MapPropertyOption; } set { this.MapPropertyOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapWithUndeclaredPropertiesAnytype1
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Object?> MapWithUndeclaredPropertiesAnytype1Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesAnytype1
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_anytype_1")]
|
||||
public Object? MapWithUndeclaredPropertiesAnytype1 { get { return this. MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapWithUndeclaredPropertiesAnytype2
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Object?> MapWithUndeclaredPropertiesAnytype2Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesAnytype2
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_anytype_2")]
|
||||
public Object? MapWithUndeclaredPropertiesAnytype2 { get { return this. MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapWithUndeclaredPropertiesAnytype3
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Object>?> MapWithUndeclaredPropertiesAnytype3Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesAnytype3
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_anytype_3")]
|
||||
public Dictionary<string, Object>? MapWithUndeclaredPropertiesAnytype3 { get { return this. MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapWithUndeclaredPropertiesString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, string>?> MapWithUndeclaredPropertiesStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapWithUndeclaredPropertiesString
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_with_undeclared_properties_string")]
|
||||
public Dictionary<string, string>? MapWithUndeclaredPropertiesString { get { return this. MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string, Dictionary<string, string>>? mapOfMapProperty = default;
|
||||
Dictionary<string, string>? mapProperty = default;
|
||||
Object? mapWithUndeclaredPropertiesAnytype1 = default;
|
||||
Object? mapWithUndeclaredPropertiesAnytype2 = default;
|
||||
Dictionary<string, Object>? mapWithUndeclaredPropertiesAnytype3 = default;
|
||||
Dictionary<string, string>? mapWithUndeclaredPropertiesString = default;
|
||||
Object? anytype1 = default;
|
||||
Option<Object?> anytype1 = default;
|
||||
Option<Object?> emptyMap = default;
|
||||
Option<Dictionary<string, Dictionary<string, string>>?> mapOfMapProperty = default;
|
||||
Option<Dictionary<string, string>?> mapProperty = default;
|
||||
Option<Object?> mapWithUndeclaredPropertiesAnytype1 = default;
|
||||
Option<Object?> mapWithUndeclaredPropertiesAnytype2 = default;
|
||||
Option<Dictionary<string, Object>?> mapWithUndeclaredPropertiesAnytype3 = default;
|
||||
Option<Dictionary<string, string>?> 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<Object?>(JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "empty_map":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
emptyMap = JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
emptyMap = new Option<Object?>(JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_of_map_property":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapOfMapProperty = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapOfMapProperty = new Option<Dictionary<string, Dictionary<string, string>>?>(JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_property":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapProperty = JsonSerializer.Deserialize<Dictionary<string, string>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapProperty = new Option<Dictionary<string, string>?>(JsonSerializer.Deserialize<Dictionary<string, string>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_with_undeclared_properties_anytype_1":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapWithUndeclaredPropertiesAnytype1 = JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapWithUndeclaredPropertiesAnytype1 = new Option<Object?>(JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_with_undeclared_properties_anytype_2":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapWithUndeclaredPropertiesAnytype2 = JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapWithUndeclaredPropertiesAnytype2 = new Option<Object?>(JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_with_undeclared_properties_anytype_3":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapWithUndeclaredPropertiesAnytype3 = JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapWithUndeclaredPropertiesAnytype3 = new Option<Dictionary<string, Object>?>(JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_with_undeclared_properties_string":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapWithUndeclaredPropertiesString = JsonSerializer.Deserialize<Dictionary<string, string>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "anytype_1":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
anytype1 = JsonSerializer.Deserialize<Object>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapWithUndeclaredPropertiesString = new Option<Dictionary<string, string>?>(JsonSerializer.Deserialize<Dictionary<string, string>>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -278,22 +334,70 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="className">className</param>
|
||||
/// <param name="color">color (default to "red")</param>
|
||||
[JsonConstructor]
|
||||
public Animal(string className, string color = @"red")
|
||||
public Animal(string className, Option<string?> color = default)
|
||||
{
|
||||
ClassName = className;
|
||||
Color = color;
|
||||
ColorOption = color;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -53,11 +53,18 @@ namespace UseSourceGeneration.Model
|
||||
[JsonPropertyName("className")]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Color
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> ColorOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Color
|
||||
/// </summary>
|
||||
[JsonPropertyName("color")]
|
||||
public string Color { get; set; }
|
||||
public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -123,8 +130,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? className = default;
|
||||
string? color = default;
|
||||
Option<string?> className = default;
|
||||
Option<string?> color = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -142,10 +149,10 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "className":
|
||||
className = utf8JsonReader.GetString();
|
||||
className = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "color":
|
||||
color = utf8JsonReader.GetString();
|
||||
color = new Option<string?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -186,8 +196,16 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="message">message</param>
|
||||
/// <param name="type">type</param>
|
||||
[JsonConstructor]
|
||||
public ApiResponse(int code, string message, string type)
|
||||
public ApiResponse(Option<int?> code = default, Option<string?> message = default, Option<string?> type = default)
|
||||
{
|
||||
Code = code;
|
||||
Message = message;
|
||||
Type = type;
|
||||
CodeOption = code;
|
||||
MessageOption = message;
|
||||
TypeOption = type;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Code
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> CodeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Code
|
||||
/// </summary>
|
||||
[JsonPropertyName("code")]
|
||||
public int Code { get; set; }
|
||||
public int? Code { get { return this. CodeOption; } set { this.CodeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Message
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> MessageOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Message
|
||||
/// </summary>
|
||||
[JsonPropertyName("message")]
|
||||
public string Message { get; set; }
|
||||
public string? Message { get { return this. MessageOption; } set { this.MessageOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Type
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> TypeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Type
|
||||
/// </summary>
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
public string? Type { get { return this. TypeOption; } set { this.TypeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<int?> code = default;
|
||||
Option<string?> message = default;
|
||||
Option<string?> 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<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "message":
|
||||
message = utf8JsonReader.GetString();
|
||||
message = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "type":
|
||||
type = utf8JsonReader.GetString();
|
||||
type = new Option<string?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -193,9 +214,20 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="cultivar">cultivar</param>
|
||||
/// <param name="origin">origin</param>
|
||||
[JsonConstructor]
|
||||
public Apple(string colorCode, string cultivar, string origin)
|
||||
public Apple(Option<string?> colorCode = default, Option<string?> cultivar = default, Option<string?> origin = default)
|
||||
{
|
||||
ColorCode = colorCode;
|
||||
Cultivar = cultivar;
|
||||
Origin = origin;
|
||||
ColorCodeOption = colorCode;
|
||||
CultivarOption = cultivar;
|
||||
OriginOption = origin;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ColorCode
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> ColorCodeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ColorCode
|
||||
/// </summary>
|
||||
[JsonPropertyName("color_code")]
|
||||
public string ColorCode { get; set; }
|
||||
public string? ColorCode { get { return this. ColorCodeOption; } set { this.ColorCodeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Cultivar
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> CultivarOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Cultivar
|
||||
/// </summary>
|
||||
[JsonPropertyName("cultivar")]
|
||||
public string Cultivar { get; set; }
|
||||
public string? Cultivar { get { return this. CultivarOption; } set { this.CultivarOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Origin
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> OriginOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Origin
|
||||
/// </summary>
|
||||
[JsonPropertyName("origin")]
|
||||
public string Origin { get; set; }
|
||||
public string? Origin { get { return this. OriginOption; } set { this.OriginOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -96,28 +117,31 @@ namespace UseSourceGeneration.Model
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> 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<string?> colorCode = default;
|
||||
Option<string?> cultivar = default;
|
||||
Option<string?> origin = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -169,13 +193,13 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "color_code":
|
||||
colorCode = utf8JsonReader.GetString();
|
||||
colorCode = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "cultivar":
|
||||
cultivar = utf8JsonReader.GetString();
|
||||
cultivar = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "origin":
|
||||
origin = utf8JsonReader.GetString();
|
||||
origin = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="cultivar">cultivar</param>
|
||||
/// <param name="mealy">mealy</param>
|
||||
[JsonConstructor]
|
||||
public AppleReq(string cultivar, bool mealy)
|
||||
public AppleReq(string cultivar, Option<bool?> mealy = default)
|
||||
{
|
||||
Cultivar = cultivar;
|
||||
Mealy = mealy;
|
||||
MealyOption = mealy;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -53,11 +53,18 @@ namespace UseSourceGeneration.Model
|
||||
[JsonPropertyName("cultivar")]
|
||||
public string Cultivar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Mealy
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<bool?> MealyOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Mealy
|
||||
/// </summary>
|
||||
[JsonPropertyName("mealy")]
|
||||
public bool Mealy { get; set; }
|
||||
public bool? Mealy { get { return this. MealyOption; } set { this.MealyOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string?> cultivar = default;
|
||||
Option<bool?> mealy = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -125,11 +132,11 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "cultivar":
|
||||
cultivar = utf8JsonReader.GetString();
|
||||
cultivar = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "mealy":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mealy = utf8JsonReader.GetBoolean();
|
||||
mealy = new Option<bool?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,8 +180,13 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="arrayArrayNumber">arrayArrayNumber</param>
|
||||
[JsonConstructor]
|
||||
public ArrayOfArrayOfNumberOnly(List<List<decimal>> arrayArrayNumber)
|
||||
public ArrayOfArrayOfNumberOnly(Option<List<List<decimal>>?> arrayArrayNumber = default)
|
||||
{
|
||||
ArrayArrayNumber = arrayArrayNumber;
|
||||
ArrayArrayNumberOption = arrayArrayNumber;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayArrayNumber
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<List<decimal>>?> ArrayArrayNumberOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayArrayNumber
|
||||
/// </summary>
|
||||
[JsonPropertyName("ArrayArrayNumber")]
|
||||
public List<List<decimal>> ArrayArrayNumber { get; set; }
|
||||
public List<List<decimal>>? ArrayArrayNumber { get { return this. ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
List<List<decimal>>? arrayArrayNumber = default;
|
||||
Option<List<List<decimal>>?> arrayArrayNumber = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "ArrayArrayNumber":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayArrayNumber = JsonSerializer.Deserialize<List<List<decimal>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayArrayNumber = new Option<List<List<decimal>>?>(JsonSerializer.Deserialize<List<List<decimal>>>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="arrayNumber">arrayNumber</param>
|
||||
[JsonConstructor]
|
||||
public ArrayOfNumberOnly(List<decimal> arrayNumber)
|
||||
public ArrayOfNumberOnly(Option<List<decimal>?> arrayNumber = default)
|
||||
{
|
||||
ArrayNumber = arrayNumber;
|
||||
ArrayNumberOption = arrayNumber;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayNumber
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<decimal>?> ArrayNumberOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayNumber
|
||||
/// </summary>
|
||||
[JsonPropertyName("ArrayNumber")]
|
||||
public List<decimal> ArrayNumber { get; set; }
|
||||
public List<decimal>? ArrayNumber { get { return this. ArrayNumberOption; } set { this.ArrayNumberOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
List<decimal>? arrayNumber = default;
|
||||
Option<List<decimal>?> arrayNumber = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "ArrayNumber":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayNumber = JsonSerializer.Deserialize<List<decimal>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayNumber = new Option<List<decimal>?>(JsonSerializer.Deserialize<List<decimal>>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="arrayArrayOfModel">arrayArrayOfModel</param>
|
||||
/// <param name="arrayOfString">arrayOfString</param>
|
||||
[JsonConstructor]
|
||||
public ArrayTest(List<List<long>> arrayArrayOfInteger, List<List<ReadOnlyFirst>> arrayArrayOfModel, List<string> arrayOfString)
|
||||
public ArrayTest(Option<List<List<long>>?> arrayArrayOfInteger = default, Option<List<List<ReadOnlyFirst>>?> arrayArrayOfModel = default, Option<List<string>?> arrayOfString = default)
|
||||
{
|
||||
ArrayArrayOfInteger = arrayArrayOfInteger;
|
||||
ArrayArrayOfModel = arrayArrayOfModel;
|
||||
ArrayOfString = arrayOfString;
|
||||
ArrayArrayOfIntegerOption = arrayArrayOfInteger;
|
||||
ArrayArrayOfModelOption = arrayArrayOfModel;
|
||||
ArrayOfStringOption = arrayOfString;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayArrayOfInteger
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<List<long>>?> ArrayArrayOfIntegerOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayArrayOfInteger
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_array_of_integer")]
|
||||
public List<List<long>> ArrayArrayOfInteger { get; set; }
|
||||
public List<List<long>>? ArrayArrayOfInteger { get { return this. ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayArrayOfModel
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<List<ReadOnlyFirst>>?> ArrayArrayOfModelOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayArrayOfModel
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_array_of_model")]
|
||||
public List<List<ReadOnlyFirst>> ArrayArrayOfModel { get; set; }
|
||||
public List<List<ReadOnlyFirst>>? ArrayArrayOfModel { get { return this. ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayOfString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<string>?> ArrayOfStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayOfString
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_of_string")]
|
||||
public List<string> ArrayOfString { get; set; }
|
||||
public List<string>? ArrayOfString { get { return this. ArrayOfStringOption; } set { this.ArrayOfStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -122,9 +143,9 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
List<List<long>>? arrayArrayOfInteger = default;
|
||||
List<List<ReadOnlyFirst>>? arrayArrayOfModel = default;
|
||||
List<string>? arrayOfString = default;
|
||||
Option<List<List<long>>?> arrayArrayOfInteger = default;
|
||||
Option<List<List<ReadOnlyFirst>>?> arrayArrayOfModel = default;
|
||||
Option<List<string>?> 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<List<List<long>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayArrayOfInteger = new Option<List<List<long>>?>(JsonSerializer.Deserialize<List<List<long>>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "array_array_of_model":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayArrayOfModel = JsonSerializer.Deserialize<List<List<ReadOnlyFirst>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayArrayOfModel = new Option<List<List<ReadOnlyFirst>>?>(JsonSerializer.Deserialize<List<List<ReadOnlyFirst>>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "array_of_string":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayOfString = JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayOfString = new Option<List<string>?>(JsonSerializer.Deserialize<List<string>>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="lengthCm">lengthCm</param>
|
||||
[JsonConstructor]
|
||||
public Banana(decimal lengthCm)
|
||||
public Banana(Option<decimal?> lengthCm = default)
|
||||
{
|
||||
LengthCm = lengthCm;
|
||||
LengthCmOption = lengthCm;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of LengthCm
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<decimal?> LengthCmOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets LengthCm
|
||||
/// </summary>
|
||||
[JsonPropertyName("lengthCm")]
|
||||
public decimal LengthCm { get; set; }
|
||||
public decimal? LengthCm { get { return this. LengthCmOption; } set { this.LengthCmOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
decimal? lengthCm = default;
|
||||
Option<decimal?> 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<decimal?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -161,7 +168,8 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="lengthCm">lengthCm</param>
|
||||
/// <param name="sweet">sweet</param>
|
||||
[JsonConstructor]
|
||||
public BananaReq(decimal lengthCm, bool sweet)
|
||||
public BananaReq(decimal lengthCm, Option<bool?> sweet = default)
|
||||
{
|
||||
LengthCm = lengthCm;
|
||||
Sweet = sweet;
|
||||
SweetOption = sweet;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -53,11 +53,18 @@ namespace UseSourceGeneration.Model
|
||||
[JsonPropertyName("lengthCm")]
|
||||
public decimal LengthCm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Sweet
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<bool?> SweetOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Sweet
|
||||
/// </summary>
|
||||
[JsonPropertyName("sweet")]
|
||||
public bool Sweet { get; set; }
|
||||
public bool? Sweet { get { return this. SweetOption; } set { this.SweetOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<decimal?> lengthCm = default;
|
||||
Option<bool?> 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<decimal?>(utf8JsonReader.GetDecimal());
|
||||
break;
|
||||
case "sweet":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
sweet = utf8JsonReader.GetBoolean();
|
||||
sweet = new Option<bool?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? className = default;
|
||||
Option<string?> className = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "className":
|
||||
className = utf8JsonReader.GetString();
|
||||
className = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -42,55 +42,97 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="smallCamel">smallCamel</param>
|
||||
/// <param name="smallSnake">smallSnake</param>
|
||||
[JsonConstructor]
|
||||
public Capitalization(string aTTNAME, string capitalCamel, string capitalSnake, string sCAETHFlowPoints, string smallCamel, string smallSnake)
|
||||
public Capitalization(Option<string?> aTTNAME = default, Option<string?> capitalCamel = default, Option<string?> capitalSnake = default, Option<string?> sCAETHFlowPoints = default, Option<string?> smallCamel = default, Option<string?> 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();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ATT_NAME
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> ATT_NAMEOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the pet
|
||||
/// </summary>
|
||||
/// <value>Name of the pet </value>
|
||||
[JsonPropertyName("ATT_NAME")]
|
||||
public string ATT_NAME { get; set; }
|
||||
public string? ATT_NAME { get { return this. ATT_NAMEOption; } set { this.ATT_NAMEOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of CapitalCamel
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> CapitalCamelOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets CapitalCamel
|
||||
/// </summary>
|
||||
[JsonPropertyName("CapitalCamel")]
|
||||
public string CapitalCamel { get; set; }
|
||||
public string? CapitalCamel { get { return this. CapitalCamelOption; } set { this.CapitalCamelOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of CapitalSnake
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> CapitalSnakeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets CapitalSnake
|
||||
/// </summary>
|
||||
[JsonPropertyName("Capital_Snake")]
|
||||
public string CapitalSnake { get; set; }
|
||||
public string? CapitalSnake { get { return this. CapitalSnakeOption; } set { this.CapitalSnakeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of SCAETHFlowPoints
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> SCAETHFlowPointsOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets SCAETHFlowPoints
|
||||
/// </summary>
|
||||
[JsonPropertyName("SCA_ETH_Flow_Points")]
|
||||
public string SCAETHFlowPoints { get; set; }
|
||||
public string? SCAETHFlowPoints { get { return this. SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of SmallCamel
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> SmallCamelOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets SmallCamel
|
||||
/// </summary>
|
||||
[JsonPropertyName("smallCamel")]
|
||||
public string SmallCamel { get; set; }
|
||||
public string? SmallCamel { get { return this. SmallCamelOption; } set { this.SmallCamelOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of SmallSnake
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> SmallSnakeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets SmallSnake
|
||||
/// </summary>
|
||||
[JsonPropertyName("small_Snake")]
|
||||
public string SmallSnake { get; set; }
|
||||
public string? SmallSnake { get { return this. SmallSnakeOption; } set { this.SmallSnakeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string?> aTTNAME = default;
|
||||
Option<string?> capitalCamel = default;
|
||||
Option<string?> capitalSnake = default;
|
||||
Option<string?> sCAETHFlowPoints = default;
|
||||
Option<string?> smallCamel = default;
|
||||
Option<string?> smallSnake = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -173,22 +215,22 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "ATT_NAME":
|
||||
aTTNAME = utf8JsonReader.GetString();
|
||||
aTTNAME = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "CapitalCamel":
|
||||
capitalCamel = utf8JsonReader.GetString();
|
||||
capitalCamel = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "Capital_Snake":
|
||||
capitalSnake = utf8JsonReader.GetString();
|
||||
capitalSnake = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "SCA_ETH_Flow_Points":
|
||||
sCAETHFlowPoints = utf8JsonReader.GetString();
|
||||
sCAETHFlowPoints = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "smallCamel":
|
||||
smallCamel = utf8JsonReader.GetString();
|
||||
smallCamel = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "small_Snake":
|
||||
smallSnake = utf8JsonReader.GetString();
|
||||
smallSnake = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,22 +36,29 @@ namespace UseSourceGeneration.Model
|
||||
/// Initializes a new instance of the <see cref="Cat" /> class.
|
||||
/// </summary>
|
||||
/// <param name="className">className</param>
|
||||
/// <param name="declawed">declawed</param>
|
||||
/// <param name="color">color (default to "red")</param>
|
||||
/// <param name="declawed">declawed</param>
|
||||
[JsonConstructor]
|
||||
public Cat(string className, bool declawed, string color = @"red") : base(className, color)
|
||||
public Cat(string className, Option<string?> color = default, Option<bool?> declawed = default) : base(className, color)
|
||||
{
|
||||
Declawed = declawed;
|
||||
DeclawedOption = declawed;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Declawed
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<bool?> DeclawedOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Declawed
|
||||
/// </summary>
|
||||
[JsonPropertyName("declawed")]
|
||||
public bool Declawed { get; set; }
|
||||
public bool? Declawed { get { return this. DeclawedOption; } set { this.DeclawedOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string?> className = default;
|
||||
Option<string?> color = default;
|
||||
Option<bool?> declawed = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -110,14 +117,14 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "className":
|
||||
className = utf8JsonReader.GetString();
|
||||
className = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "color":
|
||||
color = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "declawed":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
declawed = utf8JsonReader.GetBoolean();
|
||||
break;
|
||||
case "color":
|
||||
color = utf8JsonReader.GetString();
|
||||
declawed = new Option<bool?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -161,9 +171,19 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,20 +38,27 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="id">id</param>
|
||||
/// <param name="name">name (default to "default-name")</param>
|
||||
[JsonConstructor]
|
||||
public Category(long id, string name = @"default-name")
|
||||
public Category(Option<long?> id = default, string name = @"default-name")
|
||||
{
|
||||
Id = id;
|
||||
IdOption = id;
|
||||
Name = name;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Id
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<long?> IdOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
@ -113,8 +120,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
long? id = default;
|
||||
string? name = default;
|
||||
Option<long?> id = default;
|
||||
Option<string?> 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<long?>(utf8JsonReader.GetInt64());
|
||||
break;
|
||||
case "name":
|
||||
name = utf8JsonReader.GetString();
|
||||
name = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -177,7 +187,12 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="name">name</param>
|
||||
/// <param name="petType">petType (default to PetTypeEnum.ChildCat)</param>
|
||||
[JsonConstructor]
|
||||
public ChildCat(string name, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType))
|
||||
public ChildCat(Option<string?> name = default, Option<PetTypeEnum?> petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value))
|
||||
{
|
||||
Name = name;
|
||||
PetType = petType;
|
||||
NameOption = name;
|
||||
PetTypeOption = petType;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -91,26 +91,39 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of PetType
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public new Option<PetTypeEnum?> PetTypeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PetType
|
||||
/// </summary>
|
||||
[JsonPropertyName("pet_type")]
|
||||
public new PetTypeEnum PetType { get; set; }
|
||||
public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Name
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> NameOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string?> name = default;
|
||||
Option<ChildCat.PetTypeEnum?> petType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -169,13 +182,12 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "name":
|
||||
name = utf8JsonReader.GetString();
|
||||
name = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "pet_type":
|
||||
string? petTypeRawValue = utf8JsonReader.GetString();
|
||||
petType = petTypeRawValue == null
|
||||
? null
|
||||
: ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue);
|
||||
if (petTypeRawValue != null)
|
||||
petType = new Option<ChildCat.PetTypeEnum?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -216,9 +228,13 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="varClass">varClass</param>
|
||||
[JsonConstructor]
|
||||
public ClassModel(string varClass)
|
||||
public ClassModel(Option<string?> varClass = default)
|
||||
{
|
||||
VarClass = varClass;
|
||||
VarClassOption = varClass;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarClass
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> VarClassOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarClass
|
||||
/// </summary>
|
||||
[JsonPropertyName("_class")]
|
||||
public string VarClass { get; set; }
|
||||
public string? VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? varClass = default;
|
||||
Option<string?> varClass = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "_class":
|
||||
varClass = utf8JsonReader.GetString();
|
||||
varClass = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? quadrilateralType = default;
|
||||
string? shapeType = default;
|
||||
Option<string?> quadrilateralType = default;
|
||||
Option<string?> shapeType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -132,10 +132,10 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "quadrilateralType":
|
||||
quadrilateralType = utf8JsonReader.GetString();
|
||||
quadrilateralType = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "shapeType":
|
||||
shapeType = utf8JsonReader.GetString();
|
||||
shapeType = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -176,7 +182,14 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? className = default;
|
||||
Option<string?> className = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "className":
|
||||
className = utf8JsonReader.GetString();
|
||||
className = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -37,20 +37,27 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="dateOnlyProperty">dateOnlyProperty</param>
|
||||
[JsonConstructor]
|
||||
public DateOnlyClass(DateTime dateOnlyProperty)
|
||||
public DateOnlyClass(Option<DateTime?> dateOnlyProperty = default)
|
||||
{
|
||||
DateOnlyProperty = dateOnlyProperty;
|
||||
DateOnlyPropertyOption = dateOnlyProperty;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DateOnlyProperty
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DateTime?> DateOnlyPropertyOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DateOnlyProperty
|
||||
/// </summary>
|
||||
/// <example>Fri Jul 21 00:00:00 UTC 2017</example>
|
||||
[JsonPropertyName("dateOnlyProperty")]
|
||||
public DateTime DateOnlyProperty { get; set; }
|
||||
public DateTime? DateOnlyProperty { get { return this. DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -110,7 +117,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
DateTime? dateOnlyProperty = default;
|
||||
Option<DateTime?> dateOnlyProperty = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -129,7 +136,7 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "dateOnlyProperty":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
dateOnlyProperty = JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
dateOnlyProperty = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -167,7 +174,8 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="name">name</param>
|
||||
[JsonConstructor]
|
||||
public DeprecatedObject(string name)
|
||||
public DeprecatedObject(Option<string?> name = default)
|
||||
{
|
||||
Name = name;
|
||||
NameOption = name;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Name
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> NameOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
public string? Name { get { return this. NameOption; } set { this.NameOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? name = default;
|
||||
Option<string?> name = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "name":
|
||||
name = utf8JsonReader.GetString();
|
||||
name = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,23 +35,30 @@ namespace UseSourceGeneration.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Dog" /> class.
|
||||
/// </summary>
|
||||
/// <param name="breed">breed</param>
|
||||
/// <param name="className">className</param>
|
||||
/// <param name="breed">breed</param>
|
||||
/// <param name="color">color (default to "red")</param>
|
||||
[JsonConstructor]
|
||||
public Dog(string breed, string className, string color = @"red") : base(className, color)
|
||||
public Dog(string className, Option<string?> breed = default, Option<string?> color = default) : base(className, color)
|
||||
{
|
||||
Breed = breed;
|
||||
BreedOption = breed;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Breed
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> BreedOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Breed
|
||||
/// </summary>
|
||||
[JsonPropertyName("breed")]
|
||||
public string Breed { get; set; }
|
||||
public string? Breed { get { return this. BreedOption; } set { this.BreedOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string?> className = default;
|
||||
Option<string?> breed = default;
|
||||
Option<string?> 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<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "breed":
|
||||
breed = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "color":
|
||||
color = utf8JsonReader.GetString();
|
||||
color = new Option<string?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,9 +170,22 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,44 +36,72 @@ namespace UseSourceGeneration.Model
|
||||
/// Initializes a new instance of the <see cref="Drawing" /> class.
|
||||
/// </summary>
|
||||
/// <param name="mainShape">mainShape</param>
|
||||
/// <param name="shapes">shapes</param>
|
||||
/// <param name="nullableShape">nullableShape</param>
|
||||
/// <param name="shapeOrNull">shapeOrNull</param>
|
||||
/// <param name="shapes">shapes</param>
|
||||
[JsonConstructor]
|
||||
public Drawing(Shape mainShape, List<Shape> shapes, NullableShape? nullableShape = default, ShapeOrNull? shapeOrNull = default) : base()
|
||||
public Drawing(Option<Shape?> mainShape = default, Option<NullableShape?> nullableShape = default, Option<ShapeOrNull?> shapeOrNull = default, Option<List<Shape>?> shapes = default) : base()
|
||||
{
|
||||
MainShape = mainShape;
|
||||
Shapes = shapes;
|
||||
NullableShape = nullableShape;
|
||||
ShapeOrNull = shapeOrNull;
|
||||
MainShapeOption = mainShape;
|
||||
NullableShapeOption = nullableShape;
|
||||
ShapeOrNullOption = shapeOrNull;
|
||||
ShapesOption = shapes;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MainShape
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Shape?> MainShapeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MainShape
|
||||
/// </summary>
|
||||
[JsonPropertyName("mainShape")]
|
||||
public Shape MainShape { get; set; }
|
||||
public Shape? MainShape { get { return this. MainShapeOption; } set { this.MainShapeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Shapes
|
||||
/// Used to track the state of NullableShape
|
||||
/// </summary>
|
||||
[JsonPropertyName("shapes")]
|
||||
public List<Shape> Shapes { get; set; }
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<NullableShape?> NullableShapeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets NullableShape
|
||||
/// </summary>
|
||||
[JsonPropertyName("nullableShape")]
|
||||
public NullableShape? NullableShape { get; set; }
|
||||
public NullableShape? NullableShape { get { return this. NullableShapeOption; } set { this.NullableShapeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ShapeOrNull
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<ShapeOrNull?> ShapeOrNullOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ShapeOrNull
|
||||
/// </summary>
|
||||
[JsonPropertyName("shapeOrNull")]
|
||||
public ShapeOrNull? ShapeOrNull { get; set; }
|
||||
public ShapeOrNull? ShapeOrNull { get { return this. ShapeOrNullOption; } set { this.ShapeOrNullOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Shapes
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<Shape>?> ShapesOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Shapes
|
||||
/// </summary>
|
||||
[JsonPropertyName("shapes")]
|
||||
public List<Shape>? Shapes { get { return this. ShapesOption; } set { this.ShapesOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<Shape>? shapes = default;
|
||||
NullableShape? nullableShape = default;
|
||||
ShapeOrNull? shapeOrNull = default;
|
||||
Option<Shape?> mainShape = default;
|
||||
Option<NullableShape?> nullableShape = default;
|
||||
Option<ShapeOrNull?> shapeOrNull = default;
|
||||
Option<List<Shape>?> shapes = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -164,19 +192,19 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "mainShape":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mainShape = JsonSerializer.Deserialize<Shape>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "shapes":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
shapes = JsonSerializer.Deserialize<List<Shape>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mainShape = new Option<Shape?>(JsonSerializer.Deserialize<Shape>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "nullableShape":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
nullableShape = JsonSerializer.Deserialize<NullableShape>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
nullableShape = new Option<NullableShape?>(JsonSerializer.Deserialize<NullableShape>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "shapeOrNull":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
shapeOrNull = JsonSerializer.Deserialize<ShapeOrNull>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
shapeOrNull = new Option<ShapeOrNull?>(JsonSerializer.Deserialize<ShapeOrNull>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "shapes":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
shapes = new Option<List<Shape>?>(JsonSerializer.Deserialize<List<Shape>>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -217,14 +245,38 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="arrayEnum">arrayEnum</param>
|
||||
/// <param name="justSymbol">justSymbol</param>
|
||||
[JsonConstructor]
|
||||
public EnumArrays(List<EnumArrays.ArrayEnumEnum> arrayEnum, JustSymbolEnum justSymbol)
|
||||
public EnumArrays(Option<List<EnumArrays.ArrayEnumEnum>?> arrayEnum = default, Option<JustSymbolEnum?> justSymbol = default)
|
||||
{
|
||||
ArrayEnum = arrayEnum;
|
||||
JustSymbol = justSymbol;
|
||||
ArrayEnumOption = arrayEnum;
|
||||
JustSymbolOption = justSymbol;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -102,9 +102,8 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of JustSymbol
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<JustSymbolEnum?> JustSymbolOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets JustSymbol
|
||||
/// </summary>
|
||||
[JsonPropertyName("just_symbol")]
|
||||
public JustSymbolEnum JustSymbol { get; set; }
|
||||
public JustSymbolEnum? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayEnum
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<EnumArrays.ArrayEnumEnum>?> ArrayEnumOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayEnum
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_enum")]
|
||||
public List<EnumArrays.ArrayEnumEnum> ArrayEnum { get; set; }
|
||||
public List<EnumArrays.ArrayEnumEnum>? ArrayEnum { get { return this. ArrayEnumOption; } set { this.ArrayEnumOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -247,8 +259,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
List<EnumArrays.ArrayEnumEnum>? arrayEnum = default;
|
||||
EnumArrays.JustSymbolEnum? justSymbol = default;
|
||||
Option<List<EnumArrays.ArrayEnumEnum>?> arrayEnum = default;
|
||||
Option<EnumArrays.JustSymbolEnum?> justSymbol = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -267,13 +279,12 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "array_enum":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayEnum = JsonSerializer.Deserialize<List<EnumArrays.ArrayEnumEnum>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayEnum = new Option<List<EnumArrays.ArrayEnumEnum>?>(JsonSerializer.Deserialize<List<EnumArrays.ArrayEnumEnum>>(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.JustSymbolEnum?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -314,10 +325,15 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? shapeType = default;
|
||||
string? triangleType = default;
|
||||
Option<string?> shapeType = default;
|
||||
Option<string?> triangleType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -132,10 +132,10 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "shapeType":
|
||||
shapeType = utf8JsonReader.GetString();
|
||||
shapeType = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "triangleType":
|
||||
triangleType = utf8JsonReader.GetString();
|
||||
triangleType = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -176,7 +182,14 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -37,20 +37,27 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="sourceURI">Test capitalization</param>
|
||||
[JsonConstructor]
|
||||
public File(string sourceURI)
|
||||
public File(Option<string?> sourceURI = default)
|
||||
{
|
||||
SourceURI = sourceURI;
|
||||
SourceURIOption = sourceURI;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of SourceURI
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> SourceURIOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Test capitalization
|
||||
/// </summary>
|
||||
/// <value>Test capitalization</value>
|
||||
[JsonPropertyName("sourceURI")]
|
||||
public string SourceURI { get; set; }
|
||||
public string? SourceURI { get { return this. SourceURIOption; } set { this.SourceURIOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -105,7 +112,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? sourceURI = default;
|
||||
Option<string?> sourceURI = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "sourceURI":
|
||||
sourceURI = utf8JsonReader.GetString();
|
||||
sourceURI = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="file">file</param>
|
||||
/// <param name="files">files</param>
|
||||
[JsonConstructor]
|
||||
public FileSchemaTestClass(File file, List<File> files)
|
||||
public FileSchemaTestClass(Option<File?> file = default, Option<List<File>?> files = default)
|
||||
{
|
||||
File = file;
|
||||
Files = files;
|
||||
FileOption = file;
|
||||
FilesOption = files;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of File
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<File?> FileOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets File
|
||||
/// </summary>
|
||||
[JsonPropertyName("file")]
|
||||
public File File { get; set; }
|
||||
public File? File { get { return this. FileOption; } set { this.FileOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Files
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<File>?> FilesOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Files
|
||||
/// </summary>
|
||||
[JsonPropertyName("files")]
|
||||
public List<File> Files { get; set; }
|
||||
public List<File>? Files { get { return this. FilesOption; } set { this.FilesOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
File? file = default;
|
||||
List<File>? files = default;
|
||||
Option<File?> file = default;
|
||||
Option<List<File>?> files = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -133,11 +147,11 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "file":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
file = JsonSerializer.Deserialize<File>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
file = new Option<File?>(JsonSerializer.Deserialize<File>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "files":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
files = JsonSerializer.Deserialize<List<File>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
files = new Option<List<File>?>(JsonSerializer.Deserialize<List<File>>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="bar">bar (default to "bar")</param>
|
||||
[JsonConstructor]
|
||||
public Foo(string bar = @"bar")
|
||||
public Foo(Option<string?> bar = default)
|
||||
{
|
||||
Bar = bar;
|
||||
BarOption = bar;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Bar
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> BarOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Bar
|
||||
/// </summary>
|
||||
[JsonPropertyName("bar")]
|
||||
public string Bar { get; set; }
|
||||
public string? Bar { get { return this. BarOption; } set { this.BarOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? bar = default;
|
||||
Option<string?> bar = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "bar":
|
||||
bar = utf8JsonReader.GetString();
|
||||
bar = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="varString">varString</param>
|
||||
[JsonConstructor]
|
||||
public FooGetDefaultResponse(Foo varString)
|
||||
public FooGetDefaultResponse(Option<Foo?> varString = default)
|
||||
{
|
||||
VarString = varString;
|
||||
VarStringOption = varString;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Foo?> VarStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarString
|
||||
/// </summary>
|
||||
[JsonPropertyName("string")]
|
||||
public Foo VarString { get; set; }
|
||||
public Foo? VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
Foo? varString = default;
|
||||
Option<Foo?> varString = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -123,7 +130,7 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "string":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
varString = JsonSerializer.Deserialize<Foo>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
varString = new Option<Foo?>(JsonSerializer.Deserialize<Foo>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,11 @@ namespace UseSourceGeneration.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FormatTest" /> class.
|
||||
/// </summary>
|
||||
/// <param name="binary">binary</param>
|
||||
/// <param name="varByte">varByte</param>
|
||||
/// <param name="date">date</param>
|
||||
/// <param name="number">number</param>
|
||||
/// <param name="password">password</param>
|
||||
/// <param name="binary">binary</param>
|
||||
/// <param name="dateTime">dateTime</param>
|
||||
/// <param name="varDecimal">varDecimal</param>
|
||||
/// <param name="varDouble">varDouble</param>
|
||||
@ -45,8 +47,6 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="int32">int32</param>
|
||||
/// <param name="int64">int64</param>
|
||||
/// <param name="integer">integer</param>
|
||||
/// <param name="number">number</param>
|
||||
/// <param name="password">password</param>
|
||||
/// <param name="patternWithBackslash">None</param>
|
||||
/// <param name="patternWithDigits">A string that is a 10 digit number. Can have leading zeros.</param>
|
||||
/// <param name="patternWithDigitsAndDelimiter">A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.</param>
|
||||
@ -55,38 +55,32 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="unsignedLong">unsignedLong</param>
|
||||
/// <param name="uuid">uuid</param>
|
||||
[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<System.IO.Stream?> binary = default, Option<DateTime?> dateTime = default, Option<decimal?> varDecimal = default, Option<double?> varDouble = default, Option<float?> varFloat = default, Option<int?> int32 = default, Option<long?> int64 = default, Option<int?> integer = default, Option<string?> patternWithBackslash = default, Option<string?> patternWithDigits = default, Option<string?> patternWithDigitsAndDelimiter = default, Option<string?> varString = default, Option<uint?> unsignedInteger = default, Option<ulong?> unsignedLong = default, Option<Guid?> 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();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Binary
|
||||
/// </summary>
|
||||
[JsonPropertyName("binary")]
|
||||
public System.IO.Stream Binary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarByte
|
||||
/// </summary>
|
||||
@ -100,49 +94,6 @@ namespace UseSourceGeneration.Model
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DateTime
|
||||
/// </summary>
|
||||
/// <example>2007-12-03T10:15:30+01:00</example>
|
||||
[JsonPropertyName("dateTime")]
|
||||
public DateTime DateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarDecimal
|
||||
/// </summary>
|
||||
[JsonPropertyName("decimal")]
|
||||
public decimal VarDecimal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarDouble
|
||||
/// </summary>
|
||||
[JsonPropertyName("double")]
|
||||
public double VarDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarFloat
|
||||
/// </summary>
|
||||
[JsonPropertyName("float")]
|
||||
public float VarFloat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Int32
|
||||
/// </summary>
|
||||
[JsonPropertyName("int32")]
|
||||
public int Int32 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Int64
|
||||
/// </summary>
|
||||
[JsonPropertyName("int64")]
|
||||
public long Int64 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Integer
|
||||
/// </summary>
|
||||
[JsonPropertyName("integer")]
|
||||
public int Integer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Number
|
||||
/// </summary>
|
||||
@ -155,51 +106,205 @@ namespace UseSourceGeneration.Model
|
||||
[JsonPropertyName("password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Binary
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<System.IO.Stream?> BinaryOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Binary
|
||||
/// </summary>
|
||||
[JsonPropertyName("binary")]
|
||||
public System.IO.Stream? Binary { get { return this. BinaryOption; } set { this.BinaryOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DateTime
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DateTime?> DateTimeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DateTime
|
||||
/// </summary>
|
||||
/// <example>2007-12-03T10:15:30+01:00</example>
|
||||
[JsonPropertyName("dateTime")]
|
||||
public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarDecimal
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<decimal?> VarDecimalOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarDecimal
|
||||
/// </summary>
|
||||
[JsonPropertyName("decimal")]
|
||||
public decimal? VarDecimal { get { return this. VarDecimalOption; } set { this.VarDecimalOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarDouble
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<double?> VarDoubleOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarDouble
|
||||
/// </summary>
|
||||
[JsonPropertyName("double")]
|
||||
public double? VarDouble { get { return this. VarDoubleOption; } set { this.VarDoubleOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarFloat
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<float?> VarFloatOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarFloat
|
||||
/// </summary>
|
||||
[JsonPropertyName("float")]
|
||||
public float? VarFloat { get { return this. VarFloatOption; } set { this.VarFloatOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Int32
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> Int32Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Int32
|
||||
/// </summary>
|
||||
[JsonPropertyName("int32")]
|
||||
public int? Int32 { get { return this. Int32Option; } set { this.Int32Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Int64
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<long?> Int64Option { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Int64
|
||||
/// </summary>
|
||||
[JsonPropertyName("int64")]
|
||||
public long? Int64 { get { return this. Int64Option; } set { this.Int64Option = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Integer
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> IntegerOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Integer
|
||||
/// </summary>
|
||||
[JsonPropertyName("integer")]
|
||||
public int? Integer { get { return this. IntegerOption; } set { this.IntegerOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of PatternWithBackslash
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> PatternWithBackslashOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
/// <value>None</value>
|
||||
[JsonPropertyName("pattern_with_backslash")]
|
||||
public string PatternWithBackslash { get; set; }
|
||||
public string? PatternWithBackslash { get { return this. PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of PatternWithDigits
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> PatternWithDigitsOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string that is a 10 digit number. Can have leading zeros.
|
||||
/// </summary>
|
||||
/// <value>A string that is a 10 digit number. Can have leading zeros.</value>
|
||||
[JsonPropertyName("pattern_with_digits")]
|
||||
public string PatternWithDigits { get; set; }
|
||||
public string? PatternWithDigits { get { return this. PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of PatternWithDigitsAndDelimiter
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> PatternWithDigitsAndDelimiterOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
|
||||
/// </summary>
|
||||
/// <value>A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.</value>
|
||||
[JsonPropertyName("pattern_with_digits_and_delimiter")]
|
||||
public string PatternWithDigitsAndDelimiter { get; set; }
|
||||
public string? PatternWithDigitsAndDelimiter { get { return this. PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> VarStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarString
|
||||
/// </summary>
|
||||
[JsonPropertyName("string")]
|
||||
public string VarString { get; set; }
|
||||
public string? VarString { get { return this. VarStringOption; } set { this.VarStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of UnsignedInteger
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<uint?> UnsignedIntegerOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets UnsignedInteger
|
||||
/// </summary>
|
||||
[JsonPropertyName("unsigned_integer")]
|
||||
public uint UnsignedInteger { get; set; }
|
||||
public uint? UnsignedInteger { get { return this. UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of UnsignedLong
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<ulong?> UnsignedLongOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets UnsignedLong
|
||||
/// </summary>
|
||||
[JsonPropertyName("unsigned_long")]
|
||||
public ulong UnsignedLong { get; set; }
|
||||
public ulong? UnsignedLong { get { return this. UnsignedLongOption; } set { this.UnsignedLongOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Uuid
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Guid?> UuidOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Uuid
|
||||
/// </summary>
|
||||
/// <example>72f98069-206d-4f12-9f12-3d1e525a8e84</example>
|
||||
[JsonPropertyName("uuid")]
|
||||
public Guid Uuid { get; set; }
|
||||
public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> 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<byte[]?> varByte = default;
|
||||
Option<DateTime?> date = default;
|
||||
Option<decimal?> number = default;
|
||||
Option<string?> password = default;
|
||||
Option<System.IO.Stream?> binary = default;
|
||||
Option<DateTime?> dateTime = default;
|
||||
Option<decimal?> varDecimal = default;
|
||||
Option<double?> varDouble = default;
|
||||
Option<float?> varFloat = default;
|
||||
Option<int?> int32 = default;
|
||||
Option<long?> int64 = default;
|
||||
Option<int?> integer = default;
|
||||
Option<string?> patternWithBackslash = default;
|
||||
Option<string?> patternWithDigits = default;
|
||||
Option<string?> patternWithDigitsAndDelimiter = default;
|
||||
Option<string?> varString = default;
|
||||
Option<uint?> unsignedInteger = default;
|
||||
Option<ulong?> unsignedLong = default;
|
||||
Option<Guid?> uuid = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -437,76 +546,76 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "binary":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
binary = JsonSerializer.Deserialize<System.IO.Stream>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "byte":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
varByte = JsonSerializer.Deserialize<byte[]>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
varByte = new Option<byte[]?>(JsonSerializer.Deserialize<byte[]>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "date":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
date = JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "dateTime":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
dateTime = JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "decimal":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
varDecimal = JsonSerializer.Deserialize<decimal>(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<DateTime?>(JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "number":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
number = utf8JsonReader.GetDecimal();
|
||||
number = new Option<decimal?>(utf8JsonReader.GetDecimal());
|
||||
break;
|
||||
case "password":
|
||||
password = utf8JsonReader.GetString();
|
||||
password = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "binary":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
binary = new Option<System.IO.Stream?>(JsonSerializer.Deserialize<System.IO.Stream>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "dateTime":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
dateTime = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "decimal":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
varDecimal = new Option<decimal?>(JsonSerializer.Deserialize<decimal>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "double":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
varDouble = new Option<double?>(utf8JsonReader.GetDouble());
|
||||
break;
|
||||
case "float":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
varFloat = new Option<float?>((float)utf8JsonReader.GetDouble());
|
||||
break;
|
||||
case "int32":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
int32 = new Option<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "int64":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
int64 = new Option<long?>(utf8JsonReader.GetInt64());
|
||||
break;
|
||||
case "integer":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
integer = new Option<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "pattern_with_backslash":
|
||||
patternWithBackslash = utf8JsonReader.GetString();
|
||||
patternWithBackslash = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "pattern_with_digits":
|
||||
patternWithDigits = utf8JsonReader.GetString();
|
||||
patternWithDigits = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "pattern_with_digits_and_delimiter":
|
||||
patternWithDigitsAndDelimiter = utf8JsonReader.GetString();
|
||||
patternWithDigitsAndDelimiter = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "string":
|
||||
varString = utf8JsonReader.GetString();
|
||||
varString = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "unsigned_integer":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
unsignedInteger = utf8JsonReader.GetUInt32();
|
||||
unsignedInteger = new Option<uint?>(utf8JsonReader.GetUInt32());
|
||||
break;
|
||||
case "unsigned_long":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
unsignedLong = utf8JsonReader.GetUInt64();
|
||||
unsignedLong = new Option<ulong?>(utf8JsonReader.GetUInt64());
|
||||
break;
|
||||
case "uuid":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
uuid = utf8JsonReader.GetGuid();
|
||||
uuid = new Option<Guid?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -598,28 +719,83 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,10 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="apple"></param>
|
||||
/// <param name="color">color</param>
|
||||
public Fruit(Apple apple, string color)
|
||||
public Fruit(Apple apple, Option<string?> color = default)
|
||||
{
|
||||
Apple = apple;
|
||||
Color = color;
|
||||
ColorOption = color;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -49,10 +49,10 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="banana"></param>
|
||||
/// <param name="color">color</param>
|
||||
public Fruit(Banana banana, string color)
|
||||
public Fruit(Banana banana, Option<string?> color = default)
|
||||
{
|
||||
Banana = banana;
|
||||
Color = color;
|
||||
ColorOption = color;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
@ -68,11 +68,18 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
public Banana? Banana { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Color
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> ColorOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Color
|
||||
/// </summary>
|
||||
[JsonPropertyName("color")]
|
||||
public string Color { get; set; }
|
||||
public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
@ -120,7 +127,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? color = default;
|
||||
Option<string?> 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<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,31 +38,52 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="apple"></param>
|
||||
/// <param name="banana"></param>
|
||||
/// <param name="color">color</param>
|
||||
public GmFruit(Apple? apple, Banana? banana, string color)
|
||||
public GmFruit(Option<Apple?> apple, Option<Banana?> banana, Option<string?> color = default)
|
||||
{
|
||||
Apple = apple;
|
||||
Banana = banana;
|
||||
Color = color;
|
||||
AppleOption = apple;
|
||||
BananaOption = banana;
|
||||
ColorOption = color;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Apple
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Apple?> AppleOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Apple
|
||||
/// </summary>
|
||||
public Apple? Apple { get; set; }
|
||||
public Apple? Apple { get { return this.AppleOption; } set { this.AppleOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Banana
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Banana?> BananaOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Banana
|
||||
/// </summary>
|
||||
public Banana? Banana { get; set; }
|
||||
public Banana? Banana { get { return this.BananaOption; } set { this.BananaOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Color
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> ColorOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Color
|
||||
/// </summary>
|
||||
[JsonPropertyName("color")]
|
||||
public string Color { get; set; }
|
||||
public string? Color { get { return this. ColorOption; } set { this.ColorOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
@ -110,7 +131,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? color = default;
|
||||
Option<string?> 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<string?>(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<Apple?> appleParsedValue = apple == null
|
||||
? default
|
||||
: new Option<Apple?>(apple);
|
||||
Option<Banana?> bananaParsedValue = banana == null
|
||||
? default
|
||||
: new Option<Banana?>(banana);
|
||||
|
||||
return new GmFruit(appleParsedValue, bananaParsedValue, color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? petType = default;
|
||||
Option<string?> petType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -132,7 +132,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "pet_type":
|
||||
petType = utf8JsonReader.GetString();
|
||||
petType = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,6 +173,9 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="bar">bar</param>
|
||||
/// <param name="foo">foo</param>
|
||||
[JsonConstructor]
|
||||
internal HasOnlyReadOnly(string bar, string foo)
|
||||
internal HasOnlyReadOnly(Option<string?> bar = default, Option<string?> foo = default)
|
||||
{
|
||||
Bar = bar;
|
||||
Foo = foo;
|
||||
BarOption = bar;
|
||||
FooOption = foo;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Bar
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> BarOption { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Bar
|
||||
/// </summary>
|
||||
[JsonPropertyName("bar")]
|
||||
public string Bar { get; }
|
||||
public string? Bar { get { return this. BarOption; } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Foo
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> FooOption { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Foo
|
||||
/// </summary>
|
||||
[JsonPropertyName("foo")]
|
||||
public string Foo { get; }
|
||||
public string? Foo { get { return this. FooOption; } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string?> bar = default;
|
||||
Option<string?> foo = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -169,10 +187,10 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "bar":
|
||||
bar = utf8JsonReader.GetString();
|
||||
bar = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "foo":
|
||||
foo = utf8JsonReader.GetString();
|
||||
foo = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="nullableMessage">nullableMessage</param>
|
||||
[JsonConstructor]
|
||||
public HealthCheckResult(string? nullableMessage = default)
|
||||
public HealthCheckResult(Option<string?> nullableMessage = default)
|
||||
{
|
||||
NullableMessage = nullableMessage;
|
||||
NullableMessageOption = nullableMessage;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of NullableMessage
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> NullableMessageOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets NullableMessage
|
||||
/// </summary>
|
||||
[JsonPropertyName("NullableMessage")]
|
||||
public string? NullableMessage { get; set; }
|
||||
public string? NullableMessage { get { return this. NullableMessageOption; } set { this.NullableMessageOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? nullableMessage = default;
|
||||
Option<string?> nullableMessage = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "NullableMessage":
|
||||
nullableMessage = utf8JsonReader.GetString();
|
||||
nullableMessage = new Option<string?>(utf8JsonReader.GetString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -157,7 +164,11 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? shapeType = default;
|
||||
string? triangleType = default;
|
||||
Option<string?> shapeType = default;
|
||||
Option<string?> triangleType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -125,10 +125,10 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "shapeType":
|
||||
shapeType = utf8JsonReader.GetString();
|
||||
shapeType = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "triangleType":
|
||||
triangleType = utf8JsonReader.GetString();
|
||||
triangleType = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -169,7 +175,14 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="var123List">var123List</param>
|
||||
[JsonConstructor]
|
||||
public List(string var123List)
|
||||
public List(Option<string?> var123List = default)
|
||||
{
|
||||
Var123List = var123List;
|
||||
Var123ListOption = var123List;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Var123List
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> Var123ListOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Var123List
|
||||
/// </summary>
|
||||
[JsonPropertyName("123-list")]
|
||||
public string Var123List { get; set; }
|
||||
public string? Var123List { get { return this. Var123ListOption; } set { this.Var123ListOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? var123List = default;
|
||||
Option<string?> var123List = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "123-list":
|
||||
var123List = utf8JsonReader.GetString();
|
||||
var123List = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="escapedLiteralString">escapedLiteralString (default to "C:\\Users\\username")</param>
|
||||
/// <param name="unescapedLiteralString">unescapedLiteralString (default to "C:\Users\username")</param>
|
||||
[JsonConstructor]
|
||||
public LiteralStringClass(string escapedLiteralString = @"C:\\Users\\username", string unescapedLiteralString = @"C:\Users\username")
|
||||
public LiteralStringClass(Option<string?> escapedLiteralString = default, Option<string?> unescapedLiteralString = default)
|
||||
{
|
||||
EscapedLiteralString = escapedLiteralString;
|
||||
UnescapedLiteralString = unescapedLiteralString;
|
||||
EscapedLiteralStringOption = escapedLiteralString;
|
||||
UnescapedLiteralStringOption = unescapedLiteralString;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of EscapedLiteralString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> EscapedLiteralStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EscapedLiteralString
|
||||
/// </summary>
|
||||
[JsonPropertyName("escapedLiteralString")]
|
||||
public string EscapedLiteralString { get; set; }
|
||||
public string? EscapedLiteralString { get { return this. EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of UnescapedLiteralString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> UnescapedLiteralStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets UnescapedLiteralString
|
||||
/// </summary>
|
||||
[JsonPropertyName("unescapedLiteralString")]
|
||||
public string UnescapedLiteralString { get; set; }
|
||||
public string? UnescapedLiteralString { get { return this. UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? escapedLiteralString = default;
|
||||
string? unescapedLiteralString = default;
|
||||
Option<string?> escapedLiteralString = default;
|
||||
Option<string?> unescapedLiteralString = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -132,10 +146,10 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "escapedLiteralString":
|
||||
escapedLiteralString = utf8JsonReader.GetString();
|
||||
escapedLiteralString = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "unescapedLiteralString":
|
||||
unescapedLiteralString = utf8JsonReader.GetString();
|
||||
unescapedLiteralString = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? className = default;
|
||||
Option<string?> 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<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="mapMapOfString">mapMapOfString</param>
|
||||
/// <param name="mapOfEnumString">mapOfEnumString</param>
|
||||
[JsonConstructor]
|
||||
public MapTest(Dictionary<string, bool> directMap, Dictionary<string, bool> indirectMap, Dictionary<string, Dictionary<string, string>> mapMapOfString, Dictionary<string, MapTest.InnerEnum> mapOfEnumString)
|
||||
public MapTest(Option<Dictionary<string, bool>?> directMap = default, Option<Dictionary<string, bool>?> indirectMap = default, Option<Dictionary<string, Dictionary<string, string>>?> mapMapOfString = default, Option<Dictionary<string, MapTest.InnerEnum>?> 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
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DirectMap
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, bool>?> DirectMapOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DirectMap
|
||||
/// </summary>
|
||||
[JsonPropertyName("direct_map")]
|
||||
public Dictionary<string, bool> DirectMap { get; set; }
|
||||
public Dictionary<string, bool>? DirectMap { get { return this. DirectMapOption; } set { this.DirectMapOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of IndirectMap
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, bool>?> IndirectMapOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets IndirectMap
|
||||
/// </summary>
|
||||
[JsonPropertyName("indirect_map")]
|
||||
public Dictionary<string, bool> IndirectMap { get; set; }
|
||||
public Dictionary<string, bool>? IndirectMap { get { return this. IndirectMapOption; } set { this.IndirectMapOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapMapOfString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Dictionary<string, string>>?> MapMapOfStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapMapOfString
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_map_of_string")]
|
||||
public Dictionary<string, Dictionary<string, string>> MapMapOfString { get; set; }
|
||||
public Dictionary<string, Dictionary<string, string>>? MapMapOfString { get { return this. MapMapOfStringOption; } set { this.MapMapOfStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MapOfEnumString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, MapTest.InnerEnum>?> MapOfEnumStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MapOfEnumString
|
||||
/// </summary>
|
||||
[JsonPropertyName("map_of_enum_string")]
|
||||
public Dictionary<string, MapTest.InnerEnum> MapOfEnumString { get; set; }
|
||||
public Dictionary<string, MapTest.InnerEnum>? MapOfEnumString { get { return this. MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -198,10 +225,10 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
Dictionary<string, bool>? directMap = default;
|
||||
Dictionary<string, bool>? indirectMap = default;
|
||||
Dictionary<string, Dictionary<string, string>>? mapMapOfString = default;
|
||||
Dictionary<string, MapTest.InnerEnum>? mapOfEnumString = default;
|
||||
Option<Dictionary<string, bool>?> directMap = default;
|
||||
Option<Dictionary<string, bool>?> indirectMap = default;
|
||||
Option<Dictionary<string, Dictionary<string, string>>?> mapMapOfString = default;
|
||||
Option<Dictionary<string, MapTest.InnerEnum>?> mapOfEnumString = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -220,19 +247,19 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "direct_map":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
directMap = JsonSerializer.Deserialize<Dictionary<string, bool>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
directMap = new Option<Dictionary<string, bool>?>(JsonSerializer.Deserialize<Dictionary<string, bool>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "indirect_map":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
indirectMap = JsonSerializer.Deserialize<Dictionary<string, bool>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
indirectMap = new Option<Dictionary<string, bool>?>(JsonSerializer.Deserialize<Dictionary<string, bool>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_map_of_string":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapMapOfString = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapMapOfString = new Option<Dictionary<string, Dictionary<string, string>>?>(JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "map_of_enum_string":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
mapOfEnumString = JsonSerializer.Deserialize<Dictionary<string, MapTest.InnerEnum>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
mapOfEnumString = new Option<Dictionary<string, MapTest.InnerEnum>?>(JsonSerializer.Deserialize<Dictionary<string, MapTest.InnerEnum>>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,40 +40,68 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="uuid">uuid</param>
|
||||
/// <param name="uuidWithPattern">uuidWithPattern</param>
|
||||
[JsonConstructor]
|
||||
public MixedPropertiesAndAdditionalPropertiesClass(DateTime dateTime, Dictionary<string, Animal> map, Guid uuid, Guid uuidWithPattern)
|
||||
public MixedPropertiesAndAdditionalPropertiesClass(Option<DateTime?> dateTime = default, Option<Dictionary<string, Animal>?> map = default, Option<Guid?> uuid = default, Option<Guid?> uuidWithPattern = default)
|
||||
{
|
||||
DateTime = dateTime;
|
||||
Map = map;
|
||||
Uuid = uuid;
|
||||
UuidWithPattern = uuidWithPattern;
|
||||
DateTimeOption = dateTime;
|
||||
MapOption = map;
|
||||
UuidOption = uuid;
|
||||
UuidWithPatternOption = uuidWithPattern;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DateTime
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DateTime?> DateTimeOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DateTime
|
||||
/// </summary>
|
||||
[JsonPropertyName("dateTime")]
|
||||
public DateTime DateTime { get; set; }
|
||||
public DateTime? DateTime { get { return this. DateTimeOption; } set { this.DateTimeOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Map
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Animal>?> MapOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Map
|
||||
/// </summary>
|
||||
[JsonPropertyName("map")]
|
||||
public Dictionary<string, Animal> Map { get; set; }
|
||||
public Dictionary<string, Animal>? Map { get { return this. MapOption; } set { this.MapOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Uuid
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Guid?> UuidOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Uuid
|
||||
/// </summary>
|
||||
[JsonPropertyName("uuid")]
|
||||
public Guid Uuid { get; set; }
|
||||
public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of UuidWithPattern
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Guid?> UuidWithPatternOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets UuidWithPattern
|
||||
/// </summary>
|
||||
[JsonPropertyName("uuid_with_pattern")]
|
||||
public Guid UuidWithPattern { get; set; }
|
||||
public Guid? UuidWithPattern { get { return this. UuidWithPatternOption; } set { this.UuidWithPatternOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string, Animal>? map = default;
|
||||
Guid? uuid = default;
|
||||
Guid? uuidWithPattern = default;
|
||||
Option<DateTime?> dateTime = default;
|
||||
Option<Dictionary<string, Animal>?> map = default;
|
||||
Option<Guid?> uuid = default;
|
||||
Option<Guid?> uuidWithPattern = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -164,19 +193,19 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "dateTime":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
dateTime = JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
dateTime = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "map":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
map = JsonSerializer.Deserialize<Dictionary<string, Animal>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
map = new Option<Dictionary<string, Animal>?>(JsonSerializer.Deserialize<Dictionary<string, Animal>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "uuid":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
uuid = utf8JsonReader.GetGuid();
|
||||
uuid = new Option<Guid?>(utf8JsonReader.GetGuid());
|
||||
break;
|
||||
case "uuid_with_pattern":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
uuidWithPattern = utf8JsonReader.GetGuid();
|
||||
uuidWithPattern = new Option<Guid?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -223,11 +252,22 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,26 +38,40 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="varClass">varClass</param>
|
||||
/// <param name="name">name</param>
|
||||
[JsonConstructor]
|
||||
public Model200Response(string varClass, int name)
|
||||
public Model200Response(Option<string?> varClass = default, Option<int?> name = default)
|
||||
{
|
||||
VarClass = varClass;
|
||||
Name = name;
|
||||
VarClassOption = varClass;
|
||||
NameOption = name;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarClass
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> VarClassOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarClass
|
||||
/// </summary>
|
||||
[JsonPropertyName("class")]
|
||||
public string VarClass { get; set; }
|
||||
public string? VarClass { get { return this. VarClassOption; } set { this.VarClassOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Name
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> NameOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public int Name { get; set; }
|
||||
public int? Name { get { return this. NameOption; } set { this.NameOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -113,8 +127,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? varClass = default;
|
||||
int? name = default;
|
||||
Option<string?> varClass = default;
|
||||
Option<int?> name = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -132,11 +146,11 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "class":
|
||||
varClass = utf8JsonReader.GetString();
|
||||
varClass = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "name":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
name = utf8JsonReader.GetInt32();
|
||||
name = new Option<int?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -177,8 +191,14 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="varClient">varClient</param>
|
||||
[JsonConstructor]
|
||||
public ModelClient(string varClient)
|
||||
public ModelClient(Option<string?> varClient = default)
|
||||
{
|
||||
VarClient = varClient;
|
||||
VarClientOption = varClient;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of VarClient
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> VarClientOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarClient
|
||||
/// </summary>
|
||||
[JsonPropertyName("client")]
|
||||
public string VarClient { get; set; }
|
||||
public string? VarClient { get { return this. VarClientOption; } set { this.VarClientOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? varClient = default;
|
||||
Option<string?> varClient = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +129,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "client":
|
||||
varClient = utf8JsonReader.GetString();
|
||||
varClient = new Option<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,12 +40,12 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="snakeCase">snakeCase</param>
|
||||
/// <param name="var123Number">var123Number</param>
|
||||
[JsonConstructor]
|
||||
public Name(int varName, string property, int snakeCase, int var123Number)
|
||||
public Name(int varName, Option<string?> property = default, Option<int?> snakeCase = default, Option<int?> 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; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Property
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> PropertyOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Property
|
||||
/// </summary>
|
||||
[JsonPropertyName("property")]
|
||||
public string Property { get; set; }
|
||||
public string? Property { get { return this. PropertyOption; } set { this.PropertyOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of SnakeCase
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> SnakeCaseOption { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets SnakeCase
|
||||
/// </summary>
|
||||
[JsonPropertyName("snake_case")]
|
||||
public int SnakeCase { get; }
|
||||
public int? SnakeCase { get { return this. SnakeCaseOption; } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Var123Number
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> Var123NumberOption { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Var123Number
|
||||
/// </summary>
|
||||
[JsonPropertyName("123Number")]
|
||||
public int Var123Number { get; }
|
||||
public int? Var123Number { get { return this. Var123NumberOption; } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<int?> varName = default;
|
||||
Option<string?> property = default;
|
||||
Option<int?> snakeCase = default;
|
||||
Option<int?> 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<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "property":
|
||||
property = utf8JsonReader.GetString();
|
||||
property = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "snake_case":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
snakeCase = utf8JsonReader.GetInt32();
|
||||
snakeCase = new Option<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "123Number":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
var123Number = utf8JsonReader.GetInt32();
|
||||
var123Number = new Option<int?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -248,10 +276,19 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,8 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
List<Dictionary<string, Object>>? aObjVariableobject = default;
|
||||
int? pkiNotificationtestID = default;
|
||||
Option<List<Dictionary<string, Object>>?> aObjVariableobject = default;
|
||||
Option<int?> pkiNotificationtestID = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -133,11 +133,11 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "a_objVariableobject":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
aObjVariableobject = JsonSerializer.Deserialize<List<Dictionary<string, Object>>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
aObjVariableobject = new Option<List<Dictionary<string, Object>>?>(JsonSerializer.Deserialize<List<Dictionary<string, Object>>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "pkiNotificationtestID":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
pkiNotificationtestID = utf8JsonReader.GetInt32();
|
||||
pkiNotificationtestID = new Option<int?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -178,6 +184,9 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
|
@ -35,9 +35,8 @@ namespace UseSourceGeneration.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NullableClass" /> class.
|
||||
/// </summary>
|
||||
/// <param name="arrayItemsNullable">arrayItemsNullable</param>
|
||||
/// <param name="objectItemsNullable">objectItemsNullable</param>
|
||||
/// <param name="arrayAndItemsNullableProp">arrayAndItemsNullableProp</param>
|
||||
/// <param name="arrayItemsNullable">arrayItemsNullable</param>
|
||||
/// <param name="arrayNullableProp">arrayNullableProp</param>
|
||||
/// <param name="booleanProp">booleanProp</param>
|
||||
/// <param name="dateProp">dateProp</param>
|
||||
@ -45,99 +44,184 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="integerProp">integerProp</param>
|
||||
/// <param name="numberProp">numberProp</param>
|
||||
/// <param name="objectAndItemsNullableProp">objectAndItemsNullableProp</param>
|
||||
/// <param name="objectItemsNullable">objectItemsNullable</param>
|
||||
/// <param name="objectNullableProp">objectNullableProp</param>
|
||||
/// <param name="stringProp">stringProp</param>
|
||||
[JsonConstructor]
|
||||
public NullableClass(List<Object> arrayItemsNullable, Dictionary<string, Object> objectItemsNullable, List<Object>? arrayAndItemsNullableProp = default, List<Object>? arrayNullableProp = default, bool? booleanProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, int? integerProp = default, decimal? numberProp = default, Dictionary<string, Object>? objectAndItemsNullableProp = default, Dictionary<string, Object>? objectNullableProp = default, string? stringProp = default) : base()
|
||||
public NullableClass(Option<List<Object>?> arrayAndItemsNullableProp = default, Option<List<Object>?> arrayItemsNullable = default, Option<List<Object>?> arrayNullableProp = default, Option<bool?> booleanProp = default, Option<DateTime?> dateProp = default, Option<DateTime?> datetimeProp = default, Option<int?> integerProp = default, Option<decimal?> numberProp = default, Option<Dictionary<string, Object>?> objectAndItemsNullableProp = default, Option<Dictionary<string, Object>?> objectItemsNullable = default, Option<Dictionary<string, Object>?> objectNullableProp = default, Option<string?> 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();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayItemsNullable
|
||||
/// Used to track the state of ArrayAndItemsNullableProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_items_nullable")]
|
||||
public List<Object> ArrayItemsNullable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ObjectItemsNullable
|
||||
/// </summary>
|
||||
[JsonPropertyName("object_items_nullable")]
|
||||
public Dictionary<string, Object> ObjectItemsNullable { get; set; }
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<Object>?> ArrayAndItemsNullablePropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayAndItemsNullableProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_and_items_nullable_prop")]
|
||||
public List<Object>? ArrayAndItemsNullableProp { get; set; }
|
||||
public List<Object>? ArrayAndItemsNullableProp { get { return this. ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayItemsNullable
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<Object>?> ArrayItemsNullableOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayItemsNullable
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_items_nullable")]
|
||||
public List<Object>? ArrayItemsNullable { get { return this. ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ArrayNullableProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<Object>?> ArrayNullablePropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ArrayNullableProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("array_nullable_prop")]
|
||||
public List<Object>? ArrayNullableProp { get; set; }
|
||||
public List<Object>? ArrayNullableProp { get { return this. ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of BooleanProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<bool?> BooleanPropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets BooleanProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("boolean_prop")]
|
||||
public bool? BooleanProp { get; set; }
|
||||
public bool? BooleanProp { get { return this. BooleanPropOption; } set { this.BooleanPropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DateProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DateTime?> DatePropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DateProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("date_prop")]
|
||||
public DateTime? DateProp { get; set; }
|
||||
public DateTime? DateProp { get { return this. DatePropOption; } set { this.DatePropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DatetimeProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DateTime?> DatetimePropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DatetimeProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("datetime_prop")]
|
||||
public DateTime? DatetimeProp { get; set; }
|
||||
public DateTime? DatetimeProp { get { return this. DatetimePropOption; } set { this.DatetimePropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of IntegerProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> IntegerPropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets IntegerProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("integer_prop")]
|
||||
public int? IntegerProp { get; set; }
|
||||
public int? IntegerProp { get { return this. IntegerPropOption; } set { this.IntegerPropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of NumberProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<decimal?> NumberPropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets NumberProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("number_prop")]
|
||||
public decimal? NumberProp { get; set; }
|
||||
public decimal? NumberProp { get { return this. NumberPropOption; } set { this.NumberPropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ObjectAndItemsNullableProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Object>?> ObjectAndItemsNullablePropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ObjectAndItemsNullableProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("object_and_items_nullable_prop")]
|
||||
public Dictionary<string, Object>? ObjectAndItemsNullableProp { get; set; }
|
||||
public Dictionary<string, Object>? ObjectAndItemsNullableProp { get { return this. ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ObjectItemsNullable
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Object>?> ObjectItemsNullableOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ObjectItemsNullable
|
||||
/// </summary>
|
||||
[JsonPropertyName("object_items_nullable")]
|
||||
public Dictionary<string, Object>? ObjectItemsNullable { get { return this. ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ObjectNullableProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Dictionary<string, Object>?> ObjectNullablePropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ObjectNullableProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("object_nullable_prop")]
|
||||
public Dictionary<string, Object>? ObjectNullableProp { get; set; }
|
||||
public Dictionary<string, Object>? ObjectNullableProp { get { return this. ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of StringProp
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> StringPropOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets StringProp
|
||||
/// </summary>
|
||||
[JsonPropertyName("string_prop")]
|
||||
public string? StringProp { get; set; }
|
||||
public string? StringProp { get { return this. StringPropOption; } set { this.StringPropOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<Object>? arrayItemsNullable = default;
|
||||
Dictionary<string, Object>? objectItemsNullable = default;
|
||||
List<Object>? arrayAndItemsNullableProp = default;
|
||||
List<Object>? arrayNullableProp = default;
|
||||
bool? booleanProp = default;
|
||||
DateTime? dateProp = default;
|
||||
DateTime? datetimeProp = default;
|
||||
int? integerProp = default;
|
||||
decimal? numberProp = default;
|
||||
Dictionary<string, Object>? objectAndItemsNullableProp = default;
|
||||
Dictionary<string, Object>? objectNullableProp = default;
|
||||
string? stringProp = default;
|
||||
Option<List<Object>?> arrayAndItemsNullableProp = default;
|
||||
Option<List<Object>?> arrayItemsNullable = default;
|
||||
Option<List<Object>?> arrayNullableProp = default;
|
||||
Option<bool?> booleanProp = default;
|
||||
Option<DateTime?> dateProp = default;
|
||||
Option<DateTime?> datetimeProp = default;
|
||||
Option<int?> integerProp = default;
|
||||
Option<decimal?> numberProp = default;
|
||||
Option<Dictionary<string, Object>?> objectAndItemsNullableProp = default;
|
||||
Option<Dictionary<string, Object>?> objectItemsNullable = default;
|
||||
Option<Dictionary<string, Object>?> objectNullableProp = default;
|
||||
Option<string?> 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<List<Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "object_items_nullable":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
objectItemsNullable = JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "array_and_items_nullable_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayAndItemsNullableProp = JsonSerializer.Deserialize<List<Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayAndItemsNullableProp = new Option<List<Object>?>(JsonSerializer.Deserialize<List<Object>>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "array_items_nullable":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayItemsNullable = new Option<List<Object>?>(JsonSerializer.Deserialize<List<Object>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "array_nullable_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
arrayNullableProp = JsonSerializer.Deserialize<List<Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
arrayNullableProp = new Option<List<Object>?>(JsonSerializer.Deserialize<List<Object>>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "boolean_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
booleanProp = utf8JsonReader.GetBoolean();
|
||||
booleanProp = new Option<bool?>(utf8JsonReader.GetBoolean());
|
||||
break;
|
||||
case "date_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
dateProp = JsonSerializer.Deserialize<DateTime?>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
dateProp = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime?>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "datetime_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
datetimeProp = JsonSerializer.Deserialize<DateTime?>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
datetimeProp = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime?>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "integer_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
integerProp = utf8JsonReader.GetInt32();
|
||||
integerProp = new Option<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "number_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
numberProp = utf8JsonReader.GetDecimal();
|
||||
numberProp = new Option<decimal?>(utf8JsonReader.GetDecimal());
|
||||
break;
|
||||
case "object_and_items_nullable_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
objectAndItemsNullableProp = JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
objectAndItemsNullableProp = new Option<Dictionary<string, Object>?>(JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "object_items_nullable":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
objectItemsNullable = new Option<Dictionary<string, Object>?>(JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "object_nullable_prop":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
objectNullableProp = JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
objectNullableProp = new Option<Dictionary<string, Object>?>(JsonSerializer.Deserialize<Dictionary<string, Object>>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
break;
|
||||
case "string_prop":
|
||||
stringProp = utf8JsonReader.GetString();
|
||||
stringProp = new Option<string?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -338,45 +422,89 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,20 +37,27 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="uuid">uuid</param>
|
||||
[JsonConstructor]
|
||||
public NullableGuidClass(Guid? uuid = default)
|
||||
public NullableGuidClass(Option<Guid?> uuid = default)
|
||||
{
|
||||
Uuid = uuid;
|
||||
UuidOption = uuid;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Uuid
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Guid?> UuidOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Uuid
|
||||
/// </summary>
|
||||
/// <example>72f98069-206d-4f12-9f12-3d1e525a8e84</example>
|
||||
[JsonPropertyName("uuid")]
|
||||
public Guid? Uuid { get; set; }
|
||||
public Guid? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -105,7 +112,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
Guid? uuid = default;
|
||||
Option<Guid?> 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<Guid?>(utf8JsonReader.GetGuid());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -159,11 +166,11 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? shapeType = default;
|
||||
Option<string?> 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<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -37,19 +37,26 @@ namespace UseSourceGeneration.Model
|
||||
/// </summary>
|
||||
/// <param name="justNumber">justNumber</param>
|
||||
[JsonConstructor]
|
||||
public NumberOnly(decimal justNumber)
|
||||
public NumberOnly(Option<decimal?> justNumber = default)
|
||||
{
|
||||
JustNumber = justNumber;
|
||||
JustNumberOption = justNumber;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of JustNumber
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<decimal?> JustNumberOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets JustNumber
|
||||
/// </summary>
|
||||
[JsonPropertyName("JustNumber")]
|
||||
public decimal JustNumber { get; set; }
|
||||
public decimal? JustNumber { get { return this. JustNumberOption; } set { this.JustNumberOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -104,7 +111,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
decimal? justNumber = default;
|
||||
Option<decimal?> 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<decimal?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -161,7 +168,8 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,43 +40,71 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="id">id</param>
|
||||
/// <param name="uuid">uuid</param>
|
||||
[JsonConstructor]
|
||||
public ObjectWithDeprecatedFields(List<string> bars, DeprecatedObject deprecatedRef, decimal id, string uuid)
|
||||
public ObjectWithDeprecatedFields(Option<List<string>?> bars = default, Option<DeprecatedObject?> deprecatedRef = default, Option<decimal?> id = default, Option<string?> uuid = default)
|
||||
{
|
||||
Bars = bars;
|
||||
DeprecatedRef = deprecatedRef;
|
||||
Id = id;
|
||||
Uuid = uuid;
|
||||
BarsOption = bars;
|
||||
DeprecatedRefOption = deprecatedRef;
|
||||
IdOption = id;
|
||||
UuidOption = uuid;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Bars
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<string>?> BarsOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Bars
|
||||
/// </summary>
|
||||
[JsonPropertyName("bars")]
|
||||
[Obsolete]
|
||||
public List<string> Bars { get; set; }
|
||||
public List<string>? Bars { get { return this. BarsOption; } set { this.BarsOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of DeprecatedRef
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DeprecatedObject?> DeprecatedRefOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DeprecatedRef
|
||||
/// </summary>
|
||||
[JsonPropertyName("deprecatedRef")]
|
||||
[Obsolete]
|
||||
public DeprecatedObject DeprecatedRef { get; set; }
|
||||
public DeprecatedObject? DeprecatedRef { get { return this. DeprecatedRefOption; } set { this.DeprecatedRefOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Id
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<decimal?> IdOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
[Obsolete]
|
||||
public decimal Id { get; set; }
|
||||
public decimal? Id { get { return this. IdOption; } set { this.IdOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Uuid
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> UuidOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Uuid
|
||||
/// </summary>
|
||||
[JsonPropertyName("uuid")]
|
||||
public string Uuid { get; set; }
|
||||
public string? Uuid { get { return this. UuidOption; } set { this.UuidOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
@ -134,10 +162,10 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
List<string>? bars = default;
|
||||
DeprecatedObject? deprecatedRef = default;
|
||||
decimal? id = default;
|
||||
string? uuid = default;
|
||||
Option<List<string>?> bars = default;
|
||||
Option<DeprecatedObject?> deprecatedRef = default;
|
||||
Option<decimal?> id = default;
|
||||
Option<string?> uuid = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -156,18 +184,18 @@ namespace UseSourceGeneration.Model
|
||||
{
|
||||
case "bars":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
bars = JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
bars = new Option<List<string>?>(JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "deprecatedRef":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
deprecatedRef = JsonSerializer.Deserialize<DeprecatedObject>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
deprecatedRef = new Option<DeprecatedObject?>(JsonSerializer.Deserialize<DeprecatedObject>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "id":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
id = utf8JsonReader.GetDecimal();
|
||||
id = new Option<decimal?>(utf8JsonReader.GetDecimal());
|
||||
break;
|
||||
case "uuid":
|
||||
uuid = utf8JsonReader.GetString();
|
||||
uuid = new Option<string?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -214,12 +242,30 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,21 +35,21 @@ namespace UseSourceGeneration.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Order" /> class.
|
||||
/// </summary>
|
||||
/// <param name="complete">complete (default to false)</param>
|
||||
/// <param name="id">id</param>
|
||||
/// <param name="petId">petId</param>
|
||||
/// <param name="quantity">quantity</param>
|
||||
/// <param name="shipDate">shipDate</param>
|
||||
/// <param name="status">Order Status</param>
|
||||
/// <param name="complete">complete (default to false)</param>
|
||||
[JsonConstructor]
|
||||
public Order(long id, long petId, int quantity, DateTime shipDate, StatusEnum status, bool complete = false)
|
||||
public Order(Option<bool?> complete = default, Option<long?> id = default, Option<long?> petId = default, Option<int?> quantity = default, Option<DateTime?> shipDate = default, Option<StatusEnum?> 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
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Status
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<StatusEnum?> StatusOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
/// <value>Order Status</value>
|
||||
[JsonPropertyName("status")]
|
||||
public StatusEnum Status { get; set; }
|
||||
public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Complete
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<bool?> CompleteOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Complete
|
||||
/// </summary>
|
||||
[JsonPropertyName("complete")]
|
||||
public bool? Complete { get { return this. CompleteOption; } set { this.CompleteOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Id
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<long?> IdOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of PetId
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<long?> PetIdOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PetId
|
||||
/// </summary>
|
||||
[JsonPropertyName("petId")]
|
||||
public long PetId { get; set; }
|
||||
public long? PetId { get { return this. PetIdOption; } set { this.PetIdOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Quantity
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<int?> QuantityOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Quantity
|
||||
/// </summary>
|
||||
[JsonPropertyName("quantity")]
|
||||
public int Quantity { get; set; }
|
||||
public int? Quantity { get { return this. QuantityOption; } set { this.QuantityOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of ShipDate
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<DateTime?> ShipDateOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ShipDate
|
||||
/// </summary>
|
||||
/// <example>2020-02-02T20:20:20.000222Z</example>
|
||||
[JsonPropertyName("shipDate")]
|
||||
public DateTime ShipDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Complete
|
||||
/// </summary>
|
||||
[JsonPropertyName("complete")]
|
||||
public bool Complete { get; set; }
|
||||
public DateTime? ShipDate { get { return this. ShipDateOption; } set { this.ShipDateOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<bool?> complete = default;
|
||||
Option<long?> id = default;
|
||||
Option<long?> petId = default;
|
||||
Option<int?> quantity = default;
|
||||
Option<DateTime?> shipDate = default;
|
||||
Option<Order.StatusEnum?> status = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -260,31 +301,30 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "complete":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
complete = new Option<bool?>(utf8JsonReader.GetBoolean());
|
||||
break;
|
||||
case "id":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
id = utf8JsonReader.GetInt64();
|
||||
id = new Option<long?>(utf8JsonReader.GetInt64());
|
||||
break;
|
||||
case "petId":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
petId = utf8JsonReader.GetInt64();
|
||||
petId = new Option<long?>(utf8JsonReader.GetInt64());
|
||||
break;
|
||||
case "quantity":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
quantity = utf8JsonReader.GetInt32();
|
||||
quantity = new Option<int?>(utf8JsonReader.GetInt32());
|
||||
break;
|
||||
case "shipDate":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
shipDate = JsonSerializer.Deserialize<DateTime>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
shipDate = new Option<DateTime?>(JsonSerializer.Deserialize<DateTime>(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.StatusEnum?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -337,18 +377,26 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,33 +39,54 @@ namespace UseSourceGeneration.Model
|
||||
/// <param name="myNumber">myNumber</param>
|
||||
/// <param name="myString">myString</param>
|
||||
[JsonConstructor]
|
||||
public OuterComposite(bool myBoolean, decimal myNumber, string myString)
|
||||
public OuterComposite(Option<bool?> myBoolean = default, Option<decimal?> myNumber = default, Option<string?> myString = default)
|
||||
{
|
||||
MyBoolean = myBoolean;
|
||||
MyNumber = myNumber;
|
||||
MyString = myString;
|
||||
MyBooleanOption = myBoolean;
|
||||
MyNumberOption = myNumber;
|
||||
MyStringOption = myString;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MyBoolean
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<bool?> MyBooleanOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MyBoolean
|
||||
/// </summary>
|
||||
[JsonPropertyName("my_boolean")]
|
||||
public bool MyBoolean { get; set; }
|
||||
public bool? MyBoolean { get { return this. MyBooleanOption; } set { this.MyBooleanOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MyNumber
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<decimal?> MyNumberOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MyNumber
|
||||
/// </summary>
|
||||
[JsonPropertyName("my_number")]
|
||||
public decimal MyNumber { get; set; }
|
||||
public decimal? MyNumber { get { return this. MyNumberOption; } set { this.MyNumberOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of MyString
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<string?> MyStringOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets MyString
|
||||
/// </summary>
|
||||
[JsonPropertyName("my_string")]
|
||||
public string MyString { get; set; }
|
||||
public string? MyString { get { return this. MyStringOption; } set { this.MyStringOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<bool?> myBoolean = default;
|
||||
Option<decimal?> myNumber = default;
|
||||
Option<string?> 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<bool?>(utf8JsonReader.GetBoolean());
|
||||
break;
|
||||
case "my_number":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
myNumber = utf8JsonReader.GetDecimal();
|
||||
myNumber = new Option<decimal?>(utf8JsonReader.GetDecimal());
|
||||
break;
|
||||
case "my_string":
|
||||
myString = utf8JsonReader.GetString();
|
||||
myString = new Option<string?>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -194,9 +215,17 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? petType = default;
|
||||
Option<string?> petType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -98,7 +98,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "pet_type":
|
||||
petType = utf8JsonReader.GetString();
|
||||
petType = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -136,6 +139,9 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -35,21 +35,21 @@ namespace UseSourceGeneration.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Pet" /> class.
|
||||
/// </summary>
|
||||
/// <param name="category">category</param>
|
||||
/// <param name="id">id</param>
|
||||
/// <param name="name">name</param>
|
||||
/// <param name="photoUrls">photoUrls</param>
|
||||
/// <param name="category">category</param>
|
||||
/// <param name="id">id</param>
|
||||
/// <param name="status">pet status in the store</param>
|
||||
/// <param name="tags">tags</param>
|
||||
[JsonConstructor]
|
||||
public Pet(Category category, long id, string name, List<string> photoUrls, StatusEnum status, List<Tag> tags)
|
||||
public Pet(string name, List<string> photoUrls, Option<Category?> category = default, Option<long?> id = default, Option<StatusEnum?> status = default, Option<List<Tag>?> 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
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Status
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<StatusEnum?> StatusOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
/// <value>pet status in the store</value>
|
||||
[JsonPropertyName("status")]
|
||||
public StatusEnum Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Category
|
||||
/// </summary>
|
||||
[JsonPropertyName("category")]
|
||||
public Category Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
@ -169,11 +163,44 @@ namespace UseSourceGeneration.Model
|
||||
[JsonPropertyName("photoUrls")]
|
||||
public List<string> PhotoUrls { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Category
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<Category?> CategoryOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Category
|
||||
/// </summary>
|
||||
[JsonPropertyName("category")]
|
||||
public Category? Category { get { return this. CategoryOption; } set { this.CategoryOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Id
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<long?> IdOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
public long? Id { get { return this. IdOption; } set { this.IdOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Used to track the state of Tags
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<List<Tag>?> TagsOption { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Tags
|
||||
/// </summary>
|
||||
[JsonPropertyName("tags")]
|
||||
public List<Tag> Tags { get; set; }
|
||||
public List<Tag>? Tags { get { return this. TagsOption; } set { this.TagsOption = new(value); } }
|
||||
|
||||
/// <summary>
|
||||
/// 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<string>? photoUrls = default;
|
||||
Pet.StatusEnum? status = default;
|
||||
List<Tag>? tags = default;
|
||||
Option<string?> name = default;
|
||||
Option<List<string>?> photoUrls = default;
|
||||
Option<Category?> category = default;
|
||||
Option<long?> id = default;
|
||||
Option<Pet.StatusEnum?> status = default;
|
||||
Option<List<Tag>?> tags = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -255,30 +282,29 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "category":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
category = JsonSerializer.Deserialize<Category>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
break;
|
||||
case "id":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
id = utf8JsonReader.GetInt64();
|
||||
break;
|
||||
case "name":
|
||||
name = utf8JsonReader.GetString();
|
||||
name = new Option<string?>(utf8JsonReader.GetString()!);
|
||||
break;
|
||||
case "photoUrls":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
photoUrls = JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
photoUrls = new Option<List<string>?>(JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "category":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
category = new Option<Category?>(JsonSerializer.Deserialize<Category>(ref utf8JsonReader, jsonSerializerOptions)!);
|
||||
break;
|
||||
case "id":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
id = new Option<long?>(utf8JsonReader.GetInt64());
|
||||
break;
|
||||
case "status":
|
||||
string? statusRawValue = utf8JsonReader.GetString();
|
||||
status = statusRawValue == null
|
||||
? null
|
||||
: Pet.StatusEnumFromStringOrDefault(statusRawValue);
|
||||
if (statusRawValue != null)
|
||||
status = new Option<Pet.StatusEnum?>(Pet.StatusEnumFromStringOrDefault(statusRawValue));
|
||||
break;
|
||||
case "tags":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
tags = JsonSerializer.Deserialize<List<Tag>>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
tags = new Option<List<Tag>?>(JsonSerializer.Deserialize<List<Tag>>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -331,21 +363,41 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? className = default;
|
||||
Option<string?> 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<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? quadrilateralType = default;
|
||||
Option<string?> 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<string?>(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
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ namespace UseSourceGeneration.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? quadrilateralType = default;
|
||||
Option<string?> quadrilateralType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
@ -122,7 +122,7 @@ namespace UseSourceGeneration.Model
|
||||
switch (localVarJsonPropertyName)
|
||||
{
|
||||
case "quadrilateralType":
|
||||
quadrilateralType = utf8JsonReader.GetString();
|
||||
quadrilateralType = new Option<string?>(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!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,6 +163,9 @@ namespace UseSourceGeneration.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user