forked from loafle/openapi-generator-original
[csharp][generichost] Fix oneof anyof serialization (#15873)
* removed redundant properties * removed commneted code * fixed oneof anyof serialization * restored discriminator as a model property * added manual sample, removed need for new discriminator property * minor pipeline change * renamed manual test solution * resolved conflicts * build samples * bug fix * fixed pipeline * added a comment
This commit is contained in:
3
.github/workflows/samples-dotnet.yaml
vendored
3
.github/workflows/samples-dotnet.yaml
vendored
@@ -5,6 +5,7 @@ on:
|
||||
paths:
|
||||
- 'samples/client/petstore/csharp/**net6.0**/'
|
||||
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-netcore**/'
|
||||
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**'
|
||||
- 'samples/server/petstore/aspnetcore-6.0/**'
|
||||
- 'samples/server/petstore/aspnetcore-6.0-pocoModels/**'
|
||||
- 'samples/server/petstore/aspnetcore-6.0-useSwashBuckle/**'
|
||||
@@ -12,6 +13,7 @@ on:
|
||||
paths:
|
||||
- 'samples/client/petstore/csharp/**net6.0**/'
|
||||
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-netcore**/'
|
||||
- 'samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/**'
|
||||
- 'samples/server/petstore/aspnetcore-6.0/**'
|
||||
- 'samples/server/petstore/aspnetcore-6.0-pocoModels/**'
|
||||
- 'samples/server/petstore/aspnetcore-6.0-project4Models/**'
|
||||
@@ -32,6 +34,7 @@ jobs:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests
|
||||
- samples/server/petstore/aspnetcore-6.0
|
||||
- samples/server/petstore/aspnetcore-6.0-pocoModels
|
||||
- samples/server/petstore/aspnetcore-6.0-project4Models
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.TreeSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* This class encapsulates the OpenAPI discriminator construct, as specified at
|
||||
@@ -114,6 +111,8 @@ public class CodegenDiscriminator {
|
||||
// is converted to a sanitized, internal representation within codegen.
|
||||
private String modelName;
|
||||
|
||||
private CodegenModel model;
|
||||
|
||||
public MappedModel(String mappingName, String modelName) {
|
||||
this.mappingName = mappingName;
|
||||
this.modelName = modelName;
|
||||
@@ -147,6 +146,10 @@ public class CodegenDiscriminator {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public CodegenModel getModel() { return model; }
|
||||
|
||||
public void setModel(CodegenModel model) { this.model = model; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -466,6 +466,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
for (Map.Entry<String, ModelsMap> entry : objs.entrySet()) {
|
||||
CodegenModel model = ModelUtils.getModelByName(entry.getKey(), objs);
|
||||
|
||||
// add the model to the discriminator's mapping so templates have access to more than just the string to string mapping
|
||||
if (model.discriminator != null && model.discriminator.getMappedModels() != null) {
|
||||
for (CodegenDiscriminator.MappedModel mappedModel : model.discriminator.getMappedModels()) {
|
||||
CodegenModel mappedCodegenModel = ModelUtils.getModelByName(mappedModel.getModelName(), objs);
|
||||
mappedModel.setModel(mappedCodegenModel);
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenProperty property : model.allVars){
|
||||
property.isNew = codegenPropertyIsNew(model, property);
|
||||
}
|
||||
|
||||
@@ -458,6 +458,36 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
for (ModelMap mo : objs.getModels()) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
|
||||
if (cm.getComposedSchemas() != null) {
|
||||
List<CodegenProperty> oneOf = cm.getComposedSchemas().getOneOf();
|
||||
if (oneOf != null) {
|
||||
Set<String> dataTypeSet = new HashSet<>();
|
||||
for (CodegenProperty oneOfProperty : oneOf) {
|
||||
if (dataTypeSet.contains(oneOfProperty.dataType)) {
|
||||
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
|
||||
// in other sub-schemas of allOf/anyOf/oneOf
|
||||
oneOfProperty.vendorExtensions.putIfAbsent("x-composed-data-type", true);
|
||||
} else {
|
||||
dataTypeSet.add(oneOfProperty.dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<CodegenProperty> anyOf = cm.getComposedSchemas().getAnyOf();
|
||||
if (anyOf != null) {
|
||||
Set<String> dataTypeSet = new HashSet<>();
|
||||
for (CodegenProperty anyOfProperty : anyOf) {
|
||||
if (dataTypeSet.contains(anyOfProperty.dataType)) {
|
||||
// add "x-duplicated-data-type" to indicate if the dataType already occurs before
|
||||
// in other sub-schemas of allOf/anyOf/oneOf
|
||||
anyOfProperty.vendorExtensions.putIfAbsent("x-composed-data-type", true);
|
||||
} else {
|
||||
dataTypeSet.add(anyOfProperty.dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cm.isEnum && !cm.vendorExtensions.containsKey(this.zeroBasedEnumVendorExtension)) {
|
||||
if (Boolean.TRUE.equals(this.zeroBasedEnums)) {
|
||||
cm.vendorExtensions.put(this.zeroBasedEnumVendorExtension, true);
|
||||
@@ -487,6 +517,17 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
Map<String, CodegenModel> enumRefs = new HashMap<>();
|
||||
for (Map.Entry<String, ModelsMap> entry : processed.entrySet()) {
|
||||
CodegenModel model = ModelUtils.getModelByName(entry.getKey(), processed);
|
||||
|
||||
// if we don't call setHasDiscriminatorWithNonEmptyMapping then hasDiscriminatorWithNonEmptyMapping will be false, and we need it in the JsonConverter
|
||||
// the checks on oneOf and anyOf must be there or else hasDiscriminatorWithNonEmptyMapping will be true for GrandparentAnimal.
|
||||
// GrandparentAnimal has a discriminator, but no oneOf nor anyOf
|
||||
// modules\openapi-generator\src\test\resources\3_0\csharp\petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
model.setHasDiscriminatorWithNonEmptyMapping(
|
||||
((model.anyOf != null && model.anyOf.size() > 0) || (model.anyOf != null &&model.oneOf.size() > 0)) &&
|
||||
model.discriminator != null &&
|
||||
model.discriminator.getMappedModels() != null &&
|
||||
model.discriminator.getMappedModels().size() > 0);
|
||||
|
||||
if (model.isEnum) {
|
||||
enumRefs.put(model.getClassname(), model);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
/// <exception cref="JsonException"></exception>
|
||||
public override {{classname}} Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
{{#lambda.trimLineBreaks}}
|
||||
int currentDepth = utf8JsonReader.CurrentDepth;
|
||||
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
|
||||
@@ -36,19 +37,115 @@
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
Utf8JsonReader {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}Reader = utf8JsonReader;
|
||||
bool {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}Deserialized = Client.ClientUtils.TryDeserialize<{{{dataType}}}>(ref {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}Reader, jsonSerializerOptions, out {{{dataType}}}{{^isBoolean}}{{nrt?}}{{/isBoolean}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}});
|
||||
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/composedSchemas.anyOf}}
|
||||
{{#allVars}}
|
||||
{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{#nrt}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/nrt}}{{^nrt}}{{{datatypeWithEnum}}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default;
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/allVars}}
|
||||
{{#model.discriminator}}
|
||||
{{#model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{#mappedModels}}
|
||||
{{#model}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
{{classname}}{{nrt?}} {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}} = null;
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/model}}
|
||||
{{/mappedModels}}
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string{{nrt?}} propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName{{nrt?}}.Equals("{{propertyBaseName}}"){{#nrt}} ?? false{{/nrt}})
|
||||
{
|
||||
string{{nrt?}} discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
{{#mappedModels}}
|
||||
if (discriminator{{nrt?}}.Equals("{{mappingName}}"){{#nrt}} ?? false{{/nrt}})
|
||||
{
|
||||
Utf8JsonReader utf8JsonReader{{model.classname}} = utf8JsonReader;
|
||||
{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<{{{model.classname}}}>(ref utf8JsonReader{{model.classname}}, jsonSerializerOptions);
|
||||
}
|
||||
{{/mappedModels}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{/model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{/model.discriminator}}
|
||||
{{^model.discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default;
|
||||
{{#-last}}
|
||||
|
||||
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
|
||||
while (utf8JsonReaderOneOf.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
|
||||
{
|
||||
{{#oneOf}}
|
||||
Utf8JsonReader utf8JsonReader{{name}} = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}>(ref utf8JsonReader{{name}}, jsonSerializerOptions, out {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}});
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/oneOf}}
|
||||
}
|
||||
}
|
||||
{{/-last}}
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/oneOf}}
|
||||
|
||||
{{#anyOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default;
|
||||
{{#-last}}
|
||||
|
||||
Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader;
|
||||
while (utf8JsonReaderAnyOf.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1)
|
||||
{
|
||||
{{#anyOf}}
|
||||
Utf8JsonReader utf8JsonReader{{name}} = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}>(ref utf8JsonReader{{name}}, jsonSerializerOptions, out {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}});
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/anyOf}}
|
||||
}
|
||||
}
|
||||
{{/-last}}
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/anyOf}}
|
||||
|
||||
{{/composedSchemas}}
|
||||
{{/model.discriminator}}
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -173,20 +270,36 @@
|
||||
|
||||
{{/isNullable}}
|
||||
{{/allVars}}
|
||||
{{#composedSchemas.oneOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
Utf8JsonReader {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}Reader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<{{{dataType}}}>(ref {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}Reader, jsonSerializerOptions, out {{{dataType}}}{{^isBoolean}}{{nrt?}}{{/isBoolean}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}))
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
{{#model.discriminator}}
|
||||
{{#model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{#mappedModels}}
|
||||
if ({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}} != null)
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{#-last}}
|
||||
throw new JsonException();
|
||||
{{/-last}}
|
||||
{{/composedSchemas.oneOf}}
|
||||
{{/mappedModels}}
|
||||
{{/model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{/model.discriminator}}
|
||||
{{^composedSchemas.oneOf}}
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
{{/composedSchemas.oneOf}}
|
||||
{{^model.discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} != null)
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
|
||||
{{#-last}}
|
||||
throw new JsonException();
|
||||
{{/-last}}
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
{{/model.discriminator}}
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/lambda.trimLineBreaks}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,20 +312,47 @@
|
||||
public override void Write(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
{{#lambda.trimLineBreaks}}
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, jsonSerializerOptions);
|
||||
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/composedSchemas.anyOf}}
|
||||
{{#composedSchemas.oneOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, jsonSerializerOptions);
|
||||
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/composedSchemas.oneOf}}
|
||||
writer.WriteStartObject();
|
||||
|
||||
{{#model.discriminator}}
|
||||
{{#model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{#mappedModels}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{model.classname}} != null) {
|
||||
{{model.classname}}JsonConverter {{#lambda.camelcase_param}}{{model.classname}}JsonConverter{{/lambda.camelcase_param}} = ({{model.classname}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{model.classname}}.GetType()));
|
||||
{{#lambda.camelcase_param}}{{model.classname}}JsonConverter{{/lambda.camelcase_param}}.WriteProperties(ref writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{model.classname}}, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
{{/mappedModels}}
|
||||
{{/model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{/model.discriminator}}
|
||||
{{^model.discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#anyOf}}
|
||||
if ({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}} != null)
|
||||
{
|
||||
{{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}.GetType()));
|
||||
{{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
{{/anyOf}}
|
||||
{{/composedSchemas}}
|
||||
{{/model.discriminator}}
|
||||
WriteProperties(ref writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
{{/lambda.trimLineBreaks}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="{{classname}}" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
{{#lambda.trimTrailingWhiteSpace}}
|
||||
{{#lambda.trimLineBreaks}}
|
||||
{{#allVars}}
|
||||
{{#isString}}
|
||||
{{^isMap}}
|
||||
@@ -363,17 +503,6 @@
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
writer.WritePropertyName("{{baseName}}");
|
||||
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
{{/isNumeric}}
|
||||
{{/isBoolean}}
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{/isUuid}}
|
||||
{{/allVars}}
|
||||
|
||||
writer.WriteEndObject();
|
||||
{{/lambda.trimLineBreaks}}
|
||||
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);{{/isDateTime}}{{/isDate}}{{/isNumeric}}{{/isBoolean}}{{/isString}}{{/isEnum}}{{/isUuid}}{{/allVars}}{{/lambda.trimLineBreaks}}{{/lambda.trimTrailingWhiteSpace}}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
{{#readWriteVars}}{{#-first}}public{{/-first}}{{/readWriteVars}}{{^readWriteVars}}internal{{/readWriteVars}} {{classname}}({{#lambda.joinWithComma}}{{#composedSchemas.anyOf}}{{{name}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}}
|
||||
{
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}} = {{#lambda.titlecase}}{{name}}{{/lambda.titlecase}};
|
||||
{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/composedSchemas.anyOf}}
|
||||
{{#allVars}}
|
||||
{{^isInherited}}
|
||||
|
||||
362
samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/.gitignore
vendored
Normal file
362
samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/.gitignore
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>OpenAPIClient_generichost_manual_tests</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\OpenAPIClient-generichost-net6.0-nrt\src\Org.OpenAPITools\Org.OpenAPITools.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,147 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Extensions;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OpenAPIClient_generichost_manual_tests
|
||||
{
|
||||
[TestClass]
|
||||
public sealed class SerializationTests
|
||||
{
|
||||
private readonly IHost _host;
|
||||
private readonly JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
public SerializationTests()
|
||||
{
|
||||
IHostBuilder hostBuild = Host.CreateDefaultBuilder(Array.Empty<string>()).ConfigureApi((context, services, options) =>
|
||||
{
|
||||
string apiKeyTokenValue = context.Configuration["<token>"] ?? "Token not found.";
|
||||
ApiKeyToken apiKeyToken = new(apiKeyTokenValue, timeout: TimeSpan.FromSeconds(1));
|
||||
options.AddTokens(apiKeyToken);
|
||||
|
||||
string bearerTokenValue = context.Configuration["<token>"] ?? "Token not found.";
|
||||
BearerToken bearerToken = new(bearerTokenValue, timeout: TimeSpan.FromSeconds(1));
|
||||
options.AddTokens(bearerToken);
|
||||
|
||||
string basicTokenUsername = context.Configuration["<username>"] ?? "Username not found.";
|
||||
string basicTokenPassword = context.Configuration["<password>"] ?? "Password not found.";
|
||||
BasicToken basicToken = new(basicTokenUsername, basicTokenPassword, timeout: TimeSpan.FromSeconds(1));
|
||||
options.AddTokens(basicToken);
|
||||
|
||||
HttpSigningConfiguration config = new("<keyId>", "<keyFilePath>", null, new List<string>(), System.Security.Cryptography.HashAlgorithmName.SHA256, "<signingAlgorithm>", 0);
|
||||
HttpSignatureToken httpSignatureToken = new(config, timeout: TimeSpan.FromSeconds(1));
|
||||
options.AddTokens(httpSignatureToken);
|
||||
|
||||
string oauthTokenValue = context.Configuration["<token>"] ?? "Token not found.";
|
||||
OAuthToken oauthToken = new(oauthTokenValue, timeout: TimeSpan.FromSeconds(1));
|
||||
options.AddTokens(oauthToken);
|
||||
});
|
||||
|
||||
_host = hostBuild.Build();
|
||||
|
||||
_jsonSerializerOptions = _host.Services.GetRequiredService<JsonSerializerOptionsProvider>().Options;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Apple()
|
||||
{
|
||||
Apple apple = new("cultivar", "origin");
|
||||
string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions);
|
||||
Apple? apple2 = JsonSerializer.Deserialize<Apple>(appleJson, _jsonSerializerOptions);
|
||||
Assert.IsTrue(apple2 != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin.Equals(apple2.Origin));
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
//public void Pig()
|
||||
//{
|
||||
// BasquePig basquePig = new("BasquePig");
|
||||
// Pig pig = new(basquePig);
|
||||
// string pigJson = JsonSerializer.Serialize(pig, _jsonSerializerOptions);
|
||||
// Pig? pig2 = JsonSerializer.Deserialize<Pig>(pigJson, _jsonSerializerOptions);
|
||||
// Assert.IsTrue(
|
||||
// pig.DanishPig == null &&
|
||||
// pig.BasquePig != null &&
|
||||
// pig2 != null &&
|
||||
// pig2.BasquePig != null &&
|
||||
// pig2.DanishPig == null &&
|
||||
// pig2.BasquePig.ClassName.Equals(pig.BasquePig.ClassName));
|
||||
//}
|
||||
|
||||
[TestMethod]
|
||||
public void DanishPig()
|
||||
{
|
||||
DanishPig danishPig = new("danishPig");
|
||||
string danishPigJson = JsonSerializer.Serialize(danishPig, _jsonSerializerOptions);
|
||||
DanishPig? danishPig2 = JsonSerializer.Deserialize<DanishPig>(danishPigJson, _jsonSerializerOptions);
|
||||
Assert.IsTrue(danishPig2 != null && danishPig.ClassName.Equals(danishPig2.ClassName));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GmFruit()
|
||||
{
|
||||
Apple apple = new("cultivar", "origin");
|
||||
Banana banana = new(10);
|
||||
GmFruit gmFruit = new(apple, banana, "yellow");
|
||||
string gmFruitJson = JsonSerializer.Serialize(gmFruit, _jsonSerializerOptions);
|
||||
GmFruit? gmFruit2 = JsonSerializer.Deserialize<GmFruit>(gmFruitJson, _jsonSerializerOptions);
|
||||
Assert.IsTrue(
|
||||
gmFruit.Apple != null &&
|
||||
gmFruit.Banana != null &&
|
||||
gmFruit2 != null &&
|
||||
gmFruit2.Apple != null &&
|
||||
gmFruit2.Banana != null &&
|
||||
gmFruit2.Apple.Cultivar.Equals(gmFruit.Apple.Cultivar) &&
|
||||
gmFruit2.Apple.Origin.Equals(gmFruit.Apple.Origin) &&
|
||||
gmFruit2.Banana.LengthCm.Equals(gmFruit.Banana.LengthCm));
|
||||
|
||||
Apple? apple2 = JsonSerializer.Deserialize<Apple>(gmFruitJson);
|
||||
Assert.IsTrue(apple2 != null && apple.Cultivar == apple2.Cultivar && apple.Origin == apple2.Origin);
|
||||
// TODO: assert the the properties from Banana and GmFruit are in additionalProperties
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EquilateralTriangle()
|
||||
{
|
||||
EquilateralTriangle equilateralTriangle = new("triangle", "equilateral");
|
||||
string equilateralTriangleJson = JsonSerializer.Serialize(equilateralTriangle, _jsonSerializerOptions);
|
||||
EquilateralTriangle? equilateralTriangle2 = JsonSerializer.Deserialize<EquilateralTriangle>(equilateralTriangleJson, _jsonSerializerOptions);
|
||||
Assert.IsTrue(equilateralTriangle2 != null && equilateralTriangle.TriangleType.Equals(equilateralTriangle2.TriangleType) && equilateralTriangle.ShapeType.Equals(equilateralTriangle2.ShapeType));
|
||||
}
|
||||
|
||||
//[TestMethod]
|
||||
//public void Quadrilateral()
|
||||
//{
|
||||
// ComplexQuadrilateral complexQuadrilateral = new("ComplexQuadrilateral", "shapeType");
|
||||
// Quadrilateral quadrilateral = new(complexQuadrilateral);
|
||||
// string quadrilateralJson = JsonSerializer.Serialize(quadrilateral, _jsonSerializerOptions);
|
||||
// Quadrilateral? quadrilateral2 = JsonSerializer.Deserialize<Quadrilateral>(quadrilateralJson, _jsonSerializerOptions);
|
||||
// Assert.IsTrue(
|
||||
// quadrilateral.ComplexQuadrilateral != null &&
|
||||
// quadrilateral2 != null &&
|
||||
// quadrilateral2.SimpleQuadrilateral == null &&
|
||||
// quadrilateral2.ComplexQuadrilateral != null &&
|
||||
// quadrilateral2.ComplexQuadrilateral.QuadrilateralType.Equals(quadrilateral.ComplexQuadrilateral.QuadrilateralType) &&
|
||||
// quadrilateral2.ComplexQuadrilateral.ShapeType.Equals(quadrilateral.ComplexQuadrilateral.ShapeType));
|
||||
//}
|
||||
|
||||
[TestMethod]
|
||||
public void ChildCat()
|
||||
{
|
||||
ChildCat childCat = new("some name", Org.OpenAPITools.Model.ChildCat.PetTypeEnum.ChildCat);
|
||||
string childCatJson = JsonSerializer.Serialize(childCat, _jsonSerializerOptions);
|
||||
ChildCat? childCat2 = JsonSerializer.Deserialize<ChildCat>(childCatJson, _jsonSerializerOptions);
|
||||
Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name.Equals(childCat2.Name));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Cat()
|
||||
{
|
||||
Cat cat = new("cat", false, "black"); // TODO: where is the address property?
|
||||
string catJson = JsonSerializer.Serialize(cat, _jsonSerializerOptions);
|
||||
Cat? cat2 = JsonSerializer.Deserialize<Cat>(catJson, _jsonSerializerOptions);
|
||||
Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color.Equals(cat2.Color)); // TODO: add the address property
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33502.453
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAPIClient-generichost-manual-tests", "OpenAPIClient-generichost-manual-tests\OpenAPIClient-generichost-manual-tests.csproj", "{B120BBFD-C287-4235-A7CC-2C5B37601EB1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Org.OpenAPITools", "..\OpenAPIClient-generichost-net6.0-nrt\src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{C48E5ACD-1ACD-4084-843E-B29DFEE1779C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B120BBFD-C287-4235-A7CC-2C5B37601EB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B120BBFD-C287-4235-A7CC-2C5B37601EB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B120BBFD-C287-4235-A7CC-2C5B37601EB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B120BBFD-C287-4235-A7CC-2C5B37601EB1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C48E5ACD-1ACD-4084-843E-B29DFEE1779C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C48E5ACD-1ACD-4084-843E-B29DFEE1779C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C48E5ACD-1ACD-4084-843E-B29DFEE1779C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C48E5ACD-1ACD-4084-843E-B29DFEE1779C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {74A8A1EC-3768-438B-A540-61CF231CE7C0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,10 +0,0 @@
|
||||
# Org.OpenAPITools.Model.CatAllOf
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Declawed** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Org.OpenAPITools.Model.ChildCatAllOf
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | **string** | | [optional]
|
||||
**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
|
||||
|
||||
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Org.OpenAPITools.Model.DogAllOf
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Breed** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task FakeOuterBooleanSerializeAsyncTest()
|
||||
{
|
||||
bool? body = default!;
|
||||
bool body = default!;
|
||||
var response = await _instance.FakeOuterBooleanSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
Assert.IsType<bool>(model);
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task FakeOuterCompositeSerializeAsyncTest()
|
||||
{
|
||||
OuterComposite? outerComposite = default!;
|
||||
OuterComposite outerComposite = default!;
|
||||
var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite);
|
||||
var model = response.AsModel();
|
||||
Assert.IsType<OuterComposite>(model);
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task FakeOuterNumberSerializeAsyncTest()
|
||||
{
|
||||
decimal? body = default!;
|
||||
decimal body = default!;
|
||||
var response = await _instance.FakeOuterNumberSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
Assert.IsType<decimal>(model);
|
||||
@@ -104,7 +104,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FakeOuterStringSerializeAsyncTest()
|
||||
{
|
||||
Guid requiredStringUuid = default!;
|
||||
string? body = default!;
|
||||
string body = default!;
|
||||
var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body);
|
||||
var model = response.AsModel();
|
||||
Assert.IsType<string>(model);
|
||||
@@ -164,16 +164,16 @@ namespace Org.OpenAPITools.Test.Api
|
||||
decimal number = default!;
|
||||
double varDouble = default!;
|
||||
string patternWithoutDelimiter = default!;
|
||||
DateTime? date = default!;
|
||||
System.IO.Stream? binary = default!;
|
||||
float? varFloat = default!;
|
||||
int? integer = default!;
|
||||
int? int32 = default!;
|
||||
long? int64 = default!;
|
||||
string? varString = default!;
|
||||
string? password = default!;
|
||||
string? callback = default!;
|
||||
DateTime? dateTime = default!;
|
||||
DateTime date = default!;
|
||||
System.IO.Stream binary = default!;
|
||||
float varFloat = default!;
|
||||
int integer = default!;
|
||||
int int32 = default!;
|
||||
long int64 = default!;
|
||||
string varString = default!;
|
||||
string password = default!;
|
||||
string callback = default!;
|
||||
DateTime dateTime = default!;
|
||||
await _instance.TestEndpointParametersAsync(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime);
|
||||
}
|
||||
|
||||
@@ -183,14 +183,14 @@ namespace Org.OpenAPITools.Test.Api
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task TestEnumParametersAsyncTest()
|
||||
{
|
||||
List<string>? enumHeaderStringArray = default!;
|
||||
List<string>? enumQueryStringArray = default!;
|
||||
double? enumQueryDouble = default!;
|
||||
int? enumQueryInteger = default!;
|
||||
List<string>? enumFormStringArray = default!;
|
||||
string? enumHeaderString = default!;
|
||||
string? enumQueryString = default!;
|
||||
string? enumFormString = default!;
|
||||
List<string> enumHeaderStringArray = default!;
|
||||
List<string> enumQueryStringArray = default!;
|
||||
double enumQueryDouble = default!;
|
||||
int enumQueryInteger = default!;
|
||||
List<string> enumFormStringArray = default!;
|
||||
string enumHeaderString = default!;
|
||||
string enumQueryString = default!;
|
||||
string enumFormString = default!;
|
||||
await _instance.TestEnumParametersAsync(enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString);
|
||||
}
|
||||
|
||||
@@ -203,9 +203,9 @@ namespace Org.OpenAPITools.Test.Api
|
||||
bool requiredBooleanGroup = default!;
|
||||
int requiredStringGroup = default!;
|
||||
long requiredInt64Group = default!;
|
||||
bool? booleanGroup = default!;
|
||||
int? stringGroup = default!;
|
||||
long? int64Group = default!;
|
||||
bool booleanGroup = default!;
|
||||
int stringGroup = default!;
|
||||
long int64Group = default!;
|
||||
await _instance.TestGroupParametersAsync(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task DeletePetAsyncTest()
|
||||
{
|
||||
long petId = default!;
|
||||
string? apiKey = default!;
|
||||
string apiKey = default!;
|
||||
await _instance.DeletePetAsync(petId, apiKey);
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task UpdatePetWithFormAsyncTest()
|
||||
{
|
||||
long petId = default!;
|
||||
string? name = default!;
|
||||
string? status = default!;
|
||||
string name = default!;
|
||||
string status = default!;
|
||||
await _instance.UpdatePetWithFormAsync(petId, name, status);
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task UploadFileAsyncTest()
|
||||
{
|
||||
long petId = default!;
|
||||
System.IO.Stream? file = default!;
|
||||
string? additionalMetadata = default!;
|
||||
System.IO.Stream file = default!;
|
||||
string additionalMetadata = default!;
|
||||
var response = await _instance.UploadFileAsync(petId, file, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
@@ -151,7 +151,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
System.IO.Stream requiredFile = default!;
|
||||
long petId = default!;
|
||||
string? additionalMetadata = default!;
|
||||
string additionalMetadata = default!;
|
||||
var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
|
||||
using Xunit;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Org.OpenAPITools.Model;
|
||||
using Org.OpenAPITools.Client;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing CatAllOf
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
public class CatAllOfTests : IDisposable
|
||||
{
|
||||
// TODO uncomment below to declare an instance variable for CatAllOf
|
||||
//private CatAllOf instance;
|
||||
|
||||
public CatAllOfTests()
|
||||
{
|
||||
// TODO uncomment below to create an instance of CatAllOf
|
||||
//instance = new CatAllOf();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Cleanup when everything is done.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of CatAllOf
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CatAllOfInstanceTest()
|
||||
{
|
||||
// TODO uncomment below to test "IsType" CatAllOf
|
||||
//Assert.IsType<CatAllOf>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Declawed'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DeclawedTest()
|
||||
{
|
||||
// TODO unit test for the property 'Declawed'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
|
||||
using Xunit;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Org.OpenAPITools.Model;
|
||||
using Org.OpenAPITools.Client;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing ChildCatAllOf
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
public class ChildCatAllOfTests : IDisposable
|
||||
{
|
||||
// TODO uncomment below to declare an instance variable for ChildCatAllOf
|
||||
//private ChildCatAllOf instance;
|
||||
|
||||
public ChildCatAllOfTests()
|
||||
{
|
||||
// TODO uncomment below to create an instance of ChildCatAllOf
|
||||
//instance = new ChildCatAllOf();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Cleanup when everything is done.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of ChildCatAllOf
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ChildCatAllOfInstanceTest()
|
||||
{
|
||||
// TODO uncomment below to test "IsType" ChildCatAllOf
|
||||
//Assert.IsType<ChildCatAllOf>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Name'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NameTest()
|
||||
{
|
||||
// TODO unit test for the property 'Name'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'PetType'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void PetTypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'PetType'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
|
||||
using Xunit;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Org.OpenAPITools.Model;
|
||||
using Org.OpenAPITools.Client;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing DogAllOf
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
public class DogAllOfTests : IDisposable
|
||||
{
|
||||
// TODO uncomment below to declare an instance variable for DogAllOf
|
||||
//private DogAllOf instance;
|
||||
|
||||
public DogAllOfTests()
|
||||
{
|
||||
// TODO uncomment below to create an instance of DogAllOf
|
||||
//instance = new DogAllOf();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Cleanup when everything is done.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of DogAllOf
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DogAllOfInstanceTest()
|
||||
{
|
||||
// TODO uncomment below to test "IsType" DogAllOf
|
||||
//Assert.IsType<DogAllOf>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Breed'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void BreedTest()
|
||||
{
|
||||
// TODO unit test for the property 'Breed'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,41 +52,5 @@ namespace Org.OpenAPITools.Test.Model
|
||||
// TODO uncomment below to test "IsType" FruitReq
|
||||
//Assert.IsType<FruitReq>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Cultivar'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CultivarTest()
|
||||
{
|
||||
// TODO unit test for the property 'Cultivar'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'LengthCm'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void LengthCmTest()
|
||||
{
|
||||
// TODO unit test for the property 'LengthCm'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Mealy'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void MealyTest()
|
||||
{
|
||||
// TODO unit test for the property 'Mealy'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Sweet'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void SweetTest()
|
||||
{
|
||||
// TODO unit test for the property 'Sweet'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,32 +61,5 @@ namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
// TODO unit test for the property 'Color'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Cultivar'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CultivarTest()
|
||||
{
|
||||
// TODO unit test for the property 'Cultivar'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'LengthCm'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void LengthCmTest()
|
||||
{
|
||||
// TODO unit test for the property 'LengthCm'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Origin'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void OriginTest()
|
||||
{
|
||||
// TODO unit test for the property 'Origin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,32 +61,5 @@ namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
// TODO unit test for the property 'Color'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Cultivar'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CultivarTest()
|
||||
{
|
||||
// TODO unit test for the property 'Cultivar'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'LengthCm'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void LengthCmTest()
|
||||
{
|
||||
// TODO unit test for the property 'LengthCm'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Origin'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void OriginTest()
|
||||
{
|
||||
// TODO unit test for the property 'Origin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,32 +61,5 @@ namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
// TODO unit test for the property 'ClassName'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'HasBaleen'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void HasBaleenTest()
|
||||
{
|
||||
// TODO unit test for the property 'HasBaleen'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'HasTeeth'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void HasTeethTest()
|
||||
{
|
||||
// TODO unit test for the property 'HasTeeth'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Type'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'Type'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,15 +53,6 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<NullableShape>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'QuadrilateralType'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void QuadrilateralTypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'QuadrilateralType'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ShapeType'
|
||||
/// </summary>
|
||||
|
||||
@@ -61,14 +61,5 @@ namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
// TODO unit test for the property 'QuadrilateralType'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ShapeType'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ShapeTypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'ShapeType'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,15 +53,6 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<ShapeOrNull>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'QuadrilateralType'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void QuadrilateralTypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'QuadrilateralType'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ShapeType'
|
||||
/// </summary>
|
||||
|
||||
@@ -53,15 +53,6 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<Shape>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'QuadrilateralType'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void QuadrilateralTypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'QuadrilateralType'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ShapeType'
|
||||
/// </summary>
|
||||
|
||||
@@ -53,15 +53,6 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<Triangle>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ShapeType'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ShapeTypeTest()
|
||||
{
|
||||
// TODO unit test for the property 'ShapeType'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'TriangleType'
|
||||
/// </summary>
|
||||
|
||||
@@ -146,10 +146,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, activity, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Activity" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="activity"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("activity_outputs");
|
||||
JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,11 +162,22 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ActivityOutputElementRepresentation" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="activityOutputElementRepresentation"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
|
||||
writer.WritePropertyName("prop2");
|
||||
JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,24 +263,28 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("empty_map");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_of_map_property");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_property");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_with_undeclared_properties_anytype_1");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_with_undeclared_properties_anytype_2");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_with_undeclared_properties_anytype_3");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_with_undeclared_properties_string");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions);
|
||||
writer.WritePropertyName("anytype_1");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions);
|
||||
|
||||
WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="AdditionalPropertiesClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="additionalPropertiesClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("empty_map");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); writer.WritePropertyName("map_of_map_property");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); writer.WritePropertyName("map_property");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); writer.WritePropertyName("map_with_undeclared_properties_anytype_1");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); writer.WritePropertyName("map_with_undeclared_properties_anytype_2");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); writer.WritePropertyName("map_with_undeclared_properties_anytype_3");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); writer.WritePropertyName("map_with_undeclared_properties_string");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); writer.WritePropertyName("anytype_1");
|
||||
JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,10 +171,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, animal, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Animal" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="animal"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("className", animal.ClassName);
|
||||
writer.WriteString("color", animal.Color);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,11 +178,22 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, apiResponse, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ApiResponse" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="apiResponse"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("code", apiResponse.Code);
|
||||
writer.WriteString("message", apiResponse.Message);
|
||||
writer.WriteString("type", apiResponse.Type);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +175,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, apple, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Apple" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="apple"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("cultivar", apple.Cultivar);
|
||||
writer.WriteString("origin", apple.Origin);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,10 +155,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, appleReq, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="AppleReq" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="appleReq"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("cultivar", appleReq.Cultivar);
|
||||
writer.WriteBoolean("mealy", appleReq.Mealy);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,10 +146,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ArrayOfArrayOfNumberOnly" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="arrayOfArrayOfNumberOnly"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("ArrayArrayNumber");
|
||||
JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,10 +146,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ArrayOfNumberOnly" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="arrayOfNumberOnly"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("ArrayNumber");
|
||||
JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +180,23 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("array_array_of_integer");
|
||||
JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions);
|
||||
writer.WritePropertyName("array_array_of_model");
|
||||
JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions);
|
||||
writer.WritePropertyName("array_of_string");
|
||||
JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions);
|
||||
|
||||
WriteProperties(ref writer, arrayTest, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ArrayTest" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="arrayTest"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("array_array_of_integer");
|
||||
JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); writer.WritePropertyName("array_array_of_model");
|
||||
JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); writer.WritePropertyName("array_of_string");
|
||||
JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteNumber("lengthCm", banana.LengthCm);
|
||||
|
||||
WriteProperties(ref writer, banana, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Banana" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="banana"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("lengthCm", banana.LengthCm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,10 +156,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, bananaReq, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="BananaReq" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="bananaReq"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
|
||||
writer.WriteBoolean("sweet", bananaReq.Sweet);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("className", basquePig.ClassName);
|
||||
|
||||
WriteProperties(ref writer, basquePig, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="BasquePig" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="basquePig"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("className", basquePig.ClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,14 +226,25 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, capitalization, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Capitalization" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="capitalization"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
|
||||
writer.WriteString("CapitalCamel", capitalization.CapitalCamel);
|
||||
writer.WriteString("Capital_Snake", capitalization.CapitalSnake);
|
||||
writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints);
|
||||
writer.WriteString("smallCamel", capitalization.SmallCamel);
|
||||
writer.WriteString("small_Snake", capitalization.SmallSnake);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +146,22 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, cat, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Cat" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="cat"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("className", cat.ClassName);
|
||||
writer.WriteBoolean("declawed", cat.Declawed);
|
||||
writer.WriteString("color", cat.Color);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
// <auto-generated>
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
|
||||
|
||||
namespace Org.OpenAPITools.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// CatAllOf
|
||||
/// </summary>
|
||||
public partial class CatAllOf : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CatAllOf" /> class.
|
||||
/// </summary>
|
||||
/// <param name="declawed">declawed</param>
|
||||
[JsonConstructor]
|
||||
public CatAllOf(bool declawed)
|
||||
{
|
||||
Declawed = declawed;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Declawed
|
||||
/// </summary>
|
||||
[JsonPropertyName("declawed")]
|
||||
public bool Declawed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
/// </summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("class CatAllOf {\n");
|
||||
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
|
||||
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Json converter for type <see cref="CatAllOf" />
|
||||
/// </summary>
|
||||
public class CatAllOfJsonConverter : JsonConverter<CatAllOf>
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes json to <see cref="CatAllOf" />
|
||||
/// </summary>
|
||||
/// <param name="utf8JsonReader"></param>
|
||||
/// <param name="typeToConvert"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="JsonException"></exception>
|
||||
public override CatAllOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
int currentDepth = utf8JsonReader.CurrentDepth;
|
||||
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
|
||||
throw new JsonException();
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
bool? declawed = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReader.GetString();
|
||||
utf8JsonReader.Read();
|
||||
|
||||
switch (propertyName)
|
||||
{
|
||||
case "declawed":
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
declawed = utf8JsonReader.GetBoolean();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (declawed == null)
|
||||
throw new ArgumentNullException(nameof(declawed), "Property is required for class CatAllOf.");
|
||||
|
||||
return new CatAllOf(declawed.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes a <see cref="CatAllOf" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="catAllOf"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, CatAllOf catAllOf, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteBoolean("declawed", catAllOf.Declawed);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,10 +162,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, category, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Category" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("id", category.Id);
|
||||
writer.WriteString("name", category.Name);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,19 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, childCat, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ChildCat" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="childCat"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("name", childCat.Name);
|
||||
|
||||
var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType);
|
||||
@@ -207,8 +220,6 @@ namespace Org.OpenAPITools.Model
|
||||
writer.WriteString("pet_type", petTypeRawValue);
|
||||
else
|
||||
writer.WriteNull("pet_type");
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
// <auto-generated>
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
|
||||
|
||||
namespace Org.OpenAPITools.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// ChildCatAllOf
|
||||
/// </summary>
|
||||
public partial class ChildCatAllOf : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChildCatAllOf" /> class.
|
||||
/// </summary>
|
||||
/// <param name="name">name</param>
|
||||
/// <param name="petType">petType (default to PetTypeEnum.ChildCat)</param>
|
||||
[JsonConstructor]
|
||||
public ChildCatAllOf(string name, PetTypeEnum petType = PetTypeEnum.ChildCat)
|
||||
{
|
||||
Name = name;
|
||||
PetType = petType;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Defines PetType
|
||||
/// </summary>
|
||||
public enum PetTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum ChildCat for value: ChildCat
|
||||
/// </summary>
|
||||
ChildCat = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="PetTypeEnum"/>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public static PetTypeEnum PetTypeEnumFromString(string value)
|
||||
{
|
||||
if (value == "ChildCat")
|
||||
return PetTypeEnum.ChildCat;
|
||||
|
||||
throw new NotImplementedException($"Could not convert value to type PetTypeEnum: '{value}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="PetTypeEnum"/>
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static PetTypeEnum? PetTypeEnumFromStringOrDefault(string value)
|
||||
{
|
||||
if (value == "ChildCat")
|
||||
return PetTypeEnum.ChildCat;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="PetTypeEnum"/> to the json value
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public static string PetTypeEnumToJsonValue(PetTypeEnum value)
|
||||
{
|
||||
if (value == PetTypeEnum.ChildCat)
|
||||
return "ChildCat";
|
||||
|
||||
throw new NotImplementedException($"Value could not be handled: '{value}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PetType
|
||||
/// </summary>
|
||||
[JsonPropertyName("pet_type")]
|
||||
public PetTypeEnum PetType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
/// </summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("class ChildCatAllOf {\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append(" PetType: ").Append(PetType).Append("\n");
|
||||
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Json converter for type <see cref="ChildCatAllOf" />
|
||||
/// </summary>
|
||||
public class ChildCatAllOfJsonConverter : JsonConverter<ChildCatAllOf>
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes json to <see cref="ChildCatAllOf" />
|
||||
/// </summary>
|
||||
/// <param name="utf8JsonReader"></param>
|
||||
/// <param name="typeToConvert"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="JsonException"></exception>
|
||||
public override ChildCatAllOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
int currentDepth = utf8JsonReader.CurrentDepth;
|
||||
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
|
||||
throw new JsonException();
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? name = default;
|
||||
ChildCatAllOf.PetTypeEnum? petType = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReader.GetString();
|
||||
utf8JsonReader.Read();
|
||||
|
||||
switch (propertyName)
|
||||
{
|
||||
case "name":
|
||||
name = utf8JsonReader.GetString();
|
||||
break;
|
||||
case "pet_type":
|
||||
string? petTypeRawValue = utf8JsonReader.GetString();
|
||||
petType = petTypeRawValue == null
|
||||
? null
|
||||
: ChildCatAllOf.PetTypeEnumFromStringOrDefault(petTypeRawValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
throw new ArgumentNullException(nameof(name), "Property is required for class ChildCatAllOf.");
|
||||
|
||||
if (petType == null)
|
||||
throw new ArgumentNullException(nameof(petType), "Property is required for class ChildCatAllOf.");
|
||||
|
||||
return new ChildCatAllOf(name, petType.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes a <see cref="ChildCatAllOf" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="childCatAllOf"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, ChildCatAllOf childCatAllOf, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("name", childCatAllOf.Name);
|
||||
|
||||
var petTypeRawValue = ChildCatAllOf.PetTypeEnumToJsonValue(childCatAllOf.PetType);
|
||||
if (petTypeRawValue != null)
|
||||
writer.WriteString("pet_type", petTypeRawValue);
|
||||
else
|
||||
writer.WriteNull("pet_type");
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("_class", classModel.VarClass);
|
||||
|
||||
WriteProperties(ref writer, classModel, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ClassModel" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="classModel"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("_class", classModel.VarClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +161,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ComplexQuadrilateral" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="complexQuadrilateral"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType);
|
||||
writer.WriteString("shapeType", complexQuadrilateral.ShapeType);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("className", danishPig.ClassName);
|
||||
|
||||
WriteProperties(ref writer, danishPig, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="DanishPig" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="danishPig"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("className", danishPig.ClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,9 +152,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(DateOnlyPropertyFormat));
|
||||
|
||||
WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="DateOnlyClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="dateOnlyClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(DateOnlyPropertyFormat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("name", deprecatedObject.Name);
|
||||
|
||||
WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="DeprecatedObject" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="deprecatedObject"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("name", deprecatedObject.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,11 +145,22 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, dog, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Dog" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="dog"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("breed", dog.Breed);
|
||||
writer.WriteString("className", dog.ClassName);
|
||||
writer.WriteString("color", dog.Color);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
// <auto-generated>
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
|
||||
|
||||
namespace Org.OpenAPITools.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// DogAllOf
|
||||
/// </summary>
|
||||
public partial class DogAllOf : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DogAllOf" /> class.
|
||||
/// </summary>
|
||||
/// <param name="breed">breed</param>
|
||||
[JsonConstructor]
|
||||
public DogAllOf(string breed)
|
||||
{
|
||||
Breed = breed;
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
partial void OnCreated();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Breed
|
||||
/// </summary>
|
||||
[JsonPropertyName("breed")]
|
||||
public string Breed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
/// </summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("class DogAllOf {\n");
|
||||
sb.Append(" Breed: ").Append(Breed).Append("\n");
|
||||
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Json converter for type <see cref="DogAllOf" />
|
||||
/// </summary>
|
||||
public class DogAllOfJsonConverter : JsonConverter<DogAllOf>
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes json to <see cref="DogAllOf" />
|
||||
/// </summary>
|
||||
/// <param name="utf8JsonReader"></param>
|
||||
/// <param name="typeToConvert"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="JsonException"></exception>
|
||||
public override DogAllOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
int currentDepth = utf8JsonReader.CurrentDepth;
|
||||
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
|
||||
throw new JsonException();
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? breed = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReader.GetString();
|
||||
utf8JsonReader.Read();
|
||||
|
||||
switch (propertyName)
|
||||
{
|
||||
case "breed":
|
||||
breed = utf8JsonReader.GetString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (breed == null)
|
||||
throw new ArgumentNullException(nameof(breed), "Property is required for class DogAllOf.");
|
||||
|
||||
return new DogAllOf(breed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes a <see cref="DogAllOf" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="dogAllOf"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, DogAllOf dogAllOf, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("breed", dogAllOf.Breed);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,16 +185,24 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("mainShape");
|
||||
JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions);
|
||||
writer.WritePropertyName("shapes");
|
||||
JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions);
|
||||
writer.WritePropertyName("nullableShape");
|
||||
JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions);
|
||||
writer.WritePropertyName("shapeOrNull");
|
||||
JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions);
|
||||
|
||||
WriteProperties(ref writer, drawing, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Drawing" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="drawing"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("mainShape");
|
||||
JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); writer.WritePropertyName("shapes");
|
||||
JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); writer.WritePropertyName("nullableShape");
|
||||
JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); writer.WritePropertyName("shapeOrNull");
|
||||
JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,16 +297,26 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, enumArrays, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="EnumArrays" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="enumArrays"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("array_enum");
|
||||
JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions);
|
||||
|
||||
var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbol);
|
||||
if (justSymbolRawValue != null)
|
||||
writer.WriteString("just_symbol", justSymbolRawValue);
|
||||
else
|
||||
writer.WriteNull("just_symbol");
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,6 +635,19 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, enumTest, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="EnumTest" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="enumTest"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumInteger));
|
||||
writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnly));
|
||||
writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumber));
|
||||
@@ -673,8 +686,6 @@ namespace Org.OpenAPITools.Model
|
||||
else
|
||||
writer.WriteNull("outerEnum");
|
||||
}
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +161,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="EquilateralTriangle" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="equilateralTriangle"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", equilateralTriangle.ShapeType);
|
||||
writer.WriteString("triangleType", equilateralTriangle.TriangleType);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("sourceURI", file.SourceURI);
|
||||
|
||||
WriteProperties(ref writer, file, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="File" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("sourceURI", file.SourceURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,12 +163,22 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("file");
|
||||
JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions);
|
||||
writer.WritePropertyName("files");
|
||||
JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions);
|
||||
|
||||
WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="FileSchemaTestClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="fileSchemaTestClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("file");
|
||||
JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); writer.WritePropertyName("files");
|
||||
JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("bar", foo.Bar);
|
||||
|
||||
WriteProperties(ref writer, foo, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Foo" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="foo"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("bar", foo.Bar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,10 +146,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="FooGetDefaultResponse" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="fooGetDefaultResponse"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("string");
|
||||
JsonSerializer.Serialize(writer, fooGetDefaultResponse.VarString, jsonSerializerOptions);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,15 +575,25 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, formatTest, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="FormatTest" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="formatTest"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("binary");
|
||||
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
|
||||
writer.WritePropertyName("byte");
|
||||
JsonSerializer.Serialize(writer, formatTest.VarByte, jsonSerializerOptions);
|
||||
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
|
||||
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); writer.WritePropertyName("byte");
|
||||
JsonSerializer.Serialize(writer, formatTest.VarByte, jsonSerializerOptions); writer.WriteString("date", formatTest.Date.ToString(DateFormat));
|
||||
writer.WriteString("dateTime", formatTest.DateTime.ToString(DateTimeFormat));
|
||||
writer.WritePropertyName("decimal");
|
||||
JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions);
|
||||
writer.WriteNumber("double", formatTest.VarDouble);
|
||||
JsonSerializer.Serialize(writer, formatTest.VarDecimal, jsonSerializerOptions); writer.WriteNumber("double", formatTest.VarDouble);
|
||||
writer.WriteNumber("float", formatTest.VarFloat);
|
||||
writer.WriteNumber("int32", formatTest.Int32);
|
||||
writer.WriteNumber("int64", formatTest.Int64);
|
||||
@@ -597,8 +607,6 @@ namespace Org.OpenAPITools.Model
|
||||
writer.WriteNumber("unsigned_integer", formatTest.UnsignedInteger);
|
||||
writer.WriteNumber("unsigned_long", formatTest.UnsignedLong);
|
||||
writer.WriteString("uuid", formatTest.Uuid);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,28 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? color = default;
|
||||
|
||||
Apple? apple = default;
|
||||
Banana? banana = default;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
|
||||
while (utf8JsonReaderOneOf.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderApple = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<Apple?>(ref utf8JsonReaderApple, jsonSerializerOptions, out apple);
|
||||
|
||||
Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<Banana?>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana);
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -149,12 +171,10 @@ namespace Org.OpenAPITools.Model
|
||||
if (color == null)
|
||||
throw new ArgumentNullException(nameof(color), "Property is required for class Fruit.");
|
||||
|
||||
Utf8JsonReader appleReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Apple>(ref appleReader, jsonSerializerOptions, out Apple? apple))
|
||||
if (apple != null)
|
||||
return new Fruit(apple, color);
|
||||
|
||||
Utf8JsonReader bananaReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Banana>(ref bananaReader, jsonSerializerOptions, out Banana? banana))
|
||||
if (banana != null)
|
||||
return new Fruit(banana, color);
|
||||
|
||||
throw new JsonException();
|
||||
@@ -169,15 +189,22 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, fruit.Apple, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, fruit.Banana, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("color", fruit.Color);
|
||||
|
||||
WriteProperties(ref writer, fruit, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Fruit" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="fruit"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("color", fruit.Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,28 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
AppleReq? appleReq = default;
|
||||
BananaReq? bananaReq = default;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
|
||||
while (utf8JsonReaderOneOf.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderAppleReq = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<AppleReq?>(ref utf8JsonReaderAppleReq, jsonSerializerOptions, out appleReq);
|
||||
|
||||
Utf8JsonReader utf8JsonReaderBananaReq = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<BananaReq?>(ref utf8JsonReaderBananaReq, jsonSerializerOptions, out bananaReq);
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -130,12 +152,10 @@ namespace Org.OpenAPITools.Model
|
||||
}
|
||||
}
|
||||
|
||||
Utf8JsonReader appleReqReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<AppleReq>(ref appleReqReader, jsonSerializerOptions, out AppleReq? appleReq))
|
||||
if (appleReq != null)
|
||||
return new FruitReq(appleReq);
|
||||
|
||||
Utf8JsonReader bananaReqReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<BananaReq>(ref bananaReqReader, jsonSerializerOptions, out BananaReq? bananaReq))
|
||||
if (bananaReq != null)
|
||||
return new FruitReq(bananaReq);
|
||||
|
||||
throw new JsonException();
|
||||
@@ -150,13 +170,22 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, fruitReq.AppleReq, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, fruitReq.BananaReq, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, fruitReq, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="FruitReq" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="fruitReq"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Org.OpenAPITools.Model
|
||||
[JsonConstructor]
|
||||
public GmFruit(Apple? apple, Banana? banana, string color)
|
||||
{
|
||||
Apple = Apple;
|
||||
Banana = Banana;
|
||||
Apple = apple;
|
||||
Banana = banana;
|
||||
Color = color;
|
||||
OnCreated();
|
||||
}
|
||||
@@ -109,14 +109,30 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
Utf8JsonReader appleReader = utf8JsonReader;
|
||||
bool appleDeserialized = Client.ClientUtils.TryDeserialize<Apple>(ref appleReader, jsonSerializerOptions, out Apple? apple);
|
||||
|
||||
Utf8JsonReader bananaReader = utf8JsonReader;
|
||||
bool bananaDeserialized = Client.ClientUtils.TryDeserialize<Banana>(ref bananaReader, jsonSerializerOptions, out Banana? banana);
|
||||
|
||||
string? color = default;
|
||||
|
||||
Apple? apple = default;
|
||||
Banana? banana = default;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader;
|
||||
while (utf8JsonReaderAnyOf.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderApple = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<Apple?>(ref utf8JsonReaderApple, jsonSerializerOptions, out apple);
|
||||
|
||||
Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<Banana?>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana);
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -156,15 +172,34 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, gmFruit.Apple, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, gmFruit.Banana, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("color", gmFruit.Color);
|
||||
if (gmFruit.Apple != null)
|
||||
{
|
||||
AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Apple.GetType()));
|
||||
AppleJsonConverter.WriteProperties(ref writer, gmFruit.Apple, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
if (gmFruit.Banana != null)
|
||||
{
|
||||
BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.Banana.GetType()));
|
||||
BananaJsonConverter.WriteProperties(ref writer, gmFruit.Banana, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, gmFruit, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="GmFruit" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="gmFruit"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("color", gmFruit.Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,9 +155,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("pet_type", grandparentAnimal.PetType);
|
||||
|
||||
WriteProperties(ref writer, grandparentAnimal, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="GrandparentAnimal" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="grandparentAnimal"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("pet_type", grandparentAnimal.PetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,10 +198,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="HasOnlyReadOnly" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="hasOnlyReadOnly"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("bar", hasOnlyReadOnly.Bar);
|
||||
writer.WriteString("foo", hasOnlyReadOnly.Foo);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,9 +142,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("NullableMessage", healthCheckResult.NullableMessage);
|
||||
|
||||
WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="HealthCheckResult" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="healthCheckResult"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("NullableMessage", healthCheckResult.NullableMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +154,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="IsoscelesTriangle" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="isoscelesTriangle"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", isoscelesTriangle.ShapeType);
|
||||
writer.WriteString("triangleType", isoscelesTriangle.TriangleType);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("123-list", list.Var123List);
|
||||
|
||||
WriteProperties(ref writer, list, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="List" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("123-list", list.Var123List);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +161,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, literalStringClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="LiteralStringClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="literalStringClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
|
||||
writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,45 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? className = default;
|
||||
|
||||
Pig? pig = null;
|
||||
Whale? whale = null;
|
||||
Zebra? zebra = null;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName?.Equals("className") ?? false)
|
||||
{
|
||||
string? discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
if (discriminator?.Equals("Pig") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderPig = utf8JsonReader;
|
||||
pig = JsonSerializer.Deserialize<Pig>(ref utf8JsonReaderPig, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("whale") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderWhale = utf8JsonReader;
|
||||
whale = JsonSerializer.Deserialize<Whale>(ref utf8JsonReaderWhale, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("zebra") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderZebra = utf8JsonReader;
|
||||
zebra = JsonSerializer.Deserialize<Zebra>(ref utf8JsonReaderZebra, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -184,18 +223,15 @@ namespace Org.OpenAPITools.Model
|
||||
if (className == null)
|
||||
throw new ArgumentNullException(nameof(className), "Property is required for class Mammal.");
|
||||
|
||||
Utf8JsonReader whaleReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Whale>(ref whaleReader, jsonSerializerOptions, out Whale? whale))
|
||||
if (pig != null)
|
||||
return new Mammal(pig, className);
|
||||
|
||||
if (whale != null)
|
||||
return new Mammal(whale, className);
|
||||
|
||||
Utf8JsonReader zebraReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Zebra>(ref zebraReader, jsonSerializerOptions, out Zebra? zebra))
|
||||
if (zebra != null)
|
||||
return new Mammal(zebra, className);
|
||||
|
||||
Utf8JsonReader pigReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Pig>(ref pigReader, jsonSerializerOptions, out Pig? pig))
|
||||
return new Mammal(pig, className);
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
@@ -208,17 +244,37 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, mammal.Whale, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, mammal.Zebra, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, mammal.Pig, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("className", mammal.ClassName);
|
||||
if (mammal.Pig != null) {
|
||||
PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType()));
|
||||
pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
if (mammal.Whale != null) {
|
||||
WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType()));
|
||||
whaleJsonConverter.WriteProperties(ref 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);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, mammal, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Mammal" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="mammal"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("className", mammal.ClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,16 +263,24 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("direct_map");
|
||||
JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions);
|
||||
writer.WritePropertyName("indirect_map");
|
||||
JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_map_of_string");
|
||||
JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions);
|
||||
writer.WritePropertyName("map_of_enum_string");
|
||||
JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions);
|
||||
|
||||
WriteProperties(ref writer, mapTest, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="MapTest" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="mapTest"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("direct_map");
|
||||
JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); writer.WritePropertyName("indirect_map");
|
||||
JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); writer.WritePropertyName("map_map_of_string");
|
||||
JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); writer.WritePropertyName("map_of_enum_string");
|
||||
JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,13 +209,23 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="MixedPropertiesAndAdditionalPropertiesClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="mixedPropertiesAndAdditionalPropertiesClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTime.ToString(DateTimeFormat));
|
||||
writer.WritePropertyName("map");
|
||||
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
|
||||
writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.Uuid);
|
||||
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.Uuid);
|
||||
writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPattern);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,10 +162,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, model200Response, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Model200Response" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="model200Response"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("class", model200Response.VarClass);
|
||||
writer.WriteNumber("name", model200Response.Name);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("client", modelClient.VarClient);
|
||||
|
||||
WriteProperties(ref writer, modelClient, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ModelClient" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("client", modelClient.VarClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,12 +233,23 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, name, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Name" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("name", name.VarName);
|
||||
writer.WriteString("property", name.Property);
|
||||
writer.WriteNumber("snake_case", name.SnakeCase);
|
||||
writer.WriteNumber("123Number", name.Var123Number);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,15 +306,24 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("array_items_nullable");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions);
|
||||
writer.WritePropertyName("object_items_nullable");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions);
|
||||
writer.WritePropertyName("array_and_items_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions);
|
||||
writer.WritePropertyName("array_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions);
|
||||
WriteProperties(ref writer, nullableClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="NullableClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="nullableClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("array_items_nullable");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); writer.WritePropertyName("object_items_nullable");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); writer.WritePropertyName("array_and_items_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); writer.WritePropertyName("array_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions);
|
||||
if (nullableClass.BooleanProp != null)
|
||||
writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value);
|
||||
else
|
||||
@@ -341,12 +350,8 @@ namespace Org.OpenAPITools.Model
|
||||
writer.WriteNull("number_prop");
|
||||
|
||||
writer.WritePropertyName("object_and_items_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions);
|
||||
writer.WritePropertyName("object_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions);
|
||||
writer.WriteString("string_prop", nullableClass.StringProp);
|
||||
|
||||
writer.WriteEndObject();
|
||||
JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); writer.WritePropertyName("object_nullable_prop");
|
||||
JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); writer.WriteString("string_prop", nullableClass.StringProp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +144,24 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="NullableGuidClass" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="nullableGuidClass"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
|
||||
if (nullableGuidClass.Uuid == null)
|
||||
writer.WriteNull("uuid");
|
||||
else
|
||||
writer.WriteString("uuid", nullableGuidClass.Uuid.Value);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,39 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? shapeType = default;
|
||||
|
||||
Quadrilateral? quadrilateral = null;
|
||||
Triangle? triangle = null;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName?.Equals("shapeType") ?? false)
|
||||
{
|
||||
string? discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
if (discriminator?.Equals("Quadrilateral") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader;
|
||||
quadrilateral = JsonSerializer.Deserialize<Quadrilateral>(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("Triangle") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader;
|
||||
triangle = JsonSerializer.Deserialize<Triangle>(ref utf8JsonReaderTriangle, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -166,14 +199,12 @@ namespace Org.OpenAPITools.Model
|
||||
if (shapeType == null)
|
||||
throw new ArgumentNullException(nameof(shapeType), "Property is required for class NullableShape.");
|
||||
|
||||
Utf8JsonReader triangleReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Triangle>(ref triangleReader, jsonSerializerOptions, out Triangle? triangle))
|
||||
return new NullableShape(triangle, shapeType);
|
||||
|
||||
Utf8JsonReader quadrilateralReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Quadrilateral>(ref quadrilateralReader, jsonSerializerOptions, out Quadrilateral? quadrilateral))
|
||||
if (quadrilateral != null)
|
||||
return new NullableShape(quadrilateral, shapeType);
|
||||
|
||||
if (triangle != null)
|
||||
return new NullableShape(triangle, shapeType);
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
@@ -186,15 +217,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, nullableShape.Triangle, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, nullableShape.Quadrilateral, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("shapeType", nullableShape.ShapeType);
|
||||
if (nullableShape.Quadrilateral != null) {
|
||||
QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType()));
|
||||
quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
if (nullableShape.Triangle != null) {
|
||||
TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType()));
|
||||
triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, nullableShape, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="NullableShape" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="nullableShape"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", nullableShape.ShapeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteNumber("JustNumber", numberOnly.JustNumber);
|
||||
|
||||
WriteProperties(ref writer, numberOnly, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="NumberOnly" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="numberOnly"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("JustNumber", numberOnly.JustNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,14 +199,23 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("bars");
|
||||
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions);
|
||||
writer.WritePropertyName("deprecatedRef");
|
||||
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
|
||||
writer.WriteNumber("id", objectWithDeprecatedFields.Id);
|
||||
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
|
||||
|
||||
WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ObjectWithDeprecatedFields" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="objectWithDeprecatedFields"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("bars");
|
||||
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); writer.WritePropertyName("deprecatedRef");
|
||||
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); writer.WriteNumber("id", objectWithDeprecatedFields.Id);
|
||||
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
string? varString = default;
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -121,8 +123,10 @@ namespace Org.OpenAPITools.Model
|
||||
}
|
||||
}
|
||||
|
||||
Utf8JsonReader varStringReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<string>(ref varStringReader, jsonSerializerOptions, out string? varString))
|
||||
if (varString != null)
|
||||
return new OneOfString(varString);
|
||||
|
||||
if (varString != null)
|
||||
return new OneOfString(varString);
|
||||
|
||||
throw new JsonException();
|
||||
@@ -137,11 +141,22 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, oneOfString.VarString, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, oneOfString, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="OneOfString" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="oneOfString"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +321,19 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, order, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Order" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("id", order.Id);
|
||||
writer.WriteNumber("petId", order.PetId);
|
||||
writer.WriteNumber("quantity", order.Quantity);
|
||||
@@ -333,8 +346,6 @@ namespace Org.OpenAPITools.Model
|
||||
writer.WriteNull("status");
|
||||
|
||||
writer.WriteBoolean("complete", order.Complete);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,11 +179,22 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, outerComposite, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="OuterComposite" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="outerComposite"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteBoolean("my_boolean", outerComposite.MyBoolean);
|
||||
writer.WriteNumber("my_number", outerComposite.MyNumber);
|
||||
writer.WriteString("my_string", outerComposite.MyString);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +121,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("pet_type", parentPet.PetType);
|
||||
|
||||
WriteProperties(ref writer, parentPet, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ParentPet" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="parentPet"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("pet_type", parentPet.PetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,13 +315,24 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, pet, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Pet" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="pet"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WritePropertyName("category");
|
||||
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
|
||||
writer.WriteNumber("id", pet.Id);
|
||||
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); writer.WriteNumber("id", pet.Id);
|
||||
writer.WriteString("name", pet.Name);
|
||||
writer.WritePropertyName("photoUrls");
|
||||
JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions);
|
||||
|
||||
var statusRawValue = Pet.StatusEnumToJsonValue(pet.Status);
|
||||
if (statusRawValue != null)
|
||||
writer.WriteString("status", statusRawValue);
|
||||
@@ -330,8 +341,6 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
writer.WritePropertyName("tags");
|
||||
JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,39 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? className = default;
|
||||
|
||||
BasquePig? basquePig = null;
|
||||
DanishPig? danishPig = null;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName?.Equals("className") ?? false)
|
||||
{
|
||||
string? discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
if (discriminator?.Equals("BasquePig") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderBasquePig = utf8JsonReader;
|
||||
basquePig = JsonSerializer.Deserialize<BasquePig>(ref utf8JsonReaderBasquePig, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("DanishPig") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderDanishPig = utf8JsonReader;
|
||||
danishPig = JsonSerializer.Deserialize<DanishPig>(ref utf8JsonReaderDanishPig, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -166,12 +199,10 @@ namespace Org.OpenAPITools.Model
|
||||
if (className == null)
|
||||
throw new ArgumentNullException(nameof(className), "Property is required for class Pig.");
|
||||
|
||||
Utf8JsonReader basquePigReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<BasquePig>(ref basquePigReader, jsonSerializerOptions, out BasquePig? basquePig))
|
||||
if (basquePig != null)
|
||||
return new Pig(basquePig, className);
|
||||
|
||||
Utf8JsonReader danishPigReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<DanishPig>(ref danishPigReader, jsonSerializerOptions, out DanishPig? danishPig))
|
||||
if (danishPig != null)
|
||||
return new Pig(danishPig, className);
|
||||
|
||||
throw new JsonException();
|
||||
@@ -186,15 +217,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, pig.BasquePig, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, pig.DanishPig, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("className", pig.ClassName);
|
||||
if (pig.BasquePig != null) {
|
||||
BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType()));
|
||||
basquePigJsonConverter.WriteProperties(ref 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);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, pig, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Pig" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="pig"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("className", pig.ClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,36 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
bool? varBool = default;
|
||||
string? varString = default;
|
||||
Object? varObject = default;
|
||||
List<string>? list = default;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
|
||||
while (utf8JsonReaderOneOf.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderVarBool = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderVarBool, jsonSerializerOptions, out varBool);
|
||||
|
||||
Utf8JsonReader utf8JsonReaderVarString = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<string?>(ref utf8JsonReaderVarString, jsonSerializerOptions, out varString);
|
||||
|
||||
Utf8JsonReader utf8JsonReaderVarObject = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<Object?>(ref utf8JsonReaderVarObject, jsonSerializerOptions, out varObject);
|
||||
|
||||
Utf8JsonReader utf8JsonReaderList = utf8JsonReader;
|
||||
OpenAPIClientUtils.TryDeserialize<List<string>?>(ref utf8JsonReaderList, jsonSerializerOptions, out list);
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -169,20 +199,16 @@ namespace Org.OpenAPITools.Model
|
||||
}
|
||||
}
|
||||
|
||||
Utf8JsonReader varBoolReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<bool>(ref varBoolReader, jsonSerializerOptions, out bool varBool))
|
||||
if (varBool != null)
|
||||
return new PolymorphicProperty(varBool);
|
||||
|
||||
Utf8JsonReader varStringReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<string>(ref varStringReader, jsonSerializerOptions, out string? varString))
|
||||
if (varString != null)
|
||||
return new PolymorphicProperty(varString);
|
||||
|
||||
Utf8JsonReader varObjectReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Object>(ref varObjectReader, jsonSerializerOptions, out Object? varObject))
|
||||
if (varObject != null)
|
||||
return new PolymorphicProperty(varObject);
|
||||
|
||||
Utf8JsonReader listReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<List<string>>(ref listReader, jsonSerializerOptions, out List<string>? list))
|
||||
if (list != null)
|
||||
return new PolymorphicProperty(list);
|
||||
|
||||
throw new JsonException();
|
||||
@@ -197,17 +223,22 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, polymorphicProperty.VarBool, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, polymorphicProperty.VarString, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, polymorphicProperty.VarObject, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, polymorphicProperty.List, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="PolymorphicProperty" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="polymorphicProperty"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,39 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? quadrilateralType = default;
|
||||
|
||||
ComplexQuadrilateral? complexQuadrilateral = null;
|
||||
SimpleQuadrilateral? simpleQuadrilateral = null;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName?.Equals("quadrilateralType") ?? false)
|
||||
{
|
||||
string? discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
if (discriminator?.Equals("ComplexQuadrilateral") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderComplexQuadrilateral = utf8JsonReader;
|
||||
complexQuadrilateral = JsonSerializer.Deserialize<ComplexQuadrilateral>(ref utf8JsonReaderComplexQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("SimpleQuadrilateral") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderSimpleQuadrilateral = utf8JsonReader;
|
||||
simpleQuadrilateral = JsonSerializer.Deserialize<SimpleQuadrilateral>(ref utf8JsonReaderSimpleQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -166,14 +199,12 @@ namespace Org.OpenAPITools.Model
|
||||
if (quadrilateralType == null)
|
||||
throw new ArgumentNullException(nameof(quadrilateralType), "Property is required for class Quadrilateral.");
|
||||
|
||||
Utf8JsonReader simpleQuadrilateralReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<SimpleQuadrilateral>(ref simpleQuadrilateralReader, jsonSerializerOptions, out SimpleQuadrilateral? simpleQuadrilateral))
|
||||
return new Quadrilateral(simpleQuadrilateral, quadrilateralType);
|
||||
|
||||
Utf8JsonReader complexQuadrilateralReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<ComplexQuadrilateral>(ref complexQuadrilateralReader, jsonSerializerOptions, out ComplexQuadrilateral? complexQuadrilateral))
|
||||
if (complexQuadrilateral != null)
|
||||
return new Quadrilateral(complexQuadrilateral, quadrilateralType);
|
||||
|
||||
if (simpleQuadrilateral != null)
|
||||
return new Quadrilateral(simpleQuadrilateral, quadrilateralType);
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
@@ -186,15 +217,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType);
|
||||
if (quadrilateral.ComplexQuadrilateral != null) {
|
||||
ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType()));
|
||||
complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
if (quadrilateral.SimpleQuadrilateral != null) {
|
||||
SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType()));
|
||||
simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, quadrilateral, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Quadrilateral" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="quadrilateral"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
|
||||
|
||||
WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="QuadrilateralInterface" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="quadrilateralInterface"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,10 +197,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ReadOnlyFirst" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="readOnlyFirst"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("bar", readOnlyFirst.Bar);
|
||||
writer.WriteString("baz", readOnlyFirst.Baz);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteNumber("return", varReturn.VarReturn);
|
||||
|
||||
WriteProperties(ref writer, varReturn, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Return" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="varReturn"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteNumber("return", varReturn.VarReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +161,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ScaleneTriangle" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="scaleneTriangle"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", scaleneTriangle.ShapeType);
|
||||
writer.WriteString("triangleType", scaleneTriangle.TriangleType);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,39 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? shapeType = default;
|
||||
|
||||
Quadrilateral? quadrilateral = null;
|
||||
Triangle? triangle = null;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName?.Equals("shapeType") ?? false)
|
||||
{
|
||||
string? discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
if (discriminator?.Equals("Quadrilateral") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader;
|
||||
quadrilateral = JsonSerializer.Deserialize<Quadrilateral>(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("Triangle") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader;
|
||||
triangle = JsonSerializer.Deserialize<Triangle>(ref utf8JsonReaderTriangle, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -166,14 +199,12 @@ namespace Org.OpenAPITools.Model
|
||||
if (shapeType == null)
|
||||
throw new ArgumentNullException(nameof(shapeType), "Property is required for class Shape.");
|
||||
|
||||
Utf8JsonReader triangleReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Triangle>(ref triangleReader, jsonSerializerOptions, out Triangle? triangle))
|
||||
return new Shape(triangle, shapeType);
|
||||
|
||||
Utf8JsonReader quadrilateralReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Quadrilateral>(ref quadrilateralReader, jsonSerializerOptions, out Quadrilateral? quadrilateral))
|
||||
if (quadrilateral != null)
|
||||
return new Shape(quadrilateral, shapeType);
|
||||
|
||||
if (triangle != null)
|
||||
return new Shape(triangle, shapeType);
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
@@ -186,15 +217,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, shape.Triangle, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, shape.Quadrilateral, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("shapeType", shape.ShapeType);
|
||||
if (shape.Quadrilateral != null) {
|
||||
QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType()));
|
||||
quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
if (shape.Triangle != null) {
|
||||
TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType()));
|
||||
triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, shape, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="Shape" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="shape"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", shape.ShapeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,20 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("shapeType", shapeInterface.ShapeType);
|
||||
|
||||
WriteProperties(ref writer, shapeInterface, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ShapeInterface" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="shapeInterface"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", shapeInterface.ShapeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,39 @@ namespace Org.OpenAPITools.Model
|
||||
|
||||
string? shapeType = default;
|
||||
|
||||
Quadrilateral? quadrilateral = null;
|
||||
Triangle? triangle = null;
|
||||
|
||||
Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader;
|
||||
while (utf8JsonReaderDiscriminator.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth)
|
||||
break;
|
||||
|
||||
if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1)
|
||||
{
|
||||
string? propertyName = utf8JsonReaderDiscriminator.GetString();
|
||||
utf8JsonReaderDiscriminator.Read();
|
||||
if (propertyName?.Equals("shapeType") ?? false)
|
||||
{
|
||||
string? discriminator = utf8JsonReaderDiscriminator.GetString();
|
||||
if (discriminator?.Equals("Quadrilateral") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader;
|
||||
quadrilateral = JsonSerializer.Deserialize<Quadrilateral>(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
if (discriminator?.Equals("Triangle") ?? false)
|
||||
{
|
||||
Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader;
|
||||
triangle = JsonSerializer.Deserialize<Triangle>(ref utf8JsonReaderTriangle, jsonSerializerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (utf8JsonReader.Read())
|
||||
{
|
||||
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
|
||||
@@ -166,14 +199,12 @@ namespace Org.OpenAPITools.Model
|
||||
if (shapeType == null)
|
||||
throw new ArgumentNullException(nameof(shapeType), "Property is required for class ShapeOrNull.");
|
||||
|
||||
Utf8JsonReader triangleReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Triangle>(ref triangleReader, jsonSerializerOptions, out Triangle? triangle))
|
||||
return new ShapeOrNull(triangle, shapeType);
|
||||
|
||||
Utf8JsonReader quadrilateralReader = utf8JsonReader;
|
||||
if (Client.ClientUtils.TryDeserialize<Quadrilateral>(ref quadrilateralReader, jsonSerializerOptions, out Quadrilateral? quadrilateral))
|
||||
if (quadrilateral != null)
|
||||
return new ShapeOrNull(quadrilateral, shapeType);
|
||||
|
||||
if (triangle != null)
|
||||
return new ShapeOrNull(triangle, shapeType);
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
|
||||
@@ -186,15 +217,32 @@ namespace Org.OpenAPITools.Model
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, shapeOrNull.Triangle, jsonSerializerOptions);
|
||||
|
||||
System.Text.Json.JsonSerializer.Serialize(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions);
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteString("shapeType", shapeOrNull.ShapeType);
|
||||
if (shapeOrNull.Quadrilateral != null) {
|
||||
QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType()));
|
||||
quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
if (shapeOrNull.Triangle != null) {
|
||||
TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType()));
|
||||
triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="ShapeOrNull" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="shapeOrNull"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("shapeType", shapeOrNull.ShapeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +161,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="SimpleQuadrilateral" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="simpleQuadrilateral"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType);
|
||||
writer.WriteString("shapeType", simpleQuadrilateral.ShapeType);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,10 +162,21 @@ namespace Org.OpenAPITools.Model
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
WriteProperties(ref writer, specialModelName, jsonSerializerOptions);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the properties of <see cref="SpecialModelName" />
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="specialModelName"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
|
||||
{
|
||||
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
|
||||
writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyName);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user