diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index fefad19184a..b346ab2fe1d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -403,7 +403,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co return super.addMustacheLambdas() .put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true)) .put("required", new RequiredParameterLambda().generator(this)) - .put("optional", new OptionalParameterLambda().generator(this)); + .put("optional", new OptionalParameterLambda().generator(this)) + .put("joinWithComma", new JoinWithCommaLambda()); } @Override diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java index 405cb0b6710..2369305102a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java @@ -42,6 +42,7 @@ import java.util.List; import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.underscore; +import static org.openapitools.codegen.CodegenDiscriminator.MappedModel; @SuppressWarnings("Duplicates") public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen { @@ -516,6 +517,14 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen { postProcessPattern(property.pattern, property.vendorExtensions); postProcessEmitDefaultValue(property.vendorExtensions); + if (GENERICHOST.equals(getLibrary())) { + // all c# libraries should want this, but avoid breaking changes for now + // a class cannot contain a property with the same name + if (property.name.equals(model.classname)) { + property.name = property.name + "Property"; + } + } + super.postProcessModelProperty(model, property); } @@ -892,8 +901,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln")); supportingFiles.add(new SupportingFile("netcore_project.mustache", packageFolder, packageName + ".csproj")); supportingFiles.add(new SupportingFile("appveyor.mustache", "", "appveyor.yml")); - supportingFiles.add(new SupportingFile("AbstractOpenAPISchema.mustache", modelPackageDir, "AbstractOpenAPISchema.cs")); - supportingFiles.add(new SupportingFile("OpenAPIDateConverter.mustache", clientPackageDir, "OpenAPIDateConverter.cs")); + supportingFiles.add(new SupportingFile("OpenAPIDateConverter.mustache", clientPackageDir, "OpenAPIDateJsonConverter.cs")); supportingFiles.add(new SupportingFile("ApiResponseEventArgs.mustache", clientPackageDir, "ApiResponseEventArgs.cs")); supportingFiles.add(new SupportingFile("IApi.mustache", clientPackageDir, getInterfacePrefix() + "Api.cs")); @@ -1327,11 +1335,129 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen { cm.isNullable = true; cm.anyOf.remove("Null"); } + + for (CodegenProperty cp : cm.readWriteVars) { + // ISSUE: https://github.com/OpenAPITools/openapi-generator/issues/11844 + // allVars may not have all properties + // see modules\openapi-generator\src\test\resources\3_0\allOf.yaml + // property boosterSeat will be in readWriteVars but not allVars + // the property is present in the model but gets removed at CodegenModel#removeDuplicatedProperty + if (Boolean.FALSE.equals(cm.allVars.stream().anyMatch(v -> v.baseName.equals(cp.baseName)))) { + LOGGER.debug("Property " + cp.baseName + " was found in readWriteVars but not in allVars. Adding it back to allVars"); + cm.allVars.add(cp); + } + } + + for (CodegenProperty cp : cm.allVars) { + // ISSUE: https://github.com/OpenAPITools/openapi-generator/issues/11845 + // some properties do not have isInherited set correctly + // see modules\openapi-generator\src\test\resources\3_0\allOf.yaml + // Child properties Type, LastName, FirstName will have isInherited set to false when it should be true + if (cp.isInherited){ + continue; + } + if (Boolean.TRUE.equals(cm.parentVars.stream().anyMatch(v -> v.baseName.equals(cp.baseName) && v.dataType.equals(cp.dataType)))) { + LOGGER.debug("Property " + cp.baseName + " was found in the parentVars but not marked as inherited."); + cp.isInherited = true; + } + } } return objs; } + /** + * ISSUE: https://github.com/OpenAPITools/openapi-generator/issues/11846 + * Ensures that a model has all inherited properties + * Check modules\openapi-generator\src\test\resources\3_0\java\petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml + * Without this method, property petType in GrandparentAnimal will not make it through ParentPet and into ChildCat + */ + private void EnsureInheritedVariablesArePresent(CodegenModel derivedModel) { + // every c# generator should definetly want this, or we should fix the issue + // still, lets avoid breaking changes :( + if (Boolean.FALSE.equals(GENERICHOST.equals(getLibrary()))){ + return; + } + + if (derivedModel.parentModel == null){ + return; + } + + for (CodegenProperty parentProperty : derivedModel.parentModel.allVars){ + if (Boolean.FALSE.equals(derivedModel.allVars.stream().anyMatch(v -> v.baseName.equals(parentProperty.baseName)))) { + CodegenProperty clone = parentProperty.clone(); + clone.isInherited = true; + LOGGER.debug("Inherited property " + clone.name + " from model" + derivedModel.parentModel.classname + " was not found in " + derivedModel.classname + ". Adding a clone now."); + derivedModel.allVars.add(clone); + } + } + + EnsureInheritedVariablesArePresent(derivedModel.parentModel); + } + + /** + * Invoked by {@link DefaultGenerator} after all models have been post-processed, allowing for a last pass of codegen-specific model cleanup. + * + * @param objs Current state of codegen object model. + * @return An in-place modified state of the codegen object model. + */ + @Override + public Map postProcessAllModels(Map objs) { + objs = super.postProcessAllModels(objs); + + // other libraries probably want these fixes, but lets avoid breaking changes for now + if (Boolean.FALSE.equals(GENERICHOST.equals(getLibrary()))){ + return objs; + } + + ArrayList allModels = new ArrayList(); + for (Map.Entry entry : objs.entrySet()) { + CodegenModel model = ModelUtils.getModelByName(entry.getKey(), objs); + allModels.add(model); + } + + for (CodegenModel cm : allModels) { + if (cm.parent != null){ + // remove the parent CodegenProperty from the model + // we need it gone so we can use allOf/oneOf/anyOf in the constructor + cm.allOf.removeIf(item -> item.equals(cm.parent)); + cm.oneOf.removeIf(item -> item.equals(cm.parent)); + cm.anyOf.removeIf(item -> item.equals(cm.parent)); + } + + cm.anyOf.forEach(anyOf -> removePropertiesDeclaredInComposedClass(anyOf, allModels, cm)); + cm.oneOf.forEach(oneOf -> removePropertiesDeclaredInComposedClass(oneOf, allModels, cm)); + cm.allOf.forEach(allOf -> removePropertiesDeclaredInComposedClass(allOf, allModels, cm)); + + EnsureInheritedVariablesArePresent(cm); + } + + return objs; + } + + /** + * Removes properties from a model which are also defined in a composed class. + * + * @param className The name which may be a composed model + * @param allModels A collection of all CodegenModel + * @param cm The CodegenModel to correct + */ + private void removePropertiesDeclaredInComposedClass(String className, List allModels, CodegenModel cm) { + CodegenModel otherModel = allModels.stream().filter(m -> m.classname.equals(className)).findFirst().orElse(null); + if (otherModel == null){ + return; + } + + otherModel.readWriteVars.stream().filter(v -> cm.readWriteVars.stream().anyMatch(cmV -> cmV.baseName.equals(v.baseName))).collect(Collectors.toList()) + .forEach(v -> { + cm.readWriteVars.removeIf(item -> item.baseName.equals(v.baseName)); + cm.vars.removeIf(item -> item.baseName.equals(v.baseName)); + cm.readOnlyVars.removeIf(item -> item.baseName.equals(v.baseName)); + cm.requiredVars.removeIf(item -> item.baseName.equals(v.baseName)); + cm.allVars.removeIf(item -> item.baseName.equals(v.baseName)); + }); + } + @Override public void postProcess() { System.out.println("################################################################################"); diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelEnum.mustache index 39bcd2eddc1..d3709c5bc94 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelEnum.mustache @@ -8,7 +8,9 @@ {{#enumVars}} {{#-first}} {{#isString}} + {{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] + {{/useGenericHost}} {{/isString}} {{/-first}} {{/enumVars}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelInnerEnum.mustache index d9e96dccdb3..d2a6d1ef1ce 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore-functions/modelInnerEnum.mustache @@ -6,7 +6,9 @@ /// {{description}} {{/description}} {{#isString}} + {{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] + {{/useGenericHost}} {{/isString}} {{>visibility}} enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}} { diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache index 4aa977913dc..d46df0dfbdb 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ApiResponse`1.mustache @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; namespace {{packageName}}.Client { diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ClientUtils.mustache index fa3db528f1b..a53daf9b6f4 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ClientUtils.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/ClientUtils.mustache @@ -46,21 +46,53 @@ namespace {{packageName}}.Client public delegate void EventHandler(object sender, T e) where T : EventArgs; /// - /// Custom JSON serializer + /// Returns true when deserialization succeeds. /// - public static Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get; set; } = new Newtonsoft.Json.JsonSerializerSettings + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, System.Text.Json.JsonSerializerOptions options, {{^netStandard}}[System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/netStandard}}out T{{#nrt}}{{^netStandard}}?{{/netStandard}}{{/nrt}} result) { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore, - ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver + try { - NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } + result = System.Text.Json.JsonSerializer.Deserialize(json, options); + return result != null; } - }; + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, {{^netStandard}}[System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/netStandard}}out T{{#nrt}}{{^netStandard}}?{{/netStandard}}{{/nrt}} result) + { + try + { + result = System.Text.Json.JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Json serializer options + /// + public static System.Text.Json.JsonSerializerOptions JsonSerializerOptions { get; set; } = new System.Text.Json.JsonSerializerOptions(); /// /// Sanitize filename by removing the path @@ -169,7 +201,7 @@ namespace {{packageName}}.Client /// /// The Content-Type array to select from. /// The Content-Type header to use. - public static string SelectHeaderContentType(string[] contentTypes) + public static string{{nrt?}} SelectHeaderContentType(string[] contentTypes) { if (contentTypes.Length == 0) return null; @@ -190,7 +222,7 @@ namespace {{packageName}}.Client /// /// The accepts array to select from. /// The Accept header to use. - public static string SelectHeaderAccept(string[] accepts) + public static string{{nrt?}} SelectHeaderAccept(string[] accepts) { if (accepts.Length == 0) return null; diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/HostConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/HostConfiguration.mustache index d8dfd3108cc..4b5039df332 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/HostConfiguration.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/HostConfiguration.mustache @@ -6,6 +6,7 @@ using System.Linq; using System.Net.Http; using Microsoft.Extensions.DependencyInjection; using {{packageName}}.Api; +using {{packageName}}.Model; namespace {{packageName}}.Client { @@ -63,6 +64,31 @@ namespace {{packageName}}.Client public HostConfiguration Add{{apiName}}HttpClients( Action{{nrt?}} client = null, Action{{nrt?}} builder = null) { + ClientUtils.JsonSerializerOptions.Converters.Add(new OpenAPIDateJsonConverter()); +{{#models}} +{{#model}} +{{^isEnum}} +{{#useGenericHost}} +{{#allOf}} +{{#-first}} + ClientUtils.JsonSerializerOptions.Converters.Add(new {{classname}}JsonConverter()); +{{/-first}} +{{/allOf}} +{{#anyOf}} +{{#-first}} + ClientUtils.JsonSerializerOptions.Converters.Add(new {{classname}}JsonConverter()); +{{/-first}} +{{/anyOf}} +{{#oneOf}} +{{#-first}} + ClientUtils.JsonSerializerOptions.Converters.Add(new {{classname}}JsonConverter()); +{{/-first}} +{{/oneOf}} +{{/useGenericHost}} +{{/isEnum}} +{{/model}} +{{/models}} + Add{{apiName}}HttpClients<{{#apiInfo}}{{#apis}}{{classname}}{{^-last}}, {{/-last}}{{/apis}}{{/apiInfo}}>(client, builder); return this; @@ -73,9 +99,9 @@ namespace {{packageName}}.Client /// /// /// - public HostConfiguration ConfigureJsonOptions(Action options) + public HostConfiguration ConfigureJsonOptions(Action options) { - options(Client.ClientUtils.JsonSerializerSettings); + options(Client.ClientUtils.JsonSerializerOptions); return this; } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache new file mode 100644 index 00000000000..a5536994cce --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache @@ -0,0 +1,128 @@ + /// + /// A Json converter for type {{classname}} + /// + public class {{classname}}JsonConverter : JsonConverter<{{classname}}> + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof({{classname}}).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override {{classname}} Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + {{#anyOf}} + Utf8JsonReader {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}Reader = reader; + Client.ClientUtils.TryDeserialize<{{.}}>(ref {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}Reader, options, out {{.}}{{nrt?}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}); + + {{/anyOf}} + {{#oneOf}} + Utf8JsonReader {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}Reader = reader; + Client.ClientUtils.TryDeserialize<{{.}}>(ref {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}Reader, options, out {{.}}{{nrt?}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}); + + {{/oneOf}} + {{#allOf}} + Utf8JsonReader {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}Reader = reader; + Client.ClientUtils.TryDeserialize<{{.}}>(ref {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}Reader, options, out {{.}}{{nrt?}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}); + {{/allOf}} + {{#allVars}} + {{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default; + {{/allVars}} + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string{{nrt?}} propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + {{#allVars}} + case "{{baseName}}": + {{#isString}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetString(); + {{/isString}} + {{#isBoolean}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetBoolean(); + {{/isBoolean}} + {{#isDecimal}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetDecimal(); + {{/isDecimal}} + {{#isNumeric}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetInt32(); + {{/isNumeric}} + {{#isLong}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetInt64(); + {{/isLong}} + {{#isDouble}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetDouble(); + {{/isDouble}} + {{#isDate}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetDateTime(); + {{/isDate}} + {{#isDateTime}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetDateTime(); + {{/isDateTime}} + {{^isString}} + {{^isBoolean}} + {{^isDecimal}} + {{^isNumeric}} + {{^isLong}} + {{^isDouble}} + {{^isDate}} + {{^isDateTime}} + {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<{{{datatypeWithEnum}}}>(ref reader, options); + {{/isDateTime}} + {{/isDate}} + {{/isDouble}} + {{/isLong}} + {{/isNumeric}} + {{/isDecimal}} + {{/isBoolean}} + {{/isString}} + break; + {{/allVars}} + } + } + } + + {{#oneOf}} + if ({{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} != null) + return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{#allOf}}{{#lambda.camelcase_param}}{{.}} {{/lambda.camelcase_param}}{{/allOf}}{{#anyOf}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{/allVars}}{{/lambda.joinWithComma}}); + + {{#-last}} + throw new JsonException(); + {{/-last}} + {{/oneOf}} + {{^oneOf}} + return new {{classname}}({{#lambda.joinWithComma}}{{#anyOf}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/anyOf}}{{#allOf}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/allOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{/allVars}}{{/lambda.joinWithComma}}); + {{/oneOf}} + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}, JsonSerializerOptions options) => throw new NotImplementedException(); + } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/OpenAPIDateConverter.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/OpenAPIDateConverter.mustache new file mode 100644 index 00000000000..144ac7328ac --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/OpenAPIDateConverter.mustache @@ -0,0 +1,34 @@ +{{>partial_header}} +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace {{packageName}}.Client +{ + /// + /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class OpenAPIDateJsonConverter : JsonConverter + { + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + DateTime.ParseExact(reader.GetString(){{nrt!}}, "yyyy-MM-dd", CultureInfo.InvariantCulture); + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); + } +} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache index 8a5bc255e33..cbcad6140a0 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/api.mustache @@ -279,7 +279,8 @@ namespace {{packageName}}.{{apiPackage}} if (({{paramName}} as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject({{paramName}}, ClientUtils.JsonSerializerSettings));{{/bodyParam}}{{#authMethods}}{{#-first}} + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject({{paramName}}, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize({{paramName}}, ClientUtils.JsonSerializerOptions));{{/bodyParam}}{{#authMethods}}{{#-first}} List tokens = new List();{{/-first}}{{#isApiKey}} @@ -347,7 +348,7 @@ namespace {{packageName}}.{{apiPackage}} request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); {{/-first}}{{/produces}}{{^netStandard}} request.Method = HttpMethod.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}};{{/netStandard}}{{#netStandard}} - request.Method = new HttpMethod("{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}");{{/netStandard}} {{! early standard versions do not have HttpMethod.Patch }} + request.Method = new HttpMethod("{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}");{{/netStandard}}{{! early standard versions do not have HttpMethod.Patch }} using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -370,7 +371,7 @@ namespace {{packageName}}.{{apiPackage}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}{{nrt?}}> apiResponse = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}{{nrt?}}>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings);{{#authMethods}} + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions);{{#authMethods}} else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit();{{/authMethods}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/model.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/model.mustache new file mode 100644 index 00000000000..44143ec95c1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/model.mustache @@ -0,0 +1,47 @@ +// +{{>partial_header}} +{{#nrt}}#nullable enable{{/nrt}} + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +{{#validatable}} +using System.ComponentModel.DataAnnotations; +{{/validatable}} +{{#useCompareNetObjects}} +using OpenAPIClientUtils = {{packageName}}.Client.ClientUtils; +{{/useCompareNetObjects}} +{{#models}} +{{#model}} + +namespace {{packageName}}.{{modelPackage}} +{ +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}} + +{{#allOf}} +{{#-first}} +{{>JsonConverter}} +{{/-first}} +{{/allOf}} +{{#anyOf}} +{{#-first}} +{{>JsonConverter}} +{{/-first}} +{{/anyOf}} +{{#oneOf}} +{{#-first}} +{{>JsonConverter}} +{{/-first}} +{{/oneOf}} +{{/isEnum}} +{{/model}} +{{/models}} +} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/modelGeneric.mustache index 2ecca5b10e7..85fcbe2fc8e 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/modelGeneric.mustache @@ -1,15 +1,88 @@ /// /// {{description}}{{^description}}{{classname}}{{/description}} /// - [DataContract(Name = "{{{name}}}")] - {{#discriminator}} - [JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")] - {{#mappedModels}} - [JsonSubtypes.KnownSubType(typeof({{{modelName}}}), "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")] - {{/mappedModels}} - {{/discriminator}} - {{>visibility}} partial class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>{{#validatable}}, IValidatableObject{{/validatable}} + {{>visibility}} partial class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>{{#validatable}}{{^parentModel}}, IValidatableObject{{/parentModel}}{{/validatable}} { + {{#oneOf}} + /// + /// Initializes a new instance of the class. + /// + /// {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} + {{#anyOf}} + /// {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} + {{/anyOf}} + {{#allOf}} + /// {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} + {{/allOf}} + {{#allVars}} + /// {{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{.}}){{/defaultValue}} + {{/allVars}} + public {{classname}}({{#lambda.joinWithComma}}{{.}}{{nrt?}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{#anyOf}}{{.}}{{nrt?}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/anyOf}}{{#allVars}}{{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^required}}{{^defaultValue}} = default{{/defaultValue}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#isInherited}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/isInherited}}{{#anyOf}}{{#isInherited}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/isInherited}}{{/anyOf}}{{#allVars}}{{#isInherited}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{/isInherited}}{{/allVars}}{{/lambda.joinWithComma}}){{/parent}} + { + {{#allVars}} + {{^isInherited}} + {{#required}} + {{^isNullable}} + if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) + throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null."); + {{/isNullable}} + {{/required}} + {{/isInherited}} + {{/allVars}} + {{.}} = {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}; + {{#anyOf}} + {{.}} = {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}; + {{/anyOf}} + {{#allOf}} + {{.}} = {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}; + {{/allOf}} + {{#allVars}} + {{^isInherited}} + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{/isInherited}} + {{/allVars}} + } + + {{/oneOf}} + {{^oneOf}} + /// + /// Initializes a new instance of the class. + /// + {{#anyOf}} + /// {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} + {{/anyOf}} + {{#allOf}} + /// {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} + {{/allOf}} + {{#allVars}} + /// {{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{.}}){{/defaultValue}} + {{/allVars}} + public {{classname}}({{#lambda.joinWithComma}}{{#anyOf}}{{.}}{{nrt?}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/anyOf}}{{#allOf}}{{.}} {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/allOf}}{{#allVars}}{{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^required}}{{^defaultValue}} = default{{/defaultValue}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}}){{#parentModel}} : base({{#lambda.joinWithComma}}{{#anyOf}}{{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}} {{/anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{/allVars}}{{/lambda.joinWithComma}}){{/parentModel}} + { + {{#allVars}} + {{^isInherited}} + {{#required}} + {{^isNullable}} + if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) + throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null."); + {{/isNullable}} + {{/required}} + {{/isInherited}} + {{/allVars}} + {{#anyOf}} + {{.}} = {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}; + {{/anyOf}} + {{#allOf}} + {{.}} = {{#lambda.camelcase_param}}{{.}}{{/lambda.camelcase_param}}; + {{/allOf}} + {{#allVars}} + {{^isInherited}} + {{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; + {{/isInherited}} + {{/allVars}} + } + + {{/oneOf}} {{#vars}} {{#items.isEnum}} {{#items}} @@ -24,257 +97,78 @@ {{/complexType}} {{/isEnum}} {{#isEnum}} - /// /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} /// {{#description}} /// {{.}} {{/description}} - {{^conditionalSerialization}} - [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isBoolean}}true{{/isBoolean}}{{^isBoolean}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/isBoolean}}{{/vendorExtensions.x-emit-default-value}})] + [JsonPropertyName("{{baseName}}")] {{#deprecated}} [Obsolete] {{/deprecated}} - public {{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{name}} { get; set; } - {{#isReadOnly}} - - /// - /// Returns false as {{name}} should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize{{name}}() - { - return false; - } - {{/isReadOnly}} - {{/conditionalSerialization}} - {{#conditionalSerialization}} - {{#isReadOnly}} - [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isBoolean}}true{{/isBoolean}}{{^isBoolean}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/isBoolean}}{{/vendorExtensions.x-emit-default-value}})] - {{#deprecated}} - [Obsolete] - {{/deprecated}} - public {{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{name}} { get; set; } - - /// - /// Returns false as {{name}} should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize{{name}}() - { - return false; - } - {{/isReadOnly}} - - {{^isReadOnly}} - [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isBoolean}}true{{/isBoolean}}{{^isBoolean}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/isBoolean}}{{/vendorExtensions.x-emit-default-value}})] - {{#deprecated}} - [Obsolete] - {{/deprecated}} - public {{{complexType}}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} - { - get{ return _{{name}};} - set - { - _{{name}} = value; - _flag{{name}} = true; - } - } - private {{{complexType}}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} _{{name}}; - private bool _flag{{name}}; - - /// - /// Returns false as {{name}} should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize{{name}}() - { - return _flag{{name}}; - } - {{/isReadOnly}} - {{/conditionalSerialization}} + public {{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } + {{/isEnum}} {{/vars}} - {{#hasRequired}} - {{^hasOnlyReadOnly}} + {{#anyOf}} /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - {{^isAdditionalPropertiesTrue}} - protected {{classname}}() { } - {{/isAdditionalPropertiesTrue}} - {{#isAdditionalPropertiesTrue}} - protected {{classname}}() - { - this.AdditionalProperties = new Dictionary(); - } - {{/isAdditionalPropertiesTrue}} - {{/hasOnlyReadOnly}} - {{/hasRequired}} - /// - /// Initializes a new instance of the class. - /// - {{#readWriteVars}} - /// {{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}. - {{/readWriteVars}} - {{#hasOnlyReadOnly}} - [JsonConstructorAttribute] - {{/hasOnlyReadOnly}} - public {{classname}}({{#readWriteVars}}{{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^required}}{{^defaultValue}} = default{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/readWriteVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}} - { - {{#vars}} - {{^isInherited}} - {{^isReadOnly}} - {{#required}} - {{^conditionalSerialization}} - {{^vendorExtensions.x-csharp-value-type}} - // to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null) - if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) { - throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null"); - } - this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/vendorExtensions.x-csharp-value-type}} - {{#vendorExtensions.x-csharp-value-type}} - this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/vendorExtensions.x-csharp-value-type}} - {{/conditionalSerialization}} - {{#conditionalSerialization}} - {{^vendorExtensions.x-csharp-value-type}} - // to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null) - if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null) { - throw new ArgumentNullException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null"); - } - this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/vendorExtensions.x-csharp-value-type}} - {{#vendorExtensions.x-csharp-value-type}} - this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/vendorExtensions.x-csharp-value-type}} - {{/conditionalSerialization}} - {{/required}} - {{/isReadOnly}} - {{/isInherited}} - {{/vars}} - {{#vars}} - {{^isInherited}} - {{^isReadOnly}} - {{^required}} - {{#defaultValue}} - {{^conditionalSerialization}} - {{^vendorExtensions.x-csharp-value-type}} - // use default value if no "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" provided - this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? {{{defaultValue}}}; - {{/vendorExtensions.x-csharp-value-type}} - {{#vendorExtensions.x-csharp-value-type}} - this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/vendorExtensions.x-csharp-value-type}} - {{/conditionalSerialization}} - {{/defaultValue}} - {{^defaultValue}} - {{^conditionalSerialization}} - this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/conditionalSerialization}} - {{#conditionalSerialization}} - this._{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; - {{/conditionalSerialization}} - {{/defaultValue}} - {{/required}} - {{/isReadOnly}} - {{/isInherited}} - {{/vars}} - {{#isAdditionalPropertiesTrue}} - this.AdditionalProperties = new Dictionary(); - {{/isAdditionalPropertiesTrue}} - } + /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} + /// {{#description}} + /// {{.}}{{/description}} + {{#deprecated}} + [Obsolete] + {{/deprecated}} + public {{.}}{{nrt?}} {{.}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } - {{#vars}} + {{/anyOf}} + {{#oneOf}} + /// + /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} + /// {{#description}} + /// {{.}}{{/description}} + {{#deprecated}} + [Obsolete] + {{/deprecated}} + public {{.}}{{nrt?}} {{.}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } + + {{/oneOf}} + {{#allOf}} + /// + /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} + /// {{#description}} + /// {{.}}{{/description}} + {{#deprecated}} + [Obsolete] + {{/deprecated}} + public {{.}}{{nrt?}} {{.}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } + + {{/allOf}} + {{#allVars}} {{^isInherited}} {{^isEnum}} /// /// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} /// {{#description}} /// {{.}}{{/description}} - {{^conditionalSerialization}} - [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isBoolean}}true{{/isBoolean}}{{^isBoolean}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/isBoolean}}{{/vendorExtensions.x-emit-default-value}})] - {{#isDate}} - [JsonConverter(typeof(OpenAPIDateConverter))] - {{/isDate}} + [JsonPropertyName("{{baseName}}")] {{#deprecated}} [Obsolete] {{/deprecated}} public {{#isNullable}}{{#required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}}{{^isNullable}}{{#required}}{{{datatypeWithEnum}}}{{/required}}{{/isNullable}}{{#isNullable}}{{^required}}{{#lambda.optional}}{{{datatypeWithEnum}}}{{/lambda.optional}}{{/required}}{{/isNullable}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } - {{#isReadOnly}} - /// - /// Returns false as {{name}} should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize{{name}}() - { - return false; - } - {{/isReadOnly}} - {{/conditionalSerialization}} - {{#conditionalSerialization}} - {{#isReadOnly}} - [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isBoolean}}true{{/isBoolean}}{{^isBoolean}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/isBoolean}}{{/vendorExtensions.x-emit-default-value}})] - {{#isDate}} - [JsonConverter(typeof(OpenAPIDateConverter))] - {{/isDate}} - {{#deprecated}} - [Obsolete] - {{/deprecated}} - public {{#isNullable}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}}{{/isNullable}}{{^isNullable}}{{{dataType}}}{{/isNullable}} {{name}} { get; private set; } - /// - /// Returns false as {{name}} should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize{{name}}() - { - return false; - } - {{/isReadOnly}} - {{^isReadOnly}} - {{#isDate}} - [JsonConverter(typeof(OpenAPIDateConverter))] - {{/isDate}} - [DataMember(Name = "{{baseName}}"{{#required}}, IsRequired = true{{/required}}, EmitDefaultValue = {{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isBoolean}}true{{/isBoolean}}{{^isBoolean}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{/isBoolean}}{{/vendorExtensions.x-emit-default-value}})] - {{#deprecated}} - [Obsolete] - {{/deprecated}} - public {{#required}}{{#lambda.required}}{{{dataType}}}{{/lambda.required}}{{/required}}{{^required}}{{#lambda.optional}}{{{dataType}}}{{/lambda.optional}}{{/required}} {{name}} - { - get{ return _{{name}};} - set - { - _{{name}} = value; - _flag{{name}} = true; - } - } - private {{{dataType}}} _{{name}}; - private bool _flag{{name}}; - - /// - /// Returns false as {{name}} should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize{{name}}() - { - return _flag{{name}}; - } - {{/isReadOnly}} - {{/conditionalSerialization}} {{/isEnum}} {{/isInherited}} - {{/vars}} + {{/allVars}} {{#isAdditionalPropertiesTrue}} + {{^parentModel}} /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); + {{/parentModel}} {{/isAdditionalPropertiesTrue}} /// /// Returns the string presentation of the object @@ -291,27 +185,20 @@ sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); {{/vars}} {{#isAdditionalPropertiesTrue}} + {{^parentModel}} sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + {{/parentModel}} {{/isAdditionalPropertiesTrue}} sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public {{#parent}}{{^isArray}}{{^isMap}}override {{/isMap}}{{/isArray}}{{/parent}}{{^parent}}virtual {{/parent}}string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object{{nrt?}} input) { {{#useCompareNetObjects}} return OpenAPIClientUtils.compareLogic.Compare(this, input as {{classname}}).AreEqual; @@ -326,7 +213,7 @@ /// /// Instance of {{classname}} to be compared /// Boolean - public bool Equals({{classname}} input) + public bool Equals({{classname}}{{nrt?}} input) { {{#useCompareNetObjects}} return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; @@ -354,7 +241,9 @@ {{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}}) ){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesTrue}} + {{^parentModel}} && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); + {{/parentModel}} {{/isAdditionalPropertiesTrue}} {{/useCompareNetObjects}} } @@ -385,104 +274,20 @@ {{/vendorExtensions.x-is-value-type}} {{/vars}} {{#isAdditionalPropertiesTrue}} + {{^parentModel}} if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); } + {{/parentModel}} {{/isAdditionalPropertiesTrue}} return hashCode; } } {{#validatable}} -{{#discriminator}} - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { -{{/discriminator}} -{{^discriminator}} - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { -{{/discriminator}} - {{#parent}} - {{^isArray}} - {{^isMap}} - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - {{/isMap}} - {{/isArray}} - {{/parent}} - {{#vars}} - {{#hasValidation}} - {{^isEnum}} - {{#maxLength}} - // {{{name}}} ({{{dataType}}}) maxLength - if (this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" }); - } - - {{/maxLength}} - {{#minLength}} - // {{{name}}} ({{{dataType}}}) minLength - if (this.{{{name}}} != null && this.{{{name}}}.Length < {{minLength}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" }); - } - - {{/minLength}} - {{#maximum}} - // {{{name}}} ({{{dataType}}}) maximum - if (this.{{{name}}} > ({{{dataType}}}){{maximum}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" }); - } - - {{/maximum}} - {{#minimum}} - // {{{name}}} ({{{dataType}}}) minimum - if (this.{{{name}}} < ({{{dataType}}}){{minimum}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" }); - } - - {{/minimum}} - {{#pattern}} - {{^isByteArray}} - // {{{name}}} ({{{dataType}}}) pattern - Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}); - if (false == regex{{{name}}}.Match(this.{{{name}}}).Success) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" }); - } - - {{/isByteArray}} - {{/pattern}} - {{/isEnum}} - {{/hasValidation}} - {{/vars}} - yield break; - } +{{^parentModel}} +{{>validatable}} +{{/parentModel}} {{/validatable}} - } + } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelEnum.mustache index d781952b4e0..c993fc2cc3d 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelEnum.mustache @@ -8,7 +8,9 @@ {{#enumVars}} {{#-first}} {{#isString}} + {{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] + {{/useGenericHost}} {{/isString}} {{/-first}} {{/enumVars}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache index a032fb745b9..2fb5ecc51a8 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache @@ -403,94 +403,6 @@ } {{#validatable}} -{{#discriminator}} - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { -{{/discriminator}} -{{^discriminator}} - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { -{{/discriminator}} - {{#parent}} - {{^isArray}} - {{^isMap}} - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - {{/isMap}} - {{/isArray}} - {{/parent}} - {{#vars}} - {{#hasValidation}} - {{^isEnum}} - {{#maxLength}} - // {{{name}}} ({{{dataType}}}) maxLength - if (this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" }); - } - - {{/maxLength}} - {{#minLength}} - // {{{name}}} ({{{dataType}}}) minLength - if (this.{{{name}}} != null && this.{{{name}}}.Length < {{minLength}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" }); - } - - {{/minLength}} - {{#maximum}} - // {{{name}}} ({{{dataType}}}) maximum - if (this.{{{name}}} > ({{{dataType}}}){{maximum}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" }); - } - - {{/maximum}} - {{#minimum}} - // {{{name}}} ({{{dataType}}}) minimum - if (this.{{{name}}} < ({{{dataType}}}){{minimum}}) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" }); - } - - {{/minimum}} - {{#pattern}} - {{^isByteArray}} - // {{{name}}} ({{{dataType}}}) pattern - Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}); - if (false == regex{{{name}}}.Match(this.{{{name}}}).Success) - { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" }); - } - - {{/isByteArray}} - {{/pattern}} - {{/isEnum}} - {{/hasValidation}} - {{/vars}} - yield break; - } +{{>validatable}} {{/validatable}} } diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelInnerEnum.mustache index 6af921832af..f879f022dae 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelInnerEnum.mustache @@ -6,7 +6,9 @@ /// {{.}} {{/description}} {{#isString}} + {{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] + {{/useGenericHost}} {{/isString}} {{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}} { diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/netcore_project.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/netcore_project.mustache index 58f6faa7f4f..30c1ceaf2fb 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/netcore_project.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/netcore_project.mustache @@ -27,8 +27,10 @@ {{#useCompareNetObjects}} {{/useCompareNetObjects}} + {{^useGenericHost}} + {{/useGenericHost}} {{#useRestSharp}} {{/useRestSharp}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/validatable.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/validatable.mustache new file mode 100644 index 00000000000..6322bf599f6 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/validatable.mustache @@ -0,0 +1,89 @@ +{{#discriminator}} + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { +{{/discriminator}} +{{^discriminator}} + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { +{{/discriminator}} + {{#parent}} + {{^isArray}} + {{^isMap}} + foreach (var x in BaseValidate(validationContext)) + { + yield return x; + } + {{/isMap}} + {{/isArray}} + {{/parent}} + {{#vars}} + {{#hasValidation}} + {{^isEnum}} + {{#maxLength}} + // {{{name}}} ({{{dataType}}}) maxLength + if (this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" }); + } + + {{/maxLength}} + {{#minLength}} + // {{{name}}} ({{{dataType}}}) minLength + if (this.{{{name}}} != null && this.{{{name}}}.Length < {{minLength}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" }); + } + + {{/minLength}} + {{#maximum}} + // {{{name}}} ({{{dataType}}}) maximum + if (this.{{{name}}} > ({{{dataType}}}){{maximum}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" }); + } + + {{/maximum}} + {{#minimum}} + // {{{name}}} ({{{dataType}}}) minimum + if (this.{{{name}}} < ({{{dataType}}}){{minimum}}) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" }); + } + + {{/minimum}} + {{#pattern}} + {{^isByteArray}} + // {{{name}}} ({{{dataType}}}) pattern + Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}); + if (false == regex{{{name}}}.Match(this.{{{name}}}).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" }); + } + + {{/isByteArray}} + {{/pattern}} + {{/isEnum}} + {{/hasValidation}} + {{/vars}} + yield break; + } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/enumClass.mustache b/modules/openapi-generator/src/main/resources/csharp/enumClass.mustache index ee1d5a1885a..017e8acaa78 100644 --- a/modules/openapi-generator/src/main/resources/csharp/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/enumClass.mustache @@ -4,7 +4,9 @@ {{#description}} /// {{.}} {{/description}} + {{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] + {{/useGenericHost}} {{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { {{#allowableValues}} diff --git a/modules/openapi-generator/src/main/resources/csharp/modelEnum.mustache b/modules/openapi-generator/src/main/resources/csharp/modelEnum.mustache index 91be597da01..f3e0e9106dc 100644 --- a/modules/openapi-generator/src/main/resources/csharp/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/modelEnum.mustache @@ -4,9 +4,9 @@ {{#description}} /// {{.}} {{/description}} - {{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}} + {{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}{{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] - {{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}} + {{/useGenericHost}}{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}} {{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}} { {{#allowableValues}} diff --git a/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache index 4187d95bd04..26a9b36bd55 100644 --- a/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache @@ -6,7 +6,9 @@ /// {{.}} {{/description}} {{#isString}} + {{^useGenericHost}} [JsonConverter(typeof(StringEnumConverter))] + {{/useGenericHost}} {{/isString}} {{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}} { diff --git a/modules/openapi-generator/src/test/resources/3_0/allOf.yaml b/modules/openapi-generator/src/test/resources/3_0/allOf.yaml index 4d781cb871a..d11e7a877d6 100644 --- a/modules/openapi-generator/src/test/resources/3_0/allOf.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/allOf.yaml @@ -52,6 +52,9 @@ components: $ref: "#/components/schemas/Child" Child: description: A representation of a child + properties: + boosterSeat: + type: boolean allOf: - type: object properties: diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES index 2f141a0eb47..2a9214cd14b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES @@ -108,12 +108,11 @@ src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs src/Org.OpenAPITools/Client/IApi.cs src/Org.OpenAPITools/Client/OAuthToken.cs -src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs +src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs src/Org.OpenAPITools/Client/RateLimitProvider`1.cs src/Org.OpenAPITools/Client/TokenBase.cs src/Org.OpenAPITools/Client/TokenContainer`1.cs src/Org.OpenAPITools/Client/TokenProvider`1.cs -src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs src/Org.OpenAPITools/Model/Animal.cs src/Org.OpenAPITools/Model/ApiResponse.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Cat.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Cat.md index 310a5e6575e..16db4a55bd3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Cat.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Cat.md @@ -6,7 +6,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | **Color** | **string** | | [optional] [default to "red"] -**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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md index 48a3c7fd38d..dae2ff76026 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**PetType** | **string** | | [default to PetTypeEnum.ChildCat] -**Name** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ComplexQuadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ComplexQuadrilateral.md index 14da4bba22e..0926bb55e71 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ComplexQuadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ComplexQuadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Dog.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Dog.md index 70cdc80e83e..b1e39dcf07c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Dog.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Dog.md @@ -6,7 +6,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | **Color** | **string** | | [optional] [default to "red"] -**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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/EquilateralTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/EquilateralTriangle.md index 8360b5c16a5..ddc9885fe56 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/EquilateralTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/EquilateralTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Fruit.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Fruit.md index cb095b74f32..b3bee18f7ba 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Fruit.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Fruit.md @@ -5,9 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Color** | **string** | | [optional] -**Cultivar** | **string** | | [optional] -**Origin** | **string** | | [optional] -**LengthCm** | **decimal** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/FruitReq.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/FruitReq.md index 5217febc9b6..38ab0c1a6ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/FruitReq.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/FruitReq.md @@ -4,10 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Cultivar** | **string** | | -**LengthCm** | **decimal** | | -**Mealy** | **bool** | | [optional] -**Sweet** | **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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/GmFruit.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/GmFruit.md index 049f6f5c157..584c4fd323d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/GmFruit.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/GmFruit.md @@ -5,9 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Color** | **string** | | [optional] -**Cultivar** | **string** | | [optional] -**Origin** | **string** | | [optional] -**LengthCm** | **decimal** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/IsoscelesTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/IsoscelesTriangle.md index 07c62ac9338..ed481ad1448 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/IsoscelesTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/IsoscelesTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Mammal.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Mammal.md index 82a8ca6027b..5546632e4d6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Mammal.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Mammal.md @@ -4,10 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ClassName** | **string** | | -**HasBaleen** | **bool** | | [optional] -**HasTeeth** | **bool** | | [optional] -**Type** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Name.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Name.md index 1fbf5dd5e8b..2ee782c0c54 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Name.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Name.md @@ -5,7 +5,7 @@ Model for testing model name same as property name Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Name** | **int** | | +**NameProperty** | **int** | | **SnakeCase** | **int** | | [optional] [readonly] **Property** | **string** | | [optional] **_123Number** | **int** | | [optional] [readonly] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableShape.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableShape.md index 570ef48f98f..0caa1aa5b9d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableShape.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/NullableShape.md @@ -5,8 +5,6 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pig.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pig.md index fd7bb9359ac..83e58b6098d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pig.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Pig.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ClassName** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Quadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Quadrilateral.md index bb7507997a2..4fd16b32ea5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Quadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Quadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Return.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Return.md index a1dadccc421..e11cdae8db9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Return.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Return.md @@ -5,7 +5,7 @@ Model for testing reserved words Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Return** | **int** | | [optional] +**ReturnProperty** | **int** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ScaleneTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ScaleneTriangle.md index d3f15354bcc..a01c2edc068 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ScaleneTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ScaleneTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Shape.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Shape.md index 5627c30bbfc..2ec279cef3c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Shape.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/Shape.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | **QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ShapeOrNull.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ShapeOrNull.md index a348f4f8bff..056fcbfdbdd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ShapeOrNull.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/ShapeOrNull.md @@ -5,7 +5,6 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema > Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | **QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SimpleQuadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SimpleQuadrilateral.md index a36c9957a60..3bc21009b7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SimpleQuadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SimpleQuadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SpecialModelName.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SpecialModelName.md index fa146367bde..662fa6f4a38 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SpecialModelName.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/SpecialModelName.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **SpecialPropertyName** | **long** | | [optional] -**_SpecialModelName** | **string** | | [optional] +**SpecialModelNameProperty** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CatTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CatTests.cs index 701ba760282..9c3c48ffefe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CatTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CatTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Declawed' - /// - [Fact] - public void DeclawedTest() - { - // TODO unit test for the property 'Declawed' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CategoryTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CategoryTests.cs index 6ce48e601e4..621877aa973 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CategoryTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/CategoryTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Id' - /// - [Fact] - public void IdTest() - { - // TODO unit test for the property 'Id' - } /// /// Test the property 'Name' /// @@ -72,6 +64,14 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Name' } + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs index 68566fd8d56..0fe3ebfa06e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Name' - /// - [Fact] - public void NameTest() - { - // TODO unit test for the property 'Name' - } - /// - /// Test the property 'PetType' - /// - [Fact] - public void PetTypeTest() - { - // TODO unit test for the property 'PetType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs index b3529280c8d..6c50fe7aab5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DogTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DogTests.cs index 992f93a51fd..bf906f01bc6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DogTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DogTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Breed' - /// - [Fact] - public void BreedTest() - { - // TODO unit test for the property 'Breed' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs index 4f81b845d49..a22c39ca845 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'EnumString' - /// - [Fact] - public void EnumStringTest() - { - // TODO unit test for the property 'EnumString' - } /// /// Test the property 'EnumStringRequired' /// @@ -73,6 +65,14 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'EnumStringRequired' } /// + /// Test the property 'EnumString' + /// + [Fact] + public void EnumStringTest() + { + // TODO unit test for the property 'EnumString' + } + /// /// Test the property 'EnumInteger' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs index 4663cb667de..9ca755c4b07 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs index 97332800e9a..707847bbcd1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs @@ -56,6 +56,38 @@ namespace Org.OpenAPITools.Test.Model } + /// + /// Test the property 'Number' + /// + [Fact] + public void NumberTest() + { + // TODO unit test for the property 'Number' + } + /// + /// Test the property 'Byte' + /// + [Fact] + public void ByteTest() + { + // TODO unit test for the property 'Byte' + } + /// + /// Test the property 'Date' + /// + [Fact] + public void DateTest() + { + // TODO unit test for the property 'Date' + } + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } /// /// Test the property 'Integer' /// @@ -81,14 +113,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Int64' } /// - /// Test the property 'Number' - /// - [Fact] - public void NumberTest() - { - // TODO unit test for the property 'Number' - } - /// /// Test the property 'Float' /// [Fact] @@ -121,14 +145,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'String' } /// - /// Test the property 'Byte' - /// - [Fact] - public void ByteTest() - { - // TODO unit test for the property 'Byte' - } - /// /// Test the property 'Binary' /// [Fact] @@ -137,14 +153,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Binary' } /// - /// Test the property 'Date' - /// - [Fact] - public void DateTest() - { - // TODO unit test for the property 'Date' - } - /// /// Test the property 'DateTime' /// [Fact] @@ -161,14 +169,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Uuid' } /// - /// Test the property 'Password' - /// - [Fact] - public void PasswordTest() - { - // TODO unit test for the property 'Password' - } - /// /// Test the property 'PatternWithDigits' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs index 5ea9e3ffc1d..3a0b55b93e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs @@ -56,38 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Mealy' - /// - [Fact] - public void MealyTest() - { - // TODO unit test for the property 'Mealy' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } - /// - /// Test the property 'Sweet' - /// - [Fact] - public void SweetTest() - { - // TODO unit test for the property 'Sweet' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitTests.cs index 91e069bb42f..ddc424d56ea 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -64,30 +64,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Color' } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Origin' - /// - [Fact] - public void OriginTest() - { - // TODO unit test for the property 'Origin' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs index 08fb0e07a1c..cbd35f9173c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs @@ -64,30 +64,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Color' } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Origin' - /// - [Fact] - public void OriginTest() - { - // TODO unit test for the property 'Origin' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs index 755c417cc54..8e0dae93420 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MammalTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MammalTests.cs index 7b46cbf0645..6477ab950fa 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MammalTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MammalTests.cs @@ -56,38 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'HasBaleen' - /// - [Fact] - public void HasBaleenTest() - { - // TODO unit test for the property 'HasBaleen' - } - /// - /// Test the property 'HasTeeth' - /// - [Fact] - public void HasTeethTest() - { - // TODO unit test for the property 'HasTeeth' - } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } - /// - /// Test the property 'Type' - /// - [Fact] - public void TypeTest() - { - // TODO unit test for the property 'Type' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs index 5662f91d6e6..8202ef63914 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PetTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PetTests.cs index 154e66f8dfc..28ea4d8478d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PetTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PetTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Id' - /// - [Fact] - public void IdTest() - { - // TODO unit test for the property 'Id' - } - /// - /// Test the property 'Category' - /// - [Fact] - public void CategoryTest() - { - // TODO unit test for the property 'Category' - } /// /// Test the property 'Name' /// @@ -89,6 +73,22 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'PhotoUrls' } /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Category' + /// + [Fact] + public void CategoryTest() + { + // TODO unit test for the property 'Category' + } + /// /// Test the property 'Tags' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PigTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PigTests.cs index 55cf2189046..a66befe8f58 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PigTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/PigTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs index 26826681a47..3d62673d093 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs index 04cb9f1ab6b..018dffb5964 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs index d0af114157c..ef564357648 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } /// /// Test the property 'QuadrilateralType' /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeTests.cs index b01bd531f85..783a9657ed4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ShapeTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } /// /// Test the property 'QuadrilateralType' /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs index 6648e980928..3bcd65e792d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/WhaleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/WhaleTests.cs index 09610791943..9b82c29c8fd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/WhaleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/WhaleTests.cs @@ -56,6 +56,14 @@ namespace Org.OpenAPITools.Test.Model } + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } /// /// Test the property 'HasBaleen' /// @@ -72,14 +80,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'HasTeeth' } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ZebraTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ZebraTests.cs index f44e9213140..39e0561fe0f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ZebraTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/ZebraTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Type' - /// - [Fact] - public void TypeTest() - { - // TODO unit test for the property 'Type' - } /// /// Test the property 'ClassName' /// @@ -72,6 +64,14 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'ClassName' } + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 39ca9f95c47..248ddd19eb4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -197,7 +197,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -219,7 +220,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Patch; + request.Method = HttpMethod.Patch; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -242,7 +243,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs index 171b696702d..98c26686e76 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -192,7 +192,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -215,7 +215,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs index 5f8f4525c9d..ebf183e1707 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs @@ -772,7 +772,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -795,7 +795,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -869,7 +869,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -891,7 +892,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -914,7 +915,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -988,7 +989,8 @@ namespace Org.OpenAPITools.Api if ((outerComposite as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(outerComposite, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(outerComposite, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(outerComposite, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1010,7 +1012,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1033,7 +1035,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1107,7 +1109,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1129,7 +1132,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1152,7 +1155,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1226,7 +1229,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1248,7 +1252,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1271,7 +1275,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1350,7 +1354,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1373,7 +1377,7 @@ namespace Org.OpenAPITools.Api ApiResponse?> apiResponse = new ApiResponse?>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1454,7 +1458,8 @@ namespace Org.OpenAPITools.Api if ((fileSchemaTestClass as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(fileSchemaTestClass, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(fileSchemaTestClass, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(fileSchemaTestClass, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1467,7 +1472,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1490,7 +1495,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1583,7 +1588,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1596,7 +1602,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1619,7 +1625,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1700,7 +1706,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1722,7 +1729,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Patch; + request.Method = HttpMethod.Patch; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1745,7 +1752,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1936,7 +1943,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1959,7 +1966,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -2100,7 +2107,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2123,7 +2130,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2250,7 +2257,7 @@ namespace Org.OpenAPITools.Api bearerToken.UseInHeader(request, ""); - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2273,7 +2280,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -2357,7 +2364,8 @@ namespace Org.OpenAPITools.Api if ((requestBody as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(requestBody, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -2370,7 +2378,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2393,7 +2401,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2500,7 +2508,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2523,7 +2531,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2637,7 +2645,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2660,7 +2668,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 39d5c0908bb..7657255cb54 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -199,7 +199,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -231,7 +232,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Patch; + request.Method = HttpMethod.Patch; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -254,7 +255,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs index f9d802892a2..4fb94a2a8a4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs @@ -498,7 +498,8 @@ namespace Org.OpenAPITools.Api if ((pet as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(pet, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -528,7 +529,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -551,7 +552,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -652,7 +653,7 @@ namespace Org.OpenAPITools.Api oauthToken.UseInHeader(request, ""); - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -675,7 +676,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -790,7 +791,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -813,7 +814,7 @@ namespace Org.OpenAPITools.Api ApiResponse?> apiResponse = new ApiResponse?>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -931,7 +932,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -954,7 +955,7 @@ namespace Org.OpenAPITools.Api ApiResponse?> apiResponse = new ApiResponse?>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1059,7 +1060,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1082,7 +1083,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1166,7 +1167,8 @@ namespace Org.OpenAPITools.Api if ((pet as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(pet, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -1196,7 +1198,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1219,7 +1221,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1343,7 +1345,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1366,7 +1368,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1496,7 +1498,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1519,7 +1521,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1651,7 +1653,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1674,7 +1676,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs index e4adfc47c8f..314dd3a6293 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs @@ -299,7 +299,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -322,7 +322,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -409,7 +409,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -432,7 +432,7 @@ namespace Org.OpenAPITools.Api ApiResponse?> apiResponse = new ApiResponse?>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -526,7 +526,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -549,7 +549,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -630,7 +630,8 @@ namespace Org.OpenAPITools.Api if ((order as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(order, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(order, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(order, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -653,7 +654,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -676,7 +677,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs index c49fd35541c..88fb8a03686 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs @@ -445,7 +445,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -458,7 +459,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -481,7 +482,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -562,7 +563,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -575,7 +577,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -598,7 +600,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -679,7 +681,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -692,7 +695,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -715,7 +718,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -796,7 +799,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -819,7 +822,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -910,7 +913,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -933,7 +936,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1036,7 +1039,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1059,7 +1062,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1129,7 +1132,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1152,7 +1155,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1240,7 +1243,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1253,7 +1257,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1276,7 +1280,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 29d184dddae..78a0047905c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -13,7 +13,6 @@ using System; using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; namespace Org.OpenAPITools.Client { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs index 4bc32f6b983..9e19ed5f41f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -52,21 +52,53 @@ namespace Org.OpenAPITools.Client public delegate void EventHandler(object sender, T e) where T : EventArgs; /// - /// Custom JSON serializer + /// Returns true when deserialization succeeds. /// - public static Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get; set; } = new Newtonsoft.Json.JsonSerializerSettings + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, System.Text.Json.JsonSerializerOptions options, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result) { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore, - ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver + try { - NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } + result = System.Text.Json.JsonSerializer.Deserialize(json, options); + return result != null; } - }; + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T? result) + { + try + { + result = System.Text.Json.JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Json serializer options + /// + public static System.Text.Json.JsonSerializerOptions JsonSerializerOptions { get; set; } = new System.Text.Json.JsonSerializerOptions(); /// /// Sanitize filename by removing the path @@ -175,7 +207,7 @@ namespace Org.OpenAPITools.Client /// /// The Content-Type array to select from. /// The Content-Type header to use. - public static string SelectHeaderContentType(string[] contentTypes) + public static string? SelectHeaderContentType(string[] contentTypes) { if (contentTypes.Length == 0) return null; @@ -196,7 +228,7 @@ namespace Org.OpenAPITools.Client /// /// The accepts array to select from. /// The Accept header to use. - public static string SelectHeaderAccept(string[] accepts) + public static string? SelectHeaderAccept(string[] accepts) { if (accepts.Length == 0) return null; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs index 7b8ea652b16..b0a78d04cd2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Net.Http; using Microsoft.Extensions.DependencyInjection; using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; namespace Org.OpenAPITools.Client { @@ -89,6 +90,26 @@ namespace Org.OpenAPITools.Client public HostConfiguration AddApiHttpClients( Action? client = null, Action? builder = null) { + ClientUtils.JsonSerializerOptions.Converters.Add(new OpenAPIDateJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new CatJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ChildCatJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new DogJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new EquilateralTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new FruitJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new FruitReqJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new GmFruitJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new IsoscelesTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new MammalJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new NullableShapeJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new PigJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new QuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ScaleneTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ShapeJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ShapeOrNullJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new SimpleQuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new TriangleJsonConverter()); + AddApiHttpClients(client, builder); return this; @@ -99,9 +120,9 @@ namespace Org.OpenAPITools.Client /// /// /// - public HostConfiguration ConfigureJsonOptions(Action options) + public HostConfiguration ConfigureJsonOptions(Action options) { - options(Client.ClientUtils.JsonSerializerSettings); + options(Client.ClientUtils.JsonSerializerOptions); return this; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs deleted file mode 100644 index a5253e58201..00000000000 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs +++ /dev/null @@ -1,29 +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 Newtonsoft.Json.Converters; - -namespace Org.OpenAPITools.Client -{ - /// - /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 - /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types - /// - public class OpenAPIDateConverter : IsoDateTimeConverter - { - /// - /// Initializes a new instance of the class. - /// - public OpenAPIDateConverter() - { - // full-date = date-fullyear "-" date-month "-" date-mday - DateTimeFormat = "yyyy-MM-dd"; - } - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs new file mode 100644 index 00000000000..5f64123b7d5 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class OpenAPIDateJsonConverter : JsonConverter + { + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + DateTime.ParseExact(reader.GetString()!, "yyyy-MM-dd", CultureInfo.InvariantCulture); + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs deleted file mode 100644 index b3fc4c3c7a3..00000000000 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs +++ /dev/null @@ -1,76 +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 System; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace Org.OpenAPITools.Model -{ - /// - /// Abstract base class for oneOf, anyOf schemas in the OpenAPI specification - /// - public abstract partial class AbstractOpenAPISchema - { - /// - /// Custom JSON serializer - /// - static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Error, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Custom JSON serializer for objects with additional properties - /// - static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Ignore, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Gets or Sets the actual instance - /// - public abstract Object ActualInstance { get; set; } - - /// - /// Gets or Sets IsNullable to indicate whether the instance is nullable - /// - public bool IsNullable { get; protected set; } - - /// - /// Gets or Sets the schema type, which can be either `oneOf` or `anyOf` - /// - public string SchemaType { get; protected set; } - - /// - /// Converts the instance into JSON string. - /// - public abstract string ToJson(); - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 19896e401bc..6525a4a0348 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,87 +29,85 @@ namespace Org.OpenAPITools.Model /// /// AdditionalPropertiesClass /// - [DataContract(Name = "AdditionalPropertiesClass")] public partial class AdditionalPropertiesClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// mapProperty. - /// mapOfMapProperty. - /// anytype1. - /// mapWithUndeclaredPropertiesAnytype1. - /// mapWithUndeclaredPropertiesAnytype2. - /// mapWithUndeclaredPropertiesAnytype3. - /// an object with no declared properties and no undeclared properties, hence it's an empty map.. - /// mapWithUndeclaredPropertiesString. + /// mapProperty + /// mapOfMapProperty + /// anytype1 + /// mapWithUndeclaredPropertiesAnytype1 + /// mapWithUndeclaredPropertiesAnytype2 + /// mapWithUndeclaredPropertiesAnytype3 + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// mapWithUndeclaredPropertiesString public AdditionalPropertiesClass(Dictionary? mapProperty = default, Dictionary>? mapOfMapProperty = default, Object? anytype1 = default, Object? mapWithUndeclaredPropertiesAnytype1 = default, Object? mapWithUndeclaredPropertiesAnytype2 = default, Dictionary? mapWithUndeclaredPropertiesAnytype3 = default, Object? emptyMap = default, Dictionary? mapWithUndeclaredPropertiesString = default) { - this.MapProperty = mapProperty; - this.MapOfMapProperty = mapOfMapProperty; - this.Anytype1 = anytype1; - this.MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - this.MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - this.MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - this.EmptyMap = emptyMap; - this.MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - this.AdditionalProperties = new Dictionary(); + MapProperty = mapProperty; + MapOfMapProperty = mapOfMapProperty; + Anytype1 = anytype1; + MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; + EmptyMap = emptyMap; + MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; } /// /// Gets or Sets MapProperty /// - [DataMember(Name = "map_property", EmitDefaultValue = false)] + [JsonPropertyName("map_property")] public Dictionary? MapProperty { get; set; } /// /// Gets or Sets MapOfMapProperty /// - [DataMember(Name = "map_of_map_property", EmitDefaultValue = false)] + [JsonPropertyName("map_of_map_property")] public Dictionary>? MapOfMapProperty { get; set; } /// /// Gets or Sets Anytype1 /// - [DataMember(Name = "anytype_1", EmitDefaultValue = true)] + [JsonPropertyName("anytype_1")] public Object? Anytype1 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_1", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] public Object? MapWithUndeclaredPropertiesAnytype1 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_2", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] public Object? MapWithUndeclaredPropertiesAnytype2 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_3", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] public Dictionary? MapWithUndeclaredPropertiesAnytype3 { get; set; } /// /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [DataMember(Name = "empty_map", EmitDefaultValue = false)] + [JsonPropertyName("empty_map")] public Object? EmptyMap { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesString /// - [DataMember(Name = "map_with_undeclared_properties_string", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_string")] public Dictionary? MapWithUndeclaredPropertiesString { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -132,21 +130,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as AdditionalPropertiesClass).AreEqual; } @@ -156,7 +145,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of AdditionalPropertiesClass to be compared /// Boolean - public bool Equals(AdditionalPropertiesClass input) + public bool Equals(AdditionalPropertiesClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs index fba745ea51d..96ce92ae1c8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Animal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,54 +29,38 @@ namespace Org.OpenAPITools.Model /// /// Animal /// - [DataContract(Name = "Animal")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - [JsonSubtypes.KnownSubType(typeof(Cat), "Cat")] - [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] public partial class Animal : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Animal() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// color (default to "red"). + /// className (required) + /// color (default to "red") public Animal(string className, string? color = "red") { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Animal and cannot be null"); - } - this.ClassName = className; - // use default value if no "color" provided - this.Color = color ?? "red"; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for Animal and cannot be null."); + ClassName = className; + Color = color; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets Color /// - [DataMember(Name = "color", EmitDefaultValue = false)] + [JsonPropertyName("color")] public string? Color { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -94,21 +77,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Animal).AreEqual; } @@ -118,7 +92,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Animal to be compared /// Boolean - public bool Equals(Animal input) + public bool Equals(Animal? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs index f4cdba70506..8bde19180cb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// ApiResponse /// - [DataContract(Name = "ApiResponse")] public partial class ApiResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// code. - /// type. - /// message. + /// code + /// type + /// message public ApiResponse(int? code = default, string? type = default, string? message = default) { - this.Code = code; - this.Type = type; - this.Message = message; - this.AdditionalProperties = new Dictionary(); + Code = code; + Type = type; + Message = message; } /// /// Gets or Sets Code /// - [DataMember(Name = "code", EmitDefaultValue = false)] + [JsonPropertyName("code")] public int? Code { get; set; } /// /// Gets or Sets Type /// - [DataMember(Name = "type", EmitDefaultValue = false)] + [JsonPropertyName("type")] public string? Type { get; set; } /// /// Gets or Sets Message /// - [DataMember(Name = "message", EmitDefaultValue = false)] + [JsonPropertyName("message")] public string? Message { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,21 +84,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ApiResponse).AreEqual; } @@ -110,7 +99,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ApiResponse to be compared /// Boolean - public bool Equals(ApiResponse input) + public bool Equals(ApiResponse? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs index 345517cc259..dadf5664d05 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Apple.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Apple /// - [DataContract(Name = "apple")] public partial class Apple : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// cultivar. - /// origin. + /// cultivar + /// origin public Apple(string? cultivar = default, string? origin = default) { - this.Cultivar = cultivar; - this.Origin = origin; - this.AdditionalProperties = new Dictionary(); + Cultivar = cultivar; + Origin = origin; } /// /// Gets or Sets Cultivar /// - [DataMember(Name = "cultivar", EmitDefaultValue = false)] + [JsonPropertyName("cultivar")] public string? Cultivar { get; set; } /// /// Gets or Sets Origin /// - [DataMember(Name = "origin", EmitDefaultValue = false)] + [JsonPropertyName("origin")] public string? Origin { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,21 +75,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Apple).AreEqual; } @@ -101,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Apple to be compared /// Boolean - public bool Equals(Apple input) + public bool Equals(Apple? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs index 7cfaecc03f1..39723c3ac11 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/AppleReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,39 +29,31 @@ namespace Org.OpenAPITools.Model /// /// AppleReq /// - [DataContract(Name = "appleReq")] public partial class AppleReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected AppleReq() { } - /// - /// Initializes a new instance of the class. - /// - /// cultivar (required). - /// mealy. + /// cultivar (required) + /// mealy public AppleReq(string cultivar, bool? mealy = default) { - // to ensure "cultivar" is required (not null) - if (cultivar == null) { - throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null"); - } - this.Cultivar = cultivar; - this.Mealy = mealy; + if (cultivar == null) + throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null."); + Cultivar = cultivar; + Mealy = mealy; } /// /// Gets or Sets Cultivar /// - [DataMember(Name = "cultivar", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("cultivar")] public string Cultivar { get; set; } /// /// Gets or Sets Mealy /// - [DataMember(Name = "mealy", EmitDefaultValue = true)] + [JsonPropertyName("mealy")] public bool? Mealy { get; set; } /// @@ -78,21 +70,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as AppleReq).AreEqual; } @@ -102,7 +85,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of AppleReq to be compared /// Boolean - public bool Equals(AppleReq input) + public bool Equals(AppleReq? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index f2ed6250a5f..e284a52634b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ArrayOfArrayOfNumberOnly /// - [DataContract(Name = "ArrayOfArrayOfNumberOnly")] public partial class ArrayOfArrayOfNumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayArrayNumber. + /// arrayArrayNumber public ArrayOfArrayOfNumberOnly(List>? arrayArrayNumber = default) { - this.ArrayArrayNumber = arrayArrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayArrayNumber = arrayArrayNumber; } /// /// Gets or Sets ArrayArrayNumber /// - [DataMember(Name = "ArrayArrayNumber", EmitDefaultValue = false)] + [JsonPropertyName("ArrayArrayNumber")] public List>? ArrayArrayNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayOfArrayOfNumberOnly).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ArrayOfArrayOfNumberOnly to be compared /// Boolean - public bool Equals(ArrayOfArrayOfNumberOnly input) + public bool Equals(ArrayOfArrayOfNumberOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 0d9d0781d94..1670dcd31a3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ArrayOfNumberOnly /// - [DataContract(Name = "ArrayOfNumberOnly")] public partial class ArrayOfNumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayNumber. + /// arrayNumber public ArrayOfNumberOnly(List? arrayNumber = default) { - this.ArrayNumber = arrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayNumber = arrayNumber; } /// /// Gets or Sets ArrayNumber /// - [DataMember(Name = "ArrayNumber", EmitDefaultValue = false)] + [JsonPropertyName("ArrayNumber")] public List? ArrayNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayOfNumberOnly).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ArrayOfNumberOnly to be compared /// Boolean - public bool Equals(ArrayOfNumberOnly input) + public bool Equals(ArrayOfNumberOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs index 3831f2ecc87..371238a32a6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// ArrayTest /// - [DataContract(Name = "ArrayTest")] public partial class ArrayTest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayOfString. - /// arrayArrayOfInteger. - /// arrayArrayOfModel. + /// arrayOfString + /// arrayArrayOfInteger + /// arrayArrayOfModel public ArrayTest(List? arrayOfString = default, List>? arrayArrayOfInteger = default, List>? arrayArrayOfModel = default) { - this.ArrayOfString = arrayOfString; - this.ArrayArrayOfInteger = arrayArrayOfInteger; - this.ArrayArrayOfModel = arrayArrayOfModel; - this.AdditionalProperties = new Dictionary(); + ArrayOfString = arrayOfString; + ArrayArrayOfInteger = arrayArrayOfInteger; + ArrayArrayOfModel = arrayArrayOfModel; } /// /// Gets or Sets ArrayOfString /// - [DataMember(Name = "array_of_string", EmitDefaultValue = false)] + [JsonPropertyName("array_of_string")] public List? ArrayOfString { get; set; } /// /// Gets or Sets ArrayArrayOfInteger /// - [DataMember(Name = "array_array_of_integer", EmitDefaultValue = false)] + [JsonPropertyName("array_array_of_integer")] public List>? ArrayArrayOfInteger { get; set; } /// /// Gets or Sets ArrayArrayOfModel /// - [DataMember(Name = "array_array_of_model", EmitDefaultValue = false)] + [JsonPropertyName("array_array_of_model")] public List>? ArrayArrayOfModel { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,21 +84,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ArrayTest).AreEqual; } @@ -110,7 +99,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ArrayTest to be compared /// Boolean - public bool Equals(ArrayTest input) + public bool Equals(ArrayTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs index f1e62ce2395..d41ec32c1d8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Banana.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Banana /// - [DataContract(Name = "banana")] public partial class Banana : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// lengthCm. + /// lengthCm public Banana(decimal? lengthCm = default) { - this.LengthCm = lengthCm; - this.AdditionalProperties = new Dictionary(); + LengthCm = lengthCm; } /// /// Gets or Sets LengthCm /// - [DataMember(Name = "lengthCm", EmitDefaultValue = false)] + [JsonPropertyName("lengthCm")] public decimal? LengthCm { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Banana).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Banana to be compared /// Boolean - public bool Equals(Banana input) + public bool Equals(Banana? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs index 1c4f23aac56..14bf914a119 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BananaReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,35 +29,31 @@ namespace Org.OpenAPITools.Model /// /// BananaReq /// - [DataContract(Name = "bananaReq")] public partial class BananaReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected BananaReq() { } - /// - /// Initializes a new instance of the class. - /// - /// lengthCm (required). - /// sweet. + /// lengthCm (required) + /// sweet public BananaReq(decimal lengthCm, bool? sweet = default) { - this.LengthCm = lengthCm; - this.Sweet = sweet; + if (lengthCm == null) + throw new ArgumentNullException("lengthCm is a required property for BananaReq and cannot be null."); + LengthCm = lengthCm; + Sweet = sweet; } /// /// Gets or Sets LengthCm /// - [DataMember(Name = "lengthCm", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } /// /// Gets or Sets Sweet /// - [DataMember(Name = "sweet", EmitDefaultValue = true)] + [JsonPropertyName("sweet")] public bool? Sweet { get; set; } /// @@ -74,21 +70,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as BananaReq).AreEqual; } @@ -98,7 +85,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of BananaReq to be compared /// Boolean - public bool Equals(BananaReq input) + public bool Equals(BananaReq? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs index 0706a3e8196..aee99a4fe2b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/BasquePig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// BasquePig /// - [DataContract(Name = "BasquePig")] public partial class BasquePig : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected BasquePig() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). + /// className (required) public BasquePig(string className) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for BasquePig and cannot be null"); - } - this.ClassName = className; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for BasquePig and cannot be null."); + ClassName = className; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,21 +68,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as BasquePig).AreEqual; } @@ -104,7 +83,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of BasquePig to be compared /// Boolean - public bool Equals(BasquePig input) + public bool Equals(BasquePig? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs index 2a49007bfbe..2a52a362f69 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Capitalization.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,71 +29,69 @@ namespace Org.OpenAPITools.Model /// /// Capitalization /// - [DataContract(Name = "Capitalization")] public partial class Capitalization : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// smallCamel. - /// capitalCamel. - /// smallSnake. - /// capitalSnake. - /// sCAETHFlowPoints. - /// Name of the pet . + /// smallCamel + /// capitalCamel + /// smallSnake + /// capitalSnake + /// sCAETHFlowPoints + /// Name of the pet public Capitalization(string? smallCamel = default, string? capitalCamel = default, string? smallSnake = default, string? capitalSnake = default, string? sCAETHFlowPoints = default, string? aTTNAME = default) { - this.SmallCamel = smallCamel; - this.CapitalCamel = capitalCamel; - this.SmallSnake = smallSnake; - this.CapitalSnake = capitalSnake; - this.SCAETHFlowPoints = sCAETHFlowPoints; - this.ATT_NAME = aTTNAME; - this.AdditionalProperties = new Dictionary(); + SmallCamel = smallCamel; + CapitalCamel = capitalCamel; + SmallSnake = smallSnake; + CapitalSnake = capitalSnake; + SCAETHFlowPoints = sCAETHFlowPoints; + ATT_NAME = aTTNAME; } /// /// Gets or Sets SmallCamel /// - [DataMember(Name = "smallCamel", EmitDefaultValue = false)] + [JsonPropertyName("smallCamel")] public string? SmallCamel { get; set; } /// /// Gets or Sets CapitalCamel /// - [DataMember(Name = "CapitalCamel", EmitDefaultValue = false)] + [JsonPropertyName("CapitalCamel")] public string? CapitalCamel { get; set; } /// /// Gets or Sets SmallSnake /// - [DataMember(Name = "small_Snake", EmitDefaultValue = false)] + [JsonPropertyName("small_Snake")] public string? SmallSnake { get; set; } /// /// Gets or Sets CapitalSnake /// - [DataMember(Name = "Capital_Snake", EmitDefaultValue = false)] + [JsonPropertyName("Capital_Snake")] public string? CapitalSnake { get; set; } /// /// Gets or Sets SCAETHFlowPoints /// - [DataMember(Name = "SCA_ETH_Flow_Points", EmitDefaultValue = false)] + [JsonPropertyName("SCA_ETH_Flow_Points")] public string? SCAETHFlowPoints { get; set; } /// /// Name of the pet /// /// Name of the pet - [DataMember(Name = "ATT_NAME", EmitDefaultValue = false)] + [JsonPropertyName("ATT_NAME")] public string? ATT_NAME { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,21 +112,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Capitalization).AreEqual; } @@ -138,7 +127,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Capitalization to be compared /// Boolean - public bool Equals(Capitalization input) + public bool Equals(Capitalization? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs index 53ebf92552e..445b880871b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Cat.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,41 +29,23 @@ namespace Org.OpenAPITools.Model /// /// Cat /// - [DataContract(Name = "Cat")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - public partial class Cat : Animal, IEquatable, IValidatableObject + public partial class Cat : Animal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Cat() + /// catAllOf + /// className (required) + /// color (default to "red") + public Cat(CatAllOf catAllOf, string className, string? color = "red") : base(className, color) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required) (default to "Cat"). - /// declawed. - /// color (default to "red"). - public Cat(string className = "Cat", bool? declawed = default, string? color = "red") : base(className, color) - { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + CatAllOf = catAllOf; } /// - /// Gets or Sets Declawed + /// Gets or Sets Cat /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] - public bool? Declawed { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public CatAllOf? CatAllOf { get; set; } /// /// Returns the string presentation of the object @@ -75,27 +56,16 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class Cat {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Declawed: ").Append(Declawed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Cat).AreEqual; } @@ -105,7 +75,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Cat to be compared /// Boolean - public bool Equals(Cat input) + public bool Equals(Cat? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -119,38 +89,76 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 59) + this.Declawed.GetHashCode(); - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type Cat + /// + public class CatJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Cat).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override Cat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader catAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref catAllOfReader, options, out CatAllOf? catAllOf); + string? className = default; + string? color = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "className": + className = reader.GetString(); + break; + case "color": + color = reader.GetString(); + break; + } + } + } + + return new Cat(catAllOf, className, color); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/CatAllOf.cs index 1f47a8e5439..c397e1b6bc3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/CatAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// CatAllOf /// - [DataContract(Name = "Cat_allOf")] public partial class CatAllOf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// declawed. + /// declawed public CatAllOf(bool? declawed = default) { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + Declawed = declawed; } /// /// Gets or Sets Declawed /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] + [JsonPropertyName("declawed")] public bool? Declawed { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as CatAllOf).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of CatAllOf to be compared /// Boolean - public bool Equals(CatAllOf input) + public bool Equals(CatAllOf? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs index c9ed80eeb11..e0de84830c2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,50 +29,38 @@ namespace Org.OpenAPITools.Model /// /// Category /// - [DataContract(Name = "Category")] public partial class Category : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Category() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required) (default to "default-name"). - /// id. + /// name (required) (default to "default-name") + /// id public Category(string name = "default-name", long? id = default) { - // to ensure "name" is required (not null) - if (name == null) { - throw new ArgumentNullException("name is a required property for Category and cannot be null"); - } - this.Name = name; - this.Id = id; - this.AdditionalProperties = new Dictionary(); + if (name == null) + throw new ArgumentNullException("name is a required property for Category and cannot be null."); + Name = name; + Id = id; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long? Id { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -89,21 +77,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Category).AreEqual; } @@ -113,7 +92,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Category to be compared /// Boolean - public bool Equals(Category input) + public bool Equals(Category? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs index 1fe9959c94d..453cec2cc19 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,61 +29,22 @@ namespace Org.OpenAPITools.Model /// /// ChildCat /// - [DataContract(Name = "ChildCat")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - public partial class ChildCat : ParentPet, IEquatable, IValidatableObject + public partial class ChildCat : ParentPet, IEquatable { - /// - /// Defines PetType - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum PetTypeEnum - { - /// - /// Enum ChildCat for value: ChildCat - /// - [EnumMember(Value = "ChildCat")] - ChildCat = 1 - - } - - - /// - /// Gets or Sets PetType - /// - [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] - public PetTypeEnum PetType { get; set; } /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ChildCat() + /// childCatAllOf + /// petType (required) + public ChildCat(ChildCatAllOf childCatAllOf, string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// petType (required) (default to PetTypeEnum.ChildCat). - /// name. - public ChildCat(PetTypeEnum petType = PetTypeEnum.ChildCat, string? name = default) : base() - { - this.PetType = petType; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + ChildCatAllOf = childCatAllOf; } /// - /// Gets or Sets Name + /// Gets or Sets ChildCat /// - [DataMember(Name = "name", EmitDefaultValue = false)] - public string? Name { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public ChildCatAllOf? ChildCatAllOf { get; set; } /// /// Returns the string presentation of the object @@ -95,28 +55,16 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCat).AreEqual; } @@ -126,7 +74,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ChildCat to be compared /// Boolean - public bool Equals(ChildCat input) + public bool Equals(ChildCat? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -140,42 +88,72 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 59) + this.PetType.GetHashCode(); - if (this.Name != null) - { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); - } - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type ChildCat + /// + public class ChildCatJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ChildCat).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ChildCat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader childCatAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref childCatAllOfReader, options, out ChildCatAllOf? childCatAllOf); + string? petType = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "pet_type": + petType = reader.GetString(); + break; + } + } + } + + return new ChildCat(childCatAllOf, petType); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index ad1636c7753..0870dfe98b2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,22 @@ namespace Org.OpenAPITools.Model /// /// ChildCatAllOf /// - [DataContract(Name = "ChildCat_allOf")] public partial class ChildCatAllOf : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// name + /// petType (default to PetTypeEnum.ChildCat) + public ChildCatAllOf(string? name = default, PetTypeEnum? petType = PetTypeEnum.ChildCat) + { + Name = name; + PetType = petType; + } + /// /// Defines PetType /// - [JsonConverter(typeof(StringEnumConverter))] public enum PetTypeEnum { /// @@ -46,35 +55,23 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets PetType /// - [DataMember(Name = "pet_type", EmitDefaultValue = false)] + [JsonPropertyName("pet_type")] public PetTypeEnum? PetType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// name. - /// petType (default to PetTypeEnum.ChildCat). - public ChildCatAllOf(string? name = default, PetTypeEnum? petType = PetTypeEnum.ChildCat) - { - this.Name = name; - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string? Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -91,21 +88,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCatAllOf).AreEqual; } @@ -115,7 +103,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ChildCatAllOf to be compared /// Boolean - public bool Equals(ChildCatAllOf input) + public bool Equals(ChildCatAllOf? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs index 8aa42b57ddb..5e9b01f14a3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ClassModel.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model with \"_class\" property /// - [DataContract(Name = "ClassModel")] public partial class ClassModel : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _class. + /// _class public ClassModel(string? _class = default) { - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Class = _class; } /// /// Gets or Sets Class /// - [DataMember(Name = "_class", EmitDefaultValue = false)] + [JsonPropertyName("_class")] public string? Class { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ClassModel).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ClassModel to be compared /// Boolean - public bool Equals(ClassModel input) + public bool Equals(ClassModel? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index ab75994ddf5..219034e4ee0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// ComplexQuadrilateral /// - [DataContract(Name = "ComplexQuadrilateral")] public partial class ComplexQuadrilateral : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ComplexQuadrilateral() + /// quadrilateralInterface + /// shapeInterface + public ComplexQuadrilateral(QuadrilateralInterface quadrilateralInterface, ShapeInterface shapeInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// quadrilateralType (required). - public ComplexQuadrilateral(string shapeType, string quadrilateralType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ComplexQuadrilateral and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for ComplexQuadrilateral and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + QuadrilateralInterface = quadrilateralInterface; + ShapeInterface = shapeInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets ComplexQuadrilateral /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public QuadrilateralInterface? QuadrilateralInterface { get; set; } /// - /// Gets or Sets QuadrilateralType + /// Gets or Sets ComplexQuadrilateral /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] - public string QuadrilateralType { get; set; } + public ShapeInterface? ShapeInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,28 +66,17 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class ComplexQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ComplexQuadrilateral).AreEqual; } @@ -117,7 +86,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ComplexQuadrilateral to be compared /// Boolean - public bool Equals(ComplexQuadrilateral input) + public bool Equals(ComplexQuadrilateral? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.QuadrilateralType != null) - { - hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type ComplexQuadrilateral + /// + public class ComplexQuadrilateralJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ComplexQuadrilateral).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ComplexQuadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralInterfaceReader, options, out QuadrilateralInterface? quadrilateralInterface); + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface? shapeInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new ComplexQuadrilateral(quadrilateralInterface, shapeInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs index 7314bf3a214..54e3075e3da 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DanishPig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// DanishPig /// - [DataContract(Name = "DanishPig")] public partial class DanishPig : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected DanishPig() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). + /// className (required) public DanishPig(string className) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for DanishPig and cannot be null"); - } - this.ClassName = className; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for DanishPig and cannot be null."); + ClassName = className; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,21 +68,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DanishPig).AreEqual; } @@ -104,7 +83,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of DanishPig to be compared /// Boolean - public bool Equals(DanishPig input) + public bool Equals(DanishPig? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 191d7f38d24..e5ec23562d9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// DeprecatedObject /// - [DataContract(Name = "DeprecatedObject")] public partial class DeprecatedObject : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// name. + /// name public DeprecatedObject(string? name = default) { - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Name = name; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string? Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DeprecatedObject).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of DeprecatedObject to be compared /// Boolean - public bool Equals(DeprecatedObject input) + public bool Equals(DeprecatedObject? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs index 3714017fe63..6d62a3aa47b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Dog.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,41 +29,23 @@ namespace Org.OpenAPITools.Model /// /// Dog /// - [DataContract(Name = "Dog")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - public partial class Dog : Animal, IEquatable, IValidatableObject + public partial class Dog : Animal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Dog() + /// dogAllOf + /// className (required) + /// color (default to "red") + public Dog(DogAllOf dogAllOf, string className, string? color = "red") : base(className, color) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required) (default to "Dog"). - /// breed. - /// color (default to "red"). - public Dog(string className = "Dog", string? breed = default, string? color = "red") : base(className, color) - { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + DogAllOf = dogAllOf; } /// - /// Gets or Sets Breed + /// Gets or Sets Dog /// - [DataMember(Name = "breed", EmitDefaultValue = false)] - public string? Breed { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public DogAllOf? DogAllOf { get; set; } /// /// Returns the string presentation of the object @@ -75,27 +56,16 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class Dog {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Breed: ").Append(Breed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Dog).AreEqual; } @@ -105,7 +75,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Dog to be compared /// Boolean - public bool Equals(Dog input) + public bool Equals(Dog? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -119,41 +89,76 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - if (this.Breed != null) - { - hashCode = (hashCode * 59) + this.Breed.GetHashCode(); - } - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type Dog + /// + public class DogJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Dog).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override Dog Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader dogAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref dogAllOfReader, options, out DogAllOf? dogAllOf); + string? className = default; + string? color = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "className": + className = reader.GetString(); + break; + case "color": + color = reader.GetString(); + break; + } + } + } + + return new Dog(dogAllOf, className, color); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DogAllOf.cs index 134ad1d40db..f6a94b443ea 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DogAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// DogAllOf /// - [DataContract(Name = "Dog_allOf")] public partial class DogAllOf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// breed. + /// breed public DogAllOf(string? breed = default) { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + Breed = breed; } /// /// Gets or Sets Breed /// - [DataMember(Name = "breed", EmitDefaultValue = false)] + [JsonPropertyName("breed")] public string? Breed { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as DogAllOf).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of DogAllOf to be compared /// Boolean - public bool Equals(DogAllOf input) + public bool Equals(DogAllOf? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs index 14558ee5aea..d3eb89c0bd4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,45 @@ namespace Org.OpenAPITools.Model /// /// Drawing /// - [DataContract(Name = "Drawing")] public partial class Drawing : Dictionary, IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// mainShape. - /// shapeOrNull. - /// nullableShape. - /// shapes. - public Drawing(Shape? mainShape = default, ShapeOrNull? shapeOrNull = default, NullableShape? nullableShape = default, List? shapes = default) : base() + /// mainShape + /// shapeOrNull + /// nullableShape + /// shapes + public Drawing(Shape? mainShape = default, ShapeOrNull? shapeOrNull = default, NullableShape? nullableShape = default, List? shapes = default) { - this.MainShape = mainShape; - this.ShapeOrNull = shapeOrNull; - this.NullableShape = nullableShape; - this.Shapes = shapes; + MainShape = mainShape; + ShapeOrNull = shapeOrNull; + NullableShape = nullableShape; + Shapes = shapes; } /// /// Gets or Sets MainShape /// - [DataMember(Name = "mainShape", EmitDefaultValue = false)] + [JsonPropertyName("mainShape")] public Shape? MainShape { get; set; } /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [JsonPropertyName("shapeOrNull")] public ShapeOrNull? ShapeOrNull { get; set; } /// /// Gets or Sets NullableShape /// - [DataMember(Name = "nullableShape", EmitDefaultValue = true)] + [JsonPropertyName("nullableShape")] public NullableShape? NullableShape { get; set; } /// /// Gets or Sets Shapes /// - [DataMember(Name = "shapes", EmitDefaultValue = false)] + [JsonPropertyName("shapes")] public List? Shapes { get; set; } /// @@ -88,21 +87,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Drawing).AreEqual; } @@ -112,7 +102,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Drawing to be compared /// Boolean - public bool Equals(Drawing input) + public bool Equals(Drawing? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs index f651effcbab..eb98603b2b4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,22 @@ namespace Org.OpenAPITools.Model /// /// EnumArrays /// - [DataContract(Name = "EnumArrays")] public partial class EnumArrays : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// justSymbol + /// arrayEnum + public EnumArrays(JustSymbolEnum? justSymbol = default, List? arrayEnum = default) + { + JustSymbol = justSymbol; + ArrayEnum = arrayEnum; + } + /// /// Defines JustSymbol /// - [JsonConverter(typeof(StringEnumConverter))] public enum JustSymbolEnum { /// @@ -52,16 +61,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets JustSymbol /// - [DataMember(Name = "just_symbol", EmitDefaultValue = false)] + [JsonPropertyName("just_symbol")] public JustSymbolEnum? JustSymbol { get; set; } + /// /// Defines ArrayEnum /// - [JsonConverter(typeof(StringEnumConverter))] public enum ArrayEnumEnum { /// @@ -79,29 +87,17 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets ArrayEnum /// - [DataMember(Name = "array_enum", EmitDefaultValue = false)] + [JsonPropertyName("array_enum")] public List? ArrayEnum { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// justSymbol. - /// arrayEnum. - public EnumArrays(JustSymbolEnum? justSymbol = default, List? arrayEnum = default) - { - this.JustSymbol = justSymbol; - this.ArrayEnum = arrayEnum; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -118,21 +114,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EnumArrays).AreEqual; } @@ -142,7 +129,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of EnumArrays to be compared /// Boolean - public bool Equals(EnumArrays input) + public bool Equals(EnumArrays? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs index 48b3d7d0e7e..9aa3badce21 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines EnumClass /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumClass { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Xyz = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs index bde4245a802..c6daed78bbc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,38 @@ namespace Org.OpenAPITools.Model /// /// EnumTest /// - [DataContract(Name = "Enum_Test")] public partial class EnumTest : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// enumStringRequired (required) + /// enumString + /// enumInteger + /// enumIntegerOnly + /// enumNumber + /// outerEnum + /// outerEnumInteger + /// outerEnumDefaultValue + /// outerEnumIntegerDefaultValue + public EnumTest(EnumStringRequiredEnum enumStringRequired, EnumStringEnum? enumString = default, EnumIntegerEnum? enumInteger = default, EnumIntegerOnlyEnum? enumIntegerOnly = default, EnumNumberEnum? enumNumber = default, OuterEnum? outerEnum = default, OuterEnumInteger? outerEnumInteger = default, OuterEnumDefaultValue? outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default) + { + if (enumStringRequired == null) + throw new ArgumentNullException("enumStringRequired is a required property for EnumTest and cannot be null."); + EnumStringRequired = enumStringRequired; + EnumString = enumString; + EnumInteger = enumInteger; + EnumIntegerOnly = enumIntegerOnly; + EnumNumber = enumNumber; + OuterEnum = outerEnum; + OuterEnumInteger = outerEnumInteger; + OuterEnumDefaultValue = outerEnumDefaultValue; + OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; + } + /// /// Defines EnumStringRequired /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumStringRequiredEnum { /// @@ -58,16 +83,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumStringRequired /// - [DataMember(Name = "enum_string_required", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("enum_string_required")] public EnumStringRequiredEnum EnumStringRequired { get; set; } + /// /// Defines EnumString /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumStringEnum { /// @@ -90,12 +114,12 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumString /// - [DataMember(Name = "enum_string", EmitDefaultValue = false)] + [JsonPropertyName("enum_string")] public EnumStringEnum? EnumString { get; set; } + /// /// Defines EnumInteger /// @@ -113,12 +137,12 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumInteger /// - [DataMember(Name = "enum_integer", EmitDefaultValue = false)] + [JsonPropertyName("enum_integer")] public EnumIntegerEnum? EnumInteger { get; set; } + /// /// Defines EnumIntegerOnly /// @@ -136,16 +160,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumIntegerOnly /// - [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + [JsonPropertyName("enum_integer_only")] public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumNumberEnum { /// @@ -162,75 +185,41 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumNumber /// - [DataMember(Name = "enum_number", EmitDefaultValue = false)] + [JsonPropertyName("enum_number")] public EnumNumberEnum? EnumNumber { get; set; } - + /// /// Gets or Sets OuterEnum /// - [DataMember(Name = "outerEnum", EmitDefaultValue = true)] + [JsonPropertyName("outerEnum")] public OuterEnum? OuterEnum { get; set; } - + /// /// Gets or Sets OuterEnumInteger /// - [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumInteger")] public OuterEnumInteger? OuterEnumInteger { get; set; } - + /// /// Gets or Sets OuterEnumDefaultValue /// - [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumDefaultValue")] public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; } - + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// - [DataMember(Name = "outerEnumIntegerDefaultValue", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumIntegerDefaultValue")] public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected EnumTest() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// enumStringRequired (required). - /// enumString. - /// enumInteger. - /// enumIntegerOnly. - /// enumNumber. - /// outerEnum. - /// outerEnumInteger. - /// outerEnumDefaultValue. - /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringRequiredEnum enumStringRequired, EnumStringEnum? enumString = default, EnumIntegerEnum? enumInteger = default, EnumIntegerOnlyEnum? enumIntegerOnly = default, EnumNumberEnum? enumNumber = default, OuterEnum? outerEnum = default, OuterEnumInteger? outerEnumInteger = default, OuterEnumDefaultValue? outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default) - { - this.EnumStringRequired = enumStringRequired; - this.EnumString = enumString; - this.EnumInteger = enumInteger; - this.EnumIntegerOnly = enumIntegerOnly; - this.EnumNumber = enumNumber; - this.OuterEnum = outerEnum; - this.OuterEnumInteger = outerEnumInteger; - this.OuterEnumDefaultValue = outerEnumDefaultValue; - this.OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -254,21 +243,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EnumTest).AreEqual; } @@ -278,7 +258,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of EnumTest to be compared /// Boolean - public bool Equals(EnumTest input) + public bool Equals(EnumTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 43e72bd635a..9bd30c45c26 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// EquilateralTriangle /// - [DataContract(Name = "EquilateralTriangle")] public partial class EquilateralTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected EquilateralTriangle() + /// shapeInterface + /// triangleInterface + public EquilateralTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public EquilateralTriangle(string shapeType, string triangleType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for EquilateralTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for EquilateralTriangle and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets EquilateralTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface? ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets EquilateralTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface? TriangleInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,28 +66,17 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EquilateralTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as EquilateralTriangle).AreEqual; } @@ -117,7 +86,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of EquilateralTriangle to be compared /// Boolean - public bool Equals(EquilateralTriangle input) + public bool Equals(EquilateralTriangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type EquilateralTriangle + /// + public class EquilateralTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(EquilateralTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override EquilateralTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface? shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface? triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new EquilateralTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs index b3c3263ba5b..2ae90b249a2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/File.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,31 +29,29 @@ namespace Org.OpenAPITools.Model /// /// Must be named `File` for test. /// - [DataContract(Name = "File")] public partial class File : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// Test capitalization. + /// Test capitalization public File(string? sourceURI = default) { - this.SourceURI = sourceURI; - this.AdditionalProperties = new Dictionary(); + SourceURI = sourceURI; } /// /// Test capitalization /// /// Test capitalization - [DataMember(Name = "sourceURI", EmitDefaultValue = false)] + [JsonPropertyName("sourceURI")] public string? SourceURI { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -69,21 +67,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as File).AreEqual; } @@ -93,7 +82,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of File to be compared /// Boolean - public bool Equals(File input) + public bool Equals(File? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 06920e9adf6..26c1e83b07a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// FileSchemaTestClass /// - [DataContract(Name = "FileSchemaTestClass")] public partial class FileSchemaTestClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// file. - /// files. + /// file + /// files public FileSchemaTestClass(File? file = default, List? files = default) { - this.File = file; - this.Files = files; - this.AdditionalProperties = new Dictionary(); + File = file; + Files = files; } /// /// Gets or Sets File /// - [DataMember(Name = "file", EmitDefaultValue = false)] + [JsonPropertyName("file")] public File? File { get; set; } /// /// Gets or Sets Files /// - [DataMember(Name = "files", EmitDefaultValue = false)] + [JsonPropertyName("files")] public List? Files { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,21 +75,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FileSchemaTestClass).AreEqual; } @@ -101,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of FileSchemaTestClass to be compared /// Boolean - public bool Equals(FileSchemaTestClass input) + public bool Equals(FileSchemaTestClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs index eefb6ba9861..4997e8d3bb7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Foo.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,31 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Foo /// - [DataContract(Name = "Foo")] public partial class Foo : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// bar (default to "bar"). + /// bar (default to "bar") public Foo(string? bar = "bar") { - // use default value if no "bar" provided - this.Bar = bar ?? "bar"; - this.AdditionalProperties = new Dictionary(); + Bar = bar; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string? Bar { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -69,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Foo).AreEqual; } @@ -93,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Foo to be compared /// Boolean - public bool Equals(Foo input) + public bool Equals(Foo? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs index 8bd1caec56a..9cdaaef6335 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,169 +29,158 @@ namespace Org.OpenAPITools.Model /// /// FormatTest /// - [DataContract(Name = "format_test")] public partial class FormatTest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected FormatTest() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// number (required). - /// _byte (required). - /// date (required). - /// password (required). - /// integer. - /// int32. - /// int64. - /// _float. - /// _double. - /// _decimal. - /// _string. - /// binary. - /// dateTime. - /// uuid. - /// A string that is a 10 digit number. Can have leading zeros.. - /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.. + /// number (required) + /// _byte (required) + /// date (required) + /// password (required) + /// integer + /// int32 + /// int64 + /// _float + /// _double + /// _decimal + /// _string + /// binary + /// dateTime + /// uuid + /// A string that is a 10 digit number. Can have leading zeros. + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. public FormatTest(decimal number, byte[] _byte, DateTime date, string password, int? integer = default, int? int32 = default, long? int64 = default, float? _float = default, double? _double = default, decimal? _decimal = default, string? _string = default, System.IO.Stream? binary = default, DateTime? dateTime = default, Guid? uuid = default, string? patternWithDigits = default, string? patternWithDigitsAndDelimiter = default) { - this.Number = number; - // to ensure "_byte" is required (not null) - if (_byte == null) { - throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null"); - } - this.Byte = _byte; - this.Date = date; - // to ensure "password" is required (not null) - if (password == null) { - throw new ArgumentNullException("password is a required property for FormatTest and cannot be null"); - } - this.Password = password; - this.Integer = integer; - this.Int32 = int32; - this.Int64 = int64; - this.Float = _float; - this.Double = _double; - this.Decimal = _decimal; - this.String = _string; - this.Binary = binary; - this.DateTime = dateTime; - this.Uuid = uuid; - this.PatternWithDigits = patternWithDigits; - this.PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - this.AdditionalProperties = new Dictionary(); + if (number == null) + throw new ArgumentNullException("number is a required property for FormatTest and cannot be null."); + if (_byte == null) + throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null."); + if (date == null) + throw new ArgumentNullException("date is a required property for FormatTest and cannot be null."); + if (password == null) + throw new ArgumentNullException("password is a required property for FormatTest and cannot be null."); + Number = number; + Byte = _byte; + Date = date; + Password = password; + Integer = integer; + Int32 = int32; + Int64 = int64; + Float = _float; + Double = _double; + Decimal = _decimal; + String = _string; + Binary = binary; + DateTime = dateTime; + Uuid = uuid; + PatternWithDigits = patternWithDigits; + PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; } /// /// Gets or Sets Number /// - [DataMember(Name = "number", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("number")] public decimal Number { get; set; } /// /// Gets or Sets Byte /// - [DataMember(Name = "byte", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("byte")] public byte[] Byte { get; set; } /// /// Gets or Sets Date /// - [DataMember(Name = "date", IsRequired = true, EmitDefaultValue = false)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [JsonPropertyName("date")] public DateTime Date { get; set; } /// /// Gets or Sets Password /// - [DataMember(Name = "password", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("password")] public string Password { get; set; } /// /// Gets or Sets Integer /// - [DataMember(Name = "integer", EmitDefaultValue = false)] + [JsonPropertyName("integer")] public int? Integer { get; set; } /// /// Gets or Sets Int32 /// - [DataMember(Name = "int32", EmitDefaultValue = false)] + [JsonPropertyName("int32")] public int? Int32 { get; set; } /// /// Gets or Sets Int64 /// - [DataMember(Name = "int64", EmitDefaultValue = false)] + [JsonPropertyName("int64")] public long? Int64 { get; set; } /// /// Gets or Sets Float /// - [DataMember(Name = "float", EmitDefaultValue = false)] + [JsonPropertyName("float")] public float? Float { get; set; } /// /// Gets or Sets Double /// - [DataMember(Name = "double", EmitDefaultValue = false)] + [JsonPropertyName("double")] public double? Double { get; set; } /// /// Gets or Sets Decimal /// - [DataMember(Name = "decimal", EmitDefaultValue = false)] + [JsonPropertyName("decimal")] public decimal? Decimal { get; set; } /// /// Gets or Sets String /// - [DataMember(Name = "string", EmitDefaultValue = false)] + [JsonPropertyName("string")] public string? String { get; set; } /// /// Gets or Sets Binary /// - [DataMember(Name = "binary", EmitDefaultValue = false)] + [JsonPropertyName("binary")] public System.IO.Stream? Binary { get; set; } /// /// Gets or Sets DateTime /// - [DataMember(Name = "dateTime", EmitDefaultValue = false)] + [JsonPropertyName("dateTime")] public DateTime? DateTime { get; set; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public Guid? Uuid { get; set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. - [DataMember(Name = "pattern_with_digits", EmitDefaultValue = false)] + [JsonPropertyName("pattern_with_digits")] public string? PatternWithDigits { get; set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - [DataMember(Name = "pattern_with_digits_and_delimiter", EmitDefaultValue = false)] + [JsonPropertyName("pattern_with_digits_and_delimiter")] public string? PatternWithDigitsAndDelimiter { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -222,21 +211,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FormatTest).AreEqual; } @@ -246,7 +226,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of FormatTest to be compared /// Boolean - public bool Equals(FormatTest input) + public bool Equals(FormatTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs index 726b1e8f72e..081a09bce7d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Fruit.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,95 +19,55 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Fruit /// - [JsonConverter(typeof(FruitJsonConverter))] - [DataContract(Name = "fruit")] - public partial class Fruit : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Fruit : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Apple. - public Fruit(Apple actualInstance) + /// apple + /// color + public Fruit(Apple? apple, string? color = default) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Apple = apple; + Color = color; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Banana. - public Fruit(Banana actualInstance) + /// banana + /// color + public Fruit(Banana? banana, string? color = default) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Apple)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Banana)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Apple, Banana"); - } - } + Banana = banana; + Color = color; } /// - /// Get the actual instance of `Apple`. If the actual instance is not `Apple`, - /// the InvalidClassException will be thrown + /// Gets or Sets fruit /// - /// An instance of Apple - public Apple GetApple() - { - return (Apple)this.ActualInstance; - } + public Apple? Apple { get; set; } /// - /// Get the actual instance of `Banana`. If the actual instance is not `Banana`, - /// the InvalidClassException will be thrown + /// Gets or Sets fruit /// - /// An instance of Banana - public Banana GetBanana() - { - return (Banana)this.ActualInstance; - } + public Banana? Banana { get; set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string? Color { get; set; } /// /// Returns the string presentation of the object @@ -113,97 +75,19 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Fruit {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Fruit.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Fruit - /// - /// JSON string - /// An instance of Fruit - public static Fruit FromJson(string jsonString) - { - Fruit newFruit = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newFruit; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Apple).GetProperty("AdditionalProperties") == null) - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.SerializerSettings)); - } - else - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Apple"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Banana).GetProperty("AdditionalProperties") == null) - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.SerializerSettings)); - } - else - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Banana"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newFruit; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Fruit).AreEqual; } @@ -213,7 +97,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Fruit to be compared /// Boolean - public bool Equals(Fruit input) + public bool Equals(Fruit? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -227,8 +111,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.Color != null) + { + hashCode = (hashCode * 59) + this.Color.GetHashCode(); + } return hashCode; } } @@ -238,54 +124,82 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Fruit + /// A Json converter for type Fruit /// - public class FruitJsonConverter : JsonConverter + public class FruitJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Fruit).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Fruit).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReader, options, out Apple? apple); + + Utf8JsonReader bananaReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReader, options, out Banana? banana); + + string? color = default; + + while (reader.Read()) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "color": + color = reader.GetString(); + break; + } + } } - return null; + + if (apple != null) + return new Fruit(apple, color); + + if (banana != null) + return new Fruit(banana, color); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs index 548da490def..d6aed82b9ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FruitReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,104 +19,45 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// FruitReq /// - [JsonConverter(typeof(FruitReqJsonConverter))] - [DataContract(Name = "fruitReq")] - public partial class FruitReq : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class FruitReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public FruitReq() + /// appleReq + public FruitReq(AppleReq? appleReq) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + AppleReq = appleReq; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of AppleReq. - public FruitReq(AppleReq actualInstance) + /// bananaReq + public FruitReq(BananaReq? bananaReq) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + BananaReq = bananaReq; } /// - /// Initializes a new instance of the class - /// with the class + /// Gets or Sets fruitReq /// - /// An instance of BananaReq. - public FruitReq(BananaReq actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + public AppleReq? AppleReq { get; set; } /// - /// Gets or Sets ActualInstance + /// Gets or Sets fruitReq /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(AppleReq)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(BananaReq)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: AppleReq, BananaReq"); - } - } - } - - /// - /// Get the actual instance of `AppleReq`. If the actual instance is not `AppleReq`, - /// the InvalidClassException will be thrown - /// - /// An instance of AppleReq - public AppleReq GetAppleReq() - { - return (AppleReq)this.ActualInstance; - } - - /// - /// Get the actual instance of `BananaReq`. If the actual instance is not `BananaReq`, - /// the InvalidClassException will be thrown - /// - /// An instance of BananaReq - public BananaReq GetBananaReq() - { - return (BananaReq)this.ActualInstance; - } + public BananaReq? BananaReq { get; set; } /// /// Returns the string presentation of the object @@ -122,97 +65,18 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class FruitReq {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, FruitReq.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of FruitReq - /// - /// JSON string - /// An instance of FruitReq - public static FruitReq FromJson(string jsonString) - { - FruitReq newFruitReq = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newFruitReq; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(AppleReq).GetProperty("AdditionalProperties") == null) - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.SerializerSettings)); - } - else - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("AppleReq"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into AppleReq: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(BananaReq).GetProperty("AdditionalProperties") == null) - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.SerializerSettings)); - } - else - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("BananaReq"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into BananaReq: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newFruitReq; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as FruitReq).AreEqual; } @@ -222,7 +86,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of FruitReq to be compared /// Boolean - public bool Equals(FruitReq input) + public bool Equals(FruitReq? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -236,8 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); return hashCode; } } @@ -247,54 +109,78 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for FruitReq + /// A Json converter for type FruitReq /// - public class FruitReqJsonConverter : JsonConverter + public class FruitReqJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(FruitReq).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(FruitReq).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override FruitReq Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReqReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReqReader, options, out AppleReq? appleReq); + + Utf8JsonReader bananaReqReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReqReader, options, out BananaReq? bananaReq); + + + while (reader.Read()) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (appleReq != null) + return new FruitReq(appleReq); + + if (bananaReq != null) + return new FruitReq(bananaReq); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs index bd8f4435c92..dafca39bc42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GmFruit.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,82 +29,36 @@ namespace Org.OpenAPITools.Model /// /// GmFruit /// - [JsonConverter(typeof(GmFruitJsonConverter))] - [DataContract(Name = "gmFruit")] - public partial class GmFruit : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class GmFruit : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Apple. - public GmFruit(Apple actualInstance) + /// apple + /// banana + /// color + public GmFruit(Apple? apple, Banana? banana, string? color = default) { - this.IsNullable = false; - this.SchemaType= "anyOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Apple = apple; + Banana = banana; + Color = color; } /// - /// Initializes a new instance of the class - /// with the class + /// Gets or Sets gmFruit /// - /// An instance of Banana. - public GmFruit(Banana actualInstance) - { - this.IsNullable = false; - this.SchemaType= "anyOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; + public Apple? Apple { get; set; } /// - /// Gets or Sets ActualInstance + /// Gets or Sets gmFruit /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Apple)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Banana)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Apple, Banana"); - } - } - } + public Banana? Banana { get; set; } /// - /// Get the actual instance of `Apple`. If the actual instance is not `Apple`, - /// the InvalidClassException will be thrown + /// Gets or Sets Color /// - /// An instance of Apple - public Apple GetApple() - { - return (Apple)this.ActualInstance; - } - - /// - /// Get the actual instance of `Banana`. If the actual instance is not `Banana`, - /// the InvalidClassException will be thrown - /// - /// An instance of Banana - public Banana GetBanana() - { - return (Banana)this.ActualInstance; - } + [JsonPropertyName("color")] + public string? Color { get; set; } /// /// Returns the string presentation of the object @@ -112,70 +66,19 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class GmFruit {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, GmFruit.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of GmFruit - /// - /// JSON string - /// An instance of GmFruit - public static GmFruit FromJson(string jsonString) - { - GmFruit newGmFruit = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newGmFruit; - } - - try - { - newGmFruit = new GmFruit(JsonConvert.DeserializeObject(jsonString, GmFruit.SerializerSettings)); - // deserialization is considered successful at this point if no exception has been thrown. - return newGmFruit; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString())); - } - - try - { - newGmFruit = new GmFruit(JsonConvert.DeserializeObject(jsonString, GmFruit.SerializerSettings)); - // deserialization is considered successful at this point if no exception has been thrown. - return newGmFruit; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString())); - } - - // no match found, throw an exception - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as GmFruit).AreEqual; } @@ -185,7 +88,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of GmFruit to be compared /// Boolean - public bool Equals(GmFruit input) + public bool Equals(GmFruit? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -199,8 +102,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.Color != null) + { + hashCode = (hashCode * 59) + this.Color.GetHashCode(); + } return hashCode; } } @@ -210,54 +115,76 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for GmFruit + /// A Json converter for type GmFruit /// - public class GmFruitJsonConverter : JsonConverter + public class GmFruitJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(GmFruit).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(GmFruit).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override GmFruit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReader, options, out Apple? apple); + + Utf8JsonReader bananaReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReader, options, out Banana? banana); + + string? color = default; + + while (reader.Read()) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "color": + color = reader.GetString(); + break; + } + } } - return null; + + return new GmFruit(apple, banana, color); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 24b3df864e1..56c88c8a217 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,45 +29,30 @@ namespace Org.OpenAPITools.Model /// /// GrandparentAnimal /// - [DataContract(Name = "GrandparentAnimal")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] - [JsonSubtypes.KnownSubType(typeof(ParentPet), "ParentPet")] public partial class GrandparentAnimal : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected GrandparentAnimal() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// petType (required). + /// petType (required) public GrandparentAnimal(string petType) { - // to ensure "petType" is required (not null) - if (petType == null) { - throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null"); - } - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); + if (petType == null) + throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null."); + PetType = petType; } /// /// Gets or Sets PetType /// - [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("pet_type")] public string PetType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -84,21 +68,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as GrandparentAnimal).AreEqual; } @@ -108,7 +83,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of GrandparentAnimal to be compared /// Boolean - public bool Equals(GrandparentAnimal input) + public bool Equals(GrandparentAnimal? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 76c03db2173..ae81256f825 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,51 +29,36 @@ namespace Org.OpenAPITools.Model /// /// HasOnlyReadOnly /// - [DataContract(Name = "hasOnlyReadOnly")] public partial class HasOnlyReadOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - public HasOnlyReadOnly() + /// bar + /// foo + public HasOnlyReadOnly(string? bar = default, string? foo = default) { - this.AdditionalProperties = new Dictionary(); + Bar = bar; + Foo = foo; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string? Bar { get; private set; } - /// - /// Returns false as Bar should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBar() - { - return false; - } /// /// Gets or Sets Foo /// - [DataMember(Name = "foo", EmitDefaultValue = false)] + [JsonPropertyName("foo")] public string? Foo { get; private set; } - /// - /// Returns false as Foo should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeFoo() - { - return false; - } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -90,21 +75,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as HasOnlyReadOnly).AreEqual; } @@ -114,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of HasOnlyReadOnly to be compared /// Boolean - public bool Equals(HasOnlyReadOnly input) + public bool Equals(HasOnlyReadOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 53fa8992f61..34a2909e1c3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. /// - [DataContract(Name = "HealthCheckResult")] public partial class HealthCheckResult : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// nullableMessage. + /// nullableMessage public HealthCheckResult(string? nullableMessage = default) { - this.NullableMessage = nullableMessage; - this.AdditionalProperties = new Dictionary(); + NullableMessage = nullableMessage; } /// /// Gets or Sets NullableMessage /// - [DataMember(Name = "NullableMessage", EmitDefaultValue = true)] + [JsonPropertyName("NullableMessage")] public string? NullableMessage { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as HealthCheckResult).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of HealthCheckResult to be compared /// Boolean - public bool Equals(HealthCheckResult input) + public bool Equals(HealthCheckResult? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/InlineResponseDefault.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/InlineResponseDefault.cs index 09d4dde78f7..7e5ed58fad2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/InlineResponseDefault.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/InlineResponseDefault.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// InlineResponseDefault /// - [DataContract(Name = "inline_response_default")] public partial class InlineResponseDefault : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _string. + /// _string public InlineResponseDefault(Foo? _string = default) { - this.String = _string; - this.AdditionalProperties = new Dictionary(); + String = _string; } /// /// Gets or Sets String /// - [DataMember(Name = "string", EmitDefaultValue = false)] + [JsonPropertyName("string")] public Foo? String { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as InlineResponseDefault).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of InlineResponseDefault to be compared /// Boolean - public bool Equals(InlineResponseDefault input) + public bool Equals(InlineResponseDefault? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index d5ff97d769c..145f9840dd3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,44 +29,28 @@ namespace Org.OpenAPITools.Model /// /// IsoscelesTriangle /// - [DataContract(Name = "IsoscelesTriangle")] public partial class IsoscelesTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected IsoscelesTriangle() { } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public IsoscelesTriangle(string shapeType, string triangleType) + /// shapeInterface + /// triangleInterface + public IsoscelesTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for IsoscelesTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for IsoscelesTriangle and cannot be null"); - } - this.TriangleType = triangleType; + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets IsoscelesTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface? ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets IsoscelesTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface? TriangleInterface { get; set; } /// /// Returns the string presentation of the object @@ -76,27 +60,16 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class IsoscelesTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as IsoscelesTriangle).AreEqual; } @@ -106,7 +79,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of IsoscelesTriangle to be compared /// Boolean - public bool Equals(IsoscelesTriangle input) + public bool Equals(IsoscelesTriangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -120,14 +93,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } return hashCode; } } @@ -143,4 +108,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type IsoscelesTriangle + /// + public class IsoscelesTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(IsoscelesTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override IsoscelesTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface? shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface? triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new IsoscelesTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs index c6b2042d981..af537950c8d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/List.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// List /// - [DataContract(Name = "List")] public partial class List : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _123list. + /// _123list public List(string? _123list = default) { - this._123List = _123list; - this.AdditionalProperties = new Dictionary(); + _123List = _123list; } /// /// Gets or Sets _123List /// - [DataMember(Name = "123-list", EmitDefaultValue = false)] + [JsonPropertyName("123-list")] public string? _123List { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as List).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of List to be compared /// Boolean - public bool Equals(List input) + public bool Equals(List? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs index 68ac3161992..3ee8383a14f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Mammal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,122 +19,65 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Mammal /// - [JsonConverter(typeof(MammalJsonConverter))] - [DataContract(Name = "mammal")] - public partial class Mammal : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Mammal : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Pig. - public Mammal(Pig actualInstance) + /// pig + public Mammal(Pig? pig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Pig = pig; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Whale. - public Mammal(Whale actualInstance) + /// whale + public Mammal(Whale? whale) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Whale = whale; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Zebra. - public Mammal(Zebra actualInstance) + /// zebra + public Mammal(Zebra? zebra) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Pig)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Whale)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Zebra)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Pig, Whale, Zebra"); - } - } + Zebra = zebra; } /// - /// Get the actual instance of `Pig`. If the actual instance is not `Pig`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Pig - public Pig GetPig() - { - return (Pig)this.ActualInstance; - } + public Pig? Pig { get; set; } /// - /// Get the actual instance of `Whale`. If the actual instance is not `Whale`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Whale - public Whale GetWhale() - { - return (Whale)this.ActualInstance; - } + public Whale? Whale { get; set; } /// - /// Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Zebra - public Zebra GetZebra() - { - return (Zebra)this.ActualInstance; - } + public Zebra? Zebra { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -140,117 +85,19 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Mammal.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Mammal - /// - /// JSON string - /// An instance of Mammal - public static Mammal FromJson(string jsonString) - { - Mammal newMammal = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newMammal; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Pig).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Pig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Pig: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Whale).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Whale"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Whale: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Zebra).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Zebra"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Zebra: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newMammal; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Mammal).AreEqual; } @@ -260,7 +107,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Mammal to be compared /// Boolean - public bool Equals(Mammal input) + public bool Equals(Mammal? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -274,8 +121,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -285,54 +134,94 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Mammal + /// A Json converter for type Mammal /// - public class MammalJsonConverter : JsonConverter + public class MammalJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Mammal).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Mammal).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Mammal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader pigReader = reader; + Client.ClientUtils.TryDeserialize(ref pigReader, options, out Pig? pig); + + Utf8JsonReader whaleReader = reader; + Client.ClientUtils.TryDeserialize(ref whaleReader, options, out Whale? whale); + + Utf8JsonReader zebraReader = reader; + Client.ClientUtils.TryDeserialize(ref zebraReader, options, out Zebra? zebra); + + + while (reader.Read()) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (pig != null) + return new Mammal(pig); + + if (whale != null) + return new Mammal(whale); + + if (zebra != null) + return new Mammal(zebra); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs index 4b18ed169af..a0442d01825 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MapTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,26 @@ namespace Org.OpenAPITools.Model /// /// MapTest /// - [DataContract(Name = "MapTest")] public partial class MapTest : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// mapMapOfString + /// mapOfEnumString + /// directMap + /// indirectMap + public MapTest(Dictionary>? mapMapOfString = default, Dictionary? mapOfEnumString = default, Dictionary? directMap = default, Dictionary? indirectMap = default) + { + MapMapOfString = mapMapOfString; + MapOfEnumString = mapOfEnumString; + DirectMap = directMap; + IndirectMap = indirectMap; + } + /// /// Defines Inner /// - [JsonConverter(typeof(StringEnumConverter))] public enum InnerEnum { /// @@ -53,51 +66,35 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets MapOfEnumString /// - [DataMember(Name = "map_of_enum_string", EmitDefaultValue = false)] + [JsonPropertyName("map_of_enum_string")] public Dictionary? MapOfEnumString { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// mapMapOfString. - /// mapOfEnumString. - /// directMap. - /// indirectMap. - public MapTest(Dictionary>? mapMapOfString = default, Dictionary? mapOfEnumString = default, Dictionary? directMap = default, Dictionary? indirectMap = default) - { - this.MapMapOfString = mapMapOfString; - this.MapOfEnumString = mapOfEnumString; - this.DirectMap = directMap; - this.IndirectMap = indirectMap; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets MapMapOfString /// - [DataMember(Name = "map_map_of_string", EmitDefaultValue = false)] + [JsonPropertyName("map_map_of_string")] public Dictionary>? MapMapOfString { get; set; } /// /// Gets or Sets DirectMap /// - [DataMember(Name = "direct_map", EmitDefaultValue = false)] + [JsonPropertyName("direct_map")] public Dictionary? DirectMap { get; set; } /// /// Gets or Sets IndirectMap /// - [DataMember(Name = "indirect_map", EmitDefaultValue = false)] + [JsonPropertyName("indirect_map")] public Dictionary? IndirectMap { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -116,21 +113,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as MapTest).AreEqual; } @@ -140,7 +128,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of MapTest to be compared /// Boolean - public bool Equals(MapTest input) + public bool Equals(MapTest? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index c9994945468..a583c8f393c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// MixedPropertiesAndAdditionalPropertiesClass /// - [DataContract(Name = "MixedPropertiesAndAdditionalPropertiesClass")] public partial class MixedPropertiesAndAdditionalPropertiesClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// uuid. - /// dateTime. - /// map. + /// uuid + /// dateTime + /// map public MixedPropertiesAndAdditionalPropertiesClass(Guid? uuid = default, DateTime? dateTime = default, Dictionary? map = default) { - this.Uuid = uuid; - this.DateTime = dateTime; - this.Map = map; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + DateTime = dateTime; + Map = map; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public Guid? Uuid { get; set; } /// /// Gets or Sets DateTime /// - [DataMember(Name = "dateTime", EmitDefaultValue = false)] + [JsonPropertyName("dateTime")] public DateTime? DateTime { get; set; } /// /// Gets or Sets Map /// - [DataMember(Name = "map", EmitDefaultValue = false)] + [JsonPropertyName("map")] public Dictionary? Map { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,21 +84,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedPropertiesAndAdditionalPropertiesClass).AreEqual; } @@ -110,7 +99,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of MixedPropertiesAndAdditionalPropertiesClass to be compared /// Boolean - public bool Equals(MixedPropertiesAndAdditionalPropertiesClass input) + public bool Equals(MixedPropertiesAndAdditionalPropertiesClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs index c08ba66f533..318ef8a27a9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Model200Response.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model name starting with number /// - [DataContract(Name = "200_response")] public partial class Model200Response : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// name. - /// _class. + /// name + /// _class public Model200Response(int? name = default, string? _class = default) { - this.Name = name; - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Name = name; + Class = _class; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public int? Name { get; set; } /// /// Gets or Sets Class /// - [DataMember(Name = "class", EmitDefaultValue = false)] + [JsonPropertyName("class")] public string? Class { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,21 +75,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Model200Response).AreEqual; } @@ -101,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Model200Response to be compared /// Boolean - public bool Equals(Model200Response input) + public bool Equals(Model200Response? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs index 20b409cf263..86364761194 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ModelClient.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ModelClient /// - [DataContract(Name = "_Client")] public partial class ModelClient : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _client. + /// _client public ModelClient(string? _client = default) { - this._Client = _client; - this.AdditionalProperties = new Dictionary(); + _Client = _client; } /// /// Gets or Sets _Client /// - [DataMember(Name = "client", EmitDefaultValue = false)] + [JsonPropertyName("client")] public string? _Client { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ModelClient).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ModelClient to be compared /// Boolean - public bool Equals(ModelClient input) + public bool Equals(ModelClient? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs index d0705677db3..53afa3005ad 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Name.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,74 +29,54 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model name same as property name /// - [DataContract(Name = "Name")] public partial class Name : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Name() + /// nameProperty (required) + /// snakeCase + /// property + /// _123number + public Name(int nameProperty, int? snakeCase = default, string? property = default, int? _123number = default) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required). - /// property. - public Name(int name, string? property = default) - { - this._Name = name; - this.Property = property; - this.AdditionalProperties = new Dictionary(); + if (nameProperty == null) + throw new ArgumentNullException("nameProperty is a required property for Name and cannot be null."); + NameProperty = nameProperty; + SnakeCase = snakeCase; + Property = property; + _123Number = _123number; } /// - /// Gets or Sets _Name + /// Gets or Sets NameProperty /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] - public int _Name { get; set; } + [JsonPropertyName("name")] + public int NameProperty { get; set; } /// /// Gets or Sets SnakeCase /// - [DataMember(Name = "snake_case", EmitDefaultValue = false)] + [JsonPropertyName("snake_case")] public int? SnakeCase { get; private set; } - /// - /// Returns false as SnakeCase should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeSnakeCase() - { - return false; - } /// /// Gets or Sets Property /// - [DataMember(Name = "property", EmitDefaultValue = false)] + [JsonPropertyName("property")] public string? Property { get; set; } /// /// Gets or Sets _123Number /// - [DataMember(Name = "123Number", EmitDefaultValue = false)] + [JsonPropertyName("123Number")] public int? _123Number { get; private set; } - /// - /// Returns false as _123Number should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize_123Number() - { - return false; - } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -106,7 +86,7 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Name {\n"); - sb.Append(" _Name: ").Append(_Name).Append("\n"); + sb.Append(" NameProperty: ").Append(NameProperty).Append("\n"); sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); sb.Append(" Property: ").Append(Property).Append("\n"); sb.Append(" _123Number: ").Append(_123Number).Append("\n"); @@ -115,21 +95,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Name).AreEqual; } @@ -139,7 +110,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Name to be compared /// Boolean - public bool Equals(Name input) + public bool Equals(Name? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -153,7 +124,7 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this._Name.GetHashCode(); + hashCode = (hashCode * 59) + this.NameProperty.GetHashCode(); hashCode = (hashCode * 59) + this.SnakeCase.GetHashCode(); if (this.Property != null) { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs index c45e895dfc6..e040da9ed5e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,111 +29,109 @@ namespace Org.OpenAPITools.Model /// /// NullableClass /// - [DataContract(Name = "NullableClass")] public partial class NullableClass : Dictionary, IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// integerProp. - /// numberProp. - /// booleanProp. - /// stringProp. - /// dateProp. - /// datetimeProp. - /// arrayNullableProp. - /// arrayAndItemsNullableProp. - /// arrayItemsNullable. - /// objectNullableProp. - /// objectAndItemsNullableProp. - /// objectItemsNullable. - public NullableClass(int? integerProp = default, decimal? numberProp = default, bool? booleanProp = default, string? stringProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, List? arrayNullableProp = default, List? arrayAndItemsNullableProp = default, List? arrayItemsNullable = default, Dictionary? objectNullableProp = default, Dictionary? objectAndItemsNullableProp = default, Dictionary? objectItemsNullable = default) : base() + /// integerProp + /// numberProp + /// booleanProp + /// stringProp + /// dateProp + /// datetimeProp + /// arrayNullableProp + /// arrayAndItemsNullableProp + /// arrayItemsNullable + /// objectNullableProp + /// objectAndItemsNullableProp + /// objectItemsNullable + public NullableClass(int? integerProp = default, decimal? numberProp = default, bool? booleanProp = default, string? stringProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, List? arrayNullableProp = default, List? arrayAndItemsNullableProp = default, List? arrayItemsNullable = default, Dictionary? objectNullableProp = default, Dictionary? objectAndItemsNullableProp = default, Dictionary? objectItemsNullable = default) { - this.IntegerProp = integerProp; - this.NumberProp = numberProp; - this.BooleanProp = booleanProp; - this.StringProp = stringProp; - this.DateProp = dateProp; - this.DatetimeProp = datetimeProp; - this.ArrayNullableProp = arrayNullableProp; - this.ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - this.ArrayItemsNullable = arrayItemsNullable; - this.ObjectNullableProp = objectNullableProp; - this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; - this.ObjectItemsNullable = objectItemsNullable; + IntegerProp = integerProp; + NumberProp = numberProp; + BooleanProp = booleanProp; + StringProp = stringProp; + DateProp = dateProp; + DatetimeProp = datetimeProp; + ArrayNullableProp = arrayNullableProp; + ArrayAndItemsNullableProp = arrayAndItemsNullableProp; + ArrayItemsNullable = arrayItemsNullable; + ObjectNullableProp = objectNullableProp; + ObjectAndItemsNullableProp = objectAndItemsNullableProp; + ObjectItemsNullable = objectItemsNullable; } /// /// Gets or Sets IntegerProp /// - [DataMember(Name = "integer_prop", EmitDefaultValue = true)] + [JsonPropertyName("integer_prop")] public int? IntegerProp { get; set; } /// /// Gets or Sets NumberProp /// - [DataMember(Name = "number_prop", EmitDefaultValue = true)] + [JsonPropertyName("number_prop")] public decimal? NumberProp { get; set; } /// /// Gets or Sets BooleanProp /// - [DataMember(Name = "boolean_prop", EmitDefaultValue = true)] + [JsonPropertyName("boolean_prop")] public bool? BooleanProp { get; set; } /// /// Gets or Sets StringProp /// - [DataMember(Name = "string_prop", EmitDefaultValue = true)] + [JsonPropertyName("string_prop")] public string? StringProp { get; set; } /// /// Gets or Sets DateProp /// - [DataMember(Name = "date_prop", EmitDefaultValue = true)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [JsonPropertyName("date_prop")] public DateTime? DateProp { get; set; } /// /// Gets or Sets DatetimeProp /// - [DataMember(Name = "datetime_prop", EmitDefaultValue = true)] + [JsonPropertyName("datetime_prop")] public DateTime? DatetimeProp { get; set; } /// /// Gets or Sets ArrayNullableProp /// - [DataMember(Name = "array_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("array_nullable_prop")] public List? ArrayNullableProp { get; set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// - [DataMember(Name = "array_and_items_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("array_and_items_nullable_prop")] public List? ArrayAndItemsNullableProp { get; set; } /// /// Gets or Sets ArrayItemsNullable /// - [DataMember(Name = "array_items_nullable", EmitDefaultValue = false)] + [JsonPropertyName("array_items_nullable")] public List? ArrayItemsNullable { get; set; } /// /// Gets or Sets ObjectNullableProp /// - [DataMember(Name = "object_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("object_nullable_prop")] public Dictionary? ObjectNullableProp { get; set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// - [DataMember(Name = "object_and_items_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("object_and_items_nullable_prop")] public Dictionary? ObjectAndItemsNullableProp { get; set; } /// /// Gets or Sets ObjectItemsNullable /// - [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] + [JsonPropertyName("object_items_nullable")] public Dictionary? ObjectItemsNullable { get; set; } /// @@ -161,21 +159,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NullableClass).AreEqual; } @@ -185,7 +174,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of NullableClass to be compared /// Boolean - public bool Equals(NullableClass input) + public bool Equals(NullableClass? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs index 5dd73a56ef7..0fe8fac635e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableShape.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,105 +19,53 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - [JsonConverter(typeof(NullableShapeJsonConverter))] - [DataContract(Name = "NullableShape")] - public partial class NullableShape : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class NullableShape : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public NullableShape() + /// quadrilateral + public NullableShape(Quadrilateral? quadrilateral) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + Quadrilateral = quadrilateral; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public NullableShape(Quadrilateral actualInstance) + /// triangle + public NullableShape(Triangle? triangle) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + Triangle = triangle; } /// - /// Initializes a new instance of the class - /// with the class + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - /// An instance of Triangle. - public NullableShape(Triangle actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + public Quadrilateral? Quadrilateral { get; set; } /// - /// Gets or Sets ActualInstance + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } - } + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + public Triangle? Triangle { get; set; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets additional properties /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } - - /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown - /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -123,97 +73,19 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, NullableShape.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of NullableShape - /// - /// JSON string - /// An instance of NullableShape - public static NullableShape FromJson(string jsonString) - { - NullableShape newNullableShape = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newNullableShape; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.SerializerSettings)); - } - else - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.SerializerSettings)); - } - else - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newNullableShape; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NullableShape).AreEqual; } @@ -223,7 +95,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of NullableShape to be compared /// Boolean - public bool Equals(NullableShape input) + public bool Equals(NullableShape? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -237,8 +109,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -248,54 +122,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for NullableShape + /// A Json converter for type NullableShape /// - public class NullableShapeJsonConverter : JsonConverter + public class NullableShapeJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(NullableShape).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(NullableShape).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override NullableShape Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral? quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle? triangle); + + + while (reader.Read()) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (quadrilateral != null) + return new NullableShape(quadrilateral); + + if (triangle != null) + return new NullableShape(triangle); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs index 06bd026938f..6f413c0fca2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// NumberOnly /// - [DataContract(Name = "NumberOnly")] public partial class NumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// justNumber. + /// justNumber public NumberOnly(decimal? justNumber = default) { - this.JustNumber = justNumber; - this.AdditionalProperties = new Dictionary(); + JustNumber = justNumber; } /// /// Gets or Sets JustNumber /// - [DataMember(Name = "JustNumber", EmitDefaultValue = false)] + [JsonPropertyName("JustNumber")] public decimal? JustNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,21 +66,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as NumberOnly).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of NumberOnly to be compared /// Boolean - public bool Equals(NumberOnly input) + public bool Equals(NumberOnly? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index ff627589004..bcaaa473035 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,49 +29,47 @@ namespace Org.OpenAPITools.Model /// /// ObjectWithDeprecatedFields /// - [DataContract(Name = "ObjectWithDeprecatedFields")] public partial class ObjectWithDeprecatedFields : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// uuid. - /// id. - /// deprecatedRef. - /// bars. + /// uuid + /// id + /// deprecatedRef + /// bars public ObjectWithDeprecatedFields(string? uuid = default, decimal? id = default, DeprecatedObject? deprecatedRef = default, List? bars = default) { - this.Uuid = uuid; - this.Id = id; - this.DeprecatedRef = deprecatedRef; - this.Bars = bars; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + Id = id; + DeprecatedRef = deprecatedRef; + Bars = bars; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public string? Uuid { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] [Obsolete] public decimal? Id { get; set; } /// /// Gets or Sets DeprecatedRef /// - [DataMember(Name = "deprecatedRef", EmitDefaultValue = false)] + [JsonPropertyName("deprecatedRef")] [Obsolete] public DeprecatedObject? DeprecatedRef { get; set; } /// /// Gets or Sets Bars /// - [DataMember(Name = "bars", EmitDefaultValue = false)] + [JsonPropertyName("bars")] [Obsolete] public List? Bars { get; set; } @@ -79,7 +77,7 @@ namespace Org.OpenAPITools.Model /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -98,21 +96,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ObjectWithDeprecatedFields).AreEqual; } @@ -122,7 +111,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ObjectWithDeprecatedFields to be compared /// Boolean - public bool Equals(ObjectWithDeprecatedFields input) + public bool Equals(ObjectWithDeprecatedFields? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs index cdc227e0564..2a02518b6e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,14 +29,31 @@ namespace Org.OpenAPITools.Model /// /// Order /// - [DataContract(Name = "Order")] public partial class Order : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// id + /// petId + /// quantity + /// shipDate + /// Order Status + /// complete (default to false) + public Order(long? id = default, long? petId = default, int? quantity = default, DateTime? shipDate = default, StatusEnum? status = default, bool? complete = false) + { + Id = id; + PetId = petId; + Quantity = quantity; + ShipDate = shipDate; + Status = status; + Complete = complete; + } + /// /// Order Status /// /// Order Status - [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { /// @@ -59,68 +76,48 @@ namespace Org.OpenAPITools.Model } - /// /// Order Status /// /// Order Status - [DataMember(Name = "status", EmitDefaultValue = false)] + [JsonPropertyName("status")] public StatusEnum? Status { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// petId. - /// quantity. - /// shipDate. - /// Order Status. - /// complete (default to false). - public Order(long? id = default, long? petId = default, int? quantity = default, DateTime? shipDate = default, StatusEnum? status = default, bool? complete = false) - { - this.Id = id; - this.PetId = petId; - this.Quantity = quantity; - this.ShipDate = shipDate; - this.Status = status; - this.Complete = complete; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long? Id { get; set; } /// /// Gets or Sets PetId /// - [DataMember(Name = "petId", EmitDefaultValue = false)] + [JsonPropertyName("petId")] public long? PetId { get; set; } /// /// Gets or Sets Quantity /// - [DataMember(Name = "quantity", EmitDefaultValue = false)] + [JsonPropertyName("quantity")] public int? Quantity { get; set; } /// /// Gets or Sets ShipDate /// - [DataMember(Name = "shipDate", EmitDefaultValue = false)] + [JsonPropertyName("shipDate")] public DateTime? ShipDate { get; set; } /// /// Gets or Sets Complete /// - [DataMember(Name = "complete", EmitDefaultValue = true)] + [JsonPropertyName("complete")] public bool? Complete { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -141,21 +138,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Order).AreEqual; } @@ -165,7 +153,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Order to be compared /// Boolean - public bool Equals(Order input) + public bool Equals(Order? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs index 0acf83c4c62..f4d199456b2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// OuterComposite /// - [DataContract(Name = "OuterComposite")] public partial class OuterComposite : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// myNumber. - /// myString. - /// myBoolean. + /// myNumber + /// myString + /// myBoolean public OuterComposite(decimal? myNumber = default, string? myString = default, bool? myBoolean = default) { - this.MyNumber = myNumber; - this.MyString = myString; - this.MyBoolean = myBoolean; - this.AdditionalProperties = new Dictionary(); + MyNumber = myNumber; + MyString = myString; + MyBoolean = myBoolean; } /// /// Gets or Sets MyNumber /// - [DataMember(Name = "my_number", EmitDefaultValue = false)] + [JsonPropertyName("my_number")] public decimal? MyNumber { get; set; } /// /// Gets or Sets MyString /// - [DataMember(Name = "my_string", EmitDefaultValue = false)] + [JsonPropertyName("my_string")] public string? MyString { get; set; } /// /// Gets or Sets MyBoolean /// - [DataMember(Name = "my_boolean", EmitDefaultValue = true)] + [JsonPropertyName("my_boolean")] public bool? MyBoolean { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,21 +84,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as OuterComposite).AreEqual; } @@ -110,7 +99,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of OuterComposite to be compared /// Boolean - public bool Equals(OuterComposite input) + public bool Equals(OuterComposite? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs index 2aa496a2e07..8a82c640206 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines OuterEnum /// - [JsonConverter(typeof(StringEnumConverter))] public enum OuterEnum { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Delivered = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index dd79c7010d6..edee8308283 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines OuterEnumDefaultValue /// - [JsonConverter(typeof(StringEnumConverter))] public enum OuterEnumDefaultValue { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Delivered = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index 44dc91c700a..b1e9dc142e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -47,5 +47,4 @@ namespace Org.OpenAPITools.Model NUMBER_2 = 2 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index b927507cf97..1167271da6e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -47,5 +47,4 @@ namespace Org.OpenAPITools.Model NUMBER_2 = 2 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs index ac986b555ef..2f3aeeda770 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ParentPet.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,33 +29,15 @@ namespace Org.OpenAPITools.Model /// /// ParentPet /// - [DataContract(Name = "ParentPet")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] - public partial class ParentPet : GrandparentAnimal, IEquatable, IValidatableObject + public partial class ParentPet : GrandparentAnimal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ParentPet() + /// petType (required) + public ParentPet(string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); } - /// - /// Initializes a new instance of the class. - /// - /// petType (required) (default to "ParentPet"). - public ParentPet(string petType = "ParentPet") : base(petType) - { - this.AdditionalProperties = new Dictionary(); - } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } /// /// Returns the string presentation of the object @@ -67,26 +48,16 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class ParentPet {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ParentPet).AreEqual; } @@ -96,7 +67,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ParentPet to be compared /// Boolean - public bool Equals(ParentPet input) + public bool Equals(ParentPet? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -110,37 +81,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs index f94869df280..4d7a7561ce3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,14 +29,35 @@ namespace Org.OpenAPITools.Model /// /// Pet /// - [DataContract(Name = "Pet")] public partial class Pet : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// name (required) + /// photoUrls (required) + /// id + /// category + /// tags + /// pet status in the store + public Pet(string name, List photoUrls, long? id = default, Category? category = default, List? tags = default, StatusEnum? status = default) + { + if (name == null) + throw new ArgumentNullException("name is a required property for Pet and cannot be null."); + if (photoUrls == null) + throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null."); + Name = name; + PhotoUrls = photoUrls; + Id = id; + Category = category; + Tags = tags; + Status = status; + } + /// /// pet status in the store /// /// pet status in the store - [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { /// @@ -59,84 +80,48 @@ namespace Org.OpenAPITools.Model } - /// /// pet status in the store /// /// pet status in the store - [DataMember(Name = "status", EmitDefaultValue = false)] + [JsonPropertyName("status")] public StatusEnum? Status { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected Pet() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required). - /// photoUrls (required). - /// id. - /// category. - /// tags. - /// pet status in the store. - public Pet(string name, List photoUrls, long? id = default, Category? category = default, List? tags = default, StatusEnum? status = default) - { - // to ensure "name" is required (not null) - if (name == null) { - throw new ArgumentNullException("name is a required property for Pet and cannot be null"); - } - this.Name = name; - // to ensure "photoUrls" is required (not null) - if (photoUrls == null) { - throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null"); - } - this.PhotoUrls = photoUrls; - this.Id = id; - this.Category = category; - this.Tags = tags; - this.Status = status; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Name /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets PhotoUrls /// - [DataMember(Name = "photoUrls", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long? Id { get; set; } /// /// Gets or Sets Category /// - [DataMember(Name = "category", EmitDefaultValue = false)] + [JsonPropertyName("category")] public Category? Category { get; set; } /// /// Gets or Sets Tags /// - [DataMember(Name = "tags", EmitDefaultValue = false)] + [JsonPropertyName("tags")] public List? Tags { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -157,21 +142,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Pet).AreEqual; } @@ -181,7 +157,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Pet to be compared /// Boolean - public bool Equals(Pet input) + public bool Equals(Pet? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs index b82c0899c27..35b4df7d509 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,96 +19,51 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Pig /// - [JsonConverter(typeof(PigJsonConverter))] - [DataContract(Name = "Pig")] - public partial class Pig : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Pig : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of BasquePig. - public Pig(BasquePig actualInstance) + /// basquePig + public Pig(BasquePig? basquePig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + BasquePig = basquePig; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of DanishPig. - public Pig(DanishPig actualInstance) + /// danishPig + public Pig(DanishPig? danishPig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(BasquePig)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(DanishPig)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: BasquePig, DanishPig"); - } - } + DanishPig = danishPig; } /// - /// Get the actual instance of `BasquePig`. If the actual instance is not `BasquePig`, - /// the InvalidClassException will be thrown + /// Gets or Sets Pig /// - /// An instance of BasquePig - public BasquePig GetBasquePig() - { - return (BasquePig)this.ActualInstance; - } + public BasquePig? BasquePig { get; set; } /// - /// Get the actual instance of `DanishPig`. If the actual instance is not `DanishPig`, - /// the InvalidClassException will be thrown + /// Gets or Sets Pig /// - /// An instance of DanishPig - public DanishPig GetDanishPig() - { - return (DanishPig)this.ActualInstance; - } + public DanishPig? DanishPig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,97 +71,19 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Pig.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Pig - /// - /// JSON string - /// An instance of Pig - public static Pig FromJson(string jsonString) - { - Pig newPig = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newPig; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(BasquePig).GetProperty("AdditionalProperties") == null) - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.SerializerSettings)); - } - else - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("BasquePig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into BasquePig: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(DanishPig).GetProperty("AdditionalProperties") == null) - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.SerializerSettings)); - } - else - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("DanishPig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into DanishPig: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newPig; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Pig).AreEqual; } @@ -214,7 +93,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Pig to be compared /// Boolean - public bool Equals(Pig input) + public bool Equals(Pig? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -228,8 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +120,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Pig + /// A Json converter for type Pig /// - public class PigJsonConverter : JsonConverter + public class PigJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Pig).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Pig).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Pig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader basquePigReader = reader; + Client.ClientUtils.TryDeserialize(ref basquePigReader, options, out BasquePig? basquePig); + + Utf8JsonReader danishPigReader = reader; + Client.ClientUtils.TryDeserialize(ref danishPigReader, options, out DanishPig? danishPig); + + + while (reader.Read()) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (basquePig != null) + return new Pig(basquePig); + + if (danishPig != null) + return new Pig(danishPig); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs index a1a850f169e..9c01fdc0d1f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,96 +19,51 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Quadrilateral /// - [JsonConverter(typeof(QuadrilateralJsonConverter))] - [DataContract(Name = "Quadrilateral")] - public partial class Quadrilateral : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Quadrilateral : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of ComplexQuadrilateral. - public Quadrilateral(ComplexQuadrilateral actualInstance) + /// complexQuadrilateral + public Quadrilateral(ComplexQuadrilateral? complexQuadrilateral) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + ComplexQuadrilateral = complexQuadrilateral; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of SimpleQuadrilateral. - public Quadrilateral(SimpleQuadrilateral actualInstance) + /// simpleQuadrilateral + public Quadrilateral(SimpleQuadrilateral? simpleQuadrilateral) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(ComplexQuadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(SimpleQuadrilateral)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: ComplexQuadrilateral, SimpleQuadrilateral"); - } - } + SimpleQuadrilateral = simpleQuadrilateral; } /// - /// Get the actual instance of `ComplexQuadrilateral`. If the actual instance is not `ComplexQuadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Quadrilateral /// - /// An instance of ComplexQuadrilateral - public ComplexQuadrilateral GetComplexQuadrilateral() - { - return (ComplexQuadrilateral)this.ActualInstance; - } + public ComplexQuadrilateral? ComplexQuadrilateral { get; set; } /// - /// Get the actual instance of `SimpleQuadrilateral`. If the actual instance is not `SimpleQuadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Quadrilateral /// - /// An instance of SimpleQuadrilateral - public SimpleQuadrilateral GetSimpleQuadrilateral() - { - return (SimpleQuadrilateral)this.ActualInstance; - } + public SimpleQuadrilateral? SimpleQuadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,97 +71,19 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Quadrilateral.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Quadrilateral - /// - /// JSON string - /// An instance of Quadrilateral - public static Quadrilateral FromJson(string jsonString) - { - Quadrilateral newQuadrilateral = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newQuadrilateral; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(ComplexQuadrilateral).GetProperty("AdditionalProperties") == null) - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.SerializerSettings)); - } - else - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("ComplexQuadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into ComplexQuadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(SimpleQuadrilateral).GetProperty("AdditionalProperties") == null) - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.SerializerSettings)); - } - else - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("SimpleQuadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into SimpleQuadrilateral: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newQuadrilateral; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Quadrilateral).AreEqual; } @@ -214,7 +93,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Quadrilateral to be compared /// Boolean - public bool Equals(Quadrilateral input) + public bool Equals(Quadrilateral? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -228,8 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +120,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Quadrilateral + /// A Json converter for type Quadrilateral /// - public class QuadrilateralJsonConverter : JsonConverter + public class QuadrilateralJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Quadrilateral).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Quadrilateral).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Quadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader complexQuadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref complexQuadrilateralReader, options, out ComplexQuadrilateral? complexQuadrilateral); + + Utf8JsonReader simpleQuadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref simpleQuadrilateralReader, options, out SimpleQuadrilateral? simpleQuadrilateral); + + + while (reader.Read()) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (complexQuadrilateral != null) + return new Quadrilateral(complexQuadrilateral); + + if (simpleQuadrilateral != null) + return new Quadrilateral(simpleQuadrilateral); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index b29e2db36b6..bc36222384f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// QuadrilateralInterface /// - [DataContract(Name = "QuadrilateralInterface")] public partial class QuadrilateralInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected QuadrilateralInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// quadrilateralType (required). + /// quadrilateralType (required) public QuadrilateralInterface(string quadrilateralType) { - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null."); + QuadrilateralType = quadrilateralType; } /// /// Gets or Sets QuadrilateralType /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("quadrilateralType")] public string QuadrilateralType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,21 +68,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as QuadrilateralInterface).AreEqual; } @@ -104,7 +83,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of QuadrilateralInterface to be compared /// Boolean - public bool Equals(QuadrilateralInterface input) + public bool Equals(QuadrilateralInterface? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index c668741b960..431c19694ab 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,44 +29,36 @@ namespace Org.OpenAPITools.Model /// /// ReadOnlyFirst /// - [DataContract(Name = "ReadOnlyFirst")] public partial class ReadOnlyFirst : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// baz. - public ReadOnlyFirst(string? baz = default) + /// bar + /// baz + public ReadOnlyFirst(string? bar = default, string? baz = default) { - this.Baz = baz; - this.AdditionalProperties = new Dictionary(); + Bar = bar; + Baz = baz; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string? Bar { get; private set; } - /// - /// Returns false as Bar should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBar() - { - return false; - } /// /// Gets or Sets Baz /// - [DataMember(Name = "baz", EmitDefaultValue = false)] + [JsonPropertyName("baz")] public string? Baz { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -83,21 +75,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ReadOnlyFirst).AreEqual; } @@ -107,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ReadOnlyFirst to be compared /// Boolean - public bool Equals(ReadOnlyFirst input) + public bool Equals(ReadOnlyFirst? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs index 4b6b8710a1d..9c1b60d8791 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Return.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Model for testing reserved words /// - [DataContract(Name = "Return")] public partial class Return : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _return. - public Return(int? _return = default) + /// returnProperty + public Return(int? returnProperty = default) { - this._Return = _return; - this.AdditionalProperties = new Dictionary(); + ReturnProperty = returnProperty; } /// - /// Gets or Sets _Return + /// Gets or Sets ReturnProperty /// - [DataMember(Name = "return", EmitDefaultValue = false)] - public int? _Return { get; set; } + [JsonPropertyName("return")] + public int? ReturnProperty { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -62,27 +60,18 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Return {\n"); - sb.Append(" _Return: ").Append(_Return).Append("\n"); + sb.Append(" ReturnProperty: ").Append(ReturnProperty).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Return).AreEqual; } @@ -92,7 +81,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Return to be compared /// Boolean - public bool Equals(Return input) + public bool Equals(Return? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -106,7 +95,7 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this._Return.GetHashCode(); + hashCode = (hashCode * 59) + this.ReturnProperty.GetHashCode(); if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 206e0fbe331..5cd53033396 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// ScaleneTriangle /// - [DataContract(Name = "ScaleneTriangle")] public partial class ScaleneTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ScaleneTriangle() + /// shapeInterface + /// triangleInterface + public ScaleneTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public ScaleneTriangle(string shapeType, string triangleType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ScaleneTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for ScaleneTriangle and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets ScaleneTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface? ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets ScaleneTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface? TriangleInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,28 +66,17 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class ScaleneTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ScaleneTriangle).AreEqual; } @@ -117,7 +86,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ScaleneTriangle to be compared /// Boolean - public bool Equals(ScaleneTriangle input) + public bool Equals(ScaleneTriangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type ScaleneTriangle + /// + public class ScaleneTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ScaleneTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ScaleneTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface? shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface? triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new ScaleneTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs index dd74fa4b718..7e9dcf8cea9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Shape.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,96 +19,65 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Shape /// - [JsonConverter(typeof(ShapeJsonConverter))] - [DataContract(Name = "Shape")] - public partial class Shape : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Shape : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public Shape(Quadrilateral actualInstance) + /// quadrilateral + /// quadrilateralType (required) + public Shape(Quadrilateral? quadrilateral, string quadrilateralType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for Shape and cannot be null."); + Quadrilateral = quadrilateral; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Triangle. - public Shape(Triangle actualInstance) + /// triangle + /// quadrilateralType (required) + public Shape(Triangle? triangle, string quadrilateralType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for Shape and cannot be null."); + Triangle = triangle; + QuadrilateralType = quadrilateralType; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Shape /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } + public Quadrilateral? Quadrilateral { get; set; } /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Shape /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + public Triangle? Triangle { get; set; } + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,97 +85,20 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Shape.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Shape - /// - /// JSON string - /// An instance of Shape - public static Shape FromJson(string jsonString) - { - Shape newShape = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newShape; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.SerializerSettings)); - } - else - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.SerializerSettings)); - } - else - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newShape; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Shape).AreEqual; } @@ -214,7 +108,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Shape to be compared /// Boolean - public bool Equals(Shape input) + public bool Equals(Shape? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -228,8 +122,14 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.QuadrilateralType != null) + { + hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +139,92 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Shape + /// A Json converter for type Shape /// - public class ShapeJsonConverter : JsonConverter + public class ShapeJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Shape).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Shape).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Shape Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral? quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle? triangle); + + string? quadrilateralType = default; + + while (reader.Read()) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "quadrilateralType": + quadrilateralType = reader.GetString(); + break; + } + } } - return null; + + if (quadrilateral != null) + return new Shape(quadrilateral, quadrilateralType); + + if (triangle != null) + return new Shape(triangle, quadrilateralType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs index 55788e33f35..8e3075f6fa4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// ShapeInterface /// - [DataContract(Name = "ShapeInterface")] public partial class ShapeInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ShapeInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). + /// shapeType (required) public ShapeInterface(string shapeType) { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null"); - } - this.ShapeType = shapeType; - this.AdditionalProperties = new Dictionary(); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null."); + ShapeType = shapeType; } /// /// Gets or Sets ShapeType /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("shapeType")] public string ShapeType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,21 +68,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ShapeInterface).AreEqual; } @@ -104,7 +83,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ShapeInterface to be compared /// Boolean - public bool Equals(ShapeInterface input) + public bool Equals(ShapeInterface? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs index c6b87c89751..47284e7ab47 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,105 +19,67 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - [JsonConverter(typeof(ShapeOrNullJsonConverter))] - [DataContract(Name = "ShapeOrNull")] - public partial class ShapeOrNull : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class ShapeOrNull : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public ShapeOrNull() + /// quadrilateral + /// quadrilateralType (required) + public ShapeOrNull(Quadrilateral? quadrilateral, string quadrilateralType) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for ShapeOrNull and cannot be null."); + Quadrilateral = quadrilateral; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public ShapeOrNull(Quadrilateral actualInstance) + /// triangle + /// quadrilateralType (required) + public ShapeOrNull(Triangle? triangle, string quadrilateralType) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for ShapeOrNull and cannot be null."); + Triangle = triangle; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - /// An instance of Triangle. - public ShapeOrNull(Triangle actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + public Quadrilateral? Quadrilateral { get; set; } /// - /// Gets or Sets ActualInstance + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } - } + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + public Triangle? Triangle { get; set; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets QuadrilateralType /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets additional properties /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -123,97 +87,20 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, ShapeOrNull.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of ShapeOrNull - /// - /// JSON string - /// An instance of ShapeOrNull - public static ShapeOrNull FromJson(string jsonString) - { - ShapeOrNull newShapeOrNull = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newShapeOrNull; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.SerializerSettings)); - } - else - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.SerializerSettings)); - } - else - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newShapeOrNull; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as ShapeOrNull).AreEqual; } @@ -223,7 +110,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of ShapeOrNull to be compared /// Boolean - public bool Equals(ShapeOrNull input) + public bool Equals(ShapeOrNull? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -237,8 +124,14 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.QuadrilateralType != null) + { + hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -248,54 +141,92 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for ShapeOrNull + /// A Json converter for type ShapeOrNull /// - public class ShapeOrNullJsonConverter : JsonConverter + public class ShapeOrNullJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(ShapeOrNull).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ShapeOrNull).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override ShapeOrNull Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral? quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle? triangle); + + string? quadrilateralType = default; + + while (reader.Read()) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "quadrilateralType": + quadrilateralType = reader.GetString(); + break; + } + } } - return null; + + if (quadrilateral != null) + return new ShapeOrNull(quadrilateral, quadrilateralType); + + if (triangle != null) + return new ShapeOrNull(triangle, quadrilateralType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 1398011e13f..dd9c577e2e9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// SimpleQuadrilateral /// - [DataContract(Name = "SimpleQuadrilateral")] public partial class SimpleQuadrilateral : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected SimpleQuadrilateral() + /// quadrilateralInterface + /// shapeInterface + public SimpleQuadrilateral(QuadrilateralInterface quadrilateralInterface, ShapeInterface shapeInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// quadrilateralType (required). - public SimpleQuadrilateral(string shapeType, string quadrilateralType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for SimpleQuadrilateral and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for SimpleQuadrilateral and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + QuadrilateralInterface = quadrilateralInterface; + ShapeInterface = shapeInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets SimpleQuadrilateral /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public QuadrilateralInterface? QuadrilateralInterface { get; set; } /// - /// Gets or Sets QuadrilateralType + /// Gets or Sets SimpleQuadrilateral /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] - public string QuadrilateralType { get; set; } + public ShapeInterface? ShapeInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,28 +66,17 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class SimpleQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as SimpleQuadrilateral).AreEqual; } @@ -117,7 +86,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of SimpleQuadrilateral to be compared /// Boolean - public bool Equals(SimpleQuadrilateral input) + public bool Equals(SimpleQuadrilateral? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.QuadrilateralType != null) - { - hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type SimpleQuadrilateral + /// + public class SimpleQuadrilateralJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(SimpleQuadrilateral).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override SimpleQuadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralInterfaceReader, options, out QuadrilateralInterface? quadrilateralInterface); + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface? shapeInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new SimpleQuadrilateral(quadrilateralInterface, shapeInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs index 64d0866fbf0..6d7d21215bc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// SpecialModelName /// - [DataContract(Name = "_special_model.name_")] public partial class SpecialModelName : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// specialPropertyName. - /// specialModelName. - public SpecialModelName(long? specialPropertyName = default, string? specialModelName = default) + /// specialPropertyName + /// specialModelNameProperty + public SpecialModelName(long? specialPropertyName = default, string? specialModelNameProperty = default) { - this.SpecialPropertyName = specialPropertyName; - this._SpecialModelName = specialModelName; - this.AdditionalProperties = new Dictionary(); + SpecialPropertyName = specialPropertyName; + SpecialModelNameProperty = specialModelNameProperty; } /// /// Gets or Sets SpecialPropertyName /// - [DataMember(Name = "$special[property.name]", EmitDefaultValue = false)] + [JsonPropertyName("$special[property.name]")] public long? SpecialPropertyName { get; set; } /// - /// Gets or Sets _SpecialModelName + /// Gets or Sets SpecialModelNameProperty /// - [DataMember(Name = "_special_model.name_", EmitDefaultValue = false)] - public string? _SpecialModelName { get; set; } + [JsonPropertyName("_special_model.name_")] + public string? SpecialModelNameProperty { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -71,27 +69,18 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class SpecialModelName {\n"); sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); - sb.Append(" _SpecialModelName: ").Append(_SpecialModelName).Append("\n"); + sb.Append(" SpecialModelNameProperty: ").Append(SpecialModelNameProperty).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as SpecialModelName).AreEqual; } @@ -101,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of SpecialModelName to be compared /// Boolean - public bool Equals(SpecialModelName input) + public bool Equals(SpecialModelName? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -116,9 +105,9 @@ namespace Org.OpenAPITools.Model { int hashCode = 41; hashCode = (hashCode * 59) + this.SpecialPropertyName.GetHashCode(); - if (this._SpecialModelName != null) + if (this.SpecialModelNameProperty != null) { - hashCode = (hashCode * 59) + this._SpecialModelName.GetHashCode(); + hashCode = (hashCode * 59) + this.SpecialModelNameProperty.GetHashCode(); } if (this.AdditionalProperties != null) { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs index 09b8204eb38..69236717eb8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Tag.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Tag /// - [DataContract(Name = "Tag")] public partial class Tag : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// id. - /// name. + /// id + /// name public Tag(long? id = default, string? name = default) { - this.Id = id; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Id = id; + Name = name; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long? Id { get; set; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string? Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,21 +75,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Tag).AreEqual; } @@ -101,7 +90,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Tag to be compared /// Boolean - public bool Equals(Tag input) + public bool Equals(Tag? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs index c8cf49ef7f6..d2560007df2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Triangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,122 +19,101 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Triangle /// - [JsonConverter(typeof(TriangleJsonConverter))] - [DataContract(Name = "Triangle")] - public partial class Triangle : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Triangle : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of EquilateralTriangle. - public Triangle(EquilateralTriangle actualInstance) + /// equilateralTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(EquilateralTriangle? equilateralTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + EquilateralTriangle = equilateralTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of IsoscelesTriangle. - public Triangle(IsoscelesTriangle actualInstance) + /// isoscelesTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(IsoscelesTriangle? isoscelesTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + IsoscelesTriangle = isoscelesTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of ScaleneTriangle. - public Triangle(ScaleneTriangle actualInstance) + /// scaleneTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(ScaleneTriangle? scaleneTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(EquilateralTriangle)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(IsoscelesTriangle)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(ScaleneTriangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: EquilateralTriangle, IsoscelesTriangle, ScaleneTriangle"); - } - } + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + ScaleneTriangle = scaleneTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Get the actual instance of `EquilateralTriangle`. If the actual instance is not `EquilateralTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of EquilateralTriangle - public EquilateralTriangle GetEquilateralTriangle() - { - return (EquilateralTriangle)this.ActualInstance; - } + public EquilateralTriangle? EquilateralTriangle { get; set; } /// - /// Get the actual instance of `IsoscelesTriangle`. If the actual instance is not `IsoscelesTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of IsoscelesTriangle - public IsoscelesTriangle GetIsoscelesTriangle() - { - return (IsoscelesTriangle)this.ActualInstance; - } + public IsoscelesTriangle? IsoscelesTriangle { get; set; } /// - /// Get the actual instance of `ScaleneTriangle`. If the actual instance is not `ScaleneTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of ScaleneTriangle - public ScaleneTriangle GetScaleneTriangle() - { - return (ScaleneTriangle)this.ActualInstance; - } + public ScaleneTriangle? ScaleneTriangle { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -140,117 +121,21 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Triangle.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Triangle - /// - /// JSON string - /// An instance of Triangle - public static Triangle FromJson(string jsonString) - { - Triangle newTriangle = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newTriangle; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(EquilateralTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("EquilateralTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into EquilateralTriangle: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(IsoscelesTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("IsoscelesTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into IsoscelesTriangle: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(ScaleneTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("ScaleneTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into ScaleneTriangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newTriangle; - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Triangle).AreEqual; } @@ -260,7 +145,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Triangle to be compared /// Boolean - public bool Equals(Triangle input) + public bool Equals(Triangle? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -274,8 +159,18 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.ShapeType != null) + { + hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); + } + if (this.TriangleType != null) + { + hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -285,54 +180,102 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Triangle + /// A Json converter for type Triangle /// - public class TriangleJsonConverter : JsonConverter + public class TriangleJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Triangle).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Triangle).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Triangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader equilateralTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref equilateralTriangleReader, options, out EquilateralTriangle? equilateralTriangle); + + Utf8JsonReader isoscelesTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref isoscelesTriangleReader, options, out IsoscelesTriangle? isoscelesTriangle); + + Utf8JsonReader scaleneTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref scaleneTriangleReader, options, out ScaleneTriangle? scaleneTriangle); + + string? shapeType = default; + string? triangleType = default; + + while (reader.Read()) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string? propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "shapeType": + shapeType = reader.GetString(); + break; + case "triangleType": + triangleType = reader.GetString(); + break; + } + } } - return null; + + if (equilateralTriangle != null) + return new Triangle(equilateralTriangle, shapeType, triangleType); + + if (isoscelesTriangle != null) + return new Triangle(isoscelesTriangle, shapeType, triangleType); + + if (scaleneTriangle != null) + return new Triangle(scaleneTriangle, shapeType, triangleType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs index 8c62abd8c65..5c7344ac86a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// TriangleInterface /// - [DataContract(Name = "TriangleInterface")] public partial class TriangleInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected TriangleInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// triangleType (required). + /// triangleType (required) public TriangleInterface(string triangleType) { - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null."); + TriangleType = triangleType; } /// /// Gets or Sets TriangleType /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("triangleType")] public string TriangleType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,21 +68,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as TriangleInterface).AreEqual; } @@ -104,7 +83,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of TriangleInterface to be compared /// Boolean - public bool Equals(TriangleInterface input) + public bool Equals(TriangleInterface? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs index cc444862643..1cf4f172eca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/User.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,123 +29,121 @@ namespace Org.OpenAPITools.Model /// /// User /// - [DataContract(Name = "User")] public partial class User : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// id. - /// username. - /// firstName. - /// lastName. - /// email. - /// password. - /// phone. - /// User Status. - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value.. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.. - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389. - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values.. + /// id + /// username + /// firstName + /// lastName + /// email + /// password + /// phone + /// User Status + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. public User(long? id = default, string? username = default, string? firstName = default, string? lastName = default, string? email = default, string? password = default, string? phone = default, int? userStatus = default, Object? objectWithNoDeclaredProps = default, Object? objectWithNoDeclaredPropsNullable = default, Object? anyTypeProp = default, Object? anyTypePropNullable = default) { - this.Id = id; - this.Username = username; - this.FirstName = firstName; - this.LastName = lastName; - this.Email = email; - this.Password = password; - this.Phone = phone; - this.UserStatus = userStatus; - this.ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - this.ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; - this.AnyTypeProp = anyTypeProp; - this.AnyTypePropNullable = anyTypePropNullable; - this.AdditionalProperties = new Dictionary(); + Id = id; + Username = username; + FirstName = firstName; + LastName = lastName; + Email = email; + Password = password; + Phone = phone; + UserStatus = userStatus; + ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypeProp = anyTypeProp; + AnyTypePropNullable = anyTypePropNullable; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long? Id { get; set; } /// /// Gets or Sets Username /// - [DataMember(Name = "username", EmitDefaultValue = false)] + [JsonPropertyName("username")] public string? Username { get; set; } /// /// Gets or Sets FirstName /// - [DataMember(Name = "firstName", EmitDefaultValue = false)] + [JsonPropertyName("firstName")] public string? FirstName { get; set; } /// /// Gets or Sets LastName /// - [DataMember(Name = "lastName", EmitDefaultValue = false)] + [JsonPropertyName("lastName")] public string? LastName { get; set; } /// /// Gets or Sets Email /// - [DataMember(Name = "email", EmitDefaultValue = false)] + [JsonPropertyName("email")] public string? Email { get; set; } /// /// Gets or Sets Password /// - [DataMember(Name = "password", EmitDefaultValue = false)] + [JsonPropertyName("password")] public string? Password { get; set; } /// /// Gets or Sets Phone /// - [DataMember(Name = "phone", EmitDefaultValue = false)] + [JsonPropertyName("phone")] public string? Phone { get; set; } /// /// User Status /// /// User Status - [DataMember(Name = "userStatus", EmitDefaultValue = false)] + [JsonPropertyName("userStatus")] public int? UserStatus { get; set; } /// /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. /// /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [DataMember(Name = "objectWithNoDeclaredProps", EmitDefaultValue = false)] + [JsonPropertyName("objectWithNoDeclaredProps")] public Object? ObjectWithNoDeclaredProps { get; set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. - [DataMember(Name = "objectWithNoDeclaredPropsNullable", EmitDefaultValue = true)] + [JsonPropertyName("objectWithNoDeclaredPropsNullable")] public Object? ObjectWithNoDeclaredPropsNullable { get; set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - [DataMember(Name = "anyTypeProp", EmitDefaultValue = true)] + [JsonPropertyName("anyTypeProp")] public Object? AnyTypeProp { get; set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - [DataMember(Name = "anyTypePropNullable", EmitDefaultValue = true)] + [JsonPropertyName("anyTypePropNullable")] public Object? AnyTypePropNullable { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -172,21 +170,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as User).AreEqual; } @@ -196,7 +185,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of User to be compared /// Boolean - public bool Equals(User input) + public bool Equals(User? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs index e13e3f2d012..7e2d6f341b4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Whale.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,58 +29,46 @@ namespace Org.OpenAPITools.Model /// /// Whale /// - [DataContract(Name = "whale")] public partial class Whale : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Whale() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// hasBaleen. - /// hasTeeth. + /// className (required) + /// hasBaleen + /// hasTeeth public Whale(string className, bool? hasBaleen = default, bool? hasTeeth = default) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Whale and cannot be null"); - } - this.ClassName = className; - this.HasBaleen = hasBaleen; - this.HasTeeth = hasTeeth; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for Whale and cannot be null."); + ClassName = className; + HasBaleen = hasBaleen; + HasTeeth = hasTeeth; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets HasBaleen /// - [DataMember(Name = "hasBaleen", EmitDefaultValue = true)] + [JsonPropertyName("hasBaleen")] public bool? HasBaleen { get; set; } /// /// Gets or Sets HasTeeth /// - [DataMember(Name = "hasTeeth", EmitDefaultValue = true)] + [JsonPropertyName("hasTeeth")] public bool? HasTeeth { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -98,21 +86,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Whale).AreEqual; } @@ -122,7 +101,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Whale to be compared /// Boolean - public bool Equals(Whale input) + public bool Equals(Whale? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs index 0d4c8c67130..b4f1583fde4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -7,6 +8,7 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +#nullable enable using System; using System.Collections; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,24 @@ namespace Org.OpenAPITools.Model /// /// Zebra /// - [DataContract(Name = "zebra")] public partial class Zebra : Dictionary, IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// className (required) + /// type + public Zebra(string className, TypeEnum? type = default) + { + if (className == null) + throw new ArgumentNullException("className is a required property for Zebra and cannot be null."); + ClassName = className; + Type = type; + } + /// /// Defines Type /// - [JsonConverter(typeof(StringEnumConverter))] public enum TypeEnum { /// @@ -58,47 +69,23 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets Type /// - [DataMember(Name = "type", EmitDefaultValue = false)] + [JsonPropertyName("type")] public TypeEnum? Type { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected Zebra() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// type. - public Zebra(string className, TypeEnum? type = default) : base() - { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Zebra and cannot be null"); - } - this.ClassName = className; - this.Type = type; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -116,21 +103,12 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// /// Object to be compared /// Boolean - public override bool Equals(object input) + public override bool Equals(object? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input as Zebra).AreEqual; } @@ -140,7 +118,7 @@ namespace Org.OpenAPITools.Model /// /// Instance of Zebra to be compared /// Boolean - public bool Equals(Zebra input) + public bool Equals(Zebra? input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 3ad77f5f5e8..1531b2ee02b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -22,8 +22,6 @@ - - diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES index 2f141a0eb47..2a9214cd14b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES @@ -108,12 +108,11 @@ src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs src/Org.OpenAPITools/Client/IApi.cs src/Org.OpenAPITools/Client/OAuthToken.cs -src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs +src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs src/Org.OpenAPITools/Client/RateLimitProvider`1.cs src/Org.OpenAPITools/Client/TokenBase.cs src/Org.OpenAPITools/Client/TokenContainer`1.cs src/Org.OpenAPITools/Client/TokenProvider`1.cs -src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs src/Org.OpenAPITools/Model/Animal.cs src/Org.OpenAPITools/Model/ApiResponse.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Cat.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Cat.md index 310a5e6575e..16db4a55bd3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Cat.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Cat.md @@ -6,7 +6,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | **Color** | **string** | | [optional] [default to "red"] -**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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md index 48a3c7fd38d..dae2ff76026 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**PetType** | **string** | | [default to PetTypeEnum.ChildCat] -**Name** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ComplexQuadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ComplexQuadrilateral.md index 14da4bba22e..0926bb55e71 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ComplexQuadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ComplexQuadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Dog.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Dog.md index 70cdc80e83e..b1e39dcf07c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Dog.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Dog.md @@ -6,7 +6,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | **Color** | **string** | | [optional] [default to "red"] -**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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/EquilateralTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/EquilateralTriangle.md index 8360b5c16a5..ddc9885fe56 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/EquilateralTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/EquilateralTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Fruit.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Fruit.md index cb095b74f32..b3bee18f7ba 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Fruit.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Fruit.md @@ -5,9 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Color** | **string** | | [optional] -**Cultivar** | **string** | | [optional] -**Origin** | **string** | | [optional] -**LengthCm** | **decimal** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/FruitReq.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/FruitReq.md index 5217febc9b6..38ab0c1a6ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/FruitReq.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/FruitReq.md @@ -4,10 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Cultivar** | **string** | | -**LengthCm** | **decimal** | | -**Mealy** | **bool** | | [optional] -**Sweet** | **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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/GmFruit.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/GmFruit.md index 049f6f5c157..584c4fd323d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/GmFruit.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/GmFruit.md @@ -5,9 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Color** | **string** | | [optional] -**Cultivar** | **string** | | [optional] -**Origin** | **string** | | [optional] -**LengthCm** | **decimal** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/IsoscelesTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/IsoscelesTriangle.md index 07c62ac9338..ed481ad1448 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/IsoscelesTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/IsoscelesTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Mammal.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Mammal.md index 82a8ca6027b..5546632e4d6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Mammal.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Mammal.md @@ -4,10 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ClassName** | **string** | | -**HasBaleen** | **bool** | | [optional] -**HasTeeth** | **bool** | | [optional] -**Type** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Name.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Name.md index 1fbf5dd5e8b..2ee782c0c54 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Name.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Name.md @@ -5,7 +5,7 @@ Model for testing model name same as property name Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Name** | **int** | | +**NameProperty** | **int** | | **SnakeCase** | **int** | | [optional] [readonly] **Property** | **string** | | [optional] **_123Number** | **int** | | [optional] [readonly] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/NullableShape.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/NullableShape.md index 570ef48f98f..0caa1aa5b9d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/NullableShape.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/NullableShape.md @@ -5,8 +5,6 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Pig.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Pig.md index fd7bb9359ac..83e58b6098d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Pig.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Pig.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ClassName** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Quadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Quadrilateral.md index bb7507997a2..4fd16b32ea5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Quadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Quadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Return.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Return.md index a1dadccc421..e11cdae8db9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Return.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Return.md @@ -5,7 +5,7 @@ Model for testing reserved words Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Return** | **int** | | [optional] +**ReturnProperty** | **int** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ScaleneTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ScaleneTriangle.md index d3f15354bcc..a01c2edc068 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ScaleneTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ScaleneTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Shape.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Shape.md index 5627c30bbfc..2ec279cef3c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Shape.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/Shape.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | **QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ShapeOrNull.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ShapeOrNull.md index a348f4f8bff..056fcbfdbdd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ShapeOrNull.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/ShapeOrNull.md @@ -5,7 +5,6 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema > Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | **QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SimpleQuadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SimpleQuadrilateral.md index a36c9957a60..3bc21009b7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SimpleQuadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SimpleQuadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SpecialModelName.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SpecialModelName.md index fa146367bde..662fa6f4a38 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SpecialModelName.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/SpecialModelName.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **SpecialPropertyName** | **long** | | [optional] -**_SpecialModelName** | **string** | | [optional] +**SpecialModelNameProperty** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CatTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CatTests.cs index 701ba760282..9c3c48ffefe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CatTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CatTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Declawed' - /// - [Fact] - public void DeclawedTest() - { - // TODO unit test for the property 'Declawed' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs index 6ce48e601e4..621877aa973 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Id' - /// - [Fact] - public void IdTest() - { - // TODO unit test for the property 'Id' - } /// /// Test the property 'Name' /// @@ -72,6 +64,14 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Name' } + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs index 68566fd8d56..0fe3ebfa06e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Name' - /// - [Fact] - public void NameTest() - { - // TODO unit test for the property 'Name' - } - /// - /// Test the property 'PetType' - /// - [Fact] - public void PetTypeTest() - { - // TODO unit test for the property 'PetType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs index b3529280c8d..6c50fe7aab5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DogTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DogTests.cs index 992f93a51fd..bf906f01bc6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DogTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DogTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Breed' - /// - [Fact] - public void BreedTest() - { - // TODO unit test for the property 'Breed' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs index 4f81b845d49..a22c39ca845 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'EnumString' - /// - [Fact] - public void EnumStringTest() - { - // TODO unit test for the property 'EnumString' - } /// /// Test the property 'EnumStringRequired' /// @@ -73,6 +65,14 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'EnumStringRequired' } /// + /// Test the property 'EnumString' + /// + [Fact] + public void EnumStringTest() + { + // TODO unit test for the property 'EnumString' + } + /// /// Test the property 'EnumInteger' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs index 4663cb667de..9ca755c4b07 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs index 97332800e9a..707847bbcd1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs @@ -56,6 +56,38 @@ namespace Org.OpenAPITools.Test.Model } + /// + /// Test the property 'Number' + /// + [Fact] + public void NumberTest() + { + // TODO unit test for the property 'Number' + } + /// + /// Test the property 'Byte' + /// + [Fact] + public void ByteTest() + { + // TODO unit test for the property 'Byte' + } + /// + /// Test the property 'Date' + /// + [Fact] + public void DateTest() + { + // TODO unit test for the property 'Date' + } + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } /// /// Test the property 'Integer' /// @@ -81,14 +113,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Int64' } /// - /// Test the property 'Number' - /// - [Fact] - public void NumberTest() - { - // TODO unit test for the property 'Number' - } - /// /// Test the property 'Float' /// [Fact] @@ -121,14 +145,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'String' } /// - /// Test the property 'Byte' - /// - [Fact] - public void ByteTest() - { - // TODO unit test for the property 'Byte' - } - /// /// Test the property 'Binary' /// [Fact] @@ -137,14 +153,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Binary' } /// - /// Test the property 'Date' - /// - [Fact] - public void DateTest() - { - // TODO unit test for the property 'Date' - } - /// /// Test the property 'DateTime' /// [Fact] @@ -161,14 +169,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Uuid' } /// - /// Test the property 'Password' - /// - [Fact] - public void PasswordTest() - { - // TODO unit test for the property 'Password' - } - /// /// Test the property 'PatternWithDigits' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs index 5ea9e3ffc1d..3a0b55b93e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs @@ -56,38 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Mealy' - /// - [Fact] - public void MealyTest() - { - // TODO unit test for the property 'Mealy' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } - /// - /// Test the property 'Sweet' - /// - [Fact] - public void SweetTest() - { - // TODO unit test for the property 'Sweet' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs index 91e069bb42f..ddc424d56ea 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -64,30 +64,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Color' } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Origin' - /// - [Fact] - public void OriginTest() - { - // TODO unit test for the property 'Origin' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs index 08fb0e07a1c..cbd35f9173c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs @@ -64,30 +64,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Color' } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Origin' - /// - [Fact] - public void OriginTest() - { - // TODO unit test for the property 'Origin' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs index 755c417cc54..8e0dae93420 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs index 7b46cbf0645..6477ab950fa 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs @@ -56,38 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'HasBaleen' - /// - [Fact] - public void HasBaleenTest() - { - // TODO unit test for the property 'HasBaleen' - } - /// - /// Test the property 'HasTeeth' - /// - [Fact] - public void HasTeethTest() - { - // TODO unit test for the property 'HasTeeth' - } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } - /// - /// Test the property 'Type' - /// - [Fact] - public void TypeTest() - { - // TODO unit test for the property 'Type' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs index 5662f91d6e6..8202ef63914 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PetTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PetTests.cs index 154e66f8dfc..28ea4d8478d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PetTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PetTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Id' - /// - [Fact] - public void IdTest() - { - // TODO unit test for the property 'Id' - } - /// - /// Test the property 'Category' - /// - [Fact] - public void CategoryTest() - { - // TODO unit test for the property 'Category' - } /// /// Test the property 'Name' /// @@ -89,6 +73,22 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'PhotoUrls' } /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Category' + /// + [Fact] + public void CategoryTest() + { + // TODO unit test for the property 'Category' + } + /// /// Test the property 'Tags' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PigTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PigTests.cs index 55cf2189046..a66befe8f58 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PigTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/PigTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs index 26826681a47..3d62673d093 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs index 04cb9f1ab6b..018dffb5964 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs index d0af114157c..ef564357648 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } /// /// Test the property 'QuadrilateralType' /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs index b01bd531f85..783a9657ed4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } /// /// Test the property 'QuadrilateralType' /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs index 6648e980928..3bcd65e792d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs index 09610791943..9b82c29c8fd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs @@ -56,6 +56,14 @@ namespace Org.OpenAPITools.Test.Model } + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } /// /// Test the property 'HasBaleen' /// @@ -72,14 +80,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'HasTeeth' } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs index f44e9213140..39e0561fe0f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Type' - /// - [Fact] - public void TypeTest() - { - // TODO unit test for the property 'Type' - } /// /// Test the property 'ClassName' /// @@ -72,6 +64,14 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'ClassName' } + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 04fbded6ac3..ae1b0ceb462 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -186,7 +186,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -208,7 +209,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Patch; + request.Method = HttpMethod.Patch; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -231,7 +232,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs index ca94212113b..ceb6b546707 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -182,7 +182,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -205,7 +205,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs index 23b051d8c53..ca6efa229c0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -578,7 +578,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -601,7 +601,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -654,7 +654,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -676,7 +677,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -699,7 +700,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -773,7 +774,8 @@ namespace Org.OpenAPITools.Api if ((outerComposite as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(outerComposite, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(outerComposite, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(outerComposite, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -795,7 +797,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -818,7 +820,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -871,7 +873,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -893,7 +896,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -916,7 +919,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -969,7 +972,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -991,7 +995,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1014,7 +1018,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1093,7 +1097,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1116,7 +1120,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1197,7 +1201,8 @@ namespace Org.OpenAPITools.Api if ((fileSchemaTestClass as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(fileSchemaTestClass, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(fileSchemaTestClass, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(fileSchemaTestClass, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1210,7 +1215,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1233,7 +1238,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1326,7 +1331,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1339,7 +1345,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1362,7 +1368,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1443,7 +1449,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1465,7 +1472,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Patch; + request.Method = HttpMethod.Patch; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1488,7 +1495,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1673,7 +1680,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1696,7 +1703,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1837,7 +1844,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1860,7 +1867,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1978,7 +1985,7 @@ namespace Org.OpenAPITools.Api bearerToken.UseInHeader(request, ""); - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2001,7 +2008,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -2085,7 +2092,8 @@ namespace Org.OpenAPITools.Api if ((requestBody as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(requestBody, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -2098,7 +2106,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2121,7 +2129,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2228,7 +2236,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2251,7 +2259,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2365,7 +2373,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2388,7 +2396,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 64db05ad389..3c3924ba796 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -188,7 +188,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -220,7 +221,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Patch; + request.Method = HttpMethod.Patch; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -243,7 +244,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs index fc205708a1d..5a393bd42d7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs @@ -392,7 +392,8 @@ namespace Org.OpenAPITools.Api if ((pet as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(pet, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -422,7 +423,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -445,7 +446,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -543,7 +544,7 @@ namespace Org.OpenAPITools.Api oauthToken.UseInHeader(request, ""); - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -566,7 +567,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -681,7 +682,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -704,7 +705,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -822,7 +823,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -845,7 +846,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -947,7 +948,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -970,7 +971,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1054,7 +1055,8 @@ namespace Org.OpenAPITools.Api if ((pet as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(pet, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -1084,7 +1086,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1107,7 +1109,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1228,7 +1230,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1251,7 +1253,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1378,7 +1380,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1401,7 +1403,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1530,7 +1532,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1553,7 +1555,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs index 2fbc676393c..f6e94590d74 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs @@ -256,7 +256,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -279,7 +279,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -346,7 +346,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -369,7 +369,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -460,7 +460,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -483,7 +483,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -564,7 +564,8 @@ namespace Org.OpenAPITools.Api if ((order as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(order, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(order, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(order, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -587,7 +588,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -610,7 +611,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs index 389c19c783e..daa70321606 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs @@ -356,7 +356,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -369,7 +370,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -392,7 +393,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -473,7 +474,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -486,7 +488,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -509,7 +511,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -590,7 +592,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -603,7 +606,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Post; + request.Method = HttpMethod.Post; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -626,7 +629,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -707,7 +710,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Delete; + request.Method = HttpMethod.Delete; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -730,7 +733,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -821,7 +824,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -844,7 +847,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -925,7 +928,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -948,7 +951,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1018,7 +1021,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = HttpMethod.Get; + request.Method = HttpMethod.Get; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1041,7 +1044,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1129,7 +1132,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1142,7 +1146,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = HttpMethod.Put; + request.Method = HttpMethod.Put; using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1165,7 +1169,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 04e92f7b19e..27048d5b162 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -13,7 +13,6 @@ using System; using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; namespace Org.OpenAPITools.Client { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs index 7a500bb0896..7ebffa84ef7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -52,21 +52,53 @@ namespace Org.OpenAPITools.Client public delegate void EventHandler(object sender, T e) where T : EventArgs; /// - /// Custom JSON serializer + /// Returns true when deserialization succeeds. /// - public static Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get; set; } = new Newtonsoft.Json.JsonSerializerSettings + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, System.Text.Json.JsonSerializerOptions options, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T result) { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore, - ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver + try { - NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } + result = System.Text.Json.JsonSerializer.Deserialize(json, options); + return result != null; } - }; + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T result) + { + try + { + result = System.Text.Json.JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Json serializer options + /// + public static System.Text.Json.JsonSerializerOptions JsonSerializerOptions { get; set; } = new System.Text.Json.JsonSerializerOptions(); /// /// Sanitize filename by removing the path diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs index 7581b399840..832ccef650e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Net.Http; using Microsoft.Extensions.DependencyInjection; using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; namespace Org.OpenAPITools.Client { @@ -89,6 +90,26 @@ namespace Org.OpenAPITools.Client public HostConfiguration AddApiHttpClients( Action client = null, Action builder = null) { + ClientUtils.JsonSerializerOptions.Converters.Add(new OpenAPIDateJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new CatJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ChildCatJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new DogJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new EquilateralTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new FruitJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new FruitReqJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new GmFruitJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new IsoscelesTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new MammalJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new NullableShapeJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new PigJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new QuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ScaleneTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ShapeJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ShapeOrNullJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new SimpleQuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new TriangleJsonConverter()); + AddApiHttpClients(client, builder); return this; @@ -99,9 +120,9 @@ namespace Org.OpenAPITools.Client /// /// /// - public HostConfiguration ConfigureJsonOptions(Action options) + public HostConfiguration ConfigureJsonOptions(Action options) { - options(Client.ClientUtils.JsonSerializerSettings); + options(Client.ClientUtils.JsonSerializerOptions); return this; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs deleted file mode 100644 index a5253e58201..00000000000 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs +++ /dev/null @@ -1,29 +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 Newtonsoft.Json.Converters; - -namespace Org.OpenAPITools.Client -{ - /// - /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 - /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types - /// - public class OpenAPIDateConverter : IsoDateTimeConverter - { - /// - /// Initializes a new instance of the class. - /// - public OpenAPIDateConverter() - { - // full-date = date-fullyear "-" date-month "-" date-mday - DateTimeFormat = "yyyy-MM-dd"; - } - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs new file mode 100644 index 00000000000..a280076c5a9 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class OpenAPIDateJsonConverter : JsonConverter + { + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + DateTime.ParseExact(reader.GetString(), "yyyy-MM-dd", CultureInfo.InvariantCulture); + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs deleted file mode 100644 index b3fc4c3c7a3..00000000000 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs +++ /dev/null @@ -1,76 +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 System; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace Org.OpenAPITools.Model -{ - /// - /// Abstract base class for oneOf, anyOf schemas in the OpenAPI specification - /// - public abstract partial class AbstractOpenAPISchema - { - /// - /// Custom JSON serializer - /// - static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Error, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Custom JSON serializer for objects with additional properties - /// - static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Ignore, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Gets or Sets the actual instance - /// - public abstract Object ActualInstance { get; set; } - - /// - /// Gets or Sets IsNullable to indicate whether the instance is nullable - /// - public bool IsNullable { get; protected set; } - - /// - /// Gets or Sets the schema type, which can be either `oneOf` or `anyOf` - /// - public string SchemaType { get; protected set; } - - /// - /// Converts the instance into JSON string. - /// - public abstract string ToJson(); - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 14d0e92eaa2..69ad870ae7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,87 +29,85 @@ namespace Org.OpenAPITools.Model /// /// AdditionalPropertiesClass /// - [DataContract(Name = "AdditionalPropertiesClass")] public partial class AdditionalPropertiesClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// mapProperty. - /// mapOfMapProperty. - /// anytype1. - /// mapWithUndeclaredPropertiesAnytype1. - /// mapWithUndeclaredPropertiesAnytype2. - /// mapWithUndeclaredPropertiesAnytype3. - /// an object with no declared properties and no undeclared properties, hence it's an empty map.. - /// mapWithUndeclaredPropertiesString. + /// mapProperty + /// mapOfMapProperty + /// anytype1 + /// mapWithUndeclaredPropertiesAnytype1 + /// mapWithUndeclaredPropertiesAnytype2 + /// mapWithUndeclaredPropertiesAnytype3 + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// mapWithUndeclaredPropertiesString public AdditionalPropertiesClass(Dictionary mapProperty = default, Dictionary> mapOfMapProperty = default, Object anytype1 = default, Object mapWithUndeclaredPropertiesAnytype1 = default, Object mapWithUndeclaredPropertiesAnytype2 = default, Dictionary mapWithUndeclaredPropertiesAnytype3 = default, Object emptyMap = default, Dictionary mapWithUndeclaredPropertiesString = default) { - this.MapProperty = mapProperty; - this.MapOfMapProperty = mapOfMapProperty; - this.Anytype1 = anytype1; - this.MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - this.MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - this.MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - this.EmptyMap = emptyMap; - this.MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - this.AdditionalProperties = new Dictionary(); + MapProperty = mapProperty; + MapOfMapProperty = mapOfMapProperty; + Anytype1 = anytype1; + MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; + EmptyMap = emptyMap; + MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; } /// /// Gets or Sets MapProperty /// - [DataMember(Name = "map_property", EmitDefaultValue = false)] + [JsonPropertyName("map_property")] public Dictionary MapProperty { get; set; } /// /// Gets or Sets MapOfMapProperty /// - [DataMember(Name = "map_of_map_property", EmitDefaultValue = false)] + [JsonPropertyName("map_of_map_property")] public Dictionary> MapOfMapProperty { get; set; } /// /// Gets or Sets Anytype1 /// - [DataMember(Name = "anytype_1", EmitDefaultValue = true)] + [JsonPropertyName("anytype_1")] public Object Anytype1 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_1", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] public Object MapWithUndeclaredPropertiesAnytype1 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_2", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] public Object MapWithUndeclaredPropertiesAnytype2 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_3", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] public Dictionary MapWithUndeclaredPropertiesAnytype3 { get; set; } /// /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [DataMember(Name = "empty_map", EmitDefaultValue = false)] + [JsonPropertyName("empty_map")] public Object EmptyMap { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesString /// - [DataMember(Name = "map_with_undeclared_properties_string", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_string")] public Dictionary MapWithUndeclaredPropertiesString { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -132,15 +130,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs index 73eef470406..38f3e74da92 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Animal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,54 +29,38 @@ namespace Org.OpenAPITools.Model /// /// Animal /// - [DataContract(Name = "Animal")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - [JsonSubtypes.KnownSubType(typeof(Cat), "Cat")] - [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] public partial class Animal : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Animal() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// color (default to "red"). + /// className (required) + /// color (default to "red") public Animal(string className, string color = "red") { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Animal and cannot be null"); - } - this.ClassName = className; - // use default value if no "color" provided - this.Color = color ?? "red"; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for Animal and cannot be null."); + ClassName = className; + Color = color; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets Color /// - [DataMember(Name = "color", EmitDefaultValue = false)] + [JsonPropertyName("color")] public string Color { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -94,15 +77,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs index e5fee65b6bc..5c60a85eda5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// ApiResponse /// - [DataContract(Name = "ApiResponse")] public partial class ApiResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// code. - /// type. - /// message. + /// code + /// type + /// message public ApiResponse(int code = default, string type = default, string message = default) { - this.Code = code; - this.Type = type; - this.Message = message; - this.AdditionalProperties = new Dictionary(); + Code = code; + Type = type; + Message = message; } /// /// Gets or Sets Code /// - [DataMember(Name = "code", EmitDefaultValue = false)] + [JsonPropertyName("code")] public int Code { get; set; } /// /// Gets or Sets Type /// - [DataMember(Name = "type", EmitDefaultValue = false)] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Gets or Sets Message /// - [DataMember(Name = "message", EmitDefaultValue = false)] + [JsonPropertyName("message")] public string Message { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs index adf8438c591..849a4274934 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Apple.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Apple /// - [DataContract(Name = "apple")] public partial class Apple : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// cultivar. - /// origin. + /// cultivar + /// origin public Apple(string cultivar = default, string origin = default) { - this.Cultivar = cultivar; - this.Origin = origin; - this.AdditionalProperties = new Dictionary(); + Cultivar = cultivar; + Origin = origin; } /// /// Gets or Sets Cultivar /// - [DataMember(Name = "cultivar", EmitDefaultValue = false)] + [JsonPropertyName("cultivar")] public string Cultivar { get; set; } /// /// Gets or Sets Origin /// - [DataMember(Name = "origin", EmitDefaultValue = false)] + [JsonPropertyName("origin")] public string Origin { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs index 28ce313d0b6..75d65e7ee8b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/AppleReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,39 +29,31 @@ namespace Org.OpenAPITools.Model /// /// AppleReq /// - [DataContract(Name = "appleReq")] public partial class AppleReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected AppleReq() { } - /// - /// Initializes a new instance of the class. - /// - /// cultivar (required). - /// mealy. + /// cultivar (required) + /// mealy public AppleReq(string cultivar, bool mealy = default) { - // to ensure "cultivar" is required (not null) - if (cultivar == null) { - throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null"); - } - this.Cultivar = cultivar; - this.Mealy = mealy; + if (cultivar == null) + throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null."); + Cultivar = cultivar; + Mealy = mealy; } /// /// Gets or Sets Cultivar /// - [DataMember(Name = "cultivar", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("cultivar")] public string Cultivar { get; set; } /// /// Gets or Sets Mealy /// - [DataMember(Name = "mealy", EmitDefaultValue = true)] + [JsonPropertyName("mealy")] public bool Mealy { get; set; } /// @@ -78,15 +70,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index a342794fafa..869900fa9fb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ArrayOfArrayOfNumberOnly /// - [DataContract(Name = "ArrayOfArrayOfNumberOnly")] public partial class ArrayOfArrayOfNumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayArrayNumber. + /// arrayArrayNumber public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber = default) { - this.ArrayArrayNumber = arrayArrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayArrayNumber = arrayArrayNumber; } /// /// Gets or Sets ArrayArrayNumber /// - [DataMember(Name = "ArrayArrayNumber", EmitDefaultValue = false)] + [JsonPropertyName("ArrayArrayNumber")] public List> ArrayArrayNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 349fc7ef5a1..b34ecd53520 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ArrayOfNumberOnly /// - [DataContract(Name = "ArrayOfNumberOnly")] public partial class ArrayOfNumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayNumber. + /// arrayNumber public ArrayOfNumberOnly(List arrayNumber = default) { - this.ArrayNumber = arrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayNumber = arrayNumber; } /// /// Gets or Sets ArrayNumber /// - [DataMember(Name = "ArrayNumber", EmitDefaultValue = false)] + [JsonPropertyName("ArrayNumber")] public List ArrayNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs index b7f6f3cd177..2b02f9ff2b8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// ArrayTest /// - [DataContract(Name = "ArrayTest")] public partial class ArrayTest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayOfString. - /// arrayArrayOfInteger. - /// arrayArrayOfModel. + /// arrayOfString + /// arrayArrayOfInteger + /// arrayArrayOfModel public ArrayTest(List arrayOfString = default, List> arrayArrayOfInteger = default, List> arrayArrayOfModel = default) { - this.ArrayOfString = arrayOfString; - this.ArrayArrayOfInteger = arrayArrayOfInteger; - this.ArrayArrayOfModel = arrayArrayOfModel; - this.AdditionalProperties = new Dictionary(); + ArrayOfString = arrayOfString; + ArrayArrayOfInteger = arrayArrayOfInteger; + ArrayArrayOfModel = arrayArrayOfModel; } /// /// Gets or Sets ArrayOfString /// - [DataMember(Name = "array_of_string", EmitDefaultValue = false)] + [JsonPropertyName("array_of_string")] public List ArrayOfString { get; set; } /// /// Gets or Sets ArrayArrayOfInteger /// - [DataMember(Name = "array_array_of_integer", EmitDefaultValue = false)] + [JsonPropertyName("array_array_of_integer")] public List> ArrayArrayOfInteger { get; set; } /// /// Gets or Sets ArrayArrayOfModel /// - [DataMember(Name = "array_array_of_model", EmitDefaultValue = false)] + [JsonPropertyName("array_array_of_model")] public List> ArrayArrayOfModel { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs index bb1962fc2b2..49a73481652 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Banana.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Banana /// - [DataContract(Name = "banana")] public partial class Banana : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// lengthCm. + /// lengthCm public Banana(decimal lengthCm = default) { - this.LengthCm = lengthCm; - this.AdditionalProperties = new Dictionary(); + LengthCm = lengthCm; } /// /// Gets or Sets LengthCm /// - [DataMember(Name = "lengthCm", EmitDefaultValue = false)] + [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs index 812c91b012f..2dabe4998e8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BananaReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,35 +29,31 @@ namespace Org.OpenAPITools.Model /// /// BananaReq /// - [DataContract(Name = "bananaReq")] public partial class BananaReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected BananaReq() { } - /// - /// Initializes a new instance of the class. - /// - /// lengthCm (required). - /// sweet. + /// lengthCm (required) + /// sweet public BananaReq(decimal lengthCm, bool sweet = default) { - this.LengthCm = lengthCm; - this.Sweet = sweet; + if (lengthCm == null) + throw new ArgumentNullException("lengthCm is a required property for BananaReq and cannot be null."); + LengthCm = lengthCm; + Sweet = sweet; } /// /// Gets or Sets LengthCm /// - [DataMember(Name = "lengthCm", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } /// /// Gets or Sets Sweet /// - [DataMember(Name = "sweet", EmitDefaultValue = true)] + [JsonPropertyName("sweet")] public bool Sweet { get; set; } /// @@ -74,15 +70,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs index 0706a3e8196..ab648f2b7a8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/BasquePig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// BasquePig /// - [DataContract(Name = "BasquePig")] public partial class BasquePig : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected BasquePig() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). + /// className (required) public BasquePig(string className) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for BasquePig and cannot be null"); - } - this.ClassName = className; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for BasquePig and cannot be null."); + ClassName = className; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs index 377781227e6..fef9aaffdd1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Capitalization.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,71 +29,69 @@ namespace Org.OpenAPITools.Model /// /// Capitalization /// - [DataContract(Name = "Capitalization")] public partial class Capitalization : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// smallCamel. - /// capitalCamel. - /// smallSnake. - /// capitalSnake. - /// sCAETHFlowPoints. - /// Name of the pet . + /// smallCamel + /// capitalCamel + /// smallSnake + /// capitalSnake + /// sCAETHFlowPoints + /// Name of the pet public Capitalization(string smallCamel = default, string capitalCamel = default, string smallSnake = default, string capitalSnake = default, string sCAETHFlowPoints = default, string aTTNAME = default) { - this.SmallCamel = smallCamel; - this.CapitalCamel = capitalCamel; - this.SmallSnake = smallSnake; - this.CapitalSnake = capitalSnake; - this.SCAETHFlowPoints = sCAETHFlowPoints; - this.ATT_NAME = aTTNAME; - this.AdditionalProperties = new Dictionary(); + SmallCamel = smallCamel; + CapitalCamel = capitalCamel; + SmallSnake = smallSnake; + CapitalSnake = capitalSnake; + SCAETHFlowPoints = sCAETHFlowPoints; + ATT_NAME = aTTNAME; } /// /// Gets or Sets SmallCamel /// - [DataMember(Name = "smallCamel", EmitDefaultValue = false)] + [JsonPropertyName("smallCamel")] public string SmallCamel { get; set; } /// /// Gets or Sets CapitalCamel /// - [DataMember(Name = "CapitalCamel", EmitDefaultValue = false)] + [JsonPropertyName("CapitalCamel")] public string CapitalCamel { get; set; } /// /// Gets or Sets SmallSnake /// - [DataMember(Name = "small_Snake", EmitDefaultValue = false)] + [JsonPropertyName("small_Snake")] public string SmallSnake { get; set; } /// /// Gets or Sets CapitalSnake /// - [DataMember(Name = "Capital_Snake", EmitDefaultValue = false)] + [JsonPropertyName("Capital_Snake")] public string CapitalSnake { get; set; } /// /// Gets or Sets SCAETHFlowPoints /// - [DataMember(Name = "SCA_ETH_Flow_Points", EmitDefaultValue = false)] + [JsonPropertyName("SCA_ETH_Flow_Points")] public string SCAETHFlowPoints { get; set; } /// /// Name of the pet /// /// Name of the pet - [DataMember(Name = "ATT_NAME", EmitDefaultValue = false)] + [JsonPropertyName("ATT_NAME")] public string ATT_NAME { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,15 +112,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs index d7c0634c555..f035df364dc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Cat.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,41 +29,23 @@ namespace Org.OpenAPITools.Model /// /// Cat /// - [DataContract(Name = "Cat")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - public partial class Cat : Animal, IEquatable, IValidatableObject + public partial class Cat : Animal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Cat() + /// catAllOf + /// className (required) + /// color (default to "red") + public Cat(CatAllOf catAllOf, string className, string color = "red") : base(className, color) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required) (default to "Cat"). - /// declawed. - /// color (default to "red"). - public Cat(string className = "Cat", bool declawed = default, string color = "red") : base(className, color) - { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + CatAllOf = catAllOf; } /// - /// Gets or Sets Declawed + /// Gets or Sets Cat /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] - public bool Declawed { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public CatAllOf CatAllOf { get; set; } /// /// Returns the string presentation of the object @@ -75,21 +56,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class Cat {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Declawed: ").Append(Declawed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -119,38 +89,76 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 59) + this.Declawed.GetHashCode(); - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type Cat + /// + public class CatJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Cat).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override Cat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader catAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref catAllOfReader, options, out CatAllOf catAllOf); + string className = default; + string color = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "className": + className = reader.GetString(); + break; + case "color": + color = reader.GetString(); + break; + } + } + } + + return new Cat(catAllOf, className, color); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/CatAllOf.cs index 5aa226e03f6..894ca6b9d60 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/CatAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// CatAllOf /// - [DataContract(Name = "Cat_allOf")] public partial class CatAllOf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// declawed. + /// declawed public CatAllOf(bool declawed = default) { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + Declawed = declawed; } /// /// Gets or Sets Declawed /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] + [JsonPropertyName("declawed")] public bool Declawed { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs index 8cd4fe7e9ac..04e34d0ee2e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Category.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,50 +29,38 @@ namespace Org.OpenAPITools.Model /// /// Category /// - [DataContract(Name = "Category")] public partial class Category : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Category() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required) (default to "default-name"). - /// id. + /// name (required) (default to "default-name") + /// id public Category(string name = "default-name", long id = default) { - // to ensure "name" is required (not null) - if (name == null) { - throw new ArgumentNullException("name is a required property for Category and cannot be null"); - } - this.Name = name; - this.Id = id; - this.AdditionalProperties = new Dictionary(); + if (name == null) + throw new ArgumentNullException("name is a required property for Category and cannot be null."); + Name = name; + Id = id; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -89,15 +77,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs index 991717f2591..7305880af4e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,61 +29,22 @@ namespace Org.OpenAPITools.Model /// /// ChildCat /// - [DataContract(Name = "ChildCat")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - public partial class ChildCat : ParentPet, IEquatable, IValidatableObject + public partial class ChildCat : ParentPet, IEquatable { - /// - /// Defines PetType - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum PetTypeEnum - { - /// - /// Enum ChildCat for value: ChildCat - /// - [EnumMember(Value = "ChildCat")] - ChildCat = 1 - - } - - - /// - /// Gets or Sets PetType - /// - [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] - public PetTypeEnum PetType { get; set; } /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ChildCat() + /// childCatAllOf + /// petType (required) + public ChildCat(ChildCatAllOf childCatAllOf, string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// petType (required) (default to PetTypeEnum.ChildCat). - /// name. - public ChildCat(PetTypeEnum petType = PetTypeEnum.ChildCat, string name = default) : base() - { - this.PetType = petType; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + ChildCatAllOf = childCatAllOf; } /// - /// Gets or Sets Name + /// Gets or Sets ChildCat /// - [DataMember(Name = "name", EmitDefaultValue = false)] - public string Name { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public ChildCatAllOf ChildCatAllOf { get; set; } /// /// Returns the string presentation of the object @@ -95,22 +55,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -140,42 +88,72 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 59) + this.PetType.GetHashCode(); - if (this.Name != null) - { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); - } - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type ChildCat + /// + public class ChildCatJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ChildCat).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ChildCat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader childCatAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref childCatAllOfReader, options, out ChildCatAllOf childCatAllOf); + string petType = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "pet_type": + petType = reader.GetString(); + break; + } + } + } + + return new ChildCat(childCatAllOf, petType); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index 483062ead25..212351b7f21 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,22 @@ namespace Org.OpenAPITools.Model /// /// ChildCatAllOf /// - [DataContract(Name = "ChildCat_allOf")] public partial class ChildCatAllOf : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// name + /// petType (default to PetTypeEnum.ChildCat) + public ChildCatAllOf(string name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) + { + Name = name; + PetType = petType; + } + /// /// Defines PetType /// - [JsonConverter(typeof(StringEnumConverter))] public enum PetTypeEnum { /// @@ -46,35 +55,23 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets PetType /// - [DataMember(Name = "pet_type", EmitDefaultValue = false)] + [JsonPropertyName("pet_type")] public PetTypeEnum PetType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// name. - /// petType (default to PetTypeEnum.ChildCat). - public ChildCatAllOf(string name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) - { - this.Name = name; - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -91,15 +88,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs index fa446f3a33f..bdfd6acb4df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ClassModel.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model with \"_class\" property /// - [DataContract(Name = "ClassModel")] public partial class ClassModel : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _class. + /// _class public ClassModel(string _class = default) { - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Class = _class; } /// /// Gets or Sets Class /// - [DataMember(Name = "_class", EmitDefaultValue = false)] + [JsonPropertyName("_class")] public string Class { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index ab75994ddf5..066c04dee99 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// ComplexQuadrilateral /// - [DataContract(Name = "ComplexQuadrilateral")] public partial class ComplexQuadrilateral : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ComplexQuadrilateral() + /// quadrilateralInterface + /// shapeInterface + public ComplexQuadrilateral(QuadrilateralInterface quadrilateralInterface, ShapeInterface shapeInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// quadrilateralType (required). - public ComplexQuadrilateral(string shapeType, string quadrilateralType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ComplexQuadrilateral and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for ComplexQuadrilateral and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + QuadrilateralInterface = quadrilateralInterface; + ShapeInterface = shapeInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets ComplexQuadrilateral /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public QuadrilateralInterface QuadrilateralInterface { get; set; } /// - /// Gets or Sets QuadrilateralType + /// Gets or Sets ComplexQuadrilateral /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] - public string QuadrilateralType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class ComplexQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.QuadrilateralType != null) - { - hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type ComplexQuadrilateral + /// + public class ComplexQuadrilateralJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ComplexQuadrilateral).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ComplexQuadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralInterfaceReader, options, out QuadrilateralInterface quadrilateralInterface); + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new ComplexQuadrilateral(quadrilateralInterface, shapeInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs index 7314bf3a214..941856ebe48 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DanishPig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// DanishPig /// - [DataContract(Name = "DanishPig")] public partial class DanishPig : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected DanishPig() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). + /// className (required) public DanishPig(string className) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for DanishPig and cannot be null"); - } - this.ClassName = className; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for DanishPig and cannot be null."); + ClassName = className; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs index a900bc224e4..660a1070cda 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// DeprecatedObject /// - [DataContract(Name = "DeprecatedObject")] public partial class DeprecatedObject : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// name. + /// name public DeprecatedObject(string name = default) { - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Name = name; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs index d34b90a530d..5649acf89d3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Dog.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,41 +29,23 @@ namespace Org.OpenAPITools.Model /// /// Dog /// - [DataContract(Name = "Dog")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - public partial class Dog : Animal, IEquatable, IValidatableObject + public partial class Dog : Animal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Dog() + /// dogAllOf + /// className (required) + /// color (default to "red") + public Dog(DogAllOf dogAllOf, string className, string color = "red") : base(className, color) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required) (default to "Dog"). - /// breed. - /// color (default to "red"). - public Dog(string className = "Dog", string breed = default, string color = "red") : base(className, color) - { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + DogAllOf = dogAllOf; } /// - /// Gets or Sets Breed + /// Gets or Sets Dog /// - [DataMember(Name = "breed", EmitDefaultValue = false)] - public string Breed { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public DogAllOf DogAllOf { get; set; } /// /// Returns the string presentation of the object @@ -75,21 +56,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class Dog {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Breed: ").Append(Breed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -119,41 +89,76 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - if (this.Breed != null) - { - hashCode = (hashCode * 59) + this.Breed.GetHashCode(); - } - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type Dog + /// + public class DogJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Dog).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override Dog Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader dogAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref dogAllOfReader, options, out DogAllOf dogAllOf); + string className = default; + string color = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "className": + className = reader.GetString(); + break; + case "color": + color = reader.GetString(); + break; + } + } + } + + return new Dog(dogAllOf, className, color); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DogAllOf.cs index 7563294d994..3c20669f2e8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DogAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// DogAllOf /// - [DataContract(Name = "Dog_allOf")] public partial class DogAllOf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// breed. + /// breed public DogAllOf(string breed = default) { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + Breed = breed; } /// /// Gets or Sets Breed /// - [DataMember(Name = "breed", EmitDefaultValue = false)] + [JsonPropertyName("breed")] public string Breed { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs index bbec316ee18..1020ef91c7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,45 @@ namespace Org.OpenAPITools.Model /// /// Drawing /// - [DataContract(Name = "Drawing")] public partial class Drawing : Dictionary, IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// mainShape. - /// shapeOrNull. - /// nullableShape. - /// shapes. - public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, NullableShape nullableShape = default, List shapes = default) : base() + /// mainShape + /// shapeOrNull + /// nullableShape + /// shapes + public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, NullableShape nullableShape = default, List shapes = default) { - this.MainShape = mainShape; - this.ShapeOrNull = shapeOrNull; - this.NullableShape = nullableShape; - this.Shapes = shapes; + MainShape = mainShape; + ShapeOrNull = shapeOrNull; + NullableShape = nullableShape; + Shapes = shapes; } /// /// Gets or Sets MainShape /// - [DataMember(Name = "mainShape", EmitDefaultValue = false)] + [JsonPropertyName("mainShape")] public Shape MainShape { get; set; } /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [JsonPropertyName("shapeOrNull")] public ShapeOrNull ShapeOrNull { get; set; } /// /// Gets or Sets NullableShape /// - [DataMember(Name = "nullableShape", EmitDefaultValue = true)] + [JsonPropertyName("nullableShape")] public NullableShape NullableShape { get; set; } /// /// Gets or Sets Shapes /// - [DataMember(Name = "shapes", EmitDefaultValue = false)] + [JsonPropertyName("shapes")] public List Shapes { get; set; } /// @@ -88,15 +87,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs index f8a52d1b5fa..cadbe7035b8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,22 @@ namespace Org.OpenAPITools.Model /// /// EnumArrays /// - [DataContract(Name = "EnumArrays")] public partial class EnumArrays : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// justSymbol + /// arrayEnum + public EnumArrays(JustSymbolEnum justSymbol = default, List arrayEnum = default) + { + JustSymbol = justSymbol; + ArrayEnum = arrayEnum; + } + /// /// Defines JustSymbol /// - [JsonConverter(typeof(StringEnumConverter))] public enum JustSymbolEnum { /// @@ -52,16 +61,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets JustSymbol /// - [DataMember(Name = "just_symbol", EmitDefaultValue = false)] + [JsonPropertyName("just_symbol")] public JustSymbolEnum JustSymbol { get; set; } + /// /// Defines ArrayEnum /// - [JsonConverter(typeof(StringEnumConverter))] public enum ArrayEnumEnum { /// @@ -79,29 +87,17 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets ArrayEnum /// - [DataMember(Name = "array_enum", EmitDefaultValue = false)] + [JsonPropertyName("array_enum")] public List ArrayEnum { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// justSymbol. - /// arrayEnum. - public EnumArrays(JustSymbolEnum justSymbol = default, List arrayEnum = default) - { - this.JustSymbol = justSymbol; - this.ArrayEnum = arrayEnum; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -118,15 +114,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs index 48b3d7d0e7e..ea5485d0b21 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines EnumClass /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumClass { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Xyz = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs index b1b8afaa9a6..301b16c0051 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,38 @@ namespace Org.OpenAPITools.Model /// /// EnumTest /// - [DataContract(Name = "Enum_Test")] public partial class EnumTest : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// enumStringRequired (required) + /// enumString + /// enumInteger + /// enumIntegerOnly + /// enumNumber + /// outerEnum + /// outerEnumInteger + /// outerEnumDefaultValue + /// outerEnumIntegerDefaultValue + public EnumTest(EnumStringRequiredEnum enumStringRequired, EnumStringEnum enumString = default, EnumIntegerEnum enumInteger = default, EnumIntegerOnlyEnum enumIntegerOnly = default, EnumNumberEnum enumNumber = default, OuterEnum outerEnum = default, OuterEnumInteger outerEnumInteger = default, OuterEnumDefaultValue outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue = default) + { + if (enumStringRequired == null) + throw new ArgumentNullException("enumStringRequired is a required property for EnumTest and cannot be null."); + EnumStringRequired = enumStringRequired; + EnumString = enumString; + EnumInteger = enumInteger; + EnumIntegerOnly = enumIntegerOnly; + EnumNumber = enumNumber; + OuterEnum = outerEnum; + OuterEnumInteger = outerEnumInteger; + OuterEnumDefaultValue = outerEnumDefaultValue; + OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; + } + /// /// Defines EnumStringRequired /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumStringRequiredEnum { /// @@ -58,16 +83,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumStringRequired /// - [DataMember(Name = "enum_string_required", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("enum_string_required")] public EnumStringRequiredEnum EnumStringRequired { get; set; } + /// /// Defines EnumString /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumStringEnum { /// @@ -90,12 +114,12 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumString /// - [DataMember(Name = "enum_string", EmitDefaultValue = false)] + [JsonPropertyName("enum_string")] public EnumStringEnum EnumString { get; set; } + /// /// Defines EnumInteger /// @@ -113,12 +137,12 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumInteger /// - [DataMember(Name = "enum_integer", EmitDefaultValue = false)] + [JsonPropertyName("enum_integer")] public EnumIntegerEnum EnumInteger { get; set; } + /// /// Defines EnumIntegerOnly /// @@ -136,16 +160,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumIntegerOnly /// - [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + [JsonPropertyName("enum_integer_only")] public EnumIntegerOnlyEnum EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumNumberEnum { /// @@ -162,75 +185,41 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumNumber /// - [DataMember(Name = "enum_number", EmitDefaultValue = false)] + [JsonPropertyName("enum_number")] public EnumNumberEnum EnumNumber { get; set; } - + /// /// Gets or Sets OuterEnum /// - [DataMember(Name = "outerEnum", EmitDefaultValue = true)] + [JsonPropertyName("outerEnum")] public OuterEnum OuterEnum { get; set; } - + /// /// Gets or Sets OuterEnumInteger /// - [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumInteger")] public OuterEnumInteger OuterEnumInteger { get; set; } - + /// /// Gets or Sets OuterEnumDefaultValue /// - [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumDefaultValue")] public OuterEnumDefaultValue OuterEnumDefaultValue { get; set; } - + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// - [DataMember(Name = "outerEnumIntegerDefaultValue", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumIntegerDefaultValue")] public OuterEnumIntegerDefaultValue OuterEnumIntegerDefaultValue { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected EnumTest() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// enumStringRequired (required). - /// enumString. - /// enumInteger. - /// enumIntegerOnly. - /// enumNumber. - /// outerEnum. - /// outerEnumInteger. - /// outerEnumDefaultValue. - /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringRequiredEnum enumStringRequired, EnumStringEnum enumString = default, EnumIntegerEnum enumInteger = default, EnumIntegerOnlyEnum enumIntegerOnly = default, EnumNumberEnum enumNumber = default, OuterEnum outerEnum = default, OuterEnumInteger outerEnumInteger = default, OuterEnumDefaultValue outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue = default) - { - this.EnumStringRequired = enumStringRequired; - this.EnumString = enumString; - this.EnumInteger = enumInteger; - this.EnumIntegerOnly = enumIntegerOnly; - this.EnumNumber = enumNumber; - this.OuterEnum = outerEnum; - this.OuterEnumInteger = outerEnumInteger; - this.OuterEnumDefaultValue = outerEnumDefaultValue; - this.OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -254,15 +243,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 43e72bd635a..a6c99bf6c4b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// EquilateralTriangle /// - [DataContract(Name = "EquilateralTriangle")] public partial class EquilateralTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected EquilateralTriangle() + /// shapeInterface + /// triangleInterface + public EquilateralTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public EquilateralTriangle(string shapeType, string triangleType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for EquilateralTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for EquilateralTriangle and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets EquilateralTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets EquilateralTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface TriangleInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EquilateralTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type EquilateralTriangle + /// + public class EquilateralTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(EquilateralTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override EquilateralTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new EquilateralTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs index e4d0738adbf..a74c1fcd9ff 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/File.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,31 +29,29 @@ namespace Org.OpenAPITools.Model /// /// Must be named `File` for test. /// - [DataContract(Name = "File")] public partial class File : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// Test capitalization. + /// Test capitalization public File(string sourceURI = default) { - this.SourceURI = sourceURI; - this.AdditionalProperties = new Dictionary(); + SourceURI = sourceURI; } /// /// Test capitalization /// /// Test capitalization - [DataMember(Name = "sourceURI", EmitDefaultValue = false)] + [JsonPropertyName("sourceURI")] public string SourceURI { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -69,15 +67,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 423799cb24e..6906e0eb38c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// FileSchemaTestClass /// - [DataContract(Name = "FileSchemaTestClass")] public partial class FileSchemaTestClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// file. - /// files. + /// file + /// files public FileSchemaTestClass(File file = default, List files = default) { - this.File = file; - this.Files = files; - this.AdditionalProperties = new Dictionary(); + File = file; + Files = files; } /// /// Gets or Sets File /// - [DataMember(Name = "file", EmitDefaultValue = false)] + [JsonPropertyName("file")] public File File { get; set; } /// /// Gets or Sets Files /// - [DataMember(Name = "files", EmitDefaultValue = false)] + [JsonPropertyName("files")] public List Files { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs index e64aac7b631..9c34541ee67 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Foo.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,31 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Foo /// - [DataContract(Name = "Foo")] public partial class Foo : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// bar (default to "bar"). + /// bar (default to "bar") public Foo(string bar = "bar") { - // use default value if no "bar" provided - this.Bar = bar ?? "bar"; - this.AdditionalProperties = new Dictionary(); + Bar = bar; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string Bar { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -69,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs index 8b846d403ff..680e378bf43 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,169 +29,158 @@ namespace Org.OpenAPITools.Model /// /// FormatTest /// - [DataContract(Name = "format_test")] public partial class FormatTest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected FormatTest() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// number (required). - /// _byte (required). - /// date (required). - /// password (required). - /// integer. - /// int32. - /// int64. - /// _float. - /// _double. - /// _decimal. - /// _string. - /// binary. - /// dateTime. - /// uuid. - /// A string that is a 10 digit number. Can have leading zeros.. - /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.. + /// number (required) + /// _byte (required) + /// date (required) + /// password (required) + /// integer + /// int32 + /// int64 + /// _float + /// _double + /// _decimal + /// _string + /// binary + /// dateTime + /// uuid + /// A string that is a 10 digit number. Can have leading zeros. + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. public FormatTest(decimal number, byte[] _byte, DateTime date, string password, int integer = default, int int32 = default, long int64 = default, float _float = default, double _double = default, decimal _decimal = default, string _string = default, System.IO.Stream binary = default, DateTime dateTime = default, Guid uuid = default, string patternWithDigits = default, string patternWithDigitsAndDelimiter = default) { - this.Number = number; - // to ensure "_byte" is required (not null) - if (_byte == null) { - throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null"); - } - this.Byte = _byte; - this.Date = date; - // to ensure "password" is required (not null) - if (password == null) { - throw new ArgumentNullException("password is a required property for FormatTest and cannot be null"); - } - this.Password = password; - this.Integer = integer; - this.Int32 = int32; - this.Int64 = int64; - this.Float = _float; - this.Double = _double; - this.Decimal = _decimal; - this.String = _string; - this.Binary = binary; - this.DateTime = dateTime; - this.Uuid = uuid; - this.PatternWithDigits = patternWithDigits; - this.PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - this.AdditionalProperties = new Dictionary(); + if (number == null) + throw new ArgumentNullException("number is a required property for FormatTest and cannot be null."); + if (_byte == null) + throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null."); + if (date == null) + throw new ArgumentNullException("date is a required property for FormatTest and cannot be null."); + if (password == null) + throw new ArgumentNullException("password is a required property for FormatTest and cannot be null."); + Number = number; + Byte = _byte; + Date = date; + Password = password; + Integer = integer; + Int32 = int32; + Int64 = int64; + Float = _float; + Double = _double; + Decimal = _decimal; + String = _string; + Binary = binary; + DateTime = dateTime; + Uuid = uuid; + PatternWithDigits = patternWithDigits; + PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; } /// /// Gets or Sets Number /// - [DataMember(Name = "number", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("number")] public decimal Number { get; set; } /// /// Gets or Sets Byte /// - [DataMember(Name = "byte", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("byte")] public byte[] Byte { get; set; } /// /// Gets or Sets Date /// - [DataMember(Name = "date", IsRequired = true, EmitDefaultValue = false)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [JsonPropertyName("date")] public DateTime Date { get; set; } /// /// Gets or Sets Password /// - [DataMember(Name = "password", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("password")] public string Password { get; set; } /// /// Gets or Sets Integer /// - [DataMember(Name = "integer", EmitDefaultValue = false)] + [JsonPropertyName("integer")] public int Integer { get; set; } /// /// Gets or Sets Int32 /// - [DataMember(Name = "int32", EmitDefaultValue = false)] + [JsonPropertyName("int32")] public int Int32 { get; set; } /// /// Gets or Sets Int64 /// - [DataMember(Name = "int64", EmitDefaultValue = false)] + [JsonPropertyName("int64")] public long Int64 { get; set; } /// /// Gets or Sets Float /// - [DataMember(Name = "float", EmitDefaultValue = false)] + [JsonPropertyName("float")] public float Float { get; set; } /// /// Gets or Sets Double /// - [DataMember(Name = "double", EmitDefaultValue = false)] + [JsonPropertyName("double")] public double Double { get; set; } /// /// Gets or Sets Decimal /// - [DataMember(Name = "decimal", EmitDefaultValue = false)] + [JsonPropertyName("decimal")] public decimal Decimal { get; set; } /// /// Gets or Sets String /// - [DataMember(Name = "string", EmitDefaultValue = false)] + [JsonPropertyName("string")] public string String { get; set; } /// /// Gets or Sets Binary /// - [DataMember(Name = "binary", EmitDefaultValue = false)] + [JsonPropertyName("binary")] public System.IO.Stream Binary { get; set; } /// /// Gets or Sets DateTime /// - [DataMember(Name = "dateTime", EmitDefaultValue = false)] + [JsonPropertyName("dateTime")] public DateTime DateTime { get; set; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public Guid Uuid { get; set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. - [DataMember(Name = "pattern_with_digits", EmitDefaultValue = false)] + [JsonPropertyName("pattern_with_digits")] public string PatternWithDigits { get; set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - [DataMember(Name = "pattern_with_digits_and_delimiter", EmitDefaultValue = false)] + [JsonPropertyName("pattern_with_digits_and_delimiter")] public string PatternWithDigitsAndDelimiter { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -222,15 +211,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs index 726b1e8f72e..0cd149e9680 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Fruit.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,95 +19,55 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Fruit /// - [JsonConverter(typeof(FruitJsonConverter))] - [DataContract(Name = "fruit")] - public partial class Fruit : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Fruit : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Apple. - public Fruit(Apple actualInstance) + /// apple + /// color + public Fruit(Apple apple, string color = default) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Apple = apple; + Color = color; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Banana. - public Fruit(Banana actualInstance) + /// banana + /// color + public Fruit(Banana banana, string color = default) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Apple)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Banana)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Apple, Banana"); - } - } + Banana = banana; + Color = color; } /// - /// Get the actual instance of `Apple`. If the actual instance is not `Apple`, - /// the InvalidClassException will be thrown + /// Gets or Sets fruit /// - /// An instance of Apple - public Apple GetApple() - { - return (Apple)this.ActualInstance; - } + public Apple Apple { get; set; } /// - /// Get the actual instance of `Banana`. If the actual instance is not `Banana`, - /// the InvalidClassException will be thrown + /// Gets or Sets fruit /// - /// An instance of Banana - public Banana GetBanana() - { - return (Banana)this.ActualInstance; - } + public Banana Banana { get; set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get; set; } /// /// Returns the string presentation of the object @@ -113,91 +75,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Fruit {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Fruit.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Fruit - /// - /// JSON string - /// An instance of Fruit - public static Fruit FromJson(string jsonString) - { - Fruit newFruit = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newFruit; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Apple).GetProperty("AdditionalProperties") == null) - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.SerializerSettings)); - } - else - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Apple"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Banana).GetProperty("AdditionalProperties") == null) - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.SerializerSettings)); - } - else - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Banana"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newFruit; - } - /// /// Returns true if objects are equal /// @@ -227,8 +111,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.Color != null) + { + hashCode = (hashCode * 59) + this.Color.GetHashCode(); + } return hashCode; } } @@ -238,54 +124,82 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Fruit + /// A Json converter for type Fruit /// - public class FruitJsonConverter : JsonConverter + public class FruitJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Fruit).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Fruit).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReader, options, out Apple apple); + + Utf8JsonReader bananaReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReader, options, out Banana banana); + + string color = default; + + while (reader.Read()) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "color": + color = reader.GetString(); + break; + } + } } - return null; + + if (apple != null) + return new Fruit(apple, color); + + if (banana != null) + return new Fruit(banana, color); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs index 548da490def..fb52312bfd4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FruitReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,104 +19,45 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// FruitReq /// - [JsonConverter(typeof(FruitReqJsonConverter))] - [DataContract(Name = "fruitReq")] - public partial class FruitReq : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class FruitReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public FruitReq() + /// appleReq + public FruitReq(AppleReq appleReq) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + AppleReq = appleReq; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of AppleReq. - public FruitReq(AppleReq actualInstance) + /// bananaReq + public FruitReq(BananaReq bananaReq) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + BananaReq = bananaReq; } /// - /// Initializes a new instance of the class - /// with the class + /// Gets or Sets fruitReq /// - /// An instance of BananaReq. - public FruitReq(BananaReq actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + public AppleReq AppleReq { get; set; } /// - /// Gets or Sets ActualInstance + /// Gets or Sets fruitReq /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(AppleReq)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(BananaReq)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: AppleReq, BananaReq"); - } - } - } - - /// - /// Get the actual instance of `AppleReq`. If the actual instance is not `AppleReq`, - /// the InvalidClassException will be thrown - /// - /// An instance of AppleReq - public AppleReq GetAppleReq() - { - return (AppleReq)this.ActualInstance; - } - - /// - /// Get the actual instance of `BananaReq`. If the actual instance is not `BananaReq`, - /// the InvalidClassException will be thrown - /// - /// An instance of BananaReq - public BananaReq GetBananaReq() - { - return (BananaReq)this.ActualInstance; - } + public BananaReq BananaReq { get; set; } /// /// Returns the string presentation of the object @@ -122,91 +65,12 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class FruitReq {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, FruitReq.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of FruitReq - /// - /// JSON string - /// An instance of FruitReq - public static FruitReq FromJson(string jsonString) - { - FruitReq newFruitReq = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newFruitReq; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(AppleReq).GetProperty("AdditionalProperties") == null) - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.SerializerSettings)); - } - else - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("AppleReq"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into AppleReq: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(BananaReq).GetProperty("AdditionalProperties") == null) - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.SerializerSettings)); - } - else - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("BananaReq"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into BananaReq: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newFruitReq; - } - /// /// Returns true if objects are equal /// @@ -236,8 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); return hashCode; } } @@ -247,54 +109,78 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for FruitReq + /// A Json converter for type FruitReq /// - public class FruitReqJsonConverter : JsonConverter + public class FruitReqJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(FruitReq).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(FruitReq).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override FruitReq Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReqReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReqReader, options, out AppleReq appleReq); + + Utf8JsonReader bananaReqReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReqReader, options, out BananaReq bananaReq); + + + while (reader.Read()) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (appleReq != null) + return new FruitReq(appleReq); + + if (bananaReq != null) + return new FruitReq(bananaReq); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs index bd8f4435c92..b4fd0f92d41 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GmFruit.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,82 +29,36 @@ namespace Org.OpenAPITools.Model /// /// GmFruit /// - [JsonConverter(typeof(GmFruitJsonConverter))] - [DataContract(Name = "gmFruit")] - public partial class GmFruit : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class GmFruit : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Apple. - public GmFruit(Apple actualInstance) + /// apple + /// banana + /// color + public GmFruit(Apple apple, Banana banana, string color = default) { - this.IsNullable = false; - this.SchemaType= "anyOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Apple = apple; + Banana = banana; + Color = color; } /// - /// Initializes a new instance of the class - /// with the class + /// Gets or Sets gmFruit /// - /// An instance of Banana. - public GmFruit(Banana actualInstance) - { - this.IsNullable = false; - this.SchemaType= "anyOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; + public Apple Apple { get; set; } /// - /// Gets or Sets ActualInstance + /// Gets or Sets gmFruit /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Apple)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Banana)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Apple, Banana"); - } - } - } + public Banana Banana { get; set; } /// - /// Get the actual instance of `Apple`. If the actual instance is not `Apple`, - /// the InvalidClassException will be thrown + /// Gets or Sets Color /// - /// An instance of Apple - public Apple GetApple() - { - return (Apple)this.ActualInstance; - } - - /// - /// Get the actual instance of `Banana`. If the actual instance is not `Banana`, - /// the InvalidClassException will be thrown - /// - /// An instance of Banana - public Banana GetBanana() - { - return (Banana)this.ActualInstance; - } + [JsonPropertyName("color")] + public string Color { get; set; } /// /// Returns the string presentation of the object @@ -112,64 +66,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class GmFruit {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, GmFruit.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of GmFruit - /// - /// JSON string - /// An instance of GmFruit - public static GmFruit FromJson(string jsonString) - { - GmFruit newGmFruit = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newGmFruit; - } - - try - { - newGmFruit = new GmFruit(JsonConvert.DeserializeObject(jsonString, GmFruit.SerializerSettings)); - // deserialization is considered successful at this point if no exception has been thrown. - return newGmFruit; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString())); - } - - try - { - newGmFruit = new GmFruit(JsonConvert.DeserializeObject(jsonString, GmFruit.SerializerSettings)); - // deserialization is considered successful at this point if no exception has been thrown. - return newGmFruit; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString())); - } - - // no match found, throw an exception - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - /// /// Returns true if objects are equal /// @@ -199,8 +102,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.Color != null) + { + hashCode = (hashCode * 59) + this.Color.GetHashCode(); + } return hashCode; } } @@ -210,54 +115,76 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for GmFruit + /// A Json converter for type GmFruit /// - public class GmFruitJsonConverter : JsonConverter + public class GmFruitJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(GmFruit).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(GmFruit).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override GmFruit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReader, options, out Apple apple); + + Utf8JsonReader bananaReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReader, options, out Banana banana); + + string color = default; + + while (reader.Read()) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "color": + color = reader.GetString(); + break; + } + } } - return null; + + return new GmFruit(apple, banana, color); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 24b3df864e1..c7b006e6a62 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,45 +29,30 @@ namespace Org.OpenAPITools.Model /// /// GrandparentAnimal /// - [DataContract(Name = "GrandparentAnimal")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] - [JsonSubtypes.KnownSubType(typeof(ParentPet), "ParentPet")] public partial class GrandparentAnimal : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected GrandparentAnimal() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// petType (required). + /// petType (required) public GrandparentAnimal(string petType) { - // to ensure "petType" is required (not null) - if (petType == null) { - throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null"); - } - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); + if (petType == null) + throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null."); + PetType = petType; } /// /// Gets or Sets PetType /// - [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("pet_type")] public string PetType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -84,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 52099a7095e..c9c283f8528 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,51 +29,36 @@ namespace Org.OpenAPITools.Model /// /// HasOnlyReadOnly /// - [DataContract(Name = "hasOnlyReadOnly")] public partial class HasOnlyReadOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - public HasOnlyReadOnly() + /// bar + /// foo + public HasOnlyReadOnly(string bar = default, string foo = default) { - this.AdditionalProperties = new Dictionary(); + Bar = bar; + Foo = foo; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string Bar { get; private set; } - /// - /// Returns false as Bar should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBar() - { - return false; - } /// /// Gets or Sets Foo /// - [DataMember(Name = "foo", EmitDefaultValue = false)] + [JsonPropertyName("foo")] public string Foo { get; private set; } - /// - /// Returns false as Foo should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeFoo() - { - return false; - } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -90,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 616877a9f60..7c0a5e58edc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. /// - [DataContract(Name = "HealthCheckResult")] public partial class HealthCheckResult : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// nullableMessage. + /// nullableMessage public HealthCheckResult(string nullableMessage = default) { - this.NullableMessage = nullableMessage; - this.AdditionalProperties = new Dictionary(); + NullableMessage = nullableMessage; } /// /// Gets or Sets NullableMessage /// - [DataMember(Name = "NullableMessage", EmitDefaultValue = true)] + [JsonPropertyName("NullableMessage")] public string NullableMessage { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs index fc8c0d06636..6bb7d64c205 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// InlineResponseDefault /// - [DataContract(Name = "inline_response_default")] public partial class InlineResponseDefault : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _string. + /// _string public InlineResponseDefault(Foo _string = default) { - this.String = _string; - this.AdditionalProperties = new Dictionary(); + String = _string; } /// /// Gets or Sets String /// - [DataMember(Name = "string", EmitDefaultValue = false)] + [JsonPropertyName("string")] public Foo String { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index d5ff97d769c..bcfaae75661 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,44 +29,28 @@ namespace Org.OpenAPITools.Model /// /// IsoscelesTriangle /// - [DataContract(Name = "IsoscelesTriangle")] public partial class IsoscelesTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected IsoscelesTriangle() { } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public IsoscelesTriangle(string shapeType, string triangleType) + /// shapeInterface + /// triangleInterface + public IsoscelesTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for IsoscelesTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for IsoscelesTriangle and cannot be null"); - } - this.TriangleType = triangleType; + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets IsoscelesTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets IsoscelesTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface TriangleInterface { get; set; } /// /// Returns the string presentation of the object @@ -76,21 +60,10 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class IsoscelesTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -120,14 +93,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } return hashCode; } } @@ -143,4 +108,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type IsoscelesTriangle + /// + public class IsoscelesTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(IsoscelesTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override IsoscelesTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new IsoscelesTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs index adaece91e88..bf77b2f6a0f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/List.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// List /// - [DataContract(Name = "List")] public partial class List : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _123list. + /// _123list public List(string _123list = default) { - this._123List = _123list; - this.AdditionalProperties = new Dictionary(); + _123List = _123list; } /// /// Gets or Sets _123List /// - [DataMember(Name = "123-list", EmitDefaultValue = false)] + [JsonPropertyName("123-list")] public string _123List { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs index 68ac3161992..0f4a2fb2d80 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Mammal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,122 +19,65 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Mammal /// - [JsonConverter(typeof(MammalJsonConverter))] - [DataContract(Name = "mammal")] - public partial class Mammal : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Mammal : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Pig. - public Mammal(Pig actualInstance) + /// pig + public Mammal(Pig pig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Pig = pig; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Whale. - public Mammal(Whale actualInstance) + /// whale + public Mammal(Whale whale) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Whale = whale; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Zebra. - public Mammal(Zebra actualInstance) + /// zebra + public Mammal(Zebra zebra) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Pig)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Whale)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Zebra)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Pig, Whale, Zebra"); - } - } + Zebra = zebra; } /// - /// Get the actual instance of `Pig`. If the actual instance is not `Pig`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Pig - public Pig GetPig() - { - return (Pig)this.ActualInstance; - } + public Pig Pig { get; set; } /// - /// Get the actual instance of `Whale`. If the actual instance is not `Whale`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Whale - public Whale GetWhale() - { - return (Whale)this.ActualInstance; - } + public Whale Whale { get; set; } /// - /// Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Zebra - public Zebra GetZebra() - { - return (Zebra)this.ActualInstance; - } + public Zebra Zebra { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -140,111 +85,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Mammal.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Mammal - /// - /// JSON string - /// An instance of Mammal - public static Mammal FromJson(string jsonString) - { - Mammal newMammal = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newMammal; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Pig).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Pig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Pig: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Whale).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Whale"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Whale: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Zebra).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Zebra"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Zebra: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newMammal; - } - /// /// Returns true if objects are equal /// @@ -274,8 +121,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -285,54 +134,94 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Mammal + /// A Json converter for type Mammal /// - public class MammalJsonConverter : JsonConverter + public class MammalJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Mammal).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Mammal).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Mammal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader pigReader = reader; + Client.ClientUtils.TryDeserialize(ref pigReader, options, out Pig pig); + + Utf8JsonReader whaleReader = reader; + Client.ClientUtils.TryDeserialize(ref whaleReader, options, out Whale whale); + + Utf8JsonReader zebraReader = reader; + Client.ClientUtils.TryDeserialize(ref zebraReader, options, out Zebra zebra); + + + while (reader.Read()) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (pig != null) + return new Mammal(pig); + + if (whale != null) + return new Mammal(whale); + + if (zebra != null) + return new Mammal(zebra); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs index b5ab56afe6a..1976383a3fd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MapTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,26 @@ namespace Org.OpenAPITools.Model /// /// MapTest /// - [DataContract(Name = "MapTest")] public partial class MapTest : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// mapMapOfString + /// mapOfEnumString + /// directMap + /// indirectMap + public MapTest(Dictionary> mapMapOfString = default, Dictionary mapOfEnumString = default, Dictionary directMap = default, Dictionary indirectMap = default) + { + MapMapOfString = mapMapOfString; + MapOfEnumString = mapOfEnumString; + DirectMap = directMap; + IndirectMap = indirectMap; + } + /// /// Defines Inner /// - [JsonConverter(typeof(StringEnumConverter))] public enum InnerEnum { /// @@ -53,51 +66,35 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets MapOfEnumString /// - [DataMember(Name = "map_of_enum_string", EmitDefaultValue = false)] + [JsonPropertyName("map_of_enum_string")] public Dictionary MapOfEnumString { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// mapMapOfString. - /// mapOfEnumString. - /// directMap. - /// indirectMap. - public MapTest(Dictionary> mapMapOfString = default, Dictionary mapOfEnumString = default, Dictionary directMap = default, Dictionary indirectMap = default) - { - this.MapMapOfString = mapMapOfString; - this.MapOfEnumString = mapOfEnumString; - this.DirectMap = directMap; - this.IndirectMap = indirectMap; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets MapMapOfString /// - [DataMember(Name = "map_map_of_string", EmitDefaultValue = false)] + [JsonPropertyName("map_map_of_string")] public Dictionary> MapMapOfString { get; set; } /// /// Gets or Sets DirectMap /// - [DataMember(Name = "direct_map", EmitDefaultValue = false)] + [JsonPropertyName("direct_map")] public Dictionary DirectMap { get; set; } /// /// Gets or Sets IndirectMap /// - [DataMember(Name = "indirect_map", EmitDefaultValue = false)] + [JsonPropertyName("indirect_map")] public Dictionary IndirectMap { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -116,15 +113,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 63145e93f88..506fa4484a6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// MixedPropertiesAndAdditionalPropertiesClass /// - [DataContract(Name = "MixedPropertiesAndAdditionalPropertiesClass")] public partial class MixedPropertiesAndAdditionalPropertiesClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// uuid. - /// dateTime. - /// map. + /// uuid + /// dateTime + /// map public MixedPropertiesAndAdditionalPropertiesClass(Guid uuid = default, DateTime dateTime = default, Dictionary map = default) { - this.Uuid = uuid; - this.DateTime = dateTime; - this.Map = map; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + DateTime = dateTime; + Map = map; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public Guid Uuid { get; set; } /// /// Gets or Sets DateTime /// - [DataMember(Name = "dateTime", EmitDefaultValue = false)] + [JsonPropertyName("dateTime")] public DateTime DateTime { get; set; } /// /// Gets or Sets Map /// - [DataMember(Name = "map", EmitDefaultValue = false)] + [JsonPropertyName("map")] public Dictionary Map { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs index 65d373b2874..2e994288dcc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Model200Response.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model name starting with number /// - [DataContract(Name = "200_response")] public partial class Model200Response : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// name. - /// _class. + /// name + /// _class public Model200Response(int name = default, string _class = default) { - this.Name = name; - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Name = name; + Class = _class; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public int Name { get; set; } /// /// Gets or Sets Class /// - [DataMember(Name = "class", EmitDefaultValue = false)] + [JsonPropertyName("class")] public string Class { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs index c1f5970e032..c0a1e3c7aae 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ModelClient.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ModelClient /// - [DataContract(Name = "_Client")] public partial class ModelClient : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _client. + /// _client public ModelClient(string _client = default) { - this._Client = _client; - this.AdditionalProperties = new Dictionary(); + _Client = _client; } /// /// Gets or Sets _Client /// - [DataMember(Name = "client", EmitDefaultValue = false)] + [JsonPropertyName("client")] public string _Client { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs index 9bb13253bc3..770664bf005 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Name.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,74 +29,54 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model name same as property name /// - [DataContract(Name = "Name")] public partial class Name : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Name() + /// nameProperty (required) + /// snakeCase + /// property + /// _123number + public Name(int nameProperty, int snakeCase = default, string property = default, int _123number = default) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required). - /// property. - public Name(int name, string property = default) - { - this._Name = name; - this.Property = property; - this.AdditionalProperties = new Dictionary(); + if (nameProperty == null) + throw new ArgumentNullException("nameProperty is a required property for Name and cannot be null."); + NameProperty = nameProperty; + SnakeCase = snakeCase; + Property = property; + _123Number = _123number; } /// - /// Gets or Sets _Name + /// Gets or Sets NameProperty /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] - public int _Name { get; set; } + [JsonPropertyName("name")] + public int NameProperty { get; set; } /// /// Gets or Sets SnakeCase /// - [DataMember(Name = "snake_case", EmitDefaultValue = false)] + [JsonPropertyName("snake_case")] public int SnakeCase { get; private set; } - /// - /// Returns false as SnakeCase should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeSnakeCase() - { - return false; - } /// /// Gets or Sets Property /// - [DataMember(Name = "property", EmitDefaultValue = false)] + [JsonPropertyName("property")] public string Property { get; set; } /// /// Gets or Sets _123Number /// - [DataMember(Name = "123Number", EmitDefaultValue = false)] + [JsonPropertyName("123Number")] public int _123Number { get; private set; } - /// - /// Returns false as _123Number should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize_123Number() - { - return false; - } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -106,7 +86,7 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Name {\n"); - sb.Append(" _Name: ").Append(_Name).Append("\n"); + sb.Append(" NameProperty: ").Append(NameProperty).Append("\n"); sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); sb.Append(" Property: ").Append(Property).Append("\n"); sb.Append(" _123Number: ").Append(_123Number).Append("\n"); @@ -115,15 +95,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -153,7 +124,7 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this._Name.GetHashCode(); + hashCode = (hashCode * 59) + this.NameProperty.GetHashCode(); hashCode = (hashCode * 59) + this.SnakeCase.GetHashCode(); if (this.Property != null) { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs index fd0c90505e6..5c716e97e6a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,111 +29,109 @@ namespace Org.OpenAPITools.Model /// /// NullableClass /// - [DataContract(Name = "NullableClass")] public partial class NullableClass : Dictionary, IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// integerProp. - /// numberProp. - /// booleanProp. - /// stringProp. - /// dateProp. - /// datetimeProp. - /// arrayNullableProp. - /// arrayAndItemsNullableProp. - /// arrayItemsNullable. - /// objectNullableProp. - /// objectAndItemsNullableProp. - /// objectItemsNullable. - public NullableClass(int? integerProp = default, decimal? numberProp = default, bool? booleanProp = default, string stringProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, List arrayNullableProp = default, List arrayAndItemsNullableProp = default, List arrayItemsNullable = default, Dictionary objectNullableProp = default, Dictionary objectAndItemsNullableProp = default, Dictionary objectItemsNullable = default) : base() + /// integerProp + /// numberProp + /// booleanProp + /// stringProp + /// dateProp + /// datetimeProp + /// arrayNullableProp + /// arrayAndItemsNullableProp + /// arrayItemsNullable + /// objectNullableProp + /// objectAndItemsNullableProp + /// objectItemsNullable + public NullableClass(int? integerProp = default, decimal? numberProp = default, bool? booleanProp = default, string stringProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, List arrayNullableProp = default, List arrayAndItemsNullableProp = default, List arrayItemsNullable = default, Dictionary objectNullableProp = default, Dictionary objectAndItemsNullableProp = default, Dictionary objectItemsNullable = default) { - this.IntegerProp = integerProp; - this.NumberProp = numberProp; - this.BooleanProp = booleanProp; - this.StringProp = stringProp; - this.DateProp = dateProp; - this.DatetimeProp = datetimeProp; - this.ArrayNullableProp = arrayNullableProp; - this.ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - this.ArrayItemsNullable = arrayItemsNullable; - this.ObjectNullableProp = objectNullableProp; - this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; - this.ObjectItemsNullable = objectItemsNullable; + IntegerProp = integerProp; + NumberProp = numberProp; + BooleanProp = booleanProp; + StringProp = stringProp; + DateProp = dateProp; + DatetimeProp = datetimeProp; + ArrayNullableProp = arrayNullableProp; + ArrayAndItemsNullableProp = arrayAndItemsNullableProp; + ArrayItemsNullable = arrayItemsNullable; + ObjectNullableProp = objectNullableProp; + ObjectAndItemsNullableProp = objectAndItemsNullableProp; + ObjectItemsNullable = objectItemsNullable; } /// /// Gets or Sets IntegerProp /// - [DataMember(Name = "integer_prop", EmitDefaultValue = true)] + [JsonPropertyName("integer_prop")] public int? IntegerProp { get; set; } /// /// Gets or Sets NumberProp /// - [DataMember(Name = "number_prop", EmitDefaultValue = true)] + [JsonPropertyName("number_prop")] public decimal? NumberProp { get; set; } /// /// Gets or Sets BooleanProp /// - [DataMember(Name = "boolean_prop", EmitDefaultValue = true)] + [JsonPropertyName("boolean_prop")] public bool? BooleanProp { get; set; } /// /// Gets or Sets StringProp /// - [DataMember(Name = "string_prop", EmitDefaultValue = true)] + [JsonPropertyName("string_prop")] public string StringProp { get; set; } /// /// Gets or Sets DateProp /// - [DataMember(Name = "date_prop", EmitDefaultValue = true)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [JsonPropertyName("date_prop")] public DateTime? DateProp { get; set; } /// /// Gets or Sets DatetimeProp /// - [DataMember(Name = "datetime_prop", EmitDefaultValue = true)] + [JsonPropertyName("datetime_prop")] public DateTime? DatetimeProp { get; set; } /// /// Gets or Sets ArrayNullableProp /// - [DataMember(Name = "array_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("array_nullable_prop")] public List ArrayNullableProp { get; set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// - [DataMember(Name = "array_and_items_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("array_and_items_nullable_prop")] public List ArrayAndItemsNullableProp { get; set; } /// /// Gets or Sets ArrayItemsNullable /// - [DataMember(Name = "array_items_nullable", EmitDefaultValue = false)] + [JsonPropertyName("array_items_nullable")] public List ArrayItemsNullable { get; set; } /// /// Gets or Sets ObjectNullableProp /// - [DataMember(Name = "object_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("object_nullable_prop")] public Dictionary ObjectNullableProp { get; set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// - [DataMember(Name = "object_and_items_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("object_and_items_nullable_prop")] public Dictionary ObjectAndItemsNullableProp { get; set; } /// /// Gets or Sets ObjectItemsNullable /// - [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] + [JsonPropertyName("object_items_nullable")] public Dictionary ObjectItemsNullable { get; set; } /// @@ -161,15 +159,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs index 5dd73a56ef7..4fb0d6ed89f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableShape.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,105 +19,53 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - [JsonConverter(typeof(NullableShapeJsonConverter))] - [DataContract(Name = "NullableShape")] - public partial class NullableShape : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class NullableShape : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public NullableShape() + /// quadrilateral + public NullableShape(Quadrilateral quadrilateral) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + Quadrilateral = quadrilateral; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public NullableShape(Quadrilateral actualInstance) + /// triangle + public NullableShape(Triangle triangle) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + Triangle = triangle; } /// - /// Initializes a new instance of the class - /// with the class + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - /// An instance of Triangle. - public NullableShape(Triangle actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + public Quadrilateral Quadrilateral { get; set; } /// - /// Gets or Sets ActualInstance + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } - } + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + public Triangle Triangle { get; set; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets additional properties /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } - - /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown - /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -123,91 +73,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, NullableShape.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of NullableShape - /// - /// JSON string - /// An instance of NullableShape - public static NullableShape FromJson(string jsonString) - { - NullableShape newNullableShape = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newNullableShape; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.SerializerSettings)); - } - else - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.SerializerSettings)); - } - else - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newNullableShape; - } - /// /// Returns true if objects are equal /// @@ -237,8 +109,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -248,54 +122,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for NullableShape + /// A Json converter for type NullableShape /// - public class NullableShapeJsonConverter : JsonConverter + public class NullableShapeJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(NullableShape).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(NullableShape).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override NullableShape Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle triangle); + + + while (reader.Read()) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (quadrilateral != null) + return new NullableShape(quadrilateral); + + if (triangle != null) + return new NullableShape(triangle); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs index 7787cb03338..1b5a086f3ec 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// NumberOnly /// - [DataContract(Name = "NumberOnly")] public partial class NumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// justNumber. + /// justNumber public NumberOnly(decimal justNumber = default) { - this.JustNumber = justNumber; - this.AdditionalProperties = new Dictionary(); + JustNumber = justNumber; } /// /// Gets or Sets JustNumber /// - [DataMember(Name = "JustNumber", EmitDefaultValue = false)] + [JsonPropertyName("JustNumber")] public decimal JustNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index de7d09291bf..ee1c67907f4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,49 +29,47 @@ namespace Org.OpenAPITools.Model /// /// ObjectWithDeprecatedFields /// - [DataContract(Name = "ObjectWithDeprecatedFields")] public partial class ObjectWithDeprecatedFields : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// uuid. - /// id. - /// deprecatedRef. - /// bars. + /// uuid + /// id + /// deprecatedRef + /// bars public ObjectWithDeprecatedFields(string uuid = default, decimal id = default, DeprecatedObject deprecatedRef = default, List bars = default) { - this.Uuid = uuid; - this.Id = id; - this.DeprecatedRef = deprecatedRef; - this.Bars = bars; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + Id = id; + DeprecatedRef = deprecatedRef; + Bars = bars; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public string Uuid { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] [Obsolete] public decimal Id { get; set; } /// /// Gets or Sets DeprecatedRef /// - [DataMember(Name = "deprecatedRef", EmitDefaultValue = false)] + [JsonPropertyName("deprecatedRef")] [Obsolete] public DeprecatedObject DeprecatedRef { get; set; } /// /// Gets or Sets Bars /// - [DataMember(Name = "bars", EmitDefaultValue = false)] + [JsonPropertyName("bars")] [Obsolete] public List Bars { get; set; } @@ -79,7 +77,7 @@ namespace Org.OpenAPITools.Model /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -98,15 +96,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs index 8c986b5f676..50648c48eb6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,14 +29,31 @@ namespace Org.OpenAPITools.Model /// /// Order /// - [DataContract(Name = "Order")] public partial class Order : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// id + /// petId + /// quantity + /// shipDate + /// Order Status + /// complete (default to false) + public Order(long id = default, long petId = default, int quantity = default, DateTime shipDate = default, StatusEnum status = default, bool complete = false) + { + Id = id; + PetId = petId; + Quantity = quantity; + ShipDate = shipDate; + Status = status; + Complete = complete; + } + /// /// Order Status /// /// Order Status - [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { /// @@ -59,68 +76,48 @@ namespace Org.OpenAPITools.Model } - /// /// Order Status /// /// Order Status - [DataMember(Name = "status", EmitDefaultValue = false)] + [JsonPropertyName("status")] public StatusEnum Status { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// petId. - /// quantity. - /// shipDate. - /// Order Status. - /// complete (default to false). - public Order(long id = default, long petId = default, int quantity = default, DateTime shipDate = default, StatusEnum status = default, bool complete = false) - { - this.Id = id; - this.PetId = petId; - this.Quantity = quantity; - this.ShipDate = shipDate; - this.Status = status; - this.Complete = complete; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets PetId /// - [DataMember(Name = "petId", EmitDefaultValue = false)] + [JsonPropertyName("petId")] public long PetId { get; set; } /// /// Gets or Sets Quantity /// - [DataMember(Name = "quantity", EmitDefaultValue = false)] + [JsonPropertyName("quantity")] public int Quantity { get; set; } /// /// Gets or Sets ShipDate /// - [DataMember(Name = "shipDate", EmitDefaultValue = false)] + [JsonPropertyName("shipDate")] public DateTime ShipDate { get; set; } /// /// Gets or Sets Complete /// - [DataMember(Name = "complete", EmitDefaultValue = true)] + [JsonPropertyName("complete")] public bool Complete { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -141,15 +138,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs index 7f4749fe8b5..77750e36f17 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// OuterComposite /// - [DataContract(Name = "OuterComposite")] public partial class OuterComposite : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// myNumber. - /// myString. - /// myBoolean. + /// myNumber + /// myString + /// myBoolean public OuterComposite(decimal myNumber = default, string myString = default, bool myBoolean = default) { - this.MyNumber = myNumber; - this.MyString = myString; - this.MyBoolean = myBoolean; - this.AdditionalProperties = new Dictionary(); + MyNumber = myNumber; + MyString = myString; + MyBoolean = myBoolean; } /// /// Gets or Sets MyNumber /// - [DataMember(Name = "my_number", EmitDefaultValue = false)] + [JsonPropertyName("my_number")] public decimal MyNumber { get; set; } /// /// Gets or Sets MyString /// - [DataMember(Name = "my_string", EmitDefaultValue = false)] + [JsonPropertyName("my_string")] public string MyString { get; set; } /// /// Gets or Sets MyBoolean /// - [DataMember(Name = "my_boolean", EmitDefaultValue = true)] + [JsonPropertyName("my_boolean")] public bool MyBoolean { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs index 2aa496a2e07..00283c562e5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines OuterEnum /// - [JsonConverter(typeof(StringEnumConverter))] public enum OuterEnum { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Delivered = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index dd79c7010d6..f5cf13dcc86 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines OuterEnumDefaultValue /// - [JsonConverter(typeof(StringEnumConverter))] public enum OuterEnumDefaultValue { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Delivered = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index 44dc91c700a..558ff898db8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -47,5 +47,4 @@ namespace Org.OpenAPITools.Model NUMBER_2 = 2 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index b927507cf97..4f1b6980073 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -47,5 +47,4 @@ namespace Org.OpenAPITools.Model NUMBER_2 = 2 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs index ac986b555ef..2110ce35c54 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ParentPet.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,33 +29,15 @@ namespace Org.OpenAPITools.Model /// /// ParentPet /// - [DataContract(Name = "ParentPet")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] - public partial class ParentPet : GrandparentAnimal, IEquatable, IValidatableObject + public partial class ParentPet : GrandparentAnimal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ParentPet() + /// petType (required) + public ParentPet(string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); } - /// - /// Initializes a new instance of the class. - /// - /// petType (required) (default to "ParentPet"). - public ParentPet(string petType = "ParentPet") : base(petType) - { - this.AdditionalProperties = new Dictionary(); - } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } /// /// Returns the string presentation of the object @@ -67,20 +48,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class ParentPet {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -110,37 +81,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs index c7c27fb4e98..145de340a06 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,14 +29,35 @@ namespace Org.OpenAPITools.Model /// /// Pet /// - [DataContract(Name = "Pet")] public partial class Pet : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// name (required) + /// photoUrls (required) + /// id + /// category + /// tags + /// pet status in the store + public Pet(string name, List photoUrls, long id = default, Category category = default, List tags = default, StatusEnum status = default) + { + if (name == null) + throw new ArgumentNullException("name is a required property for Pet and cannot be null."); + if (photoUrls == null) + throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null."); + Name = name; + PhotoUrls = photoUrls; + Id = id; + Category = category; + Tags = tags; + Status = status; + } + /// /// pet status in the store /// /// pet status in the store - [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { /// @@ -59,84 +80,48 @@ namespace Org.OpenAPITools.Model } - /// /// pet status in the store /// /// pet status in the store - [DataMember(Name = "status", EmitDefaultValue = false)] + [JsonPropertyName("status")] public StatusEnum Status { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected Pet() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required). - /// photoUrls (required). - /// id. - /// category. - /// tags. - /// pet status in the store. - public Pet(string name, List photoUrls, long id = default, Category category = default, List tags = default, StatusEnum status = default) - { - // to ensure "name" is required (not null) - if (name == null) { - throw new ArgumentNullException("name is a required property for Pet and cannot be null"); - } - this.Name = name; - // to ensure "photoUrls" is required (not null) - if (photoUrls == null) { - throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null"); - } - this.PhotoUrls = photoUrls; - this.Id = id; - this.Category = category; - this.Tags = tags; - this.Status = status; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Name /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets PhotoUrls /// - [DataMember(Name = "photoUrls", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets Category /// - [DataMember(Name = "category", EmitDefaultValue = false)] + [JsonPropertyName("category")] public Category Category { get; set; } /// /// Gets or Sets Tags /// - [DataMember(Name = "tags", EmitDefaultValue = false)] + [JsonPropertyName("tags")] public List Tags { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -157,15 +142,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs index b82c0899c27..fbaf444f689 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,96 +19,51 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Pig /// - [JsonConverter(typeof(PigJsonConverter))] - [DataContract(Name = "Pig")] - public partial class Pig : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Pig : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of BasquePig. - public Pig(BasquePig actualInstance) + /// basquePig + public Pig(BasquePig basquePig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + BasquePig = basquePig; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of DanishPig. - public Pig(DanishPig actualInstance) + /// danishPig + public Pig(DanishPig danishPig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(BasquePig)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(DanishPig)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: BasquePig, DanishPig"); - } - } + DanishPig = danishPig; } /// - /// Get the actual instance of `BasquePig`. If the actual instance is not `BasquePig`, - /// the InvalidClassException will be thrown + /// Gets or Sets Pig /// - /// An instance of BasquePig - public BasquePig GetBasquePig() - { - return (BasquePig)this.ActualInstance; - } + public BasquePig BasquePig { get; set; } /// - /// Get the actual instance of `DanishPig`. If the actual instance is not `DanishPig`, - /// the InvalidClassException will be thrown + /// Gets or Sets Pig /// - /// An instance of DanishPig - public DanishPig GetDanishPig() - { - return (DanishPig)this.ActualInstance; - } + public DanishPig DanishPig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,91 +71,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Pig.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Pig - /// - /// JSON string - /// An instance of Pig - public static Pig FromJson(string jsonString) - { - Pig newPig = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newPig; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(BasquePig).GetProperty("AdditionalProperties") == null) - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.SerializerSettings)); - } - else - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("BasquePig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into BasquePig: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(DanishPig).GetProperty("AdditionalProperties") == null) - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.SerializerSettings)); - } - else - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("DanishPig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into DanishPig: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newPig; - } - /// /// Returns true if objects are equal /// @@ -228,8 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +120,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Pig + /// A Json converter for type Pig /// - public class PigJsonConverter : JsonConverter + public class PigJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Pig).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Pig).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Pig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader basquePigReader = reader; + Client.ClientUtils.TryDeserialize(ref basquePigReader, options, out BasquePig basquePig); + + Utf8JsonReader danishPigReader = reader; + Client.ClientUtils.TryDeserialize(ref danishPigReader, options, out DanishPig danishPig); + + + while (reader.Read()) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (basquePig != null) + return new Pig(basquePig); + + if (danishPig != null) + return new Pig(danishPig); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs index a1a850f169e..59527b032d5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,96 +19,51 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Quadrilateral /// - [JsonConverter(typeof(QuadrilateralJsonConverter))] - [DataContract(Name = "Quadrilateral")] - public partial class Quadrilateral : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Quadrilateral : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of ComplexQuadrilateral. - public Quadrilateral(ComplexQuadrilateral actualInstance) + /// complexQuadrilateral + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + ComplexQuadrilateral = complexQuadrilateral; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of SimpleQuadrilateral. - public Quadrilateral(SimpleQuadrilateral actualInstance) + /// simpleQuadrilateral + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(ComplexQuadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(SimpleQuadrilateral)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: ComplexQuadrilateral, SimpleQuadrilateral"); - } - } + SimpleQuadrilateral = simpleQuadrilateral; } /// - /// Get the actual instance of `ComplexQuadrilateral`. If the actual instance is not `ComplexQuadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Quadrilateral /// - /// An instance of ComplexQuadrilateral - public ComplexQuadrilateral GetComplexQuadrilateral() - { - return (ComplexQuadrilateral)this.ActualInstance; - } + public ComplexQuadrilateral ComplexQuadrilateral { get; set; } /// - /// Get the actual instance of `SimpleQuadrilateral`. If the actual instance is not `SimpleQuadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Quadrilateral /// - /// An instance of SimpleQuadrilateral - public SimpleQuadrilateral GetSimpleQuadrilateral() - { - return (SimpleQuadrilateral)this.ActualInstance; - } + public SimpleQuadrilateral SimpleQuadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,91 +71,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Quadrilateral.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Quadrilateral - /// - /// JSON string - /// An instance of Quadrilateral - public static Quadrilateral FromJson(string jsonString) - { - Quadrilateral newQuadrilateral = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newQuadrilateral; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(ComplexQuadrilateral).GetProperty("AdditionalProperties") == null) - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.SerializerSettings)); - } - else - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("ComplexQuadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into ComplexQuadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(SimpleQuadrilateral).GetProperty("AdditionalProperties") == null) - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.SerializerSettings)); - } - else - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("SimpleQuadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into SimpleQuadrilateral: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newQuadrilateral; - } - /// /// Returns true if objects are equal /// @@ -228,8 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +120,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Quadrilateral + /// A Json converter for type Quadrilateral /// - public class QuadrilateralJsonConverter : JsonConverter + public class QuadrilateralJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Quadrilateral).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Quadrilateral).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Quadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader complexQuadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref complexQuadrilateralReader, options, out ComplexQuadrilateral complexQuadrilateral); + + Utf8JsonReader simpleQuadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref simpleQuadrilateralReader, options, out SimpleQuadrilateral simpleQuadrilateral); + + + while (reader.Read()) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (complexQuadrilateral != null) + return new Quadrilateral(complexQuadrilateral); + + if (simpleQuadrilateral != null) + return new Quadrilateral(simpleQuadrilateral); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index b29e2db36b6..ac7d334144d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// QuadrilateralInterface /// - [DataContract(Name = "QuadrilateralInterface")] public partial class QuadrilateralInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected QuadrilateralInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// quadrilateralType (required). + /// quadrilateralType (required) public QuadrilateralInterface(string quadrilateralType) { - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null."); + QuadrilateralType = quadrilateralType; } /// /// Gets or Sets QuadrilateralType /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("quadrilateralType")] public string QuadrilateralType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 6b4acaddf1b..4507699a2dc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,44 +29,36 @@ namespace Org.OpenAPITools.Model /// /// ReadOnlyFirst /// - [DataContract(Name = "ReadOnlyFirst")] public partial class ReadOnlyFirst : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// baz. - public ReadOnlyFirst(string baz = default) + /// bar + /// baz + public ReadOnlyFirst(string bar = default, string baz = default) { - this.Baz = baz; - this.AdditionalProperties = new Dictionary(); + Bar = bar; + Baz = baz; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string Bar { get; private set; } - /// - /// Returns false as Bar should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBar() - { - return false; - } /// /// Gets or Sets Baz /// - [DataMember(Name = "baz", EmitDefaultValue = false)] + [JsonPropertyName("baz")] public string Baz { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -83,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs index c862011ba9d..0ff72214bfb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Return.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Model for testing reserved words /// - [DataContract(Name = "Return")] public partial class Return : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _return. - public Return(int _return = default) + /// returnProperty + public Return(int returnProperty = default) { - this._Return = _return; - this.AdditionalProperties = new Dictionary(); + ReturnProperty = returnProperty; } /// - /// Gets or Sets _Return + /// Gets or Sets ReturnProperty /// - [DataMember(Name = "return", EmitDefaultValue = false)] - public int _Return { get; set; } + [JsonPropertyName("return")] + public int ReturnProperty { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -62,21 +60,12 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Return {\n"); - sb.Append(" _Return: ").Append(_Return).Append("\n"); + sb.Append(" ReturnProperty: ").Append(ReturnProperty).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -106,7 +95,7 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this._Return.GetHashCode(); + hashCode = (hashCode * 59) + this.ReturnProperty.GetHashCode(); if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 206e0fbe331..0d04295d385 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// ScaleneTriangle /// - [DataContract(Name = "ScaleneTriangle")] public partial class ScaleneTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ScaleneTriangle() + /// shapeInterface + /// triangleInterface + public ScaleneTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public ScaleneTriangle(string shapeType, string triangleType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ScaleneTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for ScaleneTriangle and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets ScaleneTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets ScaleneTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface TriangleInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class ScaleneTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type ScaleneTriangle + /// + public class ScaleneTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ScaleneTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ScaleneTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new ScaleneTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs index dd74fa4b718..98197f21b11 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Shape.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,96 +19,65 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Shape /// - [JsonConverter(typeof(ShapeJsonConverter))] - [DataContract(Name = "Shape")] - public partial class Shape : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Shape : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public Shape(Quadrilateral actualInstance) + /// quadrilateral + /// quadrilateralType (required) + public Shape(Quadrilateral quadrilateral, string quadrilateralType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for Shape and cannot be null."); + Quadrilateral = quadrilateral; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Triangle. - public Shape(Triangle actualInstance) + /// triangle + /// quadrilateralType (required) + public Shape(Triangle triangle, string quadrilateralType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for Shape and cannot be null."); + Triangle = triangle; + QuadrilateralType = quadrilateralType; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Shape /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } + public Quadrilateral Quadrilateral { get; set; } /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Shape /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,91 +85,14 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Shape.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Shape - /// - /// JSON string - /// An instance of Shape - public static Shape FromJson(string jsonString) - { - Shape newShape = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newShape; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.SerializerSettings)); - } - else - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.SerializerSettings)); - } - else - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newShape; - } - /// /// Returns true if objects are equal /// @@ -228,8 +122,14 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.QuadrilateralType != null) + { + hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +139,92 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Shape + /// A Json converter for type Shape /// - public class ShapeJsonConverter : JsonConverter + public class ShapeJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Shape).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Shape).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Shape Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle triangle); + + string quadrilateralType = default; + + while (reader.Read()) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "quadrilateralType": + quadrilateralType = reader.GetString(); + break; + } + } } - return null; + + if (quadrilateral != null) + return new Shape(quadrilateral, quadrilateralType); + + if (triangle != null) + return new Shape(triangle, quadrilateralType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs index 55788e33f35..a578a3ec3b3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// ShapeInterface /// - [DataContract(Name = "ShapeInterface")] public partial class ShapeInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ShapeInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). + /// shapeType (required) public ShapeInterface(string shapeType) { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null"); - } - this.ShapeType = shapeType; - this.AdditionalProperties = new Dictionary(); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null."); + ShapeType = shapeType; } /// /// Gets or Sets ShapeType /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("shapeType")] public string ShapeType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs index c6b87c89751..36bb39889ee 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,105 +19,67 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - [JsonConverter(typeof(ShapeOrNullJsonConverter))] - [DataContract(Name = "ShapeOrNull")] - public partial class ShapeOrNull : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class ShapeOrNull : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public ShapeOrNull() + /// quadrilateral + /// quadrilateralType (required) + public ShapeOrNull(Quadrilateral quadrilateral, string quadrilateralType) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for ShapeOrNull and cannot be null."); + Quadrilateral = quadrilateral; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public ShapeOrNull(Quadrilateral actualInstance) + /// triangle + /// quadrilateralType (required) + public ShapeOrNull(Triangle triangle, string quadrilateralType) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for ShapeOrNull and cannot be null."); + Triangle = triangle; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - /// An instance of Triangle. - public ShapeOrNull(Triangle actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + public Quadrilateral Quadrilateral { get; set; } /// - /// Gets or Sets ActualInstance + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } - } + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + public Triangle Triangle { get; set; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets QuadrilateralType /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets additional properties /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -123,91 +87,14 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, ShapeOrNull.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of ShapeOrNull - /// - /// JSON string - /// An instance of ShapeOrNull - public static ShapeOrNull FromJson(string jsonString) - { - ShapeOrNull newShapeOrNull = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newShapeOrNull; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.SerializerSettings)); - } - else - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.SerializerSettings)); - } - else - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newShapeOrNull; - } - /// /// Returns true if objects are equal /// @@ -237,8 +124,14 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.QuadrilateralType != null) + { + hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -248,54 +141,92 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for ShapeOrNull + /// A Json converter for type ShapeOrNull /// - public class ShapeOrNullJsonConverter : JsonConverter + public class ShapeOrNullJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(ShapeOrNull).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ShapeOrNull).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override ShapeOrNull Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle triangle); + + string quadrilateralType = default; + + while (reader.Read()) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "quadrilateralType": + quadrilateralType = reader.GetString(); + break; + } + } } - return null; + + if (quadrilateral != null) + return new ShapeOrNull(quadrilateral, quadrilateralType); + + if (triangle != null) + return new ShapeOrNull(triangle, quadrilateralType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 1398011e13f..049f67bb410 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// SimpleQuadrilateral /// - [DataContract(Name = "SimpleQuadrilateral")] public partial class SimpleQuadrilateral : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected SimpleQuadrilateral() + /// quadrilateralInterface + /// shapeInterface + public SimpleQuadrilateral(QuadrilateralInterface quadrilateralInterface, ShapeInterface shapeInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// quadrilateralType (required). - public SimpleQuadrilateral(string shapeType, string quadrilateralType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for SimpleQuadrilateral and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for SimpleQuadrilateral and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + QuadrilateralInterface = quadrilateralInterface; + ShapeInterface = shapeInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets SimpleQuadrilateral /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public QuadrilateralInterface QuadrilateralInterface { get; set; } /// - /// Gets or Sets QuadrilateralType + /// Gets or Sets SimpleQuadrilateral /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] - public string QuadrilateralType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class SimpleQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.QuadrilateralType != null) - { - hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type SimpleQuadrilateral + /// + public class SimpleQuadrilateralJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(SimpleQuadrilateral).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override SimpleQuadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralInterfaceReader, options, out QuadrilateralInterface quadrilateralInterface); + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new SimpleQuadrilateral(quadrilateralInterface, shapeInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs index e24187da5be..48bdc9ff428 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// SpecialModelName /// - [DataContract(Name = "_special_model.name_")] public partial class SpecialModelName : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// specialPropertyName. - /// specialModelName. - public SpecialModelName(long specialPropertyName = default, string specialModelName = default) + /// specialPropertyName + /// specialModelNameProperty + public SpecialModelName(long specialPropertyName = default, string specialModelNameProperty = default) { - this.SpecialPropertyName = specialPropertyName; - this._SpecialModelName = specialModelName; - this.AdditionalProperties = new Dictionary(); + SpecialPropertyName = specialPropertyName; + SpecialModelNameProperty = specialModelNameProperty; } /// /// Gets or Sets SpecialPropertyName /// - [DataMember(Name = "$special[property.name]", EmitDefaultValue = false)] + [JsonPropertyName("$special[property.name]")] public long SpecialPropertyName { get; set; } /// - /// Gets or Sets _SpecialModelName + /// Gets or Sets SpecialModelNameProperty /// - [DataMember(Name = "_special_model.name_", EmitDefaultValue = false)] - public string _SpecialModelName { get; set; } + [JsonPropertyName("_special_model.name_")] + public string SpecialModelNameProperty { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -71,21 +69,12 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class SpecialModelName {\n"); sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); - sb.Append(" _SpecialModelName: ").Append(_SpecialModelName).Append("\n"); + sb.Append(" SpecialModelNameProperty: ").Append(SpecialModelNameProperty).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -116,9 +105,9 @@ namespace Org.OpenAPITools.Model { int hashCode = 41; hashCode = (hashCode * 59) + this.SpecialPropertyName.GetHashCode(); - if (this._SpecialModelName != null) + if (this.SpecialModelNameProperty != null) { - hashCode = (hashCode * 59) + this._SpecialModelName.GetHashCode(); + hashCode = (hashCode * 59) + this.SpecialModelNameProperty.GetHashCode(); } if (this.AdditionalProperties != null) { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs index cca02fceb32..a4d54a81f9a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Tag.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Tag /// - [DataContract(Name = "Tag")] public partial class Tag : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// id. - /// name. + /// id + /// name public Tag(long id = default, string name = default) { - this.Id = id; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Id = id; + Name = name; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs index c8cf49ef7f6..ac2db7bde5d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Triangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,122 +19,101 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Triangle /// - [JsonConverter(typeof(TriangleJsonConverter))] - [DataContract(Name = "Triangle")] - public partial class Triangle : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Triangle : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of EquilateralTriangle. - public Triangle(EquilateralTriangle actualInstance) + /// equilateralTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(EquilateralTriangle equilateralTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + EquilateralTriangle = equilateralTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of IsoscelesTriangle. - public Triangle(IsoscelesTriangle actualInstance) + /// isoscelesTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(IsoscelesTriangle isoscelesTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + IsoscelesTriangle = isoscelesTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of ScaleneTriangle. - public Triangle(ScaleneTriangle actualInstance) + /// scaleneTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(ScaleneTriangle scaleneTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(EquilateralTriangle)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(IsoscelesTriangle)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(ScaleneTriangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: EquilateralTriangle, IsoscelesTriangle, ScaleneTriangle"); - } - } + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + ScaleneTriangle = scaleneTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Get the actual instance of `EquilateralTriangle`. If the actual instance is not `EquilateralTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of EquilateralTriangle - public EquilateralTriangle GetEquilateralTriangle() - { - return (EquilateralTriangle)this.ActualInstance; - } + public EquilateralTriangle EquilateralTriangle { get; set; } /// - /// Get the actual instance of `IsoscelesTriangle`. If the actual instance is not `IsoscelesTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of IsoscelesTriangle - public IsoscelesTriangle GetIsoscelesTriangle() - { - return (IsoscelesTriangle)this.ActualInstance; - } + public IsoscelesTriangle IsoscelesTriangle { get; set; } /// - /// Get the actual instance of `ScaleneTriangle`. If the actual instance is not `ScaleneTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of ScaleneTriangle - public ScaleneTriangle GetScaleneTriangle() - { - return (ScaleneTriangle)this.ActualInstance; - } + public ScaleneTriangle ScaleneTriangle { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -140,111 +121,15 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Triangle.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Triangle - /// - /// JSON string - /// An instance of Triangle - public static Triangle FromJson(string jsonString) - { - Triangle newTriangle = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newTriangle; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(EquilateralTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("EquilateralTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into EquilateralTriangle: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(IsoscelesTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("IsoscelesTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into IsoscelesTriangle: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(ScaleneTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("ScaleneTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into ScaleneTriangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newTriangle; - } - /// /// Returns true if objects are equal /// @@ -274,8 +159,18 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.ShapeType != null) + { + hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); + } + if (this.TriangleType != null) + { + hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -285,54 +180,102 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Triangle + /// A Json converter for type Triangle /// - public class TriangleJsonConverter : JsonConverter + public class TriangleJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Triangle).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Triangle).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Triangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader equilateralTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref equilateralTriangleReader, options, out EquilateralTriangle equilateralTriangle); + + Utf8JsonReader isoscelesTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref isoscelesTriangleReader, options, out IsoscelesTriangle isoscelesTriangle); + + Utf8JsonReader scaleneTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref scaleneTriangleReader, options, out ScaleneTriangle scaleneTriangle); + + string shapeType = default; + string triangleType = default; + + while (reader.Read()) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "shapeType": + shapeType = reader.GetString(); + break; + case "triangleType": + triangleType = reader.GetString(); + break; + } + } } - return null; + + if (equilateralTriangle != null) + return new Triangle(equilateralTriangle, shapeType, triangleType); + + if (isoscelesTriangle != null) + return new Triangle(isoscelesTriangle, shapeType, triangleType); + + if (scaleneTriangle != null) + return new Triangle(scaleneTriangle, shapeType, triangleType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs index 8c62abd8c65..f24f847c0c2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// TriangleInterface /// - [DataContract(Name = "TriangleInterface")] public partial class TriangleInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected TriangleInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// triangleType (required). + /// triangleType (required) public TriangleInterface(string triangleType) { - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null."); + TriangleType = triangleType; } /// /// Gets or Sets TriangleType /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("triangleType")] public string TriangleType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs index 709d9397d87..aacb22aaec2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/User.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,123 +29,121 @@ namespace Org.OpenAPITools.Model /// /// User /// - [DataContract(Name = "User")] public partial class User : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// id. - /// username. - /// firstName. - /// lastName. - /// email. - /// password. - /// phone. - /// User Status. - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value.. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.. - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389. - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values.. + /// id + /// username + /// firstName + /// lastName + /// email + /// password + /// phone + /// User Status + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. public User(long id = default, string username = default, string firstName = default, string lastName = default, string email = default, string password = default, string phone = default, int userStatus = default, Object objectWithNoDeclaredProps = default, Object objectWithNoDeclaredPropsNullable = default, Object anyTypeProp = default, Object anyTypePropNullable = default) { - this.Id = id; - this.Username = username; - this.FirstName = firstName; - this.LastName = lastName; - this.Email = email; - this.Password = password; - this.Phone = phone; - this.UserStatus = userStatus; - this.ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - this.ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; - this.AnyTypeProp = anyTypeProp; - this.AnyTypePropNullable = anyTypePropNullable; - this.AdditionalProperties = new Dictionary(); + Id = id; + Username = username; + FirstName = firstName; + LastName = lastName; + Email = email; + Password = password; + Phone = phone; + UserStatus = userStatus; + ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypeProp = anyTypeProp; + AnyTypePropNullable = anyTypePropNullable; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets Username /// - [DataMember(Name = "username", EmitDefaultValue = false)] + [JsonPropertyName("username")] public string Username { get; set; } /// /// Gets or Sets FirstName /// - [DataMember(Name = "firstName", EmitDefaultValue = false)] + [JsonPropertyName("firstName")] public string FirstName { get; set; } /// /// Gets or Sets LastName /// - [DataMember(Name = "lastName", EmitDefaultValue = false)] + [JsonPropertyName("lastName")] public string LastName { get; set; } /// /// Gets or Sets Email /// - [DataMember(Name = "email", EmitDefaultValue = false)] + [JsonPropertyName("email")] public string Email { get; set; } /// /// Gets or Sets Password /// - [DataMember(Name = "password", EmitDefaultValue = false)] + [JsonPropertyName("password")] public string Password { get; set; } /// /// Gets or Sets Phone /// - [DataMember(Name = "phone", EmitDefaultValue = false)] + [JsonPropertyName("phone")] public string Phone { get; set; } /// /// User Status /// /// User Status - [DataMember(Name = "userStatus", EmitDefaultValue = false)] + [JsonPropertyName("userStatus")] public int UserStatus { get; set; } /// /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. /// /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [DataMember(Name = "objectWithNoDeclaredProps", EmitDefaultValue = false)] + [JsonPropertyName("objectWithNoDeclaredProps")] public Object ObjectWithNoDeclaredProps { get; set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. - [DataMember(Name = "objectWithNoDeclaredPropsNullable", EmitDefaultValue = true)] + [JsonPropertyName("objectWithNoDeclaredPropsNullable")] public Object ObjectWithNoDeclaredPropsNullable { get; set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - [DataMember(Name = "anyTypeProp", EmitDefaultValue = true)] + [JsonPropertyName("anyTypeProp")] public Object AnyTypeProp { get; set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - [DataMember(Name = "anyTypePropNullable", EmitDefaultValue = true)] + [JsonPropertyName("anyTypePropNullable")] public Object AnyTypePropNullable { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -172,15 +170,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs index 2eb7fa28c7f..632ae576572 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Whale.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,58 +29,46 @@ namespace Org.OpenAPITools.Model /// /// Whale /// - [DataContract(Name = "whale")] public partial class Whale : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Whale() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// hasBaleen. - /// hasTeeth. + /// className (required) + /// hasBaleen + /// hasTeeth public Whale(string className, bool hasBaleen = default, bool hasTeeth = default) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Whale and cannot be null"); - } - this.ClassName = className; - this.HasBaleen = hasBaleen; - this.HasTeeth = hasTeeth; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for Whale and cannot be null."); + ClassName = className; + HasBaleen = hasBaleen; + HasTeeth = hasTeeth; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets HasBaleen /// - [DataMember(Name = "hasBaleen", EmitDefaultValue = true)] + [JsonPropertyName("hasBaleen")] public bool HasBaleen { get; set; } /// /// Gets or Sets HasTeeth /// - [DataMember(Name = "hasTeeth", EmitDefaultValue = true)] + [JsonPropertyName("hasTeeth")] public bool HasTeeth { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -98,15 +86,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs index ddb4196e854..2bb9c1d7c5b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,24 @@ namespace Org.OpenAPITools.Model /// /// Zebra /// - [DataContract(Name = "zebra")] public partial class Zebra : Dictionary, IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// className (required) + /// type + public Zebra(string className, TypeEnum type = default) + { + if (className == null) + throw new ArgumentNullException("className is a required property for Zebra and cannot be null."); + ClassName = className; + Type = type; + } + /// /// Defines Type /// - [JsonConverter(typeof(StringEnumConverter))] public enum TypeEnum { /// @@ -58,47 +69,23 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets Type /// - [DataMember(Name = "type", EmitDefaultValue = false)] + [JsonPropertyName("type")] public TypeEnum Type { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected Zebra() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// type. - public Zebra(string className, TypeEnum type = default) : base() - { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Zebra and cannot be null"); - } - this.ClassName = className; - this.Type = type; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -116,15 +103,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj index d3e3c613615..a14df8ce387 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -21,8 +21,6 @@ - - diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES index 2f141a0eb47..2a9214cd14b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES @@ -108,12 +108,11 @@ src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs src/Org.OpenAPITools/Client/IApi.cs src/Org.OpenAPITools/Client/OAuthToken.cs -src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs +src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs src/Org.OpenAPITools/Client/RateLimitProvider`1.cs src/Org.OpenAPITools/Client/TokenBase.cs src/Org.OpenAPITools/Client/TokenContainer`1.cs src/Org.OpenAPITools/Client/TokenProvider`1.cs -src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs src/Org.OpenAPITools/Model/Animal.cs src/Org.OpenAPITools/Model/ApiResponse.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Cat.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Cat.md index 310a5e6575e..16db4a55bd3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Cat.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Cat.md @@ -6,7 +6,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | **Color** | **string** | | [optional] [default to "red"] -**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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md index 48a3c7fd38d..dae2ff76026 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**PetType** | **string** | | [default to PetTypeEnum.ChildCat] -**Name** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ComplexQuadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ComplexQuadrilateral.md index 14da4bba22e..0926bb55e71 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ComplexQuadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ComplexQuadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Dog.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Dog.md index 70cdc80e83e..b1e39dcf07c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Dog.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Dog.md @@ -6,7 +6,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | **Color** | **string** | | [optional] [default to "red"] -**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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/EquilateralTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/EquilateralTriangle.md index 8360b5c16a5..ddc9885fe56 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/EquilateralTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/EquilateralTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Fruit.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Fruit.md index cb095b74f32..b3bee18f7ba 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Fruit.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Fruit.md @@ -5,9 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Color** | **string** | | [optional] -**Cultivar** | **string** | | [optional] -**Origin** | **string** | | [optional] -**LengthCm** | **decimal** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/FruitReq.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/FruitReq.md index 5217febc9b6..38ab0c1a6ca 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/FruitReq.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/FruitReq.md @@ -4,10 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Cultivar** | **string** | | -**LengthCm** | **decimal** | | -**Mealy** | **bool** | | [optional] -**Sweet** | **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) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/GmFruit.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/GmFruit.md index 049f6f5c157..584c4fd323d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/GmFruit.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/GmFruit.md @@ -5,9 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Color** | **string** | | [optional] -**Cultivar** | **string** | | [optional] -**Origin** | **string** | | [optional] -**LengthCm** | **decimal** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/IsoscelesTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/IsoscelesTriangle.md index 07c62ac9338..ed481ad1448 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/IsoscelesTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/IsoscelesTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Mammal.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Mammal.md index 82a8ca6027b..5546632e4d6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Mammal.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Mammal.md @@ -4,10 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ClassName** | **string** | | -**HasBaleen** | **bool** | | [optional] -**HasTeeth** | **bool** | | [optional] -**Type** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Name.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Name.md index 1fbf5dd5e8b..2ee782c0c54 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Name.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Name.md @@ -5,7 +5,7 @@ Model for testing model name same as property name Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Name** | **int** | | +**NameProperty** | **int** | | **SnakeCase** | **int** | | [optional] [readonly] **Property** | **string** | | [optional] **_123Number** | **int** | | [optional] [readonly] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableShape.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableShape.md index 570ef48f98f..0caa1aa5b9d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableShape.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/NullableShape.md @@ -5,8 +5,6 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Pig.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Pig.md index fd7bb9359ac..83e58b6098d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Pig.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Pig.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ClassName** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Quadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Quadrilateral.md index bb7507997a2..4fd16b32ea5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Quadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Quadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Return.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Return.md index a1dadccc421..e11cdae8db9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Return.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Return.md @@ -5,7 +5,7 @@ Model for testing reserved words Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Return** | **int** | | [optional] +**ReturnProperty** | **int** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ScaleneTriangle.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ScaleneTriangle.md index d3f15354bcc..a01c2edc068 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ScaleneTriangle.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ScaleneTriangle.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**TriangleType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Shape.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Shape.md index 5627c30bbfc..2ec279cef3c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Shape.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/Shape.md @@ -4,7 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | **QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ShapeOrNull.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ShapeOrNull.md index a348f4f8bff..056fcbfdbdd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ShapeOrNull.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/ShapeOrNull.md @@ -5,7 +5,6 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema > Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | **QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SimpleQuadrilateral.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SimpleQuadrilateral.md index a36c9957a60..3bc21009b7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SimpleQuadrilateral.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SimpleQuadrilateral.md @@ -4,8 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ShapeType** | **string** | | -**QuadrilateralType** | **string** | | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SpecialModelName.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SpecialModelName.md index fa146367bde..662fa6f4a38 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SpecialModelName.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/SpecialModelName.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **SpecialPropertyName** | **long** | | [optional] -**_SpecialModelName** | **string** | | [optional] +**SpecialModelNameProperty** | **string** | | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CatTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CatTests.cs index 701ba760282..9c3c48ffefe 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CatTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CatTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Declawed' - /// - [Fact] - public void DeclawedTest() - { - // TODO unit test for the property 'Declawed' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs index 6ce48e601e4..621877aa973 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/CategoryTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Id' - /// - [Fact] - public void IdTest() - { - // TODO unit test for the property 'Id' - } /// /// Test the property 'Name' /// @@ -72,6 +64,14 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Name' } + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs index 68566fd8d56..0fe3ebfa06e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Name' - /// - [Fact] - public void NameTest() - { - // TODO unit test for the property 'Name' - } - /// - /// Test the property 'PetType' - /// - [Fact] - public void PetTypeTest() - { - // TODO unit test for the property 'PetType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs index b3529280c8d..6c50fe7aab5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DogTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DogTests.cs index 992f93a51fd..bf906f01bc6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DogTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DogTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Breed' - /// - [Fact] - public void BreedTest() - { - // TODO unit test for the property 'Breed' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs index 4f81b845d49..a22c39ca845 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'EnumString' - /// - [Fact] - public void EnumStringTest() - { - // TODO unit test for the property 'EnumString' - } /// /// Test the property 'EnumStringRequired' /// @@ -73,6 +65,14 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'EnumStringRequired' } /// + /// Test the property 'EnumString' + /// + [Fact] + public void EnumStringTest() + { + // TODO unit test for the property 'EnumString' + } + /// /// Test the property 'EnumInteger' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs index 4663cb667de..9ca755c4b07 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs index 97332800e9a..707847bbcd1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs @@ -56,6 +56,38 @@ namespace Org.OpenAPITools.Test.Model } + /// + /// Test the property 'Number' + /// + [Fact] + public void NumberTest() + { + // TODO unit test for the property 'Number' + } + /// + /// Test the property 'Byte' + /// + [Fact] + public void ByteTest() + { + // TODO unit test for the property 'Byte' + } + /// + /// Test the property 'Date' + /// + [Fact] + public void DateTest() + { + // TODO unit test for the property 'Date' + } + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } /// /// Test the property 'Integer' /// @@ -81,14 +113,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Int64' } /// - /// Test the property 'Number' - /// - [Fact] - public void NumberTest() - { - // TODO unit test for the property 'Number' - } - /// /// Test the property 'Float' /// [Fact] @@ -121,14 +145,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'String' } /// - /// Test the property 'Byte' - /// - [Fact] - public void ByteTest() - { - // TODO unit test for the property 'Byte' - } - /// /// Test the property 'Binary' /// [Fact] @@ -137,14 +153,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Binary' } /// - /// Test the property 'Date' - /// - [Fact] - public void DateTest() - { - // TODO unit test for the property 'Date' - } - /// /// Test the property 'DateTime' /// [Fact] @@ -161,14 +169,6 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'Uuid' } /// - /// Test the property 'Password' - /// - [Fact] - public void PasswordTest() - { - // TODO unit test for the property 'Password' - } - /// /// Test the property 'PatternWithDigits' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs index 5ea9e3ffc1d..3a0b55b93e3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs @@ -56,38 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Mealy' - /// - [Fact] - public void MealyTest() - { - // TODO unit test for the property 'Mealy' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } - /// - /// Test the property 'Sweet' - /// - [Fact] - public void SweetTest() - { - // TODO unit test for the property 'Sweet' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs index 91e069bb42f..ddc424d56ea 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -64,30 +64,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Color' } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Origin' - /// - [Fact] - public void OriginTest() - { - // TODO unit test for the property 'Origin' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs index 08fb0e07a1c..cbd35f9173c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs @@ -64,30 +64,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'Color' } - /// - /// Test the property 'Cultivar' - /// - [Fact] - public void CultivarTest() - { - // TODO unit test for the property 'Cultivar' - } - /// - /// Test the property 'Origin' - /// - [Fact] - public void OriginTest() - { - // TODO unit test for the property 'Origin' - } - /// - /// Test the property 'LengthCm' - /// - [Fact] - public void LengthCmTest() - { - // TODO unit test for the property 'LengthCm' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs index 755c417cc54..8e0dae93420 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs index 7b46cbf0645..6477ab950fa 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MammalTests.cs @@ -56,38 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'HasBaleen' - /// - [Fact] - public void HasBaleenTest() - { - // TODO unit test for the property 'HasBaleen' - } - /// - /// Test the property 'HasTeeth' - /// - [Fact] - public void HasTeethTest() - { - // TODO unit test for the property 'HasTeeth' - } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } - /// - /// Test the property 'Type' - /// - [Fact] - public void TypeTest() - { - // TODO unit test for the property 'Type' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs index 5662f91d6e6..8202ef63914 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PetTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PetTests.cs index 154e66f8dfc..28ea4d8478d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PetTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PetTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Id' - /// - [Fact] - public void IdTest() - { - // TODO unit test for the property 'Id' - } - /// - /// Test the property 'Category' - /// - [Fact] - public void CategoryTest() - { - // TODO unit test for the property 'Category' - } /// /// Test the property 'Name' /// @@ -89,6 +73,22 @@ namespace Org.OpenAPITools.Test.Model // TODO unit test for the property 'PhotoUrls' } /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + /// + /// Test the property 'Category' + /// + [Fact] + public void CategoryTest() + { + // TODO unit test for the property 'Category' + } + /// /// Test the property 'Tags' /// [Fact] diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PigTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PigTests.cs index 55cf2189046..a66befe8f58 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PigTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/PigTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs index 26826681a47..3d62673d093 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs index 04cb9f1ab6b..018dffb5964 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'TriangleType' - /// - [Fact] - public void TriangleTypeTest() - { - // TODO unit test for the property 'TriangleType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs index d0af114157c..ef564357648 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } /// /// Test the property 'QuadrilateralType' /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs index b01bd531f85..783a9657ed4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ShapeTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } /// /// Test the property 'QuadrilateralType' /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs index 6648e980928..3bcd65e792d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs @@ -56,22 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'ShapeType' - /// - [Fact] - public void ShapeTypeTest() - { - // TODO unit test for the property 'ShapeType' - } - /// - /// Test the property 'QuadrilateralType' - /// - [Fact] - public void QuadrilateralTypeTest() - { - // TODO unit test for the property 'QuadrilateralType' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs index 09610791943..9b82c29c8fd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/WhaleTests.cs @@ -56,6 +56,14 @@ namespace Org.OpenAPITools.Test.Model } + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } /// /// Test the property 'HasBaleen' /// @@ -72,14 +80,6 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'HasTeeth' } - /// - /// Test the property 'ClassName' - /// - [Fact] - public void ClassNameTest() - { - // TODO unit test for the property 'ClassName' - } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs index f44e9213140..39e0561fe0f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/ZebraTests.cs @@ -56,14 +56,6 @@ namespace Org.OpenAPITools.Test.Model } - /// - /// Test the property 'Type' - /// - [Fact] - public void TypeTest() - { - // TODO unit test for the property 'Type' - } /// /// Test the property 'ClassName' /// @@ -72,6 +64,14 @@ namespace Org.OpenAPITools.Test.Model { // TODO unit test for the property 'ClassName' } + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index ddd804975cd..eb5d9fdbd58 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -186,7 +186,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -208,7 +209,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("PATCH"); + request.Method = new HttpMethod("PATCH"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -231,7 +232,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs index 0ad710171be..4d0da49464b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -182,7 +182,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -205,7 +205,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs index b777bb7a18b..5d639eaf671 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -578,7 +578,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -601,7 +601,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -654,7 +654,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -676,7 +677,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -699,7 +700,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -773,7 +774,8 @@ namespace Org.OpenAPITools.Api if ((outerComposite as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(outerComposite, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(outerComposite, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(outerComposite, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -795,7 +797,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -818,7 +820,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -871,7 +873,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -893,7 +896,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -916,7 +919,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -969,7 +972,8 @@ namespace Org.OpenAPITools.Api if ((body as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(body, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -991,7 +995,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1014,7 +1018,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1093,7 +1097,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1116,7 +1120,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1197,7 +1201,8 @@ namespace Org.OpenAPITools.Api if ((fileSchemaTestClass as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(fileSchemaTestClass, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(fileSchemaTestClass, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(fileSchemaTestClass, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1210,7 +1215,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("PUT"); + request.Method = new HttpMethod("PUT"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1233,7 +1238,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1326,7 +1331,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1339,7 +1345,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("PUT"); + request.Method = new HttpMethod("PUT"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1362,7 +1368,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1443,7 +1449,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1465,7 +1472,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("PATCH"); + request.Method = new HttpMethod("PATCH"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1488,7 +1495,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1673,7 +1680,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1696,7 +1703,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1837,7 +1844,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1860,7 +1867,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1978,7 +1985,7 @@ namespace Org.OpenAPITools.Api bearerToken.UseInHeader(request, ""); - request.Method = new HttpMethod("DELETE"); + request.Method = new HttpMethod("DELETE"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2001,7 +2008,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -2085,7 +2092,8 @@ namespace Org.OpenAPITools.Api if ((requestBody as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(requestBody, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -2098,7 +2106,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2121,7 +2129,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2228,7 +2236,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2251,7 +2259,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -2365,7 +2373,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = new HttpMethod("PUT"); + request.Method = new HttpMethod("PUT"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -2388,7 +2396,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 9181cf2a8f4..2d05b24527c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -188,7 +188,8 @@ namespace Org.OpenAPITools.Api if ((modelClient as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(modelClient, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(modelClient, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -220,7 +221,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("PATCH"); + request.Method = new HttpMethod("PATCH"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -243,7 +244,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs index a2296da32f7..da1532d4f16 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs @@ -392,7 +392,8 @@ namespace Org.OpenAPITools.Api if ((pet as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(pet, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -422,7 +423,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -445,7 +446,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -543,7 +544,7 @@ namespace Org.OpenAPITools.Api oauthToken.UseInHeader(request, ""); - request.Method = new HttpMethod("DELETE"); + request.Method = new HttpMethod("DELETE"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -566,7 +567,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -681,7 +682,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -704,7 +705,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -822,7 +823,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -845,7 +846,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -947,7 +948,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -970,7 +971,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1054,7 +1055,8 @@ namespace Org.OpenAPITools.Api if ((pet as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(pet, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(pet, ClientUtils.JsonSerializerOptions)); List tokens = new List(); @@ -1084,7 +1086,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("PUT"); + request.Method = new HttpMethod("PUT"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1107,7 +1109,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1228,7 +1230,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1251,7 +1253,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1378,7 +1380,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1401,7 +1403,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -1530,7 +1532,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1553,7 +1555,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs index f6f88257047..01955918901 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs @@ -256,7 +256,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = new HttpMethod("DELETE"); + request.Method = new HttpMethod("DELETE"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -279,7 +279,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -346,7 +346,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -369,7 +369,7 @@ namespace Org.OpenAPITools.Api ApiResponse> apiResponse = new ApiResponse>(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject>(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize>(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); else if (apiResponse.StatusCode == (HttpStatusCode) 429) foreach(TokenBase token in tokens) token.BeginRateLimit(); @@ -460,7 +460,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -483,7 +483,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -564,7 +564,8 @@ namespace Org.OpenAPITools.Api if ((order as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(order, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(order, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(order, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -587,7 +588,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -610,7 +611,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs index a8a10871b53..6f1ca07ad96 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs @@ -356,7 +356,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -369,7 +370,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -392,7 +393,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -473,7 +474,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -486,7 +488,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -509,7 +511,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -590,7 +592,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -603,7 +606,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("POST"); + request.Method = new HttpMethod("POST"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -626,7 +629,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -707,7 +710,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = new HttpMethod("DELETE"); + request.Method = new HttpMethod("DELETE"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -730,7 +733,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -821,7 +824,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -844,7 +847,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -925,7 +928,7 @@ namespace Org.OpenAPITools.Api if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -948,7 +951,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1018,7 +1021,7 @@ namespace Org.OpenAPITools.Api request.RequestUri = uriBuilder.Uri; - request.Method = new HttpMethod("GET"); + request.Method = new HttpMethod("GET"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1041,7 +1044,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } @@ -1129,7 +1132,8 @@ namespace Org.OpenAPITools.Api if ((user as object) is System.IO.Stream stream) request.Content = new StreamContent(stream); else - request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + // request.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(user, ClientUtils.JsonSerializerSettings)); + request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(user, ClientUtils.JsonSerializerOptions)); request.RequestUri = uriBuilder.Uri; @@ -1142,7 +1146,7 @@ namespace Org.OpenAPITools.Api if (contentType != null) request.Content.Headers.Add("ContentType", contentType); - request.Method = new HttpMethod("PUT"); + request.Method = new HttpMethod("PUT"); using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) { @@ -1165,7 +1169,7 @@ namespace Org.OpenAPITools.Api ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); if (apiResponse.IsSuccessStatusCode) - apiResponse.Content = Newtonsoft.Json.JsonConvert.DeserializeObject(apiResponse.RawContent, ClientUtils.JsonSerializerSettings); + apiResponse.Content = System.Text.Json.JsonSerializer.Deserialize(apiResponse.RawContent, ClientUtils.JsonSerializerOptions); return apiResponse; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs index 04e92f7b19e..27048d5b162 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -13,7 +13,6 @@ using System; using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; namespace Org.OpenAPITools.Client { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs index 7a500bb0896..046eefc2fdf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -52,21 +52,53 @@ namespace Org.OpenAPITools.Client public delegate void EventHandler(object sender, T e) where T : EventArgs; /// - /// Custom JSON serializer + /// Returns true when deserialization succeeds. /// - public static Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get; set; } = new Newtonsoft.Json.JsonSerializerSettings + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, System.Text.Json.JsonSerializerOptions options, out T result) { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore, - ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver + try { - NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } + result = System.Text.Json.JsonSerializer.Deserialize(json, options); + return result != null; } - }; + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, out T result) + { + try + { + result = System.Text.Json.JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Json serializer options + /// + public static System.Text.Json.JsonSerializerOptions JsonSerializerOptions { get; set; } = new System.Text.Json.JsonSerializerOptions(); /// /// Sanitize filename by removing the path diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs index 7581b399840..832ccef650e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Net.Http; using Microsoft.Extensions.DependencyInjection; using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; namespace Org.OpenAPITools.Client { @@ -89,6 +90,26 @@ namespace Org.OpenAPITools.Client public HostConfiguration AddApiHttpClients( Action client = null, Action builder = null) { + ClientUtils.JsonSerializerOptions.Converters.Add(new OpenAPIDateJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new CatJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ChildCatJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new DogJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new EquilateralTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new FruitJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new FruitReqJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new GmFruitJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new IsoscelesTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new MammalJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new NullableShapeJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new PigJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new QuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ScaleneTriangleJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ShapeJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new ShapeOrNullJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new SimpleQuadrilateralJsonConverter()); + ClientUtils.JsonSerializerOptions.Converters.Add(new TriangleJsonConverter()); + AddApiHttpClients(client, builder); return this; @@ -99,9 +120,9 @@ namespace Org.OpenAPITools.Client /// /// /// - public HostConfiguration ConfigureJsonOptions(Action options) + public HostConfiguration ConfigureJsonOptions(Action options) { - options(Client.ClientUtils.JsonSerializerSettings); + options(Client.ClientUtils.JsonSerializerOptions); return this; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs deleted file mode 100644 index a5253e58201..00000000000 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs +++ /dev/null @@ -1,29 +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 Newtonsoft.Json.Converters; - -namespace Org.OpenAPITools.Client -{ - /// - /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 - /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types - /// - public class OpenAPIDateConverter : IsoDateTimeConverter - { - /// - /// Initializes a new instance of the class. - /// - public OpenAPIDateConverter() - { - // full-date = date-fullyear "-" date-month "-" date-mday - DateTimeFormat = "yyyy-MM-dd"; - } - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs new file mode 100644 index 00000000000..a280076c5a9 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/OpenAPIDateJsonConverter.cs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class OpenAPIDateJsonConverter : JsonConverter + { + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => + DateTime.ParseExact(reader.GetString(), "yyyy-MM-dd", CultureInfo.InvariantCulture); + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs deleted file mode 100644 index b3fc4c3c7a3..00000000000 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AbstractOpenAPISchema.cs +++ /dev/null @@ -1,76 +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 System; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace Org.OpenAPITools.Model -{ - /// - /// Abstract base class for oneOf, anyOf schemas in the OpenAPI specification - /// - public abstract partial class AbstractOpenAPISchema - { - /// - /// Custom JSON serializer - /// - static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Error, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Custom JSON serializer for objects with additional properties - /// - static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings - { - // OpenAPI generated types generally hide default constructors. - ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, - MissingMemberHandling = MissingMemberHandling.Ignore, - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - } - }; - - /// - /// Gets or Sets the actual instance - /// - public abstract Object ActualInstance { get; set; } - - /// - /// Gets or Sets IsNullable to indicate whether the instance is nullable - /// - public bool IsNullable { get; protected set; } - - /// - /// Gets or Sets the schema type, which can be either `oneOf` or `anyOf` - /// - public string SchemaType { get; protected set; } - - /// - /// Converts the instance into JSON string. - /// - public abstract string ToJson(); - } -} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 14d0e92eaa2..69ad870ae7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,87 +29,85 @@ namespace Org.OpenAPITools.Model /// /// AdditionalPropertiesClass /// - [DataContract(Name = "AdditionalPropertiesClass")] public partial class AdditionalPropertiesClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// mapProperty. - /// mapOfMapProperty. - /// anytype1. - /// mapWithUndeclaredPropertiesAnytype1. - /// mapWithUndeclaredPropertiesAnytype2. - /// mapWithUndeclaredPropertiesAnytype3. - /// an object with no declared properties and no undeclared properties, hence it's an empty map.. - /// mapWithUndeclaredPropertiesString. + /// mapProperty + /// mapOfMapProperty + /// anytype1 + /// mapWithUndeclaredPropertiesAnytype1 + /// mapWithUndeclaredPropertiesAnytype2 + /// mapWithUndeclaredPropertiesAnytype3 + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// mapWithUndeclaredPropertiesString public AdditionalPropertiesClass(Dictionary mapProperty = default, Dictionary> mapOfMapProperty = default, Object anytype1 = default, Object mapWithUndeclaredPropertiesAnytype1 = default, Object mapWithUndeclaredPropertiesAnytype2 = default, Dictionary mapWithUndeclaredPropertiesAnytype3 = default, Object emptyMap = default, Dictionary mapWithUndeclaredPropertiesString = default) { - this.MapProperty = mapProperty; - this.MapOfMapProperty = mapOfMapProperty; - this.Anytype1 = anytype1; - this.MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; - this.MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; - this.MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; - this.EmptyMap = emptyMap; - this.MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; - this.AdditionalProperties = new Dictionary(); + MapProperty = mapProperty; + MapOfMapProperty = mapOfMapProperty; + Anytype1 = anytype1; + MapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3; + EmptyMap = emptyMap; + MapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString; } /// /// Gets or Sets MapProperty /// - [DataMember(Name = "map_property", EmitDefaultValue = false)] + [JsonPropertyName("map_property")] public Dictionary MapProperty { get; set; } /// /// Gets or Sets MapOfMapProperty /// - [DataMember(Name = "map_of_map_property", EmitDefaultValue = false)] + [JsonPropertyName("map_of_map_property")] public Dictionary> MapOfMapProperty { get; set; } /// /// Gets or Sets Anytype1 /// - [DataMember(Name = "anytype_1", EmitDefaultValue = true)] + [JsonPropertyName("anytype_1")] public Object Anytype1 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_1", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] public Object MapWithUndeclaredPropertiesAnytype1 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_2", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] public Object MapWithUndeclaredPropertiesAnytype2 { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 /// - [DataMember(Name = "map_with_undeclared_properties_anytype_3", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] public Dictionary MapWithUndeclaredPropertiesAnytype3 { get; set; } /// /// an object with no declared properties and no undeclared properties, hence it's an empty map. /// /// an object with no declared properties and no undeclared properties, hence it's an empty map. - [DataMember(Name = "empty_map", EmitDefaultValue = false)] + [JsonPropertyName("empty_map")] public Object EmptyMap { get; set; } /// /// Gets or Sets MapWithUndeclaredPropertiesString /// - [DataMember(Name = "map_with_undeclared_properties_string", EmitDefaultValue = false)] + [JsonPropertyName("map_with_undeclared_properties_string")] public Dictionary MapWithUndeclaredPropertiesString { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -132,15 +130,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs index 73eef470406..38f3e74da92 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Animal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,54 +29,38 @@ namespace Org.OpenAPITools.Model /// /// Animal /// - [DataContract(Name = "Animal")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - [JsonSubtypes.KnownSubType(typeof(Cat), "Cat")] - [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] public partial class Animal : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Animal() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// color (default to "red"). + /// className (required) + /// color (default to "red") public Animal(string className, string color = "red") { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Animal and cannot be null"); - } - this.ClassName = className; - // use default value if no "color" provided - this.Color = color ?? "red"; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for Animal and cannot be null."); + ClassName = className; + Color = color; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets Color /// - [DataMember(Name = "color", EmitDefaultValue = false)] + [JsonPropertyName("color")] public string Color { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -94,15 +77,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs index e5fee65b6bc..5c60a85eda5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// ApiResponse /// - [DataContract(Name = "ApiResponse")] public partial class ApiResponse : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// code. - /// type. - /// message. + /// code + /// type + /// message public ApiResponse(int code = default, string type = default, string message = default) { - this.Code = code; - this.Type = type; - this.Message = message; - this.AdditionalProperties = new Dictionary(); + Code = code; + Type = type; + Message = message; } /// /// Gets or Sets Code /// - [DataMember(Name = "code", EmitDefaultValue = false)] + [JsonPropertyName("code")] public int Code { get; set; } /// /// Gets or Sets Type /// - [DataMember(Name = "type", EmitDefaultValue = false)] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Gets or Sets Message /// - [DataMember(Name = "message", EmitDefaultValue = false)] + [JsonPropertyName("message")] public string Message { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs index adf8438c591..849a4274934 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Apple.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Apple /// - [DataContract(Name = "apple")] public partial class Apple : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// cultivar. - /// origin. + /// cultivar + /// origin public Apple(string cultivar = default, string origin = default) { - this.Cultivar = cultivar; - this.Origin = origin; - this.AdditionalProperties = new Dictionary(); + Cultivar = cultivar; + Origin = origin; } /// /// Gets or Sets Cultivar /// - [DataMember(Name = "cultivar", EmitDefaultValue = false)] + [JsonPropertyName("cultivar")] public string Cultivar { get; set; } /// /// Gets or Sets Origin /// - [DataMember(Name = "origin", EmitDefaultValue = false)] + [JsonPropertyName("origin")] public string Origin { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs index 28ce313d0b6..75d65e7ee8b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/AppleReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,39 +29,31 @@ namespace Org.OpenAPITools.Model /// /// AppleReq /// - [DataContract(Name = "appleReq")] public partial class AppleReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected AppleReq() { } - /// - /// Initializes a new instance of the class. - /// - /// cultivar (required). - /// mealy. + /// cultivar (required) + /// mealy public AppleReq(string cultivar, bool mealy = default) { - // to ensure "cultivar" is required (not null) - if (cultivar == null) { - throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null"); - } - this.Cultivar = cultivar; - this.Mealy = mealy; + if (cultivar == null) + throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null."); + Cultivar = cultivar; + Mealy = mealy; } /// /// Gets or Sets Cultivar /// - [DataMember(Name = "cultivar", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("cultivar")] public string Cultivar { get; set; } /// /// Gets or Sets Mealy /// - [DataMember(Name = "mealy", EmitDefaultValue = true)] + [JsonPropertyName("mealy")] public bool Mealy { get; set; } /// @@ -78,15 +70,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index a342794fafa..869900fa9fb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ArrayOfArrayOfNumberOnly /// - [DataContract(Name = "ArrayOfArrayOfNumberOnly")] public partial class ArrayOfArrayOfNumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayArrayNumber. + /// arrayArrayNumber public ArrayOfArrayOfNumberOnly(List> arrayArrayNumber = default) { - this.ArrayArrayNumber = arrayArrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayArrayNumber = arrayArrayNumber; } /// /// Gets or Sets ArrayArrayNumber /// - [DataMember(Name = "ArrayArrayNumber", EmitDefaultValue = false)] + [JsonPropertyName("ArrayArrayNumber")] public List> ArrayArrayNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 349fc7ef5a1..b34ecd53520 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ArrayOfNumberOnly /// - [DataContract(Name = "ArrayOfNumberOnly")] public partial class ArrayOfNumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayNumber. + /// arrayNumber public ArrayOfNumberOnly(List arrayNumber = default) { - this.ArrayNumber = arrayNumber; - this.AdditionalProperties = new Dictionary(); + ArrayNumber = arrayNumber; } /// /// Gets or Sets ArrayNumber /// - [DataMember(Name = "ArrayNumber", EmitDefaultValue = false)] + [JsonPropertyName("ArrayNumber")] public List ArrayNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs index b7f6f3cd177..2b02f9ff2b8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// ArrayTest /// - [DataContract(Name = "ArrayTest")] public partial class ArrayTest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// arrayOfString. - /// arrayArrayOfInteger. - /// arrayArrayOfModel. + /// arrayOfString + /// arrayArrayOfInteger + /// arrayArrayOfModel public ArrayTest(List arrayOfString = default, List> arrayArrayOfInteger = default, List> arrayArrayOfModel = default) { - this.ArrayOfString = arrayOfString; - this.ArrayArrayOfInteger = arrayArrayOfInteger; - this.ArrayArrayOfModel = arrayArrayOfModel; - this.AdditionalProperties = new Dictionary(); + ArrayOfString = arrayOfString; + ArrayArrayOfInteger = arrayArrayOfInteger; + ArrayArrayOfModel = arrayArrayOfModel; } /// /// Gets or Sets ArrayOfString /// - [DataMember(Name = "array_of_string", EmitDefaultValue = false)] + [JsonPropertyName("array_of_string")] public List ArrayOfString { get; set; } /// /// Gets or Sets ArrayArrayOfInteger /// - [DataMember(Name = "array_array_of_integer", EmitDefaultValue = false)] + [JsonPropertyName("array_array_of_integer")] public List> ArrayArrayOfInteger { get; set; } /// /// Gets or Sets ArrayArrayOfModel /// - [DataMember(Name = "array_array_of_model", EmitDefaultValue = false)] + [JsonPropertyName("array_array_of_model")] public List> ArrayArrayOfModel { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs index bb1962fc2b2..49a73481652 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Banana.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Banana /// - [DataContract(Name = "banana")] public partial class Banana : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// lengthCm. + /// lengthCm public Banana(decimal lengthCm = default) { - this.LengthCm = lengthCm; - this.AdditionalProperties = new Dictionary(); + LengthCm = lengthCm; } /// /// Gets or Sets LengthCm /// - [DataMember(Name = "lengthCm", EmitDefaultValue = false)] + [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs index 812c91b012f..2dabe4998e8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BananaReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,35 +29,31 @@ namespace Org.OpenAPITools.Model /// /// BananaReq /// - [DataContract(Name = "bananaReq")] public partial class BananaReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected BananaReq() { } - /// - /// Initializes a new instance of the class. - /// - /// lengthCm (required). - /// sweet. + /// lengthCm (required) + /// sweet public BananaReq(decimal lengthCm, bool sweet = default) { - this.LengthCm = lengthCm; - this.Sweet = sweet; + if (lengthCm == null) + throw new ArgumentNullException("lengthCm is a required property for BananaReq and cannot be null."); + LengthCm = lengthCm; + Sweet = sweet; } /// /// Gets or Sets LengthCm /// - [DataMember(Name = "lengthCm", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("lengthCm")] public decimal LengthCm { get; set; } /// /// Gets or Sets Sweet /// - [DataMember(Name = "sweet", EmitDefaultValue = true)] + [JsonPropertyName("sweet")] public bool Sweet { get; set; } /// @@ -74,15 +70,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs index 0706a3e8196..ab648f2b7a8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/BasquePig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// BasquePig /// - [DataContract(Name = "BasquePig")] public partial class BasquePig : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected BasquePig() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). + /// className (required) public BasquePig(string className) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for BasquePig and cannot be null"); - } - this.ClassName = className; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for BasquePig and cannot be null."); + ClassName = className; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs index 377781227e6..fef9aaffdd1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Capitalization.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,71 +29,69 @@ namespace Org.OpenAPITools.Model /// /// Capitalization /// - [DataContract(Name = "Capitalization")] public partial class Capitalization : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// smallCamel. - /// capitalCamel. - /// smallSnake. - /// capitalSnake. - /// sCAETHFlowPoints. - /// Name of the pet . + /// smallCamel + /// capitalCamel + /// smallSnake + /// capitalSnake + /// sCAETHFlowPoints + /// Name of the pet public Capitalization(string smallCamel = default, string capitalCamel = default, string smallSnake = default, string capitalSnake = default, string sCAETHFlowPoints = default, string aTTNAME = default) { - this.SmallCamel = smallCamel; - this.CapitalCamel = capitalCamel; - this.SmallSnake = smallSnake; - this.CapitalSnake = capitalSnake; - this.SCAETHFlowPoints = sCAETHFlowPoints; - this.ATT_NAME = aTTNAME; - this.AdditionalProperties = new Dictionary(); + SmallCamel = smallCamel; + CapitalCamel = capitalCamel; + SmallSnake = smallSnake; + CapitalSnake = capitalSnake; + SCAETHFlowPoints = sCAETHFlowPoints; + ATT_NAME = aTTNAME; } /// /// Gets or Sets SmallCamel /// - [DataMember(Name = "smallCamel", EmitDefaultValue = false)] + [JsonPropertyName("smallCamel")] public string SmallCamel { get; set; } /// /// Gets or Sets CapitalCamel /// - [DataMember(Name = "CapitalCamel", EmitDefaultValue = false)] + [JsonPropertyName("CapitalCamel")] public string CapitalCamel { get; set; } /// /// Gets or Sets SmallSnake /// - [DataMember(Name = "small_Snake", EmitDefaultValue = false)] + [JsonPropertyName("small_Snake")] public string SmallSnake { get; set; } /// /// Gets or Sets CapitalSnake /// - [DataMember(Name = "Capital_Snake", EmitDefaultValue = false)] + [JsonPropertyName("Capital_Snake")] public string CapitalSnake { get; set; } /// /// Gets or Sets SCAETHFlowPoints /// - [DataMember(Name = "SCA_ETH_Flow_Points", EmitDefaultValue = false)] + [JsonPropertyName("SCA_ETH_Flow_Points")] public string SCAETHFlowPoints { get; set; } /// /// Name of the pet /// /// Name of the pet - [DataMember(Name = "ATT_NAME", EmitDefaultValue = false)] + [JsonPropertyName("ATT_NAME")] public string ATT_NAME { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,15 +112,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs index d7c0634c555..f035df364dc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Cat.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,41 +29,23 @@ namespace Org.OpenAPITools.Model /// /// Cat /// - [DataContract(Name = "Cat")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - public partial class Cat : Animal, IEquatable, IValidatableObject + public partial class Cat : Animal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Cat() + /// catAllOf + /// className (required) + /// color (default to "red") + public Cat(CatAllOf catAllOf, string className, string color = "red") : base(className, color) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required) (default to "Cat"). - /// declawed. - /// color (default to "red"). - public Cat(string className = "Cat", bool declawed = default, string color = "red") : base(className, color) - { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + CatAllOf = catAllOf; } /// - /// Gets or Sets Declawed + /// Gets or Sets Cat /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] - public bool Declawed { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public CatAllOf CatAllOf { get; set; } /// /// Returns the string presentation of the object @@ -75,21 +56,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class Cat {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Declawed: ").Append(Declawed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -119,38 +89,76 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 59) + this.Declawed.GetHashCode(); - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type Cat + /// + public class CatJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Cat).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override Cat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader catAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref catAllOfReader, options, out CatAllOf catAllOf); + string className = default; + string color = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "className": + className = reader.GetString(); + break; + case "color": + color = reader.GetString(); + break; + } + } + } + + return new Cat(catAllOf, className, color); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/CatAllOf.cs index 5aa226e03f6..894ca6b9d60 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/CatAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// CatAllOf /// - [DataContract(Name = "Cat_allOf")] public partial class CatAllOf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// declawed. + /// declawed public CatAllOf(bool declawed = default) { - this.Declawed = declawed; - this.AdditionalProperties = new Dictionary(); + Declawed = declawed; } /// /// Gets or Sets Declawed /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] + [JsonPropertyName("declawed")] public bool Declawed { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs index 8cd4fe7e9ac..04e34d0ee2e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Category.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,50 +29,38 @@ namespace Org.OpenAPITools.Model /// /// Category /// - [DataContract(Name = "Category")] public partial class Category : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Category() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required) (default to "default-name"). - /// id. + /// name (required) (default to "default-name") + /// id public Category(string name = "default-name", long id = default) { - // to ensure "name" is required (not null) - if (name == null) { - throw new ArgumentNullException("name is a required property for Category and cannot be null"); - } - this.Name = name; - this.Id = id; - this.AdditionalProperties = new Dictionary(); + if (name == null) + throw new ArgumentNullException("name is a required property for Category and cannot be null."); + Name = name; + Id = id; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -89,15 +77,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs index 991717f2591..7305880af4e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,61 +29,22 @@ namespace Org.OpenAPITools.Model /// /// ChildCat /// - [DataContract(Name = "ChildCat")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - public partial class ChildCat : ParentPet, IEquatable, IValidatableObject + public partial class ChildCat : ParentPet, IEquatable { - /// - /// Defines PetType - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum PetTypeEnum - { - /// - /// Enum ChildCat for value: ChildCat - /// - [EnumMember(Value = "ChildCat")] - ChildCat = 1 - - } - - - /// - /// Gets or Sets PetType - /// - [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] - public PetTypeEnum PetType { get; set; } /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ChildCat() + /// childCatAllOf + /// petType (required) + public ChildCat(ChildCatAllOf childCatAllOf, string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// petType (required) (default to PetTypeEnum.ChildCat). - /// name. - public ChildCat(PetTypeEnum petType = PetTypeEnum.ChildCat, string name = default) : base() - { - this.PetType = petType; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + ChildCatAllOf = childCatAllOf; } /// - /// Gets or Sets Name + /// Gets or Sets ChildCat /// - [DataMember(Name = "name", EmitDefaultValue = false)] - public string Name { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public ChildCatAllOf ChildCatAllOf { get; set; } /// /// Returns the string presentation of the object @@ -95,22 +55,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -140,42 +88,72 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - hashCode = (hashCode * 59) + this.PetType.GetHashCode(); - if (this.Name != null) - { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); - } - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type ChildCat + /// + public class ChildCatJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ChildCat).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ChildCat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader childCatAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref childCatAllOfReader, options, out ChildCatAllOf childCatAllOf); + string petType = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "pet_type": + petType = reader.GetString(); + break; + } + } + } + + return new ChildCat(childCatAllOf, petType); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs index 483062ead25..212351b7f21 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCatAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,22 @@ namespace Org.OpenAPITools.Model /// /// ChildCatAllOf /// - [DataContract(Name = "ChildCat_allOf")] public partial class ChildCatAllOf : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// name + /// petType (default to PetTypeEnum.ChildCat) + public ChildCatAllOf(string name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) + { + Name = name; + PetType = petType; + } + /// /// Defines PetType /// - [JsonConverter(typeof(StringEnumConverter))] public enum PetTypeEnum { /// @@ -46,35 +55,23 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets PetType /// - [DataMember(Name = "pet_type", EmitDefaultValue = false)] + [JsonPropertyName("pet_type")] public PetTypeEnum PetType { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// name. - /// petType (default to PetTypeEnum.ChildCat). - public ChildCatAllOf(string name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) - { - this.Name = name; - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -91,15 +88,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs index fa446f3a33f..bdfd6acb4df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ClassModel.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model with \"_class\" property /// - [DataContract(Name = "ClassModel")] public partial class ClassModel : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _class. + /// _class public ClassModel(string _class = default) { - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Class = _class; } /// /// Gets or Sets Class /// - [DataMember(Name = "_class", EmitDefaultValue = false)] + [JsonPropertyName("_class")] public string Class { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index ab75994ddf5..066c04dee99 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// ComplexQuadrilateral /// - [DataContract(Name = "ComplexQuadrilateral")] public partial class ComplexQuadrilateral : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ComplexQuadrilateral() + /// quadrilateralInterface + /// shapeInterface + public ComplexQuadrilateral(QuadrilateralInterface quadrilateralInterface, ShapeInterface shapeInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// quadrilateralType (required). - public ComplexQuadrilateral(string shapeType, string quadrilateralType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ComplexQuadrilateral and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for ComplexQuadrilateral and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + QuadrilateralInterface = quadrilateralInterface; + ShapeInterface = shapeInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets ComplexQuadrilateral /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public QuadrilateralInterface QuadrilateralInterface { get; set; } /// - /// Gets or Sets QuadrilateralType + /// Gets or Sets ComplexQuadrilateral /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] - public string QuadrilateralType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class ComplexQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.QuadrilateralType != null) - { - hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type ComplexQuadrilateral + /// + public class ComplexQuadrilateralJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ComplexQuadrilateral).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ComplexQuadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralInterfaceReader, options, out QuadrilateralInterface quadrilateralInterface); + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new ComplexQuadrilateral(quadrilateralInterface, shapeInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs index 7314bf3a214..941856ebe48 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DanishPig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// DanishPig /// - [DataContract(Name = "DanishPig")] public partial class DanishPig : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected DanishPig() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). + /// className (required) public DanishPig(string className) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for DanishPig and cannot be null"); - } - this.ClassName = className; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for DanishPig and cannot be null."); + ClassName = className; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs index a900bc224e4..660a1070cda 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// DeprecatedObject /// - [DataContract(Name = "DeprecatedObject")] public partial class DeprecatedObject : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// name. + /// name public DeprecatedObject(string name = default) { - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Name = name; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs index d34b90a530d..5649acf89d3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Dog.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,41 +29,23 @@ namespace Org.OpenAPITools.Model /// /// Dog /// - [DataContract(Name = "Dog")] - [JsonConverter(typeof(JsonSubtypes), "ClassName")] - public partial class Dog : Animal, IEquatable, IValidatableObject + public partial class Dog : Animal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Dog() + /// dogAllOf + /// className (required) + /// color (default to "red") + public Dog(DogAllOf dogAllOf, string className, string color = "red") : base(className, color) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required) (default to "Dog"). - /// breed. - /// color (default to "red"). - public Dog(string className = "Dog", string breed = default, string color = "red") : base(className, color) - { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + DogAllOf = dogAllOf; } /// - /// Gets or Sets Breed + /// Gets or Sets Dog /// - [DataMember(Name = "breed", EmitDefaultValue = false)] - public string Breed { get; set; } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public DogAllOf DogAllOf { get; set; } /// /// Returns the string presentation of the object @@ -75,21 +56,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class Dog {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" Breed: ").Append(Breed).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -119,41 +89,76 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - if (this.Breed != null) - { - hashCode = (hashCode * 59) + this.Breed.GetHashCode(); - } - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } + /// + /// A Json converter for type Dog + /// + public class DogJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Dog).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override Dog Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader dogAllOfReader = reader; + Client.ClientUtils.TryDeserialize(ref dogAllOfReader, options, out DogAllOf dogAllOf); + string className = default; + string color = default; + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "className": + className = reader.GetString(); + break; + case "color": + color = reader.GetString(); + break; + } + } + } + + return new Dog(dogAllOf, className, color); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DogAllOf.cs index 7563294d994..3c20669f2e8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DogAllOf.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// DogAllOf /// - [DataContract(Name = "Dog_allOf")] public partial class DogAllOf : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// breed. + /// breed public DogAllOf(string breed = default) { - this.Breed = breed; - this.AdditionalProperties = new Dictionary(); + Breed = breed; } /// /// Gets or Sets Breed /// - [DataMember(Name = "breed", EmitDefaultValue = false)] + [JsonPropertyName("breed")] public string Breed { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs index bbec316ee18..1020ef91c7e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,45 @@ namespace Org.OpenAPITools.Model /// /// Drawing /// - [DataContract(Name = "Drawing")] public partial class Drawing : Dictionary, IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// mainShape. - /// shapeOrNull. - /// nullableShape. - /// shapes. - public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, NullableShape nullableShape = default, List shapes = default) : base() + /// mainShape + /// shapeOrNull + /// nullableShape + /// shapes + public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, NullableShape nullableShape = default, List shapes = default) { - this.MainShape = mainShape; - this.ShapeOrNull = shapeOrNull; - this.NullableShape = nullableShape; - this.Shapes = shapes; + MainShape = mainShape; + ShapeOrNull = shapeOrNull; + NullableShape = nullableShape; + Shapes = shapes; } /// /// Gets or Sets MainShape /// - [DataMember(Name = "mainShape", EmitDefaultValue = false)] + [JsonPropertyName("mainShape")] public Shape MainShape { get; set; } /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [JsonPropertyName("shapeOrNull")] public ShapeOrNull ShapeOrNull { get; set; } /// /// Gets or Sets NullableShape /// - [DataMember(Name = "nullableShape", EmitDefaultValue = true)] + [JsonPropertyName("nullableShape")] public NullableShape NullableShape { get; set; } /// /// Gets or Sets Shapes /// - [DataMember(Name = "shapes", EmitDefaultValue = false)] + [JsonPropertyName("shapes")] public List Shapes { get; set; } /// @@ -88,15 +87,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs index f8a52d1b5fa..cadbe7035b8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,22 @@ namespace Org.OpenAPITools.Model /// /// EnumArrays /// - [DataContract(Name = "EnumArrays")] public partial class EnumArrays : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// justSymbol + /// arrayEnum + public EnumArrays(JustSymbolEnum justSymbol = default, List arrayEnum = default) + { + JustSymbol = justSymbol; + ArrayEnum = arrayEnum; + } + /// /// Defines JustSymbol /// - [JsonConverter(typeof(StringEnumConverter))] public enum JustSymbolEnum { /// @@ -52,16 +61,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets JustSymbol /// - [DataMember(Name = "just_symbol", EmitDefaultValue = false)] + [JsonPropertyName("just_symbol")] public JustSymbolEnum JustSymbol { get; set; } + /// /// Defines ArrayEnum /// - [JsonConverter(typeof(StringEnumConverter))] public enum ArrayEnumEnum { /// @@ -79,29 +87,17 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets ArrayEnum /// - [DataMember(Name = "array_enum", EmitDefaultValue = false)] + [JsonPropertyName("array_enum")] public List ArrayEnum { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// justSymbol. - /// arrayEnum. - public EnumArrays(JustSymbolEnum justSymbol = default, List arrayEnum = default) - { - this.JustSymbol = justSymbol; - this.ArrayEnum = arrayEnum; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -118,15 +114,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs index 48b3d7d0e7e..ea5485d0b21 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines EnumClass /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumClass { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Xyz = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs index b1b8afaa9a6..301b16c0051 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,38 @@ namespace Org.OpenAPITools.Model /// /// EnumTest /// - [DataContract(Name = "Enum_Test")] public partial class EnumTest : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// enumStringRequired (required) + /// enumString + /// enumInteger + /// enumIntegerOnly + /// enumNumber + /// outerEnum + /// outerEnumInteger + /// outerEnumDefaultValue + /// outerEnumIntegerDefaultValue + public EnumTest(EnumStringRequiredEnum enumStringRequired, EnumStringEnum enumString = default, EnumIntegerEnum enumInteger = default, EnumIntegerOnlyEnum enumIntegerOnly = default, EnumNumberEnum enumNumber = default, OuterEnum outerEnum = default, OuterEnumInteger outerEnumInteger = default, OuterEnumDefaultValue outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue = default) + { + if (enumStringRequired == null) + throw new ArgumentNullException("enumStringRequired is a required property for EnumTest and cannot be null."); + EnumStringRequired = enumStringRequired; + EnumString = enumString; + EnumInteger = enumInteger; + EnumIntegerOnly = enumIntegerOnly; + EnumNumber = enumNumber; + OuterEnum = outerEnum; + OuterEnumInteger = outerEnumInteger; + OuterEnumDefaultValue = outerEnumDefaultValue; + OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; + } + /// /// Defines EnumStringRequired /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumStringRequiredEnum { /// @@ -58,16 +83,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumStringRequired /// - [DataMember(Name = "enum_string_required", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("enum_string_required")] public EnumStringRequiredEnum EnumStringRequired { get; set; } + /// /// Defines EnumString /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumStringEnum { /// @@ -90,12 +114,12 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumString /// - [DataMember(Name = "enum_string", EmitDefaultValue = false)] + [JsonPropertyName("enum_string")] public EnumStringEnum EnumString { get; set; } + /// /// Defines EnumInteger /// @@ -113,12 +137,12 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumInteger /// - [DataMember(Name = "enum_integer", EmitDefaultValue = false)] + [JsonPropertyName("enum_integer")] public EnumIntegerEnum EnumInteger { get; set; } + /// /// Defines EnumIntegerOnly /// @@ -136,16 +160,15 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumIntegerOnly /// - [DataMember(Name = "enum_integer_only", EmitDefaultValue = false)] + [JsonPropertyName("enum_integer_only")] public EnumIntegerOnlyEnum EnumIntegerOnly { get; set; } + /// /// Defines EnumNumber /// - [JsonConverter(typeof(StringEnumConverter))] public enum EnumNumberEnum { /// @@ -162,75 +185,41 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets EnumNumber /// - [DataMember(Name = "enum_number", EmitDefaultValue = false)] + [JsonPropertyName("enum_number")] public EnumNumberEnum EnumNumber { get; set; } - + /// /// Gets or Sets OuterEnum /// - [DataMember(Name = "outerEnum", EmitDefaultValue = true)] + [JsonPropertyName("outerEnum")] public OuterEnum OuterEnum { get; set; } - + /// /// Gets or Sets OuterEnumInteger /// - [DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumInteger")] public OuterEnumInteger OuterEnumInteger { get; set; } - + /// /// Gets or Sets OuterEnumDefaultValue /// - [DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumDefaultValue")] public OuterEnumDefaultValue OuterEnumDefaultValue { get; set; } - + /// /// Gets or Sets OuterEnumIntegerDefaultValue /// - [DataMember(Name = "outerEnumIntegerDefaultValue", EmitDefaultValue = false)] + [JsonPropertyName("outerEnumIntegerDefaultValue")] public OuterEnumIntegerDefaultValue OuterEnumIntegerDefaultValue { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected EnumTest() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// enumStringRequired (required). - /// enumString. - /// enumInteger. - /// enumIntegerOnly. - /// enumNumber. - /// outerEnum. - /// outerEnumInteger. - /// outerEnumDefaultValue. - /// outerEnumIntegerDefaultValue. - public EnumTest(EnumStringRequiredEnum enumStringRequired, EnumStringEnum enumString = default, EnumIntegerEnum enumInteger = default, EnumIntegerOnlyEnum enumIntegerOnly = default, EnumNumberEnum enumNumber = default, OuterEnum outerEnum = default, OuterEnumInteger outerEnumInteger = default, OuterEnumDefaultValue outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue = default) - { - this.EnumStringRequired = enumStringRequired; - this.EnumString = enumString; - this.EnumInteger = enumInteger; - this.EnumIntegerOnly = enumIntegerOnly; - this.EnumNumber = enumNumber; - this.OuterEnum = outerEnum; - this.OuterEnumInteger = outerEnumInteger; - this.OuterEnumDefaultValue = outerEnumDefaultValue; - this.OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -254,15 +243,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 43e72bd635a..a6c99bf6c4b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// EquilateralTriangle /// - [DataContract(Name = "EquilateralTriangle")] public partial class EquilateralTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected EquilateralTriangle() + /// shapeInterface + /// triangleInterface + public EquilateralTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public EquilateralTriangle(string shapeType, string triangleType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for EquilateralTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for EquilateralTriangle and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets EquilateralTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets EquilateralTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface TriangleInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class EquilateralTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type EquilateralTriangle + /// + public class EquilateralTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(EquilateralTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override EquilateralTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new EquilateralTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs index e4d0738adbf..a74c1fcd9ff 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/File.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,31 +29,29 @@ namespace Org.OpenAPITools.Model /// /// Must be named `File` for test. /// - [DataContract(Name = "File")] public partial class File : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// Test capitalization. + /// Test capitalization public File(string sourceURI = default) { - this.SourceURI = sourceURI; - this.AdditionalProperties = new Dictionary(); + SourceURI = sourceURI; } /// /// Test capitalization /// /// Test capitalization - [DataMember(Name = "sourceURI", EmitDefaultValue = false)] + [JsonPropertyName("sourceURI")] public string SourceURI { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -69,15 +67,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 423799cb24e..6906e0eb38c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// FileSchemaTestClass /// - [DataContract(Name = "FileSchemaTestClass")] public partial class FileSchemaTestClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// file. - /// files. + /// file + /// files public FileSchemaTestClass(File file = default, List files = default) { - this.File = file; - this.Files = files; - this.AdditionalProperties = new Dictionary(); + File = file; + Files = files; } /// /// Gets or Sets File /// - [DataMember(Name = "file", EmitDefaultValue = false)] + [JsonPropertyName("file")] public File File { get; set; } /// /// Gets or Sets Files /// - [DataMember(Name = "files", EmitDefaultValue = false)] + [JsonPropertyName("files")] public List Files { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs index e64aac7b631..9c34541ee67 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Foo.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,31 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Foo /// - [DataContract(Name = "Foo")] public partial class Foo : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// bar (default to "bar"). + /// bar (default to "bar") public Foo(string bar = "bar") { - // use default value if no "bar" provided - this.Bar = bar ?? "bar"; - this.AdditionalProperties = new Dictionary(); + Bar = bar; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string Bar { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -69,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs index 8b846d403ff..680e378bf43 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,169 +29,158 @@ namespace Org.OpenAPITools.Model /// /// FormatTest /// - [DataContract(Name = "format_test")] public partial class FormatTest : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected FormatTest() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// number (required). - /// _byte (required). - /// date (required). - /// password (required). - /// integer. - /// int32. - /// int64. - /// _float. - /// _double. - /// _decimal. - /// _string. - /// binary. - /// dateTime. - /// uuid. - /// A string that is a 10 digit number. Can have leading zeros.. - /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.. + /// number (required) + /// _byte (required) + /// date (required) + /// password (required) + /// integer + /// int32 + /// int64 + /// _float + /// _double + /// _decimal + /// _string + /// binary + /// dateTime + /// uuid + /// A string that is a 10 digit number. Can have leading zeros. + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. public FormatTest(decimal number, byte[] _byte, DateTime date, string password, int integer = default, int int32 = default, long int64 = default, float _float = default, double _double = default, decimal _decimal = default, string _string = default, System.IO.Stream binary = default, DateTime dateTime = default, Guid uuid = default, string patternWithDigits = default, string patternWithDigitsAndDelimiter = default) { - this.Number = number; - // to ensure "_byte" is required (not null) - if (_byte == null) { - throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null"); - } - this.Byte = _byte; - this.Date = date; - // to ensure "password" is required (not null) - if (password == null) { - throw new ArgumentNullException("password is a required property for FormatTest and cannot be null"); - } - this.Password = password; - this.Integer = integer; - this.Int32 = int32; - this.Int64 = int64; - this.Float = _float; - this.Double = _double; - this.Decimal = _decimal; - this.String = _string; - this.Binary = binary; - this.DateTime = dateTime; - this.Uuid = uuid; - this.PatternWithDigits = patternWithDigits; - this.PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; - this.AdditionalProperties = new Dictionary(); + if (number == null) + throw new ArgumentNullException("number is a required property for FormatTest and cannot be null."); + if (_byte == null) + throw new ArgumentNullException("_byte is a required property for FormatTest and cannot be null."); + if (date == null) + throw new ArgumentNullException("date is a required property for FormatTest and cannot be null."); + if (password == null) + throw new ArgumentNullException("password is a required property for FormatTest and cannot be null."); + Number = number; + Byte = _byte; + Date = date; + Password = password; + Integer = integer; + Int32 = int32; + Int64 = int64; + Float = _float; + Double = _double; + Decimal = _decimal; + String = _string; + Binary = binary; + DateTime = dateTime; + Uuid = uuid; + PatternWithDigits = patternWithDigits; + PatternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter; } /// /// Gets or Sets Number /// - [DataMember(Name = "number", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("number")] public decimal Number { get; set; } /// /// Gets or Sets Byte /// - [DataMember(Name = "byte", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("byte")] public byte[] Byte { get; set; } /// /// Gets or Sets Date /// - [DataMember(Name = "date", IsRequired = true, EmitDefaultValue = false)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [JsonPropertyName("date")] public DateTime Date { get; set; } /// /// Gets or Sets Password /// - [DataMember(Name = "password", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("password")] public string Password { get; set; } /// /// Gets or Sets Integer /// - [DataMember(Name = "integer", EmitDefaultValue = false)] + [JsonPropertyName("integer")] public int Integer { get; set; } /// /// Gets or Sets Int32 /// - [DataMember(Name = "int32", EmitDefaultValue = false)] + [JsonPropertyName("int32")] public int Int32 { get; set; } /// /// Gets or Sets Int64 /// - [DataMember(Name = "int64", EmitDefaultValue = false)] + [JsonPropertyName("int64")] public long Int64 { get; set; } /// /// Gets or Sets Float /// - [DataMember(Name = "float", EmitDefaultValue = false)] + [JsonPropertyName("float")] public float Float { get; set; } /// /// Gets or Sets Double /// - [DataMember(Name = "double", EmitDefaultValue = false)] + [JsonPropertyName("double")] public double Double { get; set; } /// /// Gets or Sets Decimal /// - [DataMember(Name = "decimal", EmitDefaultValue = false)] + [JsonPropertyName("decimal")] public decimal Decimal { get; set; } /// /// Gets or Sets String /// - [DataMember(Name = "string", EmitDefaultValue = false)] + [JsonPropertyName("string")] public string String { get; set; } /// /// Gets or Sets Binary /// - [DataMember(Name = "binary", EmitDefaultValue = false)] + [JsonPropertyName("binary")] public System.IO.Stream Binary { get; set; } /// /// Gets or Sets DateTime /// - [DataMember(Name = "dateTime", EmitDefaultValue = false)] + [JsonPropertyName("dateTime")] public DateTime DateTime { get; set; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public Guid Uuid { get; set; } /// /// A string that is a 10 digit number. Can have leading zeros. /// /// A string that is a 10 digit number. Can have leading zeros. - [DataMember(Name = "pattern_with_digits", EmitDefaultValue = false)] + [JsonPropertyName("pattern_with_digits")] public string PatternWithDigits { get; set; } /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. /// /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - [DataMember(Name = "pattern_with_digits_and_delimiter", EmitDefaultValue = false)] + [JsonPropertyName("pattern_with_digits_and_delimiter")] public string PatternWithDigitsAndDelimiter { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -222,15 +211,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs index 726b1e8f72e..0cd149e9680 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Fruit.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,95 +19,55 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Fruit /// - [JsonConverter(typeof(FruitJsonConverter))] - [DataContract(Name = "fruit")] - public partial class Fruit : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Fruit : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Apple. - public Fruit(Apple actualInstance) + /// apple + /// color + public Fruit(Apple apple, string color = default) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Apple = apple; + Color = color; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Banana. - public Fruit(Banana actualInstance) + /// banana + /// color + public Fruit(Banana banana, string color = default) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Apple)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Banana)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Apple, Banana"); - } - } + Banana = banana; + Color = color; } /// - /// Get the actual instance of `Apple`. If the actual instance is not `Apple`, - /// the InvalidClassException will be thrown + /// Gets or Sets fruit /// - /// An instance of Apple - public Apple GetApple() - { - return (Apple)this.ActualInstance; - } + public Apple Apple { get; set; } /// - /// Get the actual instance of `Banana`. If the actual instance is not `Banana`, - /// the InvalidClassException will be thrown + /// Gets or Sets fruit /// - /// An instance of Banana - public Banana GetBanana() - { - return (Banana)this.ActualInstance; - } + public Banana Banana { get; set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get; set; } /// /// Returns the string presentation of the object @@ -113,91 +75,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Fruit {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Fruit.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Fruit - /// - /// JSON string - /// An instance of Fruit - public static Fruit FromJson(string jsonString) - { - Fruit newFruit = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newFruit; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Apple).GetProperty("AdditionalProperties") == null) - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.SerializerSettings)); - } - else - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Apple"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Banana).GetProperty("AdditionalProperties") == null) - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.SerializerSettings)); - } - else - { - newFruit = new Fruit(JsonConvert.DeserializeObject(jsonString, Fruit.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Banana"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newFruit; - } - /// /// Returns true if objects are equal /// @@ -227,8 +111,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.Color != null) + { + hashCode = (hashCode * 59) + this.Color.GetHashCode(); + } return hashCode; } } @@ -238,54 +124,82 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Fruit + /// A Json converter for type Fruit /// - public class FruitJsonConverter : JsonConverter + public class FruitJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Fruit).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Fruit).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReader, options, out Apple apple); + + Utf8JsonReader bananaReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReader, options, out Banana banana); + + string color = default; + + while (reader.Read()) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "color": + color = reader.GetString(); + break; + } + } } - return null; + + if (apple != null) + return new Fruit(apple, color); + + if (banana != null) + return new Fruit(banana, color); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs index 548da490def..fb52312bfd4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FruitReq.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,104 +19,45 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// FruitReq /// - [JsonConverter(typeof(FruitReqJsonConverter))] - [DataContract(Name = "fruitReq")] - public partial class FruitReq : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class FruitReq : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public FruitReq() + /// appleReq + public FruitReq(AppleReq appleReq) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + AppleReq = appleReq; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of AppleReq. - public FruitReq(AppleReq actualInstance) + /// bananaReq + public FruitReq(BananaReq bananaReq) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + BananaReq = bananaReq; } /// - /// Initializes a new instance of the class - /// with the class + /// Gets or Sets fruitReq /// - /// An instance of BananaReq. - public FruitReq(BananaReq actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + public AppleReq AppleReq { get; set; } /// - /// Gets or Sets ActualInstance + /// Gets or Sets fruitReq /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(AppleReq)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(BananaReq)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: AppleReq, BananaReq"); - } - } - } - - /// - /// Get the actual instance of `AppleReq`. If the actual instance is not `AppleReq`, - /// the InvalidClassException will be thrown - /// - /// An instance of AppleReq - public AppleReq GetAppleReq() - { - return (AppleReq)this.ActualInstance; - } - - /// - /// Get the actual instance of `BananaReq`. If the actual instance is not `BananaReq`, - /// the InvalidClassException will be thrown - /// - /// An instance of BananaReq - public BananaReq GetBananaReq() - { - return (BananaReq)this.ActualInstance; - } + public BananaReq BananaReq { get; set; } /// /// Returns the string presentation of the object @@ -122,91 +65,12 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class FruitReq {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, FruitReq.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of FruitReq - /// - /// JSON string - /// An instance of FruitReq - public static FruitReq FromJson(string jsonString) - { - FruitReq newFruitReq = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newFruitReq; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(AppleReq).GetProperty("AdditionalProperties") == null) - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.SerializerSettings)); - } - else - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("AppleReq"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into AppleReq: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(BananaReq).GetProperty("AdditionalProperties") == null) - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.SerializerSettings)); - } - else - { - newFruitReq = new FruitReq(JsonConvert.DeserializeObject(jsonString, FruitReq.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("BananaReq"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into BananaReq: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newFruitReq; - } - /// /// Returns true if objects are equal /// @@ -236,8 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); return hashCode; } } @@ -247,54 +109,78 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for FruitReq + /// A Json converter for type FruitReq /// - public class FruitReqJsonConverter : JsonConverter + public class FruitReqJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(FruitReq).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(FruitReq).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override FruitReq Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReqReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReqReader, options, out AppleReq appleReq); + + Utf8JsonReader bananaReqReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReqReader, options, out BananaReq bananaReq); + + + while (reader.Read()) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (appleReq != null) + return new FruitReq(appleReq); + + if (bananaReq != null) + return new FruitReq(bananaReq); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs index bd8f4435c92..b4fd0f92d41 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GmFruit.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,82 +29,36 @@ namespace Org.OpenAPITools.Model /// /// GmFruit /// - [JsonConverter(typeof(GmFruitJsonConverter))] - [DataContract(Name = "gmFruit")] - public partial class GmFruit : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class GmFruit : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Apple. - public GmFruit(Apple actualInstance) + /// apple + /// banana + /// color + public GmFruit(Apple apple, Banana banana, string color = default) { - this.IsNullable = false; - this.SchemaType= "anyOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Apple = apple; + Banana = banana; + Color = color; } /// - /// Initializes a new instance of the class - /// with the class + /// Gets or Sets gmFruit /// - /// An instance of Banana. - public GmFruit(Banana actualInstance) - { - this.IsNullable = false; - this.SchemaType= "anyOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; + public Apple Apple { get; set; } /// - /// Gets or Sets ActualInstance + /// Gets or Sets gmFruit /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Apple)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Banana)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Apple, Banana"); - } - } - } + public Banana Banana { get; set; } /// - /// Get the actual instance of `Apple`. If the actual instance is not `Apple`, - /// the InvalidClassException will be thrown + /// Gets or Sets Color /// - /// An instance of Apple - public Apple GetApple() - { - return (Apple)this.ActualInstance; - } - - /// - /// Get the actual instance of `Banana`. If the actual instance is not `Banana`, - /// the InvalidClassException will be thrown - /// - /// An instance of Banana - public Banana GetBanana() - { - return (Banana)this.ActualInstance; - } + [JsonPropertyName("color")] + public string Color { get; set; } /// /// Returns the string presentation of the object @@ -112,64 +66,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class GmFruit {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, GmFruit.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of GmFruit - /// - /// JSON string - /// An instance of GmFruit - public static GmFruit FromJson(string jsonString) - { - GmFruit newGmFruit = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newGmFruit; - } - - try - { - newGmFruit = new GmFruit(JsonConvert.DeserializeObject(jsonString, GmFruit.SerializerSettings)); - // deserialization is considered successful at this point if no exception has been thrown. - return newGmFruit; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Apple: {1}", jsonString, exception.ToString())); - } - - try - { - newGmFruit = new GmFruit(JsonConvert.DeserializeObject(jsonString, GmFruit.SerializerSettings)); - // deserialization is considered successful at this point if no exception has been thrown. - return newGmFruit; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Banana: {1}", jsonString, exception.ToString())); - } - - // no match found, throw an exception - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - /// /// Returns true if objects are equal /// @@ -199,8 +102,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.Color != null) + { + hashCode = (hashCode * 59) + this.Color.GetHashCode(); + } return hashCode; } } @@ -210,54 +115,76 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for GmFruit + /// A Json converter for type GmFruit /// - public class GmFruitJsonConverter : JsonConverter + public class GmFruitJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(GmFruit).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(GmFruit).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override GmFruit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader appleReader = reader; + Client.ClientUtils.TryDeserialize(ref appleReader, options, out Apple apple); + + Utf8JsonReader bananaReader = reader; + Client.ClientUtils.TryDeserialize(ref bananaReader, options, out Banana banana); + + string color = default; + + while (reader.Read()) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "color": + color = reader.GetString(); + break; + } + } } - return null; + + return new GmFruit(apple, banana, color); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 24b3df864e1..c7b006e6a62 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,45 +29,30 @@ namespace Org.OpenAPITools.Model /// /// GrandparentAnimal /// - [DataContract(Name = "GrandparentAnimal")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] - [JsonSubtypes.KnownSubType(typeof(ParentPet), "ParentPet")] public partial class GrandparentAnimal : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected GrandparentAnimal() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// petType (required). + /// petType (required) public GrandparentAnimal(string petType) { - // to ensure "petType" is required (not null) - if (petType == null) { - throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null"); - } - this.PetType = petType; - this.AdditionalProperties = new Dictionary(); + if (petType == null) + throw new ArgumentNullException("petType is a required property for GrandparentAnimal and cannot be null."); + PetType = petType; } /// /// Gets or Sets PetType /// - [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("pet_type")] public string PetType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -84,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 52099a7095e..c9c283f8528 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,51 +29,36 @@ namespace Org.OpenAPITools.Model /// /// HasOnlyReadOnly /// - [DataContract(Name = "hasOnlyReadOnly")] public partial class HasOnlyReadOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - public HasOnlyReadOnly() + /// bar + /// foo + public HasOnlyReadOnly(string bar = default, string foo = default) { - this.AdditionalProperties = new Dictionary(); + Bar = bar; + Foo = foo; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string Bar { get; private set; } - /// - /// Returns false as Bar should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBar() - { - return false; - } /// /// Gets or Sets Foo /// - [DataMember(Name = "foo", EmitDefaultValue = false)] + [JsonPropertyName("foo")] public string Foo { get; private set; } - /// - /// Returns false as Foo should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeFoo() - { - return false; - } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -90,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 616877a9f60..7c0a5e58edc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. /// - [DataContract(Name = "HealthCheckResult")] public partial class HealthCheckResult : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// nullableMessage. + /// nullableMessage public HealthCheckResult(string nullableMessage = default) { - this.NullableMessage = nullableMessage; - this.AdditionalProperties = new Dictionary(); + NullableMessage = nullableMessage; } /// /// Gets or Sets NullableMessage /// - [DataMember(Name = "NullableMessage", EmitDefaultValue = true)] + [JsonPropertyName("NullableMessage")] public string NullableMessage { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs index fc8c0d06636..6bb7d64c205 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/InlineResponseDefault.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// InlineResponseDefault /// - [DataContract(Name = "inline_response_default")] public partial class InlineResponseDefault : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _string. + /// _string public InlineResponseDefault(Foo _string = default) { - this.String = _string; - this.AdditionalProperties = new Dictionary(); + String = _string; } /// /// Gets or Sets String /// - [DataMember(Name = "string", EmitDefaultValue = false)] + [JsonPropertyName("string")] public Foo String { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index d5ff97d769c..bcfaae75661 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,44 +29,28 @@ namespace Org.OpenAPITools.Model /// /// IsoscelesTriangle /// - [DataContract(Name = "IsoscelesTriangle")] public partial class IsoscelesTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected IsoscelesTriangle() { } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public IsoscelesTriangle(string shapeType, string triangleType) + /// shapeInterface + /// triangleInterface + public IsoscelesTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for IsoscelesTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for IsoscelesTriangle and cannot be null"); - } - this.TriangleType = triangleType; + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets IsoscelesTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets IsoscelesTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface TriangleInterface { get; set; } /// /// Returns the string presentation of the object @@ -76,21 +60,10 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class IsoscelesTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -120,14 +93,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } return hashCode; } } @@ -143,4 +108,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type IsoscelesTriangle + /// + public class IsoscelesTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(IsoscelesTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override IsoscelesTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new IsoscelesTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs index adaece91e88..bf77b2f6a0f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/List.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// List /// - [DataContract(Name = "List")] public partial class List : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _123list. + /// _123list public List(string _123list = default) { - this._123List = _123list; - this.AdditionalProperties = new Dictionary(); + _123List = _123list; } /// /// Gets or Sets _123List /// - [DataMember(Name = "123-list", EmitDefaultValue = false)] + [JsonPropertyName("123-list")] public string _123List { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs index 68ac3161992..0f4a2fb2d80 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Mammal.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,122 +19,65 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Mammal /// - [JsonConverter(typeof(MammalJsonConverter))] - [DataContract(Name = "mammal")] - public partial class Mammal : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Mammal : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Pig. - public Mammal(Pig actualInstance) + /// pig + public Mammal(Pig pig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Pig = pig; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Whale. - public Mammal(Whale actualInstance) + /// whale + public Mammal(Whale whale) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + Whale = whale; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Zebra. - public Mammal(Zebra actualInstance) + /// zebra + public Mammal(Zebra zebra) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Pig)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Whale)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Zebra)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Pig, Whale, Zebra"); - } - } + Zebra = zebra; } /// - /// Get the actual instance of `Pig`. If the actual instance is not `Pig`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Pig - public Pig GetPig() - { - return (Pig)this.ActualInstance; - } + public Pig Pig { get; set; } /// - /// Get the actual instance of `Whale`. If the actual instance is not `Whale`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Whale - public Whale GetWhale() - { - return (Whale)this.ActualInstance; - } + public Whale Whale { get; set; } /// - /// Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, - /// the InvalidClassException will be thrown + /// Gets or Sets mammal /// - /// An instance of Zebra - public Zebra GetZebra() - { - return (Zebra)this.ActualInstance; - } + public Zebra Zebra { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -140,111 +85,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Mammal.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Mammal - /// - /// JSON string - /// An instance of Mammal - public static Mammal FromJson(string jsonString) - { - Mammal newMammal = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newMammal; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Pig).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Pig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Pig: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Whale).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Whale"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Whale: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Zebra).GetProperty("AdditionalProperties") == null) - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.SerializerSettings)); - } - else - { - newMammal = new Mammal(JsonConvert.DeserializeObject(jsonString, Mammal.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Zebra"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Zebra: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newMammal; - } - /// /// Returns true if objects are equal /// @@ -274,8 +121,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -285,54 +134,94 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Mammal + /// A Json converter for type Mammal /// - public class MammalJsonConverter : JsonConverter + public class MammalJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Mammal).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Mammal).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Mammal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader pigReader = reader; + Client.ClientUtils.TryDeserialize(ref pigReader, options, out Pig pig); + + Utf8JsonReader whaleReader = reader; + Client.ClientUtils.TryDeserialize(ref whaleReader, options, out Whale whale); + + Utf8JsonReader zebraReader = reader; + Client.ClientUtils.TryDeserialize(ref zebraReader, options, out Zebra zebra); + + + while (reader.Read()) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (pig != null) + return new Mammal(pig); + + if (whale != null) + return new Mammal(whale); + + if (zebra != null) + return new Mammal(zebra); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs index b5ab56afe6a..1976383a3fd 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MapTest.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,26 @@ namespace Org.OpenAPITools.Model /// /// MapTest /// - [DataContract(Name = "MapTest")] public partial class MapTest : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// mapMapOfString + /// mapOfEnumString + /// directMap + /// indirectMap + public MapTest(Dictionary> mapMapOfString = default, Dictionary mapOfEnumString = default, Dictionary directMap = default, Dictionary indirectMap = default) + { + MapMapOfString = mapMapOfString; + MapOfEnumString = mapOfEnumString; + DirectMap = directMap; + IndirectMap = indirectMap; + } + /// /// Defines Inner /// - [JsonConverter(typeof(StringEnumConverter))] public enum InnerEnum { /// @@ -53,51 +66,35 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets MapOfEnumString /// - [DataMember(Name = "map_of_enum_string", EmitDefaultValue = false)] + [JsonPropertyName("map_of_enum_string")] public Dictionary MapOfEnumString { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// mapMapOfString. - /// mapOfEnumString. - /// directMap. - /// indirectMap. - public MapTest(Dictionary> mapMapOfString = default, Dictionary mapOfEnumString = default, Dictionary directMap = default, Dictionary indirectMap = default) - { - this.MapMapOfString = mapMapOfString; - this.MapOfEnumString = mapOfEnumString; - this.DirectMap = directMap; - this.IndirectMap = indirectMap; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets MapMapOfString /// - [DataMember(Name = "map_map_of_string", EmitDefaultValue = false)] + [JsonPropertyName("map_map_of_string")] public Dictionary> MapMapOfString { get; set; } /// /// Gets or Sets DirectMap /// - [DataMember(Name = "direct_map", EmitDefaultValue = false)] + [JsonPropertyName("direct_map")] public Dictionary DirectMap { get; set; } /// /// Gets or Sets IndirectMap /// - [DataMember(Name = "indirect_map", EmitDefaultValue = false)] + [JsonPropertyName("indirect_map")] public Dictionary IndirectMap { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -116,15 +113,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 63145e93f88..506fa4484a6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// MixedPropertiesAndAdditionalPropertiesClass /// - [DataContract(Name = "MixedPropertiesAndAdditionalPropertiesClass")] public partial class MixedPropertiesAndAdditionalPropertiesClass : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// uuid. - /// dateTime. - /// map. + /// uuid + /// dateTime + /// map public MixedPropertiesAndAdditionalPropertiesClass(Guid uuid = default, DateTime dateTime = default, Dictionary map = default) { - this.Uuid = uuid; - this.DateTime = dateTime; - this.Map = map; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + DateTime = dateTime; + Map = map; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public Guid Uuid { get; set; } /// /// Gets or Sets DateTime /// - [DataMember(Name = "dateTime", EmitDefaultValue = false)] + [JsonPropertyName("dateTime")] public DateTime DateTime { get; set; } /// /// Gets or Sets Map /// - [DataMember(Name = "map", EmitDefaultValue = false)] + [JsonPropertyName("map")] public Dictionary Map { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs index 65d373b2874..2e994288dcc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Model200Response.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model name starting with number /// - [DataContract(Name = "200_response")] public partial class Model200Response : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// name. - /// _class. + /// name + /// _class public Model200Response(int name = default, string _class = default) { - this.Name = name; - this.Class = _class; - this.AdditionalProperties = new Dictionary(); + Name = name; + Class = _class; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public int Name { get; set; } /// /// Gets or Sets Class /// - [DataMember(Name = "class", EmitDefaultValue = false)] + [JsonPropertyName("class")] public string Class { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs index c1f5970e032..c0a1e3c7aae 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ModelClient.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// ModelClient /// - [DataContract(Name = "_Client")] public partial class ModelClient : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _client. + /// _client public ModelClient(string _client = default) { - this._Client = _client; - this.AdditionalProperties = new Dictionary(); + _Client = _client; } /// /// Gets or Sets _Client /// - [DataMember(Name = "client", EmitDefaultValue = false)] + [JsonPropertyName("client")] public string _Client { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs index 9bb13253bc3..770664bf005 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Name.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,74 +29,54 @@ namespace Org.OpenAPITools.Model /// /// Model for testing model name same as property name /// - [DataContract(Name = "Name")] public partial class Name : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Name() + /// nameProperty (required) + /// snakeCase + /// property + /// _123number + public Name(int nameProperty, int snakeCase = default, string property = default, int _123number = default) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required). - /// property. - public Name(int name, string property = default) - { - this._Name = name; - this.Property = property; - this.AdditionalProperties = new Dictionary(); + if (nameProperty == null) + throw new ArgumentNullException("nameProperty is a required property for Name and cannot be null."); + NameProperty = nameProperty; + SnakeCase = snakeCase; + Property = property; + _123Number = _123number; } /// - /// Gets or Sets _Name + /// Gets or Sets NameProperty /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] - public int _Name { get; set; } + [JsonPropertyName("name")] + public int NameProperty { get; set; } /// /// Gets or Sets SnakeCase /// - [DataMember(Name = "snake_case", EmitDefaultValue = false)] + [JsonPropertyName("snake_case")] public int SnakeCase { get; private set; } - /// - /// Returns false as SnakeCase should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeSnakeCase() - { - return false; - } /// /// Gets or Sets Property /// - [DataMember(Name = "property", EmitDefaultValue = false)] + [JsonPropertyName("property")] public string Property { get; set; } /// /// Gets or Sets _123Number /// - [DataMember(Name = "123Number", EmitDefaultValue = false)] + [JsonPropertyName("123Number")] public int _123Number { get; private set; } - /// - /// Returns false as _123Number should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerialize_123Number() - { - return false; - } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -106,7 +86,7 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Name {\n"); - sb.Append(" _Name: ").Append(_Name).Append("\n"); + sb.Append(" NameProperty: ").Append(NameProperty).Append("\n"); sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); sb.Append(" Property: ").Append(Property).Append("\n"); sb.Append(" _123Number: ").Append(_123Number).Append("\n"); @@ -115,15 +95,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -153,7 +124,7 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this._Name.GetHashCode(); + hashCode = (hashCode * 59) + this.NameProperty.GetHashCode(); hashCode = (hashCode * 59) + this.SnakeCase.GetHashCode(); if (this.Property != null) { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs index fd0c90505e6..5c716e97e6a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,111 +29,109 @@ namespace Org.OpenAPITools.Model /// /// NullableClass /// - [DataContract(Name = "NullableClass")] public partial class NullableClass : Dictionary, IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// integerProp. - /// numberProp. - /// booleanProp. - /// stringProp. - /// dateProp. - /// datetimeProp. - /// arrayNullableProp. - /// arrayAndItemsNullableProp. - /// arrayItemsNullable. - /// objectNullableProp. - /// objectAndItemsNullableProp. - /// objectItemsNullable. - public NullableClass(int? integerProp = default, decimal? numberProp = default, bool? booleanProp = default, string stringProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, List arrayNullableProp = default, List arrayAndItemsNullableProp = default, List arrayItemsNullable = default, Dictionary objectNullableProp = default, Dictionary objectAndItemsNullableProp = default, Dictionary objectItemsNullable = default) : base() + /// integerProp + /// numberProp + /// booleanProp + /// stringProp + /// dateProp + /// datetimeProp + /// arrayNullableProp + /// arrayAndItemsNullableProp + /// arrayItemsNullable + /// objectNullableProp + /// objectAndItemsNullableProp + /// objectItemsNullable + public NullableClass(int? integerProp = default, decimal? numberProp = default, bool? booleanProp = default, string stringProp = default, DateTime? dateProp = default, DateTime? datetimeProp = default, List arrayNullableProp = default, List arrayAndItemsNullableProp = default, List arrayItemsNullable = default, Dictionary objectNullableProp = default, Dictionary objectAndItemsNullableProp = default, Dictionary objectItemsNullable = default) { - this.IntegerProp = integerProp; - this.NumberProp = numberProp; - this.BooleanProp = booleanProp; - this.StringProp = stringProp; - this.DateProp = dateProp; - this.DatetimeProp = datetimeProp; - this.ArrayNullableProp = arrayNullableProp; - this.ArrayAndItemsNullableProp = arrayAndItemsNullableProp; - this.ArrayItemsNullable = arrayItemsNullable; - this.ObjectNullableProp = objectNullableProp; - this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; - this.ObjectItemsNullable = objectItemsNullable; + IntegerProp = integerProp; + NumberProp = numberProp; + BooleanProp = booleanProp; + StringProp = stringProp; + DateProp = dateProp; + DatetimeProp = datetimeProp; + ArrayNullableProp = arrayNullableProp; + ArrayAndItemsNullableProp = arrayAndItemsNullableProp; + ArrayItemsNullable = arrayItemsNullable; + ObjectNullableProp = objectNullableProp; + ObjectAndItemsNullableProp = objectAndItemsNullableProp; + ObjectItemsNullable = objectItemsNullable; } /// /// Gets or Sets IntegerProp /// - [DataMember(Name = "integer_prop", EmitDefaultValue = true)] + [JsonPropertyName("integer_prop")] public int? IntegerProp { get; set; } /// /// Gets or Sets NumberProp /// - [DataMember(Name = "number_prop", EmitDefaultValue = true)] + [JsonPropertyName("number_prop")] public decimal? NumberProp { get; set; } /// /// Gets or Sets BooleanProp /// - [DataMember(Name = "boolean_prop", EmitDefaultValue = true)] + [JsonPropertyName("boolean_prop")] public bool? BooleanProp { get; set; } /// /// Gets or Sets StringProp /// - [DataMember(Name = "string_prop", EmitDefaultValue = true)] + [JsonPropertyName("string_prop")] public string StringProp { get; set; } /// /// Gets or Sets DateProp /// - [DataMember(Name = "date_prop", EmitDefaultValue = true)] - [JsonConverter(typeof(OpenAPIDateConverter))] + [JsonPropertyName("date_prop")] public DateTime? DateProp { get; set; } /// /// Gets or Sets DatetimeProp /// - [DataMember(Name = "datetime_prop", EmitDefaultValue = true)] + [JsonPropertyName("datetime_prop")] public DateTime? DatetimeProp { get; set; } /// /// Gets or Sets ArrayNullableProp /// - [DataMember(Name = "array_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("array_nullable_prop")] public List ArrayNullableProp { get; set; } /// /// Gets or Sets ArrayAndItemsNullableProp /// - [DataMember(Name = "array_and_items_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("array_and_items_nullable_prop")] public List ArrayAndItemsNullableProp { get; set; } /// /// Gets or Sets ArrayItemsNullable /// - [DataMember(Name = "array_items_nullable", EmitDefaultValue = false)] + [JsonPropertyName("array_items_nullable")] public List ArrayItemsNullable { get; set; } /// /// Gets or Sets ObjectNullableProp /// - [DataMember(Name = "object_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("object_nullable_prop")] public Dictionary ObjectNullableProp { get; set; } /// /// Gets or Sets ObjectAndItemsNullableProp /// - [DataMember(Name = "object_and_items_nullable_prop", EmitDefaultValue = true)] + [JsonPropertyName("object_and_items_nullable_prop")] public Dictionary ObjectAndItemsNullableProp { get; set; } /// /// Gets or Sets ObjectItemsNullable /// - [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] + [JsonPropertyName("object_items_nullable")] public Dictionary ObjectItemsNullable { get; set; } /// @@ -161,15 +159,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs index 5dd73a56ef7..4fb0d6ed89f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableShape.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,105 +19,53 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - [JsonConverter(typeof(NullableShapeJsonConverter))] - [DataContract(Name = "NullableShape")] - public partial class NullableShape : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class NullableShape : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public NullableShape() + /// quadrilateral + public NullableShape(Quadrilateral quadrilateral) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + Quadrilateral = quadrilateral; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public NullableShape(Quadrilateral actualInstance) + /// triangle + public NullableShape(Triangle triangle) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + Triangle = triangle; } /// - /// Initializes a new instance of the class - /// with the class + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - /// An instance of Triangle. - public NullableShape(Triangle actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + public Quadrilateral Quadrilateral { get; set; } /// - /// Gets or Sets ActualInstance + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } - } + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + public Triangle Triangle { get; set; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets additional properties /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } - - /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown - /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -123,91 +73,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, NullableShape.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of NullableShape - /// - /// JSON string - /// An instance of NullableShape - public static NullableShape FromJson(string jsonString) - { - NullableShape newNullableShape = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newNullableShape; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.SerializerSettings)); - } - else - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.SerializerSettings)); - } - else - { - newNullableShape = new NullableShape(JsonConvert.DeserializeObject(jsonString, NullableShape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newNullableShape; - } - /// /// Returns true if objects are equal /// @@ -237,8 +109,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -248,54 +122,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for NullableShape + /// A Json converter for type NullableShape /// - public class NullableShapeJsonConverter : JsonConverter + public class NullableShapeJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(NullableShape).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(NullableShape).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override NullableShape Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle triangle); + + + while (reader.Read()) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (quadrilateral != null) + return new NullableShape(quadrilateral); + + if (triangle != null) + return new NullableShape(triangle); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs index 7787cb03338..1b5a086f3ec 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// NumberOnly /// - [DataContract(Name = "NumberOnly")] public partial class NumberOnly : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// justNumber. + /// justNumber public NumberOnly(decimal justNumber = default) { - this.JustNumber = justNumber; - this.AdditionalProperties = new Dictionary(); + JustNumber = justNumber; } /// /// Gets or Sets JustNumber /// - [DataMember(Name = "JustNumber", EmitDefaultValue = false)] + [JsonPropertyName("JustNumber")] public decimal JustNumber { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -68,15 +66,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index de7d09291bf..ee1c67907f4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,49 +29,47 @@ namespace Org.OpenAPITools.Model /// /// ObjectWithDeprecatedFields /// - [DataContract(Name = "ObjectWithDeprecatedFields")] public partial class ObjectWithDeprecatedFields : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// uuid. - /// id. - /// deprecatedRef. - /// bars. + /// uuid + /// id + /// deprecatedRef + /// bars public ObjectWithDeprecatedFields(string uuid = default, decimal id = default, DeprecatedObject deprecatedRef = default, List bars = default) { - this.Uuid = uuid; - this.Id = id; - this.DeprecatedRef = deprecatedRef; - this.Bars = bars; - this.AdditionalProperties = new Dictionary(); + Uuid = uuid; + Id = id; + DeprecatedRef = deprecatedRef; + Bars = bars; } /// /// Gets or Sets Uuid /// - [DataMember(Name = "uuid", EmitDefaultValue = false)] + [JsonPropertyName("uuid")] public string Uuid { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] [Obsolete] public decimal Id { get; set; } /// /// Gets or Sets DeprecatedRef /// - [DataMember(Name = "deprecatedRef", EmitDefaultValue = false)] + [JsonPropertyName("deprecatedRef")] [Obsolete] public DeprecatedObject DeprecatedRef { get; set; } /// /// Gets or Sets Bars /// - [DataMember(Name = "bars", EmitDefaultValue = false)] + [JsonPropertyName("bars")] [Obsolete] public List Bars { get; set; } @@ -79,7 +77,7 @@ namespace Org.OpenAPITools.Model /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -98,15 +96,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs index 8c986b5f676..50648c48eb6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,14 +29,31 @@ namespace Org.OpenAPITools.Model /// /// Order /// - [DataContract(Name = "Order")] public partial class Order : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// id + /// petId + /// quantity + /// shipDate + /// Order Status + /// complete (default to false) + public Order(long id = default, long petId = default, int quantity = default, DateTime shipDate = default, StatusEnum status = default, bool complete = false) + { + Id = id; + PetId = petId; + Quantity = quantity; + ShipDate = shipDate; + Status = status; + Complete = complete; + } + /// /// Order Status /// /// Order Status - [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { /// @@ -59,68 +76,48 @@ namespace Org.OpenAPITools.Model } - /// /// Order Status /// /// Order Status - [DataMember(Name = "status", EmitDefaultValue = false)] + [JsonPropertyName("status")] public StatusEnum Status { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// id. - /// petId. - /// quantity. - /// shipDate. - /// Order Status. - /// complete (default to false). - public Order(long id = default, long petId = default, int quantity = default, DateTime shipDate = default, StatusEnum status = default, bool complete = false) - { - this.Id = id; - this.PetId = petId; - this.Quantity = quantity; - this.ShipDate = shipDate; - this.Status = status; - this.Complete = complete; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets PetId /// - [DataMember(Name = "petId", EmitDefaultValue = false)] + [JsonPropertyName("petId")] public long PetId { get; set; } /// /// Gets or Sets Quantity /// - [DataMember(Name = "quantity", EmitDefaultValue = false)] + [JsonPropertyName("quantity")] public int Quantity { get; set; } /// /// Gets or Sets ShipDate /// - [DataMember(Name = "shipDate", EmitDefaultValue = false)] + [JsonPropertyName("shipDate")] public DateTime ShipDate { get; set; } /// /// Gets or Sets Complete /// - [DataMember(Name = "complete", EmitDefaultValue = true)] + [JsonPropertyName("complete")] public bool Complete { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -141,15 +138,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs index 7f4749fe8b5..77750e36f17 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,46 +29,44 @@ namespace Org.OpenAPITools.Model /// /// OuterComposite /// - [DataContract(Name = "OuterComposite")] public partial class OuterComposite : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// myNumber. - /// myString. - /// myBoolean. + /// myNumber + /// myString + /// myBoolean public OuterComposite(decimal myNumber = default, string myString = default, bool myBoolean = default) { - this.MyNumber = myNumber; - this.MyString = myString; - this.MyBoolean = myBoolean; - this.AdditionalProperties = new Dictionary(); + MyNumber = myNumber; + MyString = myString; + MyBoolean = myBoolean; } /// /// Gets or Sets MyNumber /// - [DataMember(Name = "my_number", EmitDefaultValue = false)] + [JsonPropertyName("my_number")] public decimal MyNumber { get; set; } /// /// Gets or Sets MyString /// - [DataMember(Name = "my_string", EmitDefaultValue = false)] + [JsonPropertyName("my_string")] public string MyString { get; set; } /// /// Gets or Sets MyBoolean /// - [DataMember(Name = "my_boolean", EmitDefaultValue = true)] + [JsonPropertyName("my_boolean")] public bool MyBoolean { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,15 +84,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs index 2aa496a2e07..00283c562e5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines OuterEnum /// - [JsonConverter(typeof(StringEnumConverter))] public enum OuterEnum { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Delivered = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs index dd79c7010d6..f5cf13dcc86 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,7 +29,6 @@ namespace Org.OpenAPITools.Model /// /// Defines OuterEnumDefaultValue /// - [JsonConverter(typeof(StringEnumConverter))] public enum OuterEnumDefaultValue { /// @@ -51,5 +50,4 @@ namespace Org.OpenAPITools.Model Delivered = 3 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs index 44dc91c700a..558ff898db8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -47,5 +47,4 @@ namespace Org.OpenAPITools.Model NUMBER_2 = 2 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs index b927507cf97..4f1b6980073 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -47,5 +47,4 @@ namespace Org.OpenAPITools.Model NUMBER_2 = 2 } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs index ac986b555ef..2110ce35c54 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ParentPet.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,12 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -30,33 +29,15 @@ namespace Org.OpenAPITools.Model /// /// ParentPet /// - [DataContract(Name = "ParentPet")] - [JsonConverter(typeof(JsonSubtypes), "PetType")] - [JsonSubtypes.KnownSubType(typeof(ChildCat), "ChildCat")] - public partial class ParentPet : GrandparentAnimal, IEquatable, IValidatableObject + public partial class ParentPet : GrandparentAnimal, IEquatable { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ParentPet() + /// petType (required) + public ParentPet(string petType) : base(petType) { - this.AdditionalProperties = new Dictionary(); } - /// - /// Initializes a new instance of the class. - /// - /// petType (required) (default to "ParentPet"). - public ParentPet(string petType = "ParentPet") : base(petType) - { - this.AdditionalProperties = new Dictionary(); - } - - /// - /// Gets or Sets additional properties - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } /// /// Returns the string presentation of the object @@ -67,20 +48,10 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class ParentPet {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); - sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -110,37 +81,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = base.GetHashCode(); - if (this.AdditionalProperties != null) - { - hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); - } return hashCode; } } - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - public IEnumerable Validate(ValidationContext validationContext) - { - return this.BaseValidate(validationContext); - } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - protected IEnumerable BaseValidate(ValidationContext validationContext) - { - foreach (var x in BaseValidate(validationContext)) - { - yield return x; - } - yield break; - } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs index c7c27fb4e98..145de340a06 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,14 +29,35 @@ namespace Org.OpenAPITools.Model /// /// Pet /// - [DataContract(Name = "Pet")] public partial class Pet : IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// name (required) + /// photoUrls (required) + /// id + /// category + /// tags + /// pet status in the store + public Pet(string name, List photoUrls, long id = default, Category category = default, List tags = default, StatusEnum status = default) + { + if (name == null) + throw new ArgumentNullException("name is a required property for Pet and cannot be null."); + if (photoUrls == null) + throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null."); + Name = name; + PhotoUrls = photoUrls; + Id = id; + Category = category; + Tags = tags; + Status = status; + } + /// /// pet status in the store /// /// pet status in the store - [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { /// @@ -59,84 +80,48 @@ namespace Org.OpenAPITools.Model } - /// /// pet status in the store /// /// pet status in the store - [DataMember(Name = "status", EmitDefaultValue = false)] + [JsonPropertyName("status")] public StatusEnum Status { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected Pet() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// name (required). - /// photoUrls (required). - /// id. - /// category. - /// tags. - /// pet status in the store. - public Pet(string name, List photoUrls, long id = default, Category category = default, List tags = default, StatusEnum status = default) - { - // to ensure "name" is required (not null) - if (name == null) { - throw new ArgumentNullException("name is a required property for Pet and cannot be null"); - } - this.Name = name; - // to ensure "photoUrls" is required (not null) - if (photoUrls == null) { - throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null"); - } - this.PhotoUrls = photoUrls; - this.Id = id; - this.Category = category; - this.Tags = tags; - this.Status = status; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets Name /// - [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets PhotoUrls /// - [DataMember(Name = "photoUrls", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("photoUrls")] public List PhotoUrls { get; set; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets Category /// - [DataMember(Name = "category", EmitDefaultValue = false)] + [JsonPropertyName("category")] public Category Category { get; set; } /// /// Gets or Sets Tags /// - [DataMember(Name = "tags", EmitDefaultValue = false)] + [JsonPropertyName("tags")] public List Tags { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -157,15 +142,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs index b82c0899c27..fbaf444f689 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pig.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,96 +19,51 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Pig /// - [JsonConverter(typeof(PigJsonConverter))] - [DataContract(Name = "Pig")] - public partial class Pig : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Pig : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of BasquePig. - public Pig(BasquePig actualInstance) + /// basquePig + public Pig(BasquePig basquePig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + BasquePig = basquePig; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of DanishPig. - public Pig(DanishPig actualInstance) + /// danishPig + public Pig(DanishPig danishPig) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(BasquePig)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(DanishPig)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: BasquePig, DanishPig"); - } - } + DanishPig = danishPig; } /// - /// Get the actual instance of `BasquePig`. If the actual instance is not `BasquePig`, - /// the InvalidClassException will be thrown + /// Gets or Sets Pig /// - /// An instance of BasquePig - public BasquePig GetBasquePig() - { - return (BasquePig)this.ActualInstance; - } + public BasquePig BasquePig { get; set; } /// - /// Get the actual instance of `DanishPig`. If the actual instance is not `DanishPig`, - /// the InvalidClassException will be thrown + /// Gets or Sets Pig /// - /// An instance of DanishPig - public DanishPig GetDanishPig() - { - return (DanishPig)this.ActualInstance; - } + public DanishPig DanishPig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,91 +71,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Pig.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Pig - /// - /// JSON string - /// An instance of Pig - public static Pig FromJson(string jsonString) - { - Pig newPig = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newPig; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(BasquePig).GetProperty("AdditionalProperties") == null) - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.SerializerSettings)); - } - else - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("BasquePig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into BasquePig: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(DanishPig).GetProperty("AdditionalProperties") == null) - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.SerializerSettings)); - } - else - { - newPig = new Pig(JsonConvert.DeserializeObject(jsonString, Pig.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("DanishPig"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into DanishPig: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newPig; - } - /// /// Returns true if objects are equal /// @@ -228,8 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +120,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Pig + /// A Json converter for type Pig /// - public class PigJsonConverter : JsonConverter + public class PigJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Pig).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Pig).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Pig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader basquePigReader = reader; + Client.ClientUtils.TryDeserialize(ref basquePigReader, options, out BasquePig basquePig); + + Utf8JsonReader danishPigReader = reader; + Client.ClientUtils.TryDeserialize(ref danishPigReader, options, out DanishPig danishPig); + + + while (reader.Read()) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (basquePig != null) + return new Pig(basquePig); + + if (danishPig != null) + return new Pig(danishPig); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs index a1a850f169e..59527b032d5 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,96 +19,51 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Quadrilateral /// - [JsonConverter(typeof(QuadrilateralJsonConverter))] - [DataContract(Name = "Quadrilateral")] - public partial class Quadrilateral : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Quadrilateral : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of ComplexQuadrilateral. - public Quadrilateral(ComplexQuadrilateral actualInstance) + /// complexQuadrilateral + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + ComplexQuadrilateral = complexQuadrilateral; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of SimpleQuadrilateral. - public Quadrilateral(SimpleQuadrilateral actualInstance) + /// simpleQuadrilateral + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(ComplexQuadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(SimpleQuadrilateral)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: ComplexQuadrilateral, SimpleQuadrilateral"); - } - } + SimpleQuadrilateral = simpleQuadrilateral; } /// - /// Get the actual instance of `ComplexQuadrilateral`. If the actual instance is not `ComplexQuadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Quadrilateral /// - /// An instance of ComplexQuadrilateral - public ComplexQuadrilateral GetComplexQuadrilateral() - { - return (ComplexQuadrilateral)this.ActualInstance; - } + public ComplexQuadrilateral ComplexQuadrilateral { get; set; } /// - /// Get the actual instance of `SimpleQuadrilateral`. If the actual instance is not `SimpleQuadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Quadrilateral /// - /// An instance of SimpleQuadrilateral - public SimpleQuadrilateral GetSimpleQuadrilateral() - { - return (SimpleQuadrilateral)this.ActualInstance; - } + public SimpleQuadrilateral SimpleQuadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,91 +71,13 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Quadrilateral.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Quadrilateral - /// - /// JSON string - /// An instance of Quadrilateral - public static Quadrilateral FromJson(string jsonString) - { - Quadrilateral newQuadrilateral = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newQuadrilateral; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(ComplexQuadrilateral).GetProperty("AdditionalProperties") == null) - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.SerializerSettings)); - } - else - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("ComplexQuadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into ComplexQuadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(SimpleQuadrilateral).GetProperty("AdditionalProperties") == null) - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.SerializerSettings)); - } - else - { - newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("SimpleQuadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into SimpleQuadrilateral: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newQuadrilateral; - } - /// /// Returns true if objects are equal /// @@ -228,8 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +120,88 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Quadrilateral + /// A Json converter for type Quadrilateral /// - public class QuadrilateralJsonConverter : JsonConverter + public class QuadrilateralJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Quadrilateral).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Quadrilateral).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Quadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader complexQuadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref complexQuadrilateralReader, options, out ComplexQuadrilateral complexQuadrilateral); + + Utf8JsonReader simpleQuadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref simpleQuadrilateralReader, options, out SimpleQuadrilateral simpleQuadrilateral); + + + while (reader.Read()) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } } - return null; + + if (complexQuadrilateral != null) + return new Quadrilateral(complexQuadrilateral); + + if (simpleQuadrilateral != null) + return new Quadrilateral(simpleQuadrilateral); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index b29e2db36b6..ac7d334144d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// QuadrilateralInterface /// - [DataContract(Name = "QuadrilateralInterface")] public partial class QuadrilateralInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected QuadrilateralInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// quadrilateralType (required). + /// quadrilateralType (required) public QuadrilateralInterface(string quadrilateralType) { - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for QuadrilateralInterface and cannot be null."); + QuadrilateralType = quadrilateralType; } /// /// Gets or Sets QuadrilateralType /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("quadrilateralType")] public string QuadrilateralType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 6b4acaddf1b..4507699a2dc 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,44 +29,36 @@ namespace Org.OpenAPITools.Model /// /// ReadOnlyFirst /// - [DataContract(Name = "ReadOnlyFirst")] public partial class ReadOnlyFirst : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// baz. - public ReadOnlyFirst(string baz = default) + /// bar + /// baz + public ReadOnlyFirst(string bar = default, string baz = default) { - this.Baz = baz; - this.AdditionalProperties = new Dictionary(); + Bar = bar; + Baz = baz; } /// /// Gets or Sets Bar /// - [DataMember(Name = "bar", EmitDefaultValue = false)] + [JsonPropertyName("bar")] public string Bar { get; private set; } - /// - /// Returns false as Bar should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBar() - { - return false; - } /// /// Gets or Sets Baz /// - [DataMember(Name = "baz", EmitDefaultValue = false)] + [JsonPropertyName("baz")] public string Baz { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -83,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs index c862011ba9d..0ff72214bfb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Return.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,30 +29,28 @@ namespace Org.OpenAPITools.Model /// /// Model for testing reserved words /// - [DataContract(Name = "Return")] public partial class Return : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// _return. - public Return(int _return = default) + /// returnProperty + public Return(int returnProperty = default) { - this._Return = _return; - this.AdditionalProperties = new Dictionary(); + ReturnProperty = returnProperty; } /// - /// Gets or Sets _Return + /// Gets or Sets ReturnProperty /// - [DataMember(Name = "return", EmitDefaultValue = false)] - public int _Return { get; set; } + [JsonPropertyName("return")] + public int ReturnProperty { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -62,21 +60,12 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class Return {\n"); - sb.Append(" _Return: ").Append(_Return).Append("\n"); + sb.Append(" ReturnProperty: ").Append(ReturnProperty).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -106,7 +95,7 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this._Return.GetHashCode(); + hashCode = (hashCode * 59) + this.ReturnProperty.GetHashCode(); if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 206e0fbe331..0d04295d385 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// ScaleneTriangle /// - [DataContract(Name = "ScaleneTriangle")] public partial class ScaleneTriangle : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ScaleneTriangle() + /// shapeInterface + /// triangleInterface + public ScaleneTriangle(ShapeInterface shapeInterface, TriangleInterface triangleInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// triangleType (required). - public ScaleneTriangle(string shapeType, string triangleType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ScaleneTriangle and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for ScaleneTriangle and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + ShapeInterface = shapeInterface; + TriangleInterface = triangleInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets ScaleneTriangle /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// - /// Gets or Sets TriangleType + /// Gets or Sets ScaleneTriangle /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] - public string TriangleType { get; set; } + public TriangleInterface TriangleInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class ScaleneTriangle {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.TriangleType != null) - { - hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type ScaleneTriangle + /// + public class ScaleneTriangleJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ScaleneTriangle).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override ScaleneTriangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + Utf8JsonReader triangleInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleInterfaceReader, options, out TriangleInterface triangleInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new ScaleneTriangle(shapeInterface, triangleInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs index dd74fa4b718..98197f21b11 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Shape.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,96 +19,65 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Shape /// - [JsonConverter(typeof(ShapeJsonConverter))] - [DataContract(Name = "Shape")] - public partial class Shape : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Shape : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public Shape(Quadrilateral actualInstance) + /// quadrilateral + /// quadrilateralType (required) + public Shape(Quadrilateral quadrilateral, string quadrilateralType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for Shape and cannot be null."); + Quadrilateral = quadrilateral; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Triangle. - public Shape(Triangle actualInstance) + /// triangle + /// quadrilateralType (required) + public Shape(Triangle triangle, string quadrilateralType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for Shape and cannot be null."); + Triangle = triangle; + QuadrilateralType = quadrilateralType; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets Shape /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } + public Quadrilateral Quadrilateral { get; set; } /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Shape /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -114,91 +85,14 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Shape.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Shape - /// - /// JSON string - /// An instance of Shape - public static Shape FromJson(string jsonString) - { - Shape newShape = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newShape; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.SerializerSettings)); - } - else - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.SerializerSettings)); - } - else - { - newShape = new Shape(JsonConvert.DeserializeObject(jsonString, Shape.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newShape; - } - /// /// Returns true if objects are equal /// @@ -228,8 +122,14 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.QuadrilateralType != null) + { + hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -239,54 +139,92 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Shape + /// A Json converter for type Shape /// - public class ShapeJsonConverter : JsonConverter + public class ShapeJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Shape).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Shape).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Shape Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle triangle); + + string quadrilateralType = default; + + while (reader.Read()) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "quadrilateralType": + quadrilateralType = reader.GetString(); + break; + } + } } - return null; + + if (quadrilateral != null) + return new Shape(quadrilateral, quadrilateralType); + + if (triangle != null) + return new Shape(triangle, quadrilateralType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs index 55788e33f35..a578a3ec3b3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// ShapeInterface /// - [DataContract(Name = "ShapeInterface")] public partial class ShapeInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected ShapeInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). + /// shapeType (required) public ShapeInterface(string shapeType) { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null"); - } - this.ShapeType = shapeType; - this.AdditionalProperties = new Dictionary(); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for ShapeInterface and cannot be null."); + ShapeType = shapeType; } /// /// Gets or Sets ShapeType /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("shapeType")] public string ShapeType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs index c6b87c89751..36bb39889ee 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,105 +19,67 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - [JsonConverter(typeof(ShapeOrNullJsonConverter))] - [DataContract(Name = "ShapeOrNull")] - public partial class ShapeOrNull : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class ShapeOrNull : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - public ShapeOrNull() + /// quadrilateral + /// quadrilateralType (required) + public ShapeOrNull(Quadrilateral quadrilateral, string quadrilateralType) { - this.IsNullable = true; - this.SchemaType= "oneOf"; + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for ShapeOrNull and cannot be null."); + Quadrilateral = quadrilateral; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of Quadrilateral. - public ShapeOrNull(Quadrilateral actualInstance) + /// triangle + /// quadrilateralType (required) + public ShapeOrNull(Triangle triangle, string quadrilateralType) { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; + if (quadrilateralType == null) + throw new ArgumentNullException("quadrilateralType is a required property for ShapeOrNull and cannot be null."); + Triangle = triangle; + QuadrilateralType = quadrilateralType; } /// - /// Initializes a new instance of the class - /// with the class + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - /// An instance of Triangle. - public ShapeOrNull(Triangle actualInstance) - { - this.IsNullable = true; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance; - } - - - private Object _actualInstance; + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + public Quadrilateral Quadrilateral { get; set; } /// - /// Gets or Sets ActualInstance + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(Quadrilateral)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(Triangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: Quadrilateral, Triangle"); - } - } - } + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + public Triangle Triangle { get; set; } /// - /// Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`, - /// the InvalidClassException will be thrown + /// Gets or Sets QuadrilateralType /// - /// An instance of Quadrilateral - public Quadrilateral GetQuadrilateral() - { - return (Quadrilateral)this.ActualInstance; - } + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } /// - /// Get the actual instance of `Triangle`. If the actual instance is not `Triangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets additional properties /// - /// An instance of Triangle - public Triangle GetTriangle() - { - return (Triangle)this.ActualInstance; - } + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -123,91 +87,14 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, ShapeOrNull.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of ShapeOrNull - /// - /// JSON string - /// An instance of ShapeOrNull - public static ShapeOrNull FromJson(string jsonString) - { - ShapeOrNull newShapeOrNull = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newShapeOrNull; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Quadrilateral).GetProperty("AdditionalProperties") == null) - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.SerializerSettings)); - } - else - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Quadrilateral"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Quadrilateral: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(Triangle).GetProperty("AdditionalProperties") == null) - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.SerializerSettings)); - } - else - { - newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("Triangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into Triangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newShapeOrNull; - } - /// /// Returns true if objects are equal /// @@ -237,8 +124,14 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.QuadrilateralType != null) + { + hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -248,54 +141,92 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for ShapeOrNull + /// A Json converter for type ShapeOrNull /// - public class ShapeOrNullJsonConverter : JsonConverter + public class ShapeOrNullJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(ShapeOrNull).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(ShapeOrNull).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override ShapeOrNull Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralReader, options, out Quadrilateral quadrilateral); + + Utf8JsonReader triangleReader = reader; + Client.ClientUtils.TryDeserialize(ref triangleReader, options, out Triangle triangle); + + string quadrilateralType = default; + + while (reader.Read()) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "quadrilateralType": + quadrilateralType = reader.GetString(); + break; + } + } } - return null; + + if (quadrilateral != null) + return new ShapeOrNull(quadrilateral, quadrilateralType); + + if (triangle != null) + return new ShapeOrNull(triangle, quadrilateralType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 1398011e13f..049f67bb410 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,54 +29,34 @@ namespace Org.OpenAPITools.Model /// /// SimpleQuadrilateral /// - [DataContract(Name = "SimpleQuadrilateral")] public partial class SimpleQuadrilateral : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected SimpleQuadrilateral() + /// quadrilateralInterface + /// shapeInterface + public SimpleQuadrilateral(QuadrilateralInterface quadrilateralInterface, ShapeInterface shapeInterface) { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// shapeType (required). - /// quadrilateralType (required). - public SimpleQuadrilateral(string shapeType, string quadrilateralType) - { - // to ensure "shapeType" is required (not null) - if (shapeType == null) { - throw new ArgumentNullException("shapeType is a required property for SimpleQuadrilateral and cannot be null"); - } - this.ShapeType = shapeType; - // to ensure "quadrilateralType" is required (not null) - if (quadrilateralType == null) { - throw new ArgumentNullException("quadrilateralType is a required property for SimpleQuadrilateral and cannot be null"); - } - this.QuadrilateralType = quadrilateralType; - this.AdditionalProperties = new Dictionary(); + QuadrilateralInterface = quadrilateralInterface; + ShapeInterface = shapeInterface; } /// - /// Gets or Sets ShapeType + /// Gets or Sets SimpleQuadrilateral /// - [DataMember(Name = "shapeType", IsRequired = true, EmitDefaultValue = false)] - public string ShapeType { get; set; } + public QuadrilateralInterface QuadrilateralInterface { get; set; } /// - /// Gets or Sets QuadrilateralType + /// Gets or Sets SimpleQuadrilateral /// - [DataMember(Name = "quadrilateralType", IsRequired = true, EmitDefaultValue = false)] - public string QuadrilateralType { get; set; } + public ShapeInterface ShapeInterface { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -86,22 +66,11 @@ namespace Org.OpenAPITools.Model { StringBuilder sb = new StringBuilder(); sb.Append("class SimpleQuadrilateral {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -131,14 +100,6 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ShapeType != null) - { - hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); - } - if (this.QuadrilateralType != null) - { - hashCode = (hashCode * 59) + this.QuadrilateralType.GetHashCode(); - } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); @@ -158,4 +119,64 @@ namespace Org.OpenAPITools.Model } } + /// + /// A Json converter for type SimpleQuadrilateral + /// + public class SimpleQuadrilateralJsonConverter : JsonConverter + { + /// + /// Returns a boolean if the type is compatible with this converter. + /// + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(SimpleQuadrilateral).IsAssignableFrom(typeToConvert); + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override SimpleQuadrilateral Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader quadrilateralInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref quadrilateralInterfaceReader, options, out QuadrilateralInterface quadrilateralInterface); + Utf8JsonReader shapeInterfaceReader = reader; + Client.ClientUtils.TryDeserialize(ref shapeInterfaceReader, options, out ShapeInterface shapeInterface); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + } + } + } + + return new SimpleQuadrilateral(quadrilateralInterface, shapeInterface); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions options) => throw new NotImplementedException(); + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs index e24187da5be..48bdc9ff428 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// SpecialModelName /// - [DataContract(Name = "_special_model.name_")] public partial class SpecialModelName : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// specialPropertyName. - /// specialModelName. - public SpecialModelName(long specialPropertyName = default, string specialModelName = default) + /// specialPropertyName + /// specialModelNameProperty + public SpecialModelName(long specialPropertyName = default, string specialModelNameProperty = default) { - this.SpecialPropertyName = specialPropertyName; - this._SpecialModelName = specialModelName; - this.AdditionalProperties = new Dictionary(); + SpecialPropertyName = specialPropertyName; + SpecialModelNameProperty = specialModelNameProperty; } /// /// Gets or Sets SpecialPropertyName /// - [DataMember(Name = "$special[property.name]", EmitDefaultValue = false)] + [JsonPropertyName("$special[property.name]")] public long SpecialPropertyName { get; set; } /// - /// Gets or Sets _SpecialModelName + /// Gets or Sets SpecialModelNameProperty /// - [DataMember(Name = "_special_model.name_", EmitDefaultValue = false)] - public string _SpecialModelName { get; set; } + [JsonPropertyName("_special_model.name_")] + public string SpecialModelNameProperty { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -71,21 +69,12 @@ namespace Org.OpenAPITools.Model StringBuilder sb = new StringBuilder(); sb.Append("class SpecialModelName {\n"); sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); - sb.Append(" _SpecialModelName: ").Append(_SpecialModelName).Append("\n"); + sb.Append(" SpecialModelNameProperty: ").Append(SpecialModelNameProperty).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// @@ -116,9 +105,9 @@ namespace Org.OpenAPITools.Model { int hashCode = 41; hashCode = (hashCode * 59) + this.SpecialPropertyName.GetHashCode(); - if (this._SpecialModelName != null) + if (this.SpecialModelNameProperty != null) { - hashCode = (hashCode * 59) + this._SpecialModelName.GetHashCode(); + hashCode = (hashCode * 59) + this.SpecialModelNameProperty.GetHashCode(); } if (this.AdditionalProperties != null) { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs index cca02fceb32..a4d54a81f9a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Tag.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,38 +29,36 @@ namespace Org.OpenAPITools.Model /// /// Tag /// - [DataContract(Name = "Tag")] public partial class Tag : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// id. - /// name. + /// id + /// name public Tag(long id = default, string name = default) { - this.Id = id; - this.Name = name; - this.AdditionalProperties = new Dictionary(); + Id = id; + Name = name; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets Name /// - [DataMember(Name = "name", EmitDefaultValue = false)] + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -77,15 +75,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs index c8cf49ef7f6..ac2db7bde5d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Triangle.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,122 +19,101 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using JsonSubTypes; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; -using System.Reflection; namespace Org.OpenAPITools.Model { /// /// Triangle /// - [JsonConverter(typeof(TriangleJsonConverter))] - [DataContract(Name = "Triangle")] - public partial class Triangle : AbstractOpenAPISchema, IEquatable, IValidatableObject + public partial class Triangle : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of EquilateralTriangle. - public Triangle(EquilateralTriangle actualInstance) + /// equilateralTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(EquilateralTriangle equilateralTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + EquilateralTriangle = equilateralTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of IsoscelesTriangle. - public Triangle(IsoscelesTriangle actualInstance) + /// isoscelesTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(IsoscelesTriangle isoscelesTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + IsoscelesTriangle = isoscelesTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of ScaleneTriangle. - public Triangle(ScaleneTriangle actualInstance) + /// scaleneTriangle + /// shapeType (required) + /// triangleType (required) + public Triangle(ScaleneTriangle scaleneTriangle, string shapeType, string triangleType) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(EquilateralTriangle)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(IsoscelesTriangle)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(ScaleneTriangle)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: EquilateralTriangle, IsoscelesTriangle, ScaleneTriangle"); - } - } + if (shapeType == null) + throw new ArgumentNullException("shapeType is a required property for Triangle and cannot be null."); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for Triangle and cannot be null."); + ScaleneTriangle = scaleneTriangle; + ShapeType = shapeType; + TriangleType = triangleType; } /// - /// Get the actual instance of `EquilateralTriangle`. If the actual instance is not `EquilateralTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of EquilateralTriangle - public EquilateralTriangle GetEquilateralTriangle() - { - return (EquilateralTriangle)this.ActualInstance; - } + public EquilateralTriangle EquilateralTriangle { get; set; } /// - /// Get the actual instance of `IsoscelesTriangle`. If the actual instance is not `IsoscelesTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of IsoscelesTriangle - public IsoscelesTriangle GetIsoscelesTriangle() - { - return (IsoscelesTriangle)this.ActualInstance; - } + public IsoscelesTriangle IsoscelesTriangle { get; set; } /// - /// Get the actual instance of `ScaleneTriangle`. If the actual instance is not `ScaleneTriangle`, - /// the InvalidClassException will be thrown + /// Gets or Sets Triangle /// - /// An instance of ScaleneTriangle - public ScaleneTriangle GetScaleneTriangle() - { - return (ScaleneTriangle)this.ActualInstance; - } + public ScaleneTriangle ScaleneTriangle { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -140,111 +121,15 @@ namespace Org.OpenAPITools.Model /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public override string ToJson() - { - return JsonConvert.SerializeObject(this.ActualInstance, Triangle.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of Triangle - /// - /// JSON string - /// An instance of Triangle - public static Triangle FromJson(string jsonString) - { - Triangle newTriangle = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newTriangle; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(EquilateralTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("EquilateralTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into EquilateralTriangle: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(IsoscelesTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("IsoscelesTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into IsoscelesTriangle: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(ScaleneTriangle).GetProperty("AdditionalProperties") == null) - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.SerializerSettings)); - } - else - { - newTriangle = new Triangle(JsonConvert.DeserializeObject(jsonString, Triangle.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("ScaleneTriangle"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into ScaleneTriangle: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newTriangle; - } - /// /// Returns true if objects are equal /// @@ -274,8 +159,18 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.ShapeType != null) + { + hashCode = (hashCode * 59) + this.ShapeType.GetHashCode(); + } + if (this.TriangleType != null) + { + hashCode = (hashCode * 59) + this.TriangleType.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } @@ -285,54 +180,102 @@ namespace Org.OpenAPITools.Model /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + public IEnumerable Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) { yield break; } } /// - /// Custom JSON converter for Triangle + /// A Json converter for type Triangle /// - public class TriangleJsonConverter : JsonConverter + public class TriangleJsonConverter : JsonConverter { /// - /// To write the JSON string + /// Returns a boolean if the type is compatible with this converter. /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(Triangle).GetMethod("ToJson").Invoke(value, null))); - } + /// + /// + public override bool CanConvert(Type typeToConvert) => typeof(Triangle).IsAssignableFrom(typeToConvert); /// - /// To convert a JSON string into an object + /// A Json reader. /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + /// + /// + /// + /// + /// + public override Triangle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if(reader.TokenType != JsonToken.Null) + int currentDepth = reader.CurrentDepth; + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + + Utf8JsonReader equilateralTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref equilateralTriangleReader, options, out EquilateralTriangle equilateralTriangle); + + Utf8JsonReader isoscelesTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref isoscelesTriangleReader, options, out IsoscelesTriangle isoscelesTriangle); + + Utf8JsonReader scaleneTriangleReader = reader; + Client.ClientUtils.TryDeserialize(ref scaleneTriangleReader, options, out ScaleneTriangle scaleneTriangle); + + string shapeType = default; + string triangleType = default; + + while (reader.Read()) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + if (reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth) + break; + + if (reader.TokenType == JsonTokenType.PropertyName) + { + string propertyName = reader.GetString(); + reader.Read(); + + switch (propertyName) + { + case "shapeType": + shapeType = reader.GetString(); + break; + case "triangleType": + triangleType = reader.GetString(); + break; + } + } } - return null; + + if (equilateralTriangle != null) + return new Triangle(equilateralTriangle, shapeType, triangleType); + + if (isoscelesTriangle != null) + return new Triangle(isoscelesTriangle, shapeType, triangleType); + + if (scaleneTriangle != null) + return new Triangle(scaleneTriangle, shapeType, triangleType); + + throw new JsonException(); } /// - /// Check if the object can be converted + /// A Json writer /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions options) => throw new NotImplementedException(); } - } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs index 8c62abd8c65..f24f847c0c2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,42 +29,30 @@ namespace Org.OpenAPITools.Model /// /// TriangleInterface /// - [DataContract(Name = "TriangleInterface")] public partial class TriangleInterface : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected TriangleInterface() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// triangleType (required). + /// triangleType (required) public TriangleInterface(string triangleType) { - // to ensure "triangleType" is required (not null) - if (triangleType == null) { - throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null"); - } - this.TriangleType = triangleType; - this.AdditionalProperties = new Dictionary(); + if (triangleType == null) + throw new ArgumentNullException("triangleType is a required property for TriangleInterface and cannot be null."); + TriangleType = triangleType; } /// /// Gets or Sets TriangleType /// - [DataMember(Name = "triangleType", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("triangleType")] public string TriangleType { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -80,15 +68,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs index 709d9397d87..aacb22aaec2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/User.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,123 +29,121 @@ namespace Org.OpenAPITools.Model /// /// User /// - [DataContract(Name = "User")] public partial class User : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - /// id. - /// username. - /// firstName. - /// lastName. - /// email. - /// password. - /// phone. - /// User Status. - /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value.. - /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.. - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389. - /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values.. + /// id + /// username + /// firstName + /// lastName + /// email + /// password + /// phone + /// User Status + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. public User(long id = default, string username = default, string firstName = default, string lastName = default, string email = default, string password = default, string phone = default, int userStatus = default, Object objectWithNoDeclaredProps = default, Object objectWithNoDeclaredPropsNullable = default, Object anyTypeProp = default, Object anyTypePropNullable = default) { - this.Id = id; - this.Username = username; - this.FirstName = firstName; - this.LastName = lastName; - this.Email = email; - this.Password = password; - this.Phone = phone; - this.UserStatus = userStatus; - this.ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; - this.ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; - this.AnyTypeProp = anyTypeProp; - this.AnyTypePropNullable = anyTypePropNullable; - this.AdditionalProperties = new Dictionary(); + Id = id; + Username = username; + FirstName = firstName; + LastName = lastName; + Email = email; + Password = password; + Phone = phone; + UserStatus = userStatus; + ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullable = objectWithNoDeclaredPropsNullable; + AnyTypeProp = anyTypeProp; + AnyTypePropNullable = anyTypePropNullable; } /// /// Gets or Sets Id /// - [DataMember(Name = "id", EmitDefaultValue = false)] + [JsonPropertyName("id")] public long Id { get; set; } /// /// Gets or Sets Username /// - [DataMember(Name = "username", EmitDefaultValue = false)] + [JsonPropertyName("username")] public string Username { get; set; } /// /// Gets or Sets FirstName /// - [DataMember(Name = "firstName", EmitDefaultValue = false)] + [JsonPropertyName("firstName")] public string FirstName { get; set; } /// /// Gets or Sets LastName /// - [DataMember(Name = "lastName", EmitDefaultValue = false)] + [JsonPropertyName("lastName")] public string LastName { get; set; } /// /// Gets or Sets Email /// - [DataMember(Name = "email", EmitDefaultValue = false)] + [JsonPropertyName("email")] public string Email { get; set; } /// /// Gets or Sets Password /// - [DataMember(Name = "password", EmitDefaultValue = false)] + [JsonPropertyName("password")] public string Password { get; set; } /// /// Gets or Sets Phone /// - [DataMember(Name = "phone", EmitDefaultValue = false)] + [JsonPropertyName("phone")] public string Phone { get; set; } /// /// User Status /// /// User Status - [DataMember(Name = "userStatus", EmitDefaultValue = false)] + [JsonPropertyName("userStatus")] public int UserStatus { get; set; } /// /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. /// /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. - [DataMember(Name = "objectWithNoDeclaredProps", EmitDefaultValue = false)] + [JsonPropertyName("objectWithNoDeclaredProps")] public Object ObjectWithNoDeclaredProps { get; set; } /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. /// /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. - [DataMember(Name = "objectWithNoDeclaredPropsNullable", EmitDefaultValue = true)] + [JsonPropertyName("objectWithNoDeclaredPropsNullable")] public Object ObjectWithNoDeclaredPropsNullable { get; set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 - [DataMember(Name = "anyTypeProp", EmitDefaultValue = true)] + [JsonPropertyName("anyTypeProp")] public Object AnyTypeProp { get; set; } /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. /// /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. - [DataMember(Name = "anyTypePropNullable", EmitDefaultValue = true)] + [JsonPropertyName("anyTypePropNullable")] public Object AnyTypePropNullable { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -172,15 +170,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs index 2eb7fa28c7f..632ae576572 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Whale.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,58 +29,46 @@ namespace Org.OpenAPITools.Model /// /// Whale /// - [DataContract(Name = "whale")] public partial class Whale : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. /// - [JsonConstructorAttribute] - protected Whale() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// hasBaleen. - /// hasTeeth. + /// className (required) + /// hasBaleen + /// hasTeeth public Whale(string className, bool hasBaleen = default, bool hasTeeth = default) { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Whale and cannot be null"); - } - this.ClassName = className; - this.HasBaleen = hasBaleen; - this.HasTeeth = hasTeeth; - this.AdditionalProperties = new Dictionary(); + if (className == null) + throw new ArgumentNullException("className is a required property for Whale and cannot be null."); + ClassName = className; + HasBaleen = hasBaleen; + HasTeeth = hasTeeth; } /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets HasBaleen /// - [DataMember(Name = "hasBaleen", EmitDefaultValue = true)] + [JsonPropertyName("hasBaleen")] public bool HasBaleen { get; set; } /// /// Gets or Sets HasTeeth /// - [DataMember(Name = "hasTeeth", EmitDefaultValue = true)] + [JsonPropertyName("hasTeeth")] public bool HasTeeth { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -98,15 +86,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs index ddb4196e854..2bb9c1d7c5b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs @@ -1,3 +1,4 @@ +// /* * OpenAPI Petstore * @@ -8,6 +9,7 @@ */ + using System; using System.Collections; using System.Collections.Generic; @@ -17,11 +19,9 @@ using System.IO; using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.ComponentModel.DataAnnotations; -using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model @@ -29,13 +29,24 @@ namespace Org.OpenAPITools.Model /// /// Zebra /// - [DataContract(Name = "zebra")] public partial class Zebra : Dictionary, IEquatable, IValidatableObject { + /// + /// Initializes a new instance of the class. + /// + /// className (required) + /// type + public Zebra(string className, TypeEnum type = default) + { + if (className == null) + throw new ArgumentNullException("className is a required property for Zebra and cannot be null."); + ClassName = className; + Type = type; + } + /// /// Defines Type /// - [JsonConverter(typeof(StringEnumConverter))] public enum TypeEnum { /// @@ -58,47 +69,23 @@ namespace Org.OpenAPITools.Model } - /// /// Gets or Sets Type /// - [DataMember(Name = "type", EmitDefaultValue = false)] + [JsonPropertyName("type")] public TypeEnum Type { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected Zebra() - { - this.AdditionalProperties = new Dictionary(); - } - /// - /// Initializes a new instance of the class. - /// - /// className (required). - /// type. - public Zebra(string className, TypeEnum type = default) : base() - { - // to ensure "className" is required (not null) - if (className == null) { - throw new ArgumentNullException("className is a required property for Zebra and cannot be null"); - } - this.ClassName = className; - this.Type = type; - this.AdditionalProperties = new Dictionary(); - } - + /// /// Gets or Sets ClassName /// - [DataMember(Name = "className", IsRequired = true, EmitDefaultValue = false)] + [JsonPropertyName("className")] public string ClassName { get; set; } /// /// Gets or Sets additional properties /// [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } + public Dictionary AdditionalProperties { get; set; } = new Dictionary(); /// /// Returns the string presentation of the object @@ -116,15 +103,6 @@ namespace Org.OpenAPITools.Model return sb.ToString(); } - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - /// /// Returns true if objects are equal /// diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 93b0e35e2c5..5cbefcd8fba 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -21,8 +21,6 @@ - -