[csharp][generichost] Remove discriminator property (#18445)

* fixed nullability

* minor refactor to address a comment

* removed discriminator property

* update more manual tests

* update more manual tests

* added tests and bug fixes

* fixed allof

* reworked manual tests to compare json instead of classes, reworked discriminator logic

* removed unneeded code
This commit is contained in:
devhl-labs 2024-05-21 02:32:12 -04:00 committed by GitHub
parent 27120357aa
commit ede6458d19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
446 changed files with 2326 additions and 2055 deletions

View File

@ -589,10 +589,21 @@ public class DefaultCodegen implements CodegenConfig {
return objs;
}
/**
* A property is new if it is in a derived class and the derived property is different.
* This usually occurs when the data type is different.
* We can also consider discriminators as new because the derived class discriminator will have to be defined again
* to contain a new value. Doing so prevents having to include the discriminator in the constructor.
* @param model
* @param property
* @return
*/
private boolean codegenPropertyIsNew(CodegenModel model, CodegenProperty property) {
return model.parentModel == null
? false
: model.parentModel.allVars.stream().anyMatch(p -> p.name.equals(property.name) && (p.dataType.equals(property.dataType) == false || p.datatypeWithEnum.equals(property.datatypeWithEnum) == false));
: model.parentModel.allVars.stream().anyMatch(p ->
p.name.equals(property.name) &&
(p.dataType.equals(property.dataType) == false || p.datatypeWithEnum.equals(property.datatypeWithEnum) == false || p.isDiscriminator));
}
/**

View File

@ -336,6 +336,43 @@ using System.Runtime.CompilerServices;
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
/// <summary>
/// Get the discriminator
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="discriminator"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public static string{{nrt?}} GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string{{nrt?}} localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator))
return utf8JsonReader.GetString();
}
}
throw new JsonException("The specified discriminator was not found.");
}
/// <summary>
/// The base path of the API
/// </summary>

View File

@ -44,6 +44,17 @@
{{/-last}}
{{/allVars}}
{{#discriminator}}
{{#children}}
{{#-first}}
string{{nrt?}} discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "{{discriminator.propertyBaseName}}");
{{/-first}}
if (discriminator != null && discriminator.Equals("{{name}}"))
return JsonSerializer.Deserialize<{{{name}}}>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
{{/children}}
{{/discriminator}}
{{#model.discriminator}}
{{#model.hasDiscriminatorWithNonEmptyMapping}}
{{#mappedModels}}
@ -281,7 +292,7 @@
{{#model.hasDiscriminatorWithNonEmptyMapping}}
{{#mappedModels}}
if ({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}} != null)
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/isDiscriminator}}{{/allVars}}{{/lambda.joinWithComma}});
{{#-last}}
throw new JsonException();
@ -300,14 +311,14 @@
{{/-last}}
{{/required}}
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}ParsedValue{{#required}}.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}ParsedValue{{#required}}.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/isDiscriminator}}{{/allVars}}{{/lambda.joinWithComma}});
{{/composedSchemas.oneOf}}
{{^model.discriminator}}
{{#composedSchemas}}
{{#oneOf}}
{{^vendorExtensions.x-duplicated-data-type}}
if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} != null)
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}ParsedValue{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}ParsedValue{{/required}} {{/isDiscriminator}}{{/allVars}}{{/lambda.joinWithComma}});
{{/vendorExtensions.x-duplicated-data-type}}
{{#-last}}
@ -331,6 +342,18 @@
public override void Write(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions)
{
{{#lambda.trimLineBreaks}}
{{#lambda.copy}}
{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}
{{/lambda.copy}}
{{#discriminator}}
{{#children}}
if ({{#lambda.pasteLine}}{{/lambda.pasteLine}} is {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}){
JsonSerializer.Serialize<{{{name}}}>(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions);
return;
}
{{/children}}
{{/discriminator}}
writer.WriteStartObject();
{{#model.discriminator}}
@ -339,7 +362,7 @@
{{^vendorExtensions.x-duplicated-data-type}}
if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} != null) {
{{baseType}}JsonConverter {{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}} = ({{baseType}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}.GetType()));
{{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}}.WriteProperties(ref writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}, jsonSerializerOptions);
{{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}}.WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}, jsonSerializerOptions);
}
{{/vendorExtensions.x-duplicated-data-type}}
@ -352,13 +375,13 @@
if ({{#lambda.joinWithAmpersand}}{{^required}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet {{/required}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}} != null{{/lambda.joinWithAmpersand}})
{
{{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}.GetType()));
{{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions);
{{datatypeWithEnum}}JsonConverter.WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions);
}
{{/anyOf}}
{{/composedSchemas}}
{{/model.discriminator}}
WriteProperties(ref writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions);
WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions);
writer.WriteEndObject();
{{/lambda.trimLineBreaks}}
}
@ -370,11 +393,12 @@
/// <param name="{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions)
{
{{#lambda.trimTrailingWithNewLine}}
{{#lambda.trimLineBreaks}}
{{#allVars}}
{{^isDiscriminator}}
{{^isNullable}}
{{#vendorExtensions.x-is-reference-type}}
if ({{^required}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet && {{/required}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} == null)
@ -382,8 +406,18 @@
{{/vendorExtensions.x-is-reference-type}}
{{/isNullable}}
{{/isDiscriminator}}
{{/allVars}}
{{#allVars}}
{{#isDiscriminator}}
{{^model.composedSchemas.anyOf}}
{{^model.composedSchemas.oneOf}}
writer.WriteString("{{baseName}}", {{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{/isEnum}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}.Value{{/required}}){{/isEnum}}{{/isNew}});
{{/model.composedSchemas.oneOf}}
{{/model.composedSchemas.anyOf}}
{{/isDiscriminator}}
{{^isDiscriminator}}
{{#isString}}
{{^isMap}}
{{^isEnum}}
@ -579,6 +613,7 @@
{{/isString}}
{{/isEnum}}
{{/isUuid}}
{{/isDiscriminator}}
{{/allVars}}
{{/lambda.trimLineBreaks}}
{{/lambda.trimTrailingWithNewLine}}

View File

@ -1 +1 @@
{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{parent}}{{/lambda.camelcase_sanitize_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}}
{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{parent}}{{/lambda.camelcase_sanitize_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/isDiscriminator}}{{/allVars}}

View File

@ -1 +1 @@
{{#model.allVars}}{{^required}}Option<{{/required}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}{{#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}}
{{#model.allVars}}{{^isDiscriminator}}{{^required}}Option<{{/required}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}{{#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}} {{/isDiscriminator}}{{/model.allVars}}

View File

@ -13,7 +13,9 @@
/// <param name="{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}"></param>
{{/composedSchemas.anyOf}}
{{#allVars}}
{{^isDiscriminator}}
/// <param name="{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}">{{description}}{{^description}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}</param>
{{/isDiscriminator}}
{{/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.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}} {{#model.composedSchemas.anyOf}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{baseType}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}} {{/model.composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#parentModel.composedSchemas.oneOf}}{{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{parent}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.oneOf}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}}
{
@ -22,6 +24,7 @@
{{/composedSchemas.anyOf}}
{{name}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}};
{{#allVars}}
{{^isDiscriminator}}
{{^isInherited}}
{{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}};
{{/isInherited}}
@ -30,6 +33,7 @@
{{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}};
{{/isNew}}
{{/isInherited}}
{{/isDiscriminator}}
{{/allVars}}
OnCreated();
}
@ -44,7 +48,9 @@
/// <param name="{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}"></param>
{{/composedSchemas.anyOf}}
{{#allVars}}
{{^isDiscriminator}}
/// <param name="{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}">{{description}}{{^description}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}</param>
{{/isDiscriminator}}
{{/allVars}}
{{^composedSchemas.anyOf}}
[JsonConstructor]
@ -55,6 +61,7 @@
{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}};
{{/composedSchemas.anyOf}}
{{#allVars}}
{{^isDiscriminator}}
{{^isInherited}}
{{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}};
{{/isInherited}}
@ -63,6 +70,7 @@
{{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}};
{{/isNew}}
{{/isInherited}}
{{/isDiscriminator}}
{{/allVars}}
OnCreated();
}
@ -83,6 +91,7 @@
{{>modelInnerEnum}}
{{/complexType}}
{{/isEnum}}
{{^isDiscriminator}}
{{#isEnum}}
{{^required}}
/// <summary>
@ -109,6 +118,7 @@
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}}
{{/isDiscriminator}}
{{/vars}}
{{#composedSchemas.anyOf}}
{{^vendorExtensions.x-duplicated-data-type}}
@ -152,6 +162,20 @@
{{/vendorExtensions.x-duplicated-data-type}}
{{/composedSchemas.oneOf}}
{{#allVars}}
{{#isDiscriminator}}
{{^model.composedSchemas.anyOf}}
{{^model.composedSchemas.oneOf}}
/// <summary>
/// The discriminator
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public {{#isNew}}new {{/isNew}}{{datatypeWithEnum}} {{name}} { get; } = {{^isNew}}"{{classname}}"{{/isNew}}{{#isNew}}{{^isEnum}}"{{classname}}"{{/isEnum}}{{#isEnum}}({{datatypeWithEnum}})Enum.Parse(typeof({{datatypeWithEnum}}), "{{classname}}"){{/isEnum}}{{/isNew}};
{{/model.composedSchemas.oneOf}}
{{/model.composedSchemas.anyOf}}
{{/isDiscriminator}}
{{^isDiscriminator}}
{{^isEnum}}
{{#isInherited}}
{{#isNew}}
@ -204,6 +228,7 @@
{{/isInherited}}
{{/isEnum}}
{{/isDiscriminator}}
{{/allVars}}
{{#isAdditionalPropertiesTrue}}
{{^parentModel}}
@ -227,7 +252,9 @@
sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n");
{{/parent}}
{{#vars}}
{{^isDiscriminator}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/isDiscriminator}}
{{/vars}}
{{#isAdditionalPropertiesTrue}}
{{^parentModel}}

View File

@ -266,6 +266,43 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
/// <summary>
/// Get the discriminator
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="discriminator"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public static string? GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string? localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator))
return utf8JsonReader.GetString();
}
}
throw new JsonException("The specified discriminator was not found.");
}
/// <summary>
/// The base path of the API
/// </summary>

View File

@ -37,9 +37,8 @@ namespace Org.OpenAPITools.Model
/// <param name="children">children</param>
/// <param name="firstName">firstName</param>
/// <param name="lastName">lastName</param>
/// <param name="type">type</param>
[JsonConstructor]
public Adult(Option<List<Child>?> children = default, Option<string?> firstName = default, Option<string?> lastName = default, Option<string?> type = default) : base(firstName, lastName, type)
public Adult(Option<List<Child>?> children = default, Option<string?> firstName = default, Option<string?> lastName = default) : base(firstName, lastName)
{
ChildrenOption = children;
OnCreated();
@ -60,6 +59,13 @@ namespace Org.OpenAPITools.Model
[JsonPropertyName("children")]
public List<Child>? Children { get { return this.ChildrenOption; } set { this.ChildrenOption = new(value); } }
/// <summary>
/// The discriminator
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public new string Type { get; } = "Adult";
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -148,7 +154,7 @@ namespace Org.OpenAPITools.Model
if (type.IsSet && type.Value == null)
throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult.");
return new Adult(children, firstName, lastName, type);
return new Adult(children, firstName, lastName);
}
/// <summary>
@ -162,7 +168,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, adult, jsonSerializerOptions);
WriteProperties(writer, adult, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -173,7 +179,7 @@ namespace Org.OpenAPITools.Model
/// <param name="adult"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions)
{
if (adult.ChildrenOption.IsSet && adult.Children == null)
throw new ArgumentNullException(nameof(adult.Children), "Property is required for class Adult.");
@ -184,9 +190,6 @@ namespace Org.OpenAPITools.Model
if (adult.LastNameOption.IsSet && adult.LastName == null)
throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
if (adult.TypeOption.IsSet && adult.Type == null)
throw new ArgumentNullException(nameof(adult.Type), "Property is required for class Adult.");
if (adult.ChildrenOption.IsSet)
{
writer.WritePropertyName("children");
@ -198,8 +201,7 @@ namespace Org.OpenAPITools.Model
if (adult.LastNameOption.IsSet)
writer.WriteString("lastName", adult.LastName);
if (adult.TypeOption.IsSet)
writer.WriteString("$_type", adult.Type);
writer.WriteString("$_type", adult.Type);
}
}
}

View File

@ -37,10 +37,9 @@ namespace Org.OpenAPITools.Model
/// <param name="age">age</param>
/// <param name="firstName">firstName</param>
/// <param name="lastName">lastName</param>
/// <param name="type">type</param>
/// <param name="boosterSeat">boosterSeat</param>
[JsonConstructor]
public Child(Option<int?> age = default, Option<string?> firstName = default, Option<string?> lastName = default, Option<string?> type = default, Option<bool?> boosterSeat = default) : base(firstName, lastName, type)
public Child(Option<int?> age = default, Option<string?> firstName = default, Option<string?> lastName = default, Option<bool?> boosterSeat = default) : base(firstName, lastName)
{
AgeOption = age;
BoosterSeatOption = boosterSeat;
@ -62,6 +61,13 @@ namespace Org.OpenAPITools.Model
[JsonPropertyName("age")]
public int? Age { get { return this.AgeOption; } set { this.AgeOption = new(value); } }
/// <summary>
/// The discriminator
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public new string Type { get; } = "Child";
/// <summary>
/// Used to track the state of BoosterSeat
/// </summary>
@ -172,7 +178,7 @@ namespace Org.OpenAPITools.Model
if (boosterSeat.IsSet && boosterSeat.Value == null)
throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child.");
return new Child(age, firstName, lastName, type, boosterSeat);
return new Child(age, firstName, lastName, boosterSeat);
}
/// <summary>
@ -186,7 +192,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, child, jsonSerializerOptions);
WriteProperties(writer, child, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -197,7 +203,7 @@ namespace Org.OpenAPITools.Model
/// <param name="child"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
if (child.FirstNameOption.IsSet && child.FirstName == null)
throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
@ -205,9 +211,6 @@ namespace Org.OpenAPITools.Model
if (child.LastNameOption.IsSet && child.LastName == null)
throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
if (child.TypeOption.IsSet && child.Type == null)
throw new ArgumentNullException(nameof(child.Type), "Property is required for class Child.");
if (child.AgeOption.IsSet)
writer.WriteNumber("age", child.AgeOption.Value!.Value);
@ -217,8 +220,7 @@ namespace Org.OpenAPITools.Model
if (child.LastNameOption.IsSet)
writer.WriteString("lastName", child.LastName);
if (child.TypeOption.IsSet)
writer.WriteString("$_type", child.Type);
writer.WriteString("$_type", child.Type);
if (child.BoosterSeatOption.IsSet)
writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);

View File

@ -36,13 +36,11 @@ namespace Org.OpenAPITools.Model
/// </summary>
/// <param name="firstName">firstName</param>
/// <param name="lastName">lastName</param>
/// <param name="type">type</param>
[JsonConstructor]
public Person(Option<string?> firstName = default, Option<string?> lastName = default, Option<string?> type = default)
public Person(Option<string?> firstName = default, Option<string?> lastName = default)
{
FirstNameOption = firstName;
LastNameOption = lastName;
TypeOption = type;
OnCreated();
}
@ -75,17 +73,11 @@ namespace Org.OpenAPITools.Model
public string? LastName { get { return this.LastNameOption; } set { this.LastNameOption = new(value); } }
/// <summary>
/// Used to track the state of Type
/// The discriminator
/// </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 { return this.TypeOption; } set { this.TypeOption = new(value); } }
public string Type { get; } = "Person";
/// <summary>
/// Gets or Sets additional properties
@ -103,7 +95,6 @@ namespace Org.OpenAPITools.Model
sb.Append("class Person {\n");
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
sb.Append(" LastName: ").Append(LastName).Append("\n");
sb.Append(" Type: ").Append(Type).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -156,6 +147,14 @@ namespace Org.OpenAPITools.Model
Option<string?> lastName = default;
Option<string?> type = default;
string? discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$_type");
if (discriminator != null && discriminator.Equals("Adult"))
return JsonSerializer.Deserialize<Adult>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
if (discriminator != null && discriminator.Equals("Child"))
return JsonSerializer.Deserialize<Child>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
@ -195,7 +194,7 @@ namespace Org.OpenAPITools.Model
if (type.IsSet && type.Value == null)
throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person.");
return new Person(firstName, lastName, type);
return new Person(firstName, lastName);
}
/// <summary>
@ -207,9 +206,19 @@ namespace Org.OpenAPITools.Model
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions)
{
if (person is Adult adult){
JsonSerializer.Serialize<Adult>(writer, adult, jsonSerializerOptions);
return;
}
if (person is Child child){
JsonSerializer.Serialize<Child>(writer, child, jsonSerializerOptions);
return;
}
writer.WriteStartObject();
WriteProperties(ref writer, person, jsonSerializerOptions);
WriteProperties(writer, person, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -220,7 +229,7 @@ namespace Org.OpenAPITools.Model
/// <param name="person"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions)
{
if (person.FirstNameOption.IsSet && person.FirstName == null)
throw new ArgumentNullException(nameof(person.FirstName), "Property is required for class Person.");
@ -228,17 +237,13 @@ namespace Org.OpenAPITools.Model
if (person.LastNameOption.IsSet && person.LastName == null)
throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
if (person.TypeOption.IsSet && person.Type == null)
throw new ArgumentNullException(nameof(person.Type), "Property is required for class Person.");
if (person.FirstNameOption.IsSet)
writer.WriteString("firstName", person.FirstName);
if (person.LastNameOption.IsSet)
writer.WriteString("lastName", person.LastName);
if (person.TypeOption.IsSet)
writer.WriteString("$_type", person.Type);
writer.WriteString("$_type", person.Type);
}
}
}

View File

@ -266,6 +266,43 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
/// <summary>
/// Get the discriminator
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="discriminator"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public static string? GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string? localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator))
return utf8JsonReader.GetString();
}
}
throw new JsonException("The specified discriminator was not found.");
}
/// <summary>
/// The base path of the API
/// </summary>

View File

@ -153,7 +153,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, apple, jsonSerializerOptions);
WriteProperties(writer, apple, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -164,7 +164,7 @@ namespace Org.OpenAPITools.Model
/// <param name="apple"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
if (apple.KindOption.IsSet && apple.Kind == null)
throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");

View File

@ -154,7 +154,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, banana, jsonSerializerOptions);
WriteProperties(writer, banana, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -165,7 +165,7 @@ namespace Org.OpenAPITools.Model
/// <param name="banana"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);

View File

@ -212,16 +212,16 @@ namespace Org.OpenAPITools.Model
if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null)
{
AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType()));
AppleJsonConverter.WriteProperties(ref writer, fruit.AppleOption.Value, jsonSerializerOptions);
AppleJsonConverter.WriteProperties(writer, fruit.AppleOption.Value, jsonSerializerOptions);
}
if (fruit.BananaOption.IsSet && fruit.BananaOption.Value != null)
{
BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.BananaOption.Value.GetType()));
BananaJsonConverter.WriteProperties(ref writer, fruit.BananaOption.Value, jsonSerializerOptions);
BananaJsonConverter.WriteProperties(writer, fruit.BananaOption.Value, jsonSerializerOptions);
}
WriteProperties(ref writer, fruit, jsonSerializerOptions);
WriteProperties(writer, fruit, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -232,7 +232,7 @@ namespace Org.OpenAPITools.Model
/// <param name="fruit"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
if (fruit.ColorOption.IsSet && fruit.Color == null)
throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");

View File

@ -251,6 +251,43 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
/// <summary>
/// Get the discriminator
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="discriminator"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public static string? GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string? localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator))
return utf8JsonReader.GetString();
}
}
throw new JsonException("The specified discriminator was not found.");
}
/// <summary>
/// The base path of the API
/// </summary>

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, apple, jsonSerializerOptions);
WriteProperties(writer, apple, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="apple"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
if (apple.KindOption.IsSet && apple.Kind == null)
throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");

View File

@ -153,7 +153,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, banana, jsonSerializerOptions);
WriteProperties(writer, banana, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -164,7 +164,7 @@ namespace Org.OpenAPITools.Model
/// <param name="banana"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
writer.WriteNumber("count", banana.CountOption.Value!.Value);

View File

@ -211,16 +211,16 @@ namespace Org.OpenAPITools.Model
if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null)
{
AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType()));
AppleJsonConverter.WriteProperties(ref writer, fruit.AppleOption.Value, jsonSerializerOptions);
AppleJsonConverter.WriteProperties(writer, fruit.AppleOption.Value, jsonSerializerOptions);
}
if (fruit.BananaOption.IsSet && fruit.BananaOption.Value != null)
{
BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.BananaOption.Value.GetType()));
BananaJsonConverter.WriteProperties(ref writer, fruit.BananaOption.Value, jsonSerializerOptions);
BananaJsonConverter.WriteProperties(writer, fruit.BananaOption.Value, jsonSerializerOptions);
}
WriteProperties(ref writer, fruit, jsonSerializerOptions);
WriteProperties(writer, fruit, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -231,7 +231,7 @@ namespace Org.OpenAPITools.Model
/// <param name="fruit"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
if (fruit.ColorOption.IsSet && fruit.Color == null)
throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");

View File

@ -355,6 +355,43 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
}
/// <summary>
/// Get the discriminator
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="discriminator"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator))
return utf8JsonReader.GetString();
}
}
throw new JsonException("The specified discriminator was not found.");
}
/// <summary>
/// The base path of the API
/// </summary>

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, activity, jsonSerializerOptions);
WriteProperties(writer, activity, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="activity"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");

View File

@ -175,7 +175,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions);
WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -186,7 +186,7 @@ namespace Org.OpenAPITools.Model
/// <param name="activityOutputElementRepresentation"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");

View File

@ -318,7 +318,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions);
WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -329,7 +329,7 @@ namespace Org.OpenAPITools.Model
/// <param name="additionalPropertiesClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");

View File

@ -32,12 +32,10 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="Animal" /> class.
/// </summary>
/// <param name="className">className</param>
/// <param name="color">color (default to &quot;red&quot;)</param>
[JsonConstructor]
public Animal(string className, Option<string> color = default)
public Animal(Option<string> color = default)
{
ClassName = className;
ColorOption = color;
OnCreated();
}
@ -45,10 +43,11 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets ClassName
/// The discriminator
/// </summary>
[JsonPropertyName("className")]
public string ClassName { get; set; }
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public string ClassName { get; } = "Animal";
/// <summary>
/// Used to track the state of Color
@ -77,7 +76,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class Animal {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" Color: ").Append(Color).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
@ -130,6 +128,14 @@ namespace Org.OpenAPITools.Model
Option<string> className = default;
Option<string> color = default;
string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "className");
if (discriminator != null && discriminator.Equals("Cat"))
return JsonSerializer.Deserialize<Cat>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
if (discriminator != null && discriminator.Equals("Dog"))
return JsonSerializer.Deserialize<Dog>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
@ -166,7 +172,7 @@ namespace Org.OpenAPITools.Model
if (color.IsSet && color.Value == null)
throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
return new Animal(className.Value, color);
return new Animal(color);
}
/// <summary>
@ -178,9 +184,19 @@ namespace Org.OpenAPITools.Model
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
if (animal is Cat cat){
JsonSerializer.Serialize<Cat>(writer, cat, jsonSerializerOptions);
return;
}
if (animal is Dog dog){
JsonSerializer.Serialize<Dog>(writer, dog, jsonSerializerOptions);
return;
}
writer.WriteStartObject();
WriteProperties(ref writer, animal, jsonSerializerOptions);
WriteProperties(writer, animal, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -191,11 +207,8 @@ namespace Org.OpenAPITools.Model
/// <param name="animal"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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.");

View File

@ -198,7 +198,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, apiResponse, jsonSerializerOptions);
WriteProperties(writer, apiResponse, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -209,7 +209,7 @@ namespace Org.OpenAPITools.Model
/// <param name="apiResponse"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");

View File

@ -227,7 +227,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, apple, jsonSerializerOptions);
WriteProperties(writer, apple, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -238,7 +238,7 @@ namespace Org.OpenAPITools.Model
/// <param name="apple"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");

View File

@ -164,7 +164,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, appleReq, jsonSerializerOptions);
WriteProperties(writer, appleReq, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -175,7 +175,7 @@ namespace Org.OpenAPITools.Model
/// <param name="appleReq"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
{
if (appleReq.Cultivar == null)
throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq.");

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions);
WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="arrayOfArrayOfNumberOnly"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions);
WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="arrayOfNumberOnly"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");

View File

@ -200,7 +200,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, arrayTest, jsonSerializerOptions);
WriteProperties(writer, arrayTest, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -211,7 +211,7 @@ namespace Org.OpenAPITools.Model
/// <param name="arrayTest"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, banana, jsonSerializerOptions);
WriteProperties(writer, banana, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="banana"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value);

View File

@ -165,7 +165,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, bananaReq, jsonSerializerOptions);
WriteProperties(writer, bananaReq, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -176,7 +176,7 @@ namespace Org.OpenAPITools.Model
/// <param name="bananaReq"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteNumber("lengthCm", bananaReq.LengthCm);

View File

@ -147,7 +147,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, basquePig, jsonSerializerOptions);
WriteProperties(writer, basquePig, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -158,7 +158,7 @@ namespace Org.OpenAPITools.Model
/// <param name="basquePig"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
{
if (basquePig.ClassName == null)
throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig.");

View File

@ -267,7 +267,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, capitalization, jsonSerializerOptions);
WriteProperties(writer, capitalization, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -278,7 +278,7 @@ namespace Org.OpenAPITools.Model
/// <param name="capitalization"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");

View File

@ -32,11 +32,10 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="Cat" /> class.
/// </summary>
/// <param name="className">className</param>
/// <param name="color">color (default to &quot;red&quot;)</param>
/// <param name="declawed">declawed</param>
[JsonConstructor]
public Cat(string className, Option<string> color = default, Option<bool?> declawed = default) : base(className, color)
public Cat(Option<string> color = default, Option<bool?> declawed = default) : base(color)
{
DeclawedOption = declawed;
OnCreated();
@ -44,6 +43,13 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// The discriminator
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public new string ClassName { get; } = "Cat";
/// <summary>
/// Used to track the state of Declawed
/// </summary>
@ -141,7 +147,7 @@ namespace Org.OpenAPITools.Model
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);
return new Cat(color, declawed);
}
/// <summary>
@ -155,7 +161,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, cat, jsonSerializerOptions);
WriteProperties(writer, cat, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -166,11 +172,8 @@ namespace Org.OpenAPITools.Model
/// <param name="cat"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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.");

View File

@ -171,7 +171,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, category, jsonSerializerOptions);
WriteProperties(writer, category, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -182,7 +182,7 @@ namespace Org.OpenAPITools.Model
/// <param name="category"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
{
if (category.Name == null)
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");

View File

@ -32,12 +32,10 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="ChildCat" /> class.
/// </summary>
/// <param name="petType">petType</param>
/// <param name="name">name</param>
[JsonConstructor]
public ChildCat(ChildCatAllOfPetType petType, Option<string> name = default) : base(ChildCatAllOfPetTypeValueConverter.ToJsonValue(petType))
public ChildCat(Option<string> name = default) : base()
{
PetType = petType;
NameOption = name;
OnCreated();
}
@ -45,10 +43,11 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// Gets or Sets PetType
/// The discriminator
/// </summary>
[JsonPropertyName("pet_type")]
public new ChildCatAllOfPetType PetType { get; set; }
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public new ChildCatAllOfPetType PetType { get; } = (ChildCatAllOfPetType)Enum.Parse(typeof(ChildCatAllOfPetType), "ChildCat");
/// <summary>
/// Used to track the state of Name
@ -72,7 +71,6 @@ namespace Org.OpenAPITools.Model
StringBuilder sb = new StringBuilder();
sb.Append("class ChildCat {\n");
sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n");
sb.Append(" PetType: ").Append(PetType).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -142,7 +140,7 @@ namespace Org.OpenAPITools.Model
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat.");
return new ChildCat(petType.Value.Value, name);
return new ChildCat(name);
}
/// <summary>
@ -156,7 +154,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, childCat, jsonSerializerOptions);
WriteProperties(writer, childCat, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -167,13 +165,12 @@ namespace Org.OpenAPITools.Model
/// <param name="childCat"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
if (childCat.NameOption.IsSet && childCat.Name == null)
throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
var petTypeRawValue = ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType);
writer.WriteString("pet_type", petTypeRawValue);
writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType));
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, classModel, jsonSerializerOptions);
WriteProperties(writer, classModel, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="classModel"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
if (classModel.ClassOption.IsSet && classModel.Class == null)
throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");

View File

@ -166,7 +166,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions);
WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -177,7 +177,7 @@ namespace Org.OpenAPITools.Model
/// <param name="complexQuadrilateral"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
if (complexQuadrilateral.QuadrilateralType == null)
throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral.");

View File

@ -147,7 +147,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, danishPig, jsonSerializerOptions);
WriteProperties(writer, danishPig, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -158,7 +158,7 @@ namespace Org.OpenAPITools.Model
/// <param name="danishPig"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
{
if (danishPig.ClassName == null)
throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig.");

View File

@ -158,7 +158,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions);
WriteProperties(writer, dateOnlyClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -169,7 +169,7 @@ namespace Org.OpenAPITools.Model
/// <param name="dateOnlyClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat));

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions);
WriteProperties(writer, deprecatedObject, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="deprecatedObject"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");

View File

@ -32,11 +32,10 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="Dog" /> class.
/// </summary>
/// <param name="className">className</param>
/// <param name="breed">breed</param>
/// <param name="color">color (default to &quot;red&quot;)</param>
[JsonConstructor]
public Dog(string className, Option<string> breed = default, Option<string> color = default) : base(className, color)
public Dog(Option<string> breed = default, Option<string> color = default) : base(color)
{
BreedOption = breed;
OnCreated();
@ -44,6 +43,13 @@ namespace Org.OpenAPITools.Model
partial void OnCreated();
/// <summary>
/// The discriminator
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public new string ClassName { get; } = "Dog";
/// <summary>
/// Used to track the state of Breed
/// </summary>
@ -140,7 +146,7 @@ namespace Org.OpenAPITools.Model
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);
return new Dog(breed, color);
}
/// <summary>
@ -154,7 +160,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, dog, jsonSerializerOptions);
WriteProperties(writer, dog, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -165,11 +171,8 @@ namespace Org.OpenAPITools.Model
/// <param name="dog"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
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.");

View File

@ -218,7 +218,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, drawing, jsonSerializerOptions);
WriteProperties(writer, drawing, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -229,7 +229,7 @@ namespace Org.OpenAPITools.Model
/// <param name="drawing"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");

View File

@ -177,7 +177,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, enumArrays, jsonSerializerOptions);
WriteProperties(writer, enumArrays, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -188,7 +188,7 @@ namespace Org.OpenAPITools.Model
/// <param name="enumArrays"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");

View File

@ -346,7 +346,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, enumTest, jsonSerializerOptions);
WriteProperties(writer, enumTest, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -357,7 +357,7 @@ namespace Org.OpenAPITools.Model
/// <param name="enumTest"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);

View File

@ -166,7 +166,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions);
WriteProperties(writer, equilateralTriangle, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -177,7 +177,7 @@ namespace Org.OpenAPITools.Model
/// <param name="equilateralTriangle"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
{
if (equilateralTriangle.ShapeType == null)
throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle.");

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, file, jsonSerializerOptions);
WriteProperties(writer, file, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="file"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
if (file.SourceURIOption.IsSet && file.SourceURI == null)
throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");

View File

@ -176,7 +176,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions);
WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -187,7 +187,7 @@ namespace Org.OpenAPITools.Model
/// <param name="fileSchemaTestClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, foo, jsonSerializerOptions);
WriteProperties(writer, foo, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="foo"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
if (foo.BarOption.IsSet && foo.Bar == null)
throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions);
WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="fooGetDefaultResponse"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");

View File

@ -703,7 +703,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, formatTest, jsonSerializerOptions);
WriteProperties(writer, formatTest, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -714,7 +714,7 @@ namespace Org.OpenAPITools.Model
/// <param name="formatTest"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
{
if (formatTest.Byte == null)
throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest.");

View File

@ -195,7 +195,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, fruit, jsonSerializerOptions);
WriteProperties(writer, fruit, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -206,7 +206,7 @@ namespace Org.OpenAPITools.Model
/// <param name="fruit"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
if (fruit.ColorOption.IsSet && fruit.Color == null)
throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");

View File

@ -169,7 +169,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, fruitReq, jsonSerializerOptions);
WriteProperties(writer, fruitReq, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -180,7 +180,7 @@ namespace Org.OpenAPITools.Model
/// <param name="fruitReq"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions)
{
}

View File

@ -203,16 +203,16 @@ namespace Org.OpenAPITools.Model
if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null)
{
AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType()));
AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions);
AppleJsonConverter.WriteProperties(writer, gmFruit.AppleOption.Value, jsonSerializerOptions);
}
if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null)
{
BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType()));
BananaJsonConverter.WriteProperties(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions);
BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions);
}
WriteProperties(ref writer, gmFruit, jsonSerializerOptions);
WriteProperties(writer, gmFruit, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -223,7 +223,7 @@ namespace Org.OpenAPITools.Model
/// <param name="gmFruit"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");

View File

@ -32,21 +32,20 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="GrandparentAnimal" /> class.
/// </summary>
/// <param name="petType">petType</param>
[JsonConstructor]
public GrandparentAnimal(string petType)
public GrandparentAnimal()
{
PetType = petType;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets PetType
/// The discriminator
/// </summary>
[JsonPropertyName("pet_type")]
public string PetType { get; set; }
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public string PetType { get; } = "GrandparentAnimal";
/// <summary>
/// Gets or Sets additional properties
@ -62,7 +61,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class GrandparentAnimal {\n");
sb.Append(" PetType: ").Append(PetType).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -113,6 +111,14 @@ namespace Org.OpenAPITools.Model
Option<string> petType = default;
string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "pet_type");
if (discriminator != null && discriminator.Equals("ChildCat"))
return JsonSerializer.Deserialize<ChildCat>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
if (discriminator != null && discriminator.Equals("ParentPet"))
return JsonSerializer.Deserialize<ParentPet>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
@ -143,7 +149,7 @@ namespace Org.OpenAPITools.Model
if (petType.IsSet && petType.Value == null)
throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal.");
return new GrandparentAnimal(petType.Value);
return new GrandparentAnimal();
}
/// <summary>
@ -155,9 +161,19 @@ namespace Org.OpenAPITools.Model
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions)
{
if (grandparentAnimal is ChildCat childCat){
JsonSerializer.Serialize<ChildCat>(writer, childCat, jsonSerializerOptions);
return;
}
if (grandparentAnimal is ParentPet parentPet){
JsonSerializer.Serialize<ParentPet>(writer, parentPet, jsonSerializerOptions);
return;
}
writer.WriteStartObject();
WriteProperties(ref writer, grandparentAnimal, jsonSerializerOptions);
WriteProperties(writer, grandparentAnimal, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -168,11 +184,8 @@ namespace Org.OpenAPITools.Model
/// <param name="grandparentAnimal"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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);
}
}

View File

@ -215,7 +215,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions);
WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -226,7 +226,7 @@ namespace Org.OpenAPITools.Model
/// <param name="hasOnlyReadOnly"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");

View File

@ -148,7 +148,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions);
WriteProperties(writer, healthCheckResult, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -159,7 +159,7 @@ namespace Org.OpenAPITools.Model
/// <param name="healthCheckResult"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions)
{
if (healthCheckResult.NullableMessageOption.IsSet)
if (healthCheckResult.NullableMessageOption.Value != null)

View File

@ -159,7 +159,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions);
WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -170,7 +170,7 @@ namespace Org.OpenAPITools.Model
/// <param name="isoscelesTriangle"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
{
if (isoscelesTriangle.ShapeType == null)
throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle.");

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, list, jsonSerializerOptions);
WriteProperties(writer, list, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="list"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
if (list.Var123ListOption.IsSet && list.Var123List == null)
throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");

View File

@ -174,7 +174,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, literalStringClass, jsonSerializerOptions);
WriteProperties(writer, literalStringClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -185,7 +185,7 @@ namespace Org.OpenAPITools.Model
/// <param name="literalStringClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Mammal" /> class.
/// </summary>
/// <param name="whale"></param>
/// <param name="className">className</param>
public Mammal(Whale whale, string className)
public Mammal(Whale whale)
{
Whale = whale;
ClassName = className;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Mammal" /> class.
/// </summary>
/// <param name="zebra"></param>
/// <param name="className">className</param>
public Mammal(Zebra zebra, string className)
public Mammal(Zebra zebra)
{
Zebra = zebra;
ClassName = className;
OnCreated();
}
@ -57,11 +53,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Mammal" /> class.
/// </summary>
/// <param name="pig"></param>
/// <param name="className">className</param>
public Mammal(Pig pig, string className)
public Mammal(Pig pig)
{
Pig = pig;
ClassName = className;
OnCreated();
}
@ -82,12 +76,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public Pig Pig { get; set; }
/// <summary>
/// Gets or Sets ClassName
/// </summary>
[JsonPropertyName("className")]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -102,7 +90,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class Mammal {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -223,13 +210,13 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal.");
if (pig != null)
return new Mammal(pig, className.Value);
return new Mammal(pig);
if (whale != null)
return new Mammal(whale, className.Value);
return new Mammal(whale);
if (zebra != null)
return new Mammal(zebra, className.Value);
return new Mammal(zebra);
throw new JsonException();
}
@ -247,20 +234,20 @@ namespace Org.OpenAPITools.Model
if (mammal.Whale != null) {
WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType()));
whaleJsonConverter.WriteProperties(ref writer, mammal.Whale, jsonSerializerOptions);
whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions);
}
if (mammal.Zebra != null) {
ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType()));
zebraJsonConverter.WriteProperties(ref writer, mammal.Zebra, jsonSerializerOptions);
zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions);
}
if (mammal.Pig != null) {
PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType()));
pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions);
pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions);
}
WriteProperties(ref writer, mammal, jsonSerializerOptions);
WriteProperties(writer, mammal, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -271,12 +258,9 @@ namespace Org.OpenAPITools.Model
/// <param name="mammal"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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);
}
}
}

View File

@ -224,7 +224,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, mapTest, jsonSerializerOptions);
WriteProperties(writer, mapTest, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -235,7 +235,7 @@ namespace Org.OpenAPITools.Model
/// <param name="mapTest"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");

View File

@ -236,7 +236,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions);
WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -247,7 +247,7 @@ namespace Org.OpenAPITools.Model
/// <param name="mixedPropertiesAndAdditionalPropertiesClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");

View File

@ -175,7 +175,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, model200Response, jsonSerializerOptions);
WriteProperties(writer, model200Response, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -186,7 +186,7 @@ namespace Org.OpenAPITools.Model
/// <param name="model200Response"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
if (model200Response.ClassOption.IsSet && model200Response.Class == null)
throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, modelClient, jsonSerializerOptions);
WriteProperties(writer, modelClient, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="modelClient"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");

View File

@ -260,7 +260,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, name, jsonSerializerOptions);
WriteProperties(writer, name, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -271,7 +271,7 @@ namespace Org.OpenAPITools.Model
/// <param name="name"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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.");

View File

@ -168,7 +168,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions);
WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -179,7 +179,7 @@ namespace Org.OpenAPITools.Model
/// <param name="notificationtestGetElementsV1ResponseMPayload"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions)
{
if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null)
throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload.");

View File

@ -395,7 +395,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, nullableClass, jsonSerializerOptions);
WriteProperties(writer, nullableClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -406,7 +406,7 @@ namespace Org.OpenAPITools.Model
/// <param name="nullableClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");

View File

@ -150,7 +150,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions);
WriteProperties(writer, nullableGuidClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -161,7 +161,7 @@ namespace Org.OpenAPITools.Model
/// <param name="nullableGuidClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions)
{
if (nullableGuidClass.UuidOption.IsSet)
if (nullableGuidClass.UuidOption.Value != null)

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="NullableShape" /> class.
/// </summary>
/// <param name="triangle"></param>
/// <param name="shapeType">shapeType</param>
public NullableShape(Triangle triangle, string shapeType)
public NullableShape(Triangle triangle)
{
Triangle = triangle;
ShapeType = shapeType;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="NullableShape" /> class.
/// </summary>
/// <param name="quadrilateral"></param>
/// <param name="shapeType">shapeType</param>
public NullableShape(Quadrilateral quadrilateral, string shapeType)
public NullableShape(Quadrilateral quadrilateral)
{
Quadrilateral = quadrilateral;
ShapeType = shapeType;
OnCreated();
}
@ -65,12 +61,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public Quadrilateral Quadrilateral { get; set; }
/// <summary>
/// Gets or Sets ShapeType
/// </summary>
[JsonPropertyName("shapeType")]
public string ShapeType { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -85,7 +75,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class NullableShape {\n");
sb.Append(" ShapeType: ").Append(ShapeType).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -200,10 +189,10 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape.");
if (quadrilateral != null)
return new NullableShape(quadrilateral, shapeType.Value);
return new NullableShape(quadrilateral);
if (triangle != null)
return new NullableShape(triangle, shapeType.Value);
return new NullableShape(triangle);
throw new JsonException();
}
@ -221,15 +210,15 @@ namespace Org.OpenAPITools.Model
if (nullableShape.Triangle != null) {
TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType()));
triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions);
triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions);
}
if (nullableShape.Quadrilateral != null) {
QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType()));
quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions);
quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions);
}
WriteProperties(ref writer, nullableShape, jsonSerializerOptions);
WriteProperties(writer, nullableShape, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -240,12 +229,9 @@ namespace Org.OpenAPITools.Model
/// <param name="nullableShape"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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);
}
}
}

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, numberOnly, jsonSerializerOptions);
WriteProperties(writer, numberOnly, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="numberOnly"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value);

View File

@ -226,7 +226,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions);
WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -237,7 +237,7 @@ namespace Org.OpenAPITools.Model
/// <param name="objectWithDeprecatedFields"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");

View File

@ -138,7 +138,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, oneOfString, jsonSerializerOptions);
WriteProperties(writer, oneOfString, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -149,7 +149,7 @@ namespace Org.OpenAPITools.Model
/// <param name="oneOfString"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions)
{
}

View File

@ -279,7 +279,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, order, jsonSerializerOptions);
WriteProperties(writer, order, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -290,7 +290,7 @@ namespace Org.OpenAPITools.Model
/// <param name="order"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
writer.WriteBoolean("complete", order.CompleteOption.Value.Value);

View File

@ -199,7 +199,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, outerComposite, jsonSerializerOptions);
WriteProperties(writer, outerComposite, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -210,7 +210,7 @@ namespace Org.OpenAPITools.Model
/// <param name="outerComposite"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");

View File

@ -32,15 +32,21 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="ParentPet" /> class.
/// </summary>
/// <param name="petType">petType</param>
[JsonConstructor]
public ParentPet(string petType) : base(petType)
public ParentPet() : base()
{
OnCreated();
}
partial void OnCreated();
/// <summary>
/// The discriminator
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public new string PetType { get; } = "ParentPet";
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -79,6 +85,11 @@ namespace Org.OpenAPITools.Model
Option<string> petType = default;
string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "pet_type");
if (discriminator != null && discriminator.Equals("ChildCat"))
return JsonSerializer.Deserialize<ChildCat>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value.");
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
@ -109,7 +120,7 @@ namespace Org.OpenAPITools.Model
if (petType.IsSet && petType.Value == null)
throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet.");
return new ParentPet(petType.Value);
return new ParentPet();
}
/// <summary>
@ -121,9 +132,14 @@ namespace Org.OpenAPITools.Model
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions)
{
if (parentPet is ChildCat childCat){
JsonSerializer.Serialize<ChildCat>(writer, childCat, jsonSerializerOptions);
return;
}
writer.WriteStartObject();
WriteProperties(ref writer, parentPet, jsonSerializerOptions);
WriteProperties(writer, parentPet, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -134,11 +150,8 @@ namespace Org.OpenAPITools.Model
/// <param name="parentPet"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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);
}
}

View File

@ -265,7 +265,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, pet, jsonSerializerOptions);
WriteProperties(writer, pet, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -276,7 +276,7 @@ namespace Org.OpenAPITools.Model
/// <param name="pet"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
{
if (pet.Name == null)
throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet.");

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Pig" /> class.
/// </summary>
/// <param name="basquePig"></param>
/// <param name="className">className</param>
public Pig(BasquePig basquePig, string className)
public Pig(BasquePig basquePig)
{
BasquePig = basquePig;
ClassName = className;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Pig" /> class.
/// </summary>
/// <param name="danishPig"></param>
/// <param name="className">className</param>
public Pig(DanishPig danishPig, string className)
public Pig(DanishPig danishPig)
{
DanishPig = danishPig;
ClassName = className;
OnCreated();
}
@ -65,12 +61,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public DanishPig DanishPig { get; set; }
/// <summary>
/// Gets or Sets ClassName
/// </summary>
[JsonPropertyName("className")]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -85,7 +75,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class Pig {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -200,10 +189,10 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig.");
if (basquePig != null)
return new Pig(basquePig, className.Value);
return new Pig(basquePig);
if (danishPig != null)
return new Pig(danishPig, className.Value);
return new Pig(danishPig);
throw new JsonException();
}
@ -221,15 +210,15 @@ namespace Org.OpenAPITools.Model
if (pig.BasquePig != null) {
BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType()));
basquePigJsonConverter.WriteProperties(ref writer, pig.BasquePig, jsonSerializerOptions);
basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions);
}
if (pig.DanishPig != null) {
DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType()));
danishPigJsonConverter.WriteProperties(ref writer, pig.DanishPig, jsonSerializerOptions);
danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions);
}
WriteProperties(ref writer, pig, jsonSerializerOptions);
WriteProperties(writer, pig, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -240,12 +229,9 @@ namespace Org.OpenAPITools.Model
/// <param name="pig"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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);
}
}
}

View File

@ -220,7 +220,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions);
WriteProperties(writer, polymorphicProperty, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -231,7 +231,7 @@ namespace Org.OpenAPITools.Model
/// <param name="polymorphicProperty"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions)
{
}

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Quadrilateral" /> class.
/// </summary>
/// <param name="simpleQuadrilateral"></param>
/// <param name="quadrilateralType">quadrilateralType</param>
public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilateralType)
public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral)
{
SimpleQuadrilateral = simpleQuadrilateral;
QuadrilateralType = quadrilateralType;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Quadrilateral" /> class.
/// </summary>
/// <param name="complexQuadrilateral"></param>
/// <param name="quadrilateralType">quadrilateralType</param>
public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilateralType)
public Quadrilateral(ComplexQuadrilateral complexQuadrilateral)
{
ComplexQuadrilateral = complexQuadrilateral;
QuadrilateralType = quadrilateralType;
OnCreated();
}
@ -65,12 +61,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public ComplexQuadrilateral ComplexQuadrilateral { get; set; }
/// <summary>
/// Gets or Sets QuadrilateralType
/// </summary>
[JsonPropertyName("quadrilateralType")]
public string QuadrilateralType { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -85,7 +75,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class Quadrilateral {\n");
sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -200,10 +189,10 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral.");
if (complexQuadrilateral != null)
return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value);
return new Quadrilateral(complexQuadrilateral);
if (simpleQuadrilateral != null)
return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value);
return new Quadrilateral(simpleQuadrilateral);
throw new JsonException();
}
@ -221,15 +210,15 @@ namespace Org.OpenAPITools.Model
if (quadrilateral.SimpleQuadrilateral != null) {
SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType()));
simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions);
simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions);
}
if (quadrilateral.ComplexQuadrilateral != null) {
ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType()));
complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions);
complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions);
}
WriteProperties(ref writer, quadrilateral, jsonSerializerOptions);
WriteProperties(writer, quadrilateral, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -240,12 +229,9 @@ namespace Org.OpenAPITools.Model
/// <param name="quadrilateral"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(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);
}
}
}

View File

@ -147,7 +147,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions);
WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -158,7 +158,7 @@ namespace Org.OpenAPITools.Model
/// <param name="quadrilateralInterface"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
{
if (quadrilateralInterface.QuadrilateralType == null)
throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface.");

View File

@ -212,7 +212,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions);
WriteProperties(writer, readOnlyFirst, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -223,7 +223,7 @@ namespace Org.OpenAPITools.Model
/// <param name="readOnlyFirst"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");

View File

@ -1086,7 +1086,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, requiredClass, jsonSerializerOptions);
WriteProperties(writer, requiredClass, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -1097,7 +1097,7 @@ namespace Org.OpenAPITools.Model
/// <param name="requiredClass"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions)
{
if (requiredClass.RequiredNotnullableArrayOfString == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");

View File

@ -210,7 +210,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, varReturn, jsonSerializerOptions);
WriteProperties(writer, varReturn, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -221,7 +221,7 @@ namespace Org.OpenAPITools.Model
/// <param name="varReturn"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
{
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");

View File

@ -176,7 +176,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, rolesReportsHash, jsonSerializerOptions);
WriteProperties(writer, rolesReportsHash, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -187,7 +187,7 @@ namespace Org.OpenAPITools.Model
/// <param name="rolesReportsHash"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, rolesReportsHashRole, jsonSerializerOptions);
WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="rolesReportsHashRole"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");

View File

@ -166,7 +166,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions);
WriteProperties(writer, scaleneTriangle, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -177,7 +177,7 @@ namespace Org.OpenAPITools.Model
/// <param name="scaleneTriangle"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
{
if (scaleneTriangle.ShapeType == null)
throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle.");

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Shape" /> class.
/// </summary>
/// <param name="triangle"></param>
/// <param name="shapeType">shapeType</param>
public Shape(Triangle triangle, string shapeType)
public Shape(Triangle triangle)
{
Triangle = triangle;
ShapeType = shapeType;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Shape" /> class.
/// </summary>
/// <param name="quadrilateral"></param>
/// <param name="shapeType">shapeType</param>
public Shape(Quadrilateral quadrilateral, string shapeType)
public Shape(Quadrilateral quadrilateral)
{
Quadrilateral = quadrilateral;
ShapeType = shapeType;
OnCreated();
}
@ -65,12 +61,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public Quadrilateral Quadrilateral { get; set; }
/// <summary>
/// Gets or Sets ShapeType
/// </summary>
[JsonPropertyName("shapeType")]
public string ShapeType { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -85,7 +75,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class Shape {\n");
sb.Append(" ShapeType: ").Append(ShapeType).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -200,10 +189,10 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape.");
if (quadrilateral != null)
return new Shape(quadrilateral, shapeType.Value);
return new Shape(quadrilateral);
if (triangle != null)
return new Shape(triangle, shapeType.Value);
return new Shape(triangle);
throw new JsonException();
}
@ -221,15 +210,15 @@ namespace Org.OpenAPITools.Model
if (shape.Triangle != null) {
TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType()));
triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions);
triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions);
}
if (shape.Quadrilateral != null) {
QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType()));
quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions);
quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions);
}
WriteProperties(ref writer, shape, jsonSerializerOptions);
WriteProperties(writer, shape, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -240,12 +229,9 @@ namespace Org.OpenAPITools.Model
/// <param name="shape"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions)
{
if (shape.ShapeType == null)
throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape.");
writer.WriteString("shapeType", shape.ShapeType);
}
}
}

View File

@ -147,7 +147,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, shapeInterface, jsonSerializerOptions);
WriteProperties(writer, shapeInterface, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -158,7 +158,7 @@ namespace Org.OpenAPITools.Model
/// <param name="shapeInterface"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
{
if (shapeInterface.ShapeType == null)
throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface.");

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="ShapeOrNull" /> class.
/// </summary>
/// <param name="triangle"></param>
/// <param name="shapeType">shapeType</param>
public ShapeOrNull(Triangle triangle, string shapeType)
public ShapeOrNull(Triangle triangle)
{
Triangle = triangle;
ShapeType = shapeType;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="ShapeOrNull" /> class.
/// </summary>
/// <param name="quadrilateral"></param>
/// <param name="shapeType">shapeType</param>
public ShapeOrNull(Quadrilateral quadrilateral, string shapeType)
public ShapeOrNull(Quadrilateral quadrilateral)
{
Quadrilateral = quadrilateral;
ShapeType = shapeType;
OnCreated();
}
@ -65,12 +61,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public Quadrilateral Quadrilateral { get; set; }
/// <summary>
/// Gets or Sets ShapeType
/// </summary>
[JsonPropertyName("shapeType")]
public string ShapeType { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -85,7 +75,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class ShapeOrNull {\n");
sb.Append(" ShapeType: ").Append(ShapeType).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -200,10 +189,10 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull.");
if (quadrilateral != null)
return new ShapeOrNull(quadrilateral, shapeType.Value);
return new ShapeOrNull(quadrilateral);
if (triangle != null)
return new ShapeOrNull(triangle, shapeType.Value);
return new ShapeOrNull(triangle);
throw new JsonException();
}
@ -221,15 +210,15 @@ namespace Org.OpenAPITools.Model
if (shapeOrNull.Triangle != null) {
TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType()));
triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions);
triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions);
}
if (shapeOrNull.Quadrilateral != null) {
QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType()));
quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions);
quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions);
}
WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions);
WriteProperties(writer, shapeOrNull, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -240,12 +229,9 @@ namespace Org.OpenAPITools.Model
/// <param name="shapeOrNull"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions)
{
if (shapeOrNull.ShapeType == null)
throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull.");
writer.WriteString("shapeType", shapeOrNull.ShapeType);
}
}
}

View File

@ -166,7 +166,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions);
WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -177,7 +177,7 @@ namespace Org.OpenAPITools.Model
/// <param name="simpleQuadrilateral"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
{
if (simpleQuadrilateral.QuadrilateralType == null)
throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral.");

View File

@ -175,7 +175,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, specialModelName, jsonSerializerOptions);
WriteProperties(writer, specialModelName, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -186,7 +186,7 @@ namespace Org.OpenAPITools.Model
/// <param name="specialModelName"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");

View File

@ -175,7 +175,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, tag, jsonSerializerOptions);
WriteProperties(writer, tag, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -186,7 +186,7 @@ namespace Org.OpenAPITools.Model
/// <param name="tag"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
if (tag.NameOption.IsSet && tag.Name == null)
throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, testCollectionEndingWithWordList, jsonSerializerOptions);
WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="testCollectionEndingWithWordList"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");

View File

@ -152,7 +152,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, testCollectionEndingWithWordListObject, jsonSerializerOptions);
WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -163,7 +163,7 @@ namespace Org.OpenAPITools.Model
/// <param name="testCollectionEndingWithWordListObject"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");

View File

@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions);
WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -162,7 +162,7 @@ namespace Org.OpenAPITools.Model
/// <param name="testInlineFreeformAdditionalPropertiesRequest"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");

View File

@ -33,11 +33,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Triangle" /> class.
/// </summary>
/// <param name="equilateralTriangle"></param>
/// <param name="triangleType">triangleType</param>
public Triangle(EquilateralTriangle equilateralTriangle, string triangleType)
public Triangle(EquilateralTriangle equilateralTriangle)
{
EquilateralTriangle = equilateralTriangle;
TriangleType = triangleType;
OnCreated();
}
@ -45,11 +43,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Triangle" /> class.
/// </summary>
/// <param name="isoscelesTriangle"></param>
/// <param name="triangleType">triangleType</param>
public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType)
public Triangle(IsoscelesTriangle isoscelesTriangle)
{
IsoscelesTriangle = isoscelesTriangle;
TriangleType = triangleType;
OnCreated();
}
@ -57,11 +53,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Triangle" /> class.
/// </summary>
/// <param name="scaleneTriangle"></param>
/// <param name="triangleType">triangleType</param>
public Triangle(ScaleneTriangle scaleneTriangle, string triangleType)
public Triangle(ScaleneTriangle scaleneTriangle)
{
ScaleneTriangle = scaleneTriangle;
TriangleType = triangleType;
OnCreated();
}
@ -82,12 +76,6 @@ namespace Org.OpenAPITools.Model
/// </summary>
public ScaleneTriangle ScaleneTriangle { get; set; }
/// <summary>
/// Gets or Sets TriangleType
/// </summary>
[JsonPropertyName("triangleType")]
public string TriangleType { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
@ -102,7 +90,6 @@ namespace Org.OpenAPITools.Model
{
StringBuilder sb = new StringBuilder();
sb.Append("class Triangle {\n");
sb.Append(" TriangleType: ").Append(TriangleType).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -223,13 +210,13 @@ namespace Org.OpenAPITools.Model
throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle.");
if (equilateralTriangle != null)
return new Triangle(equilateralTriangle, triangleType.Value);
return new Triangle(equilateralTriangle);
if (isoscelesTriangle != null)
return new Triangle(isoscelesTriangle, triangleType.Value);
return new Triangle(isoscelesTriangle);
if (scaleneTriangle != null)
return new Triangle(scaleneTriangle, triangleType.Value);
return new Triangle(scaleneTriangle);
throw new JsonException();
}
@ -247,20 +234,20 @@ namespace Org.OpenAPITools.Model
if (triangle.EquilateralTriangle != null) {
EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType()));
equilateralTriangleJsonConverter.WriteProperties(ref writer, triangle.EquilateralTriangle, jsonSerializerOptions);
equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions);
}
if (triangle.IsoscelesTriangle != null) {
IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType()));
isoscelesTriangleJsonConverter.WriteProperties(ref writer, triangle.IsoscelesTriangle, jsonSerializerOptions);
isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions);
}
if (triangle.ScaleneTriangle != null) {
ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType()));
scaleneTriangleJsonConverter.WriteProperties(ref writer, triangle.ScaleneTriangle, jsonSerializerOptions);
scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions);
}
WriteProperties(ref writer, triangle, jsonSerializerOptions);
WriteProperties(writer, triangle, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -271,12 +258,9 @@ namespace Org.OpenAPITools.Model
/// <param name="triangle"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions)
{
if (triangle.TriangleType == null)
throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle.");
writer.WriteString("triangleType", triangle.TriangleType);
}
}
}

View File

@ -147,7 +147,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, triangleInterface, jsonSerializerOptions);
WriteProperties(writer, triangleInterface, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -158,7 +158,7 @@ namespace Org.OpenAPITools.Model
/// <param name="triangleInterface"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions)
{
if (triangleInterface.TriangleType == null)
throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface.");

View File

@ -406,7 +406,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, user, jsonSerializerOptions);
WriteProperties(writer, user, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -417,7 +417,7 @@ namespace Org.OpenAPITools.Model
/// <param name="user"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
if (user.EmailOption.IsSet && user.Email == null)
throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");

View File

@ -195,7 +195,7 @@ namespace Org.OpenAPITools.Model
{
writer.WriteStartObject();
WriteProperties(ref writer, whale, jsonSerializerOptions);
WriteProperties(writer, whale, jsonSerializerOptions);
writer.WriteEndObject();
}
@ -206,7 +206,7 @@ namespace Org.OpenAPITools.Model
/// <param name="whale"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions)
{
if (whale.ClassName == null)
throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale.");

Some files were not shown because too many files have changed in this diff Show More