From 77fecf27eb68500d62df3d056ce98d999af13839 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 9 Jan 2026 18:10:43 +0000 Subject: [PATCH 1/6] bin/generate-samples: Remove warning about sleep The sleep itself has been commented out for a long time (commit 04fa53b69266 from September 2023, to be specific). Signed-off-by: Stephen Finucane --- bin/generate-samples.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/generate-samples.sh b/bin/generate-samples.sh index 197eb9183912..f1d3303024ac 100755 --- a/bin/generate-samples.sh +++ b/bin/generate-samples.sh @@ -52,8 +52,6 @@ if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then # shellcheck disable=SC2068 java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} else - echo "Please press CTRL+C to stop or the script will continue in 5 seconds." - #sleep 5 if [ ${#files[@]} -eq 0 ]; then files=("${root}"/bin/configs/*.yaml) fi From 588b3a9ce0e5ccf8d0fe42b672ad3a138b7b1ab4 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 20 Jan 2026 13:36:36 +0000 Subject: [PATCH 2/6] bin/generate-samples: Fix output on tmux Commit 23dae2bcd8c9 reworked this script to start capturing exceptions but the mechanism used was crude and broke output on tmux, since `/dev/pts/0` is hardcoded to a specific pseudo-terminal but each tmux pane gets its own pts. Rework this to use files instead. Signed-off-by: Stephen Finucane --- bin/generate-samples.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/bin/generate-samples.sh b/bin/generate-samples.sh index f1d3303024ac..b282b313c5c2 100755 --- a/bin/generate-samples.sh +++ b/bin/generate-samples.sh @@ -47,24 +47,26 @@ For example: echo "$header" +tmpfile=$(mktemp) +trap "rm -f $tmpfile" EXIT + if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then - # shellcheck disable=SC2086 - # shellcheck disable=SC2068 - java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} + # shellcheck disable=SC2086 + # shellcheck disable=SC2068 + java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} 2>&1 | tee "$tmpfile" + retcode=${PIPESTATUS[0]} else - if [ ${#files[@]} -eq 0 ]; then - files=("${root}"/bin/configs/*.yaml) - fi + if [ ${#files[@]} -eq 0 ]; then + files=("${root}"/bin/configs/*.yaml) + fi - # shellcheck disable=SC2086 - # shellcheck disable=SC2068 - if java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee /dev/pts/0 | grep -q -i "exception"; then - echo "Found exception(s) when running the generator(s) to update the samples." - export GENERATE_ERROR=1 - fi + # shellcheck disable=SC2086 + # shellcheck disable=SC2068 + java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee "$tmpfile" + retcode=${PIPESTATUS[0]} fi -if [[ -n "$GENERATE_ERROR" ]]; then +if [[ $retcode -ne 0 ]] || grep -q -i "exception" "$tmpfile"; then echo "Found exception(s) when running the generator(s) to update the samples." exit 1 fi From 145789e24caeafc6acd4a1a43a8c6cd592245a1f Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 22 Jan 2026 17:18:27 +0800 Subject: [PATCH 3/6] update error message, trigger build failur --- bin/generate-samples.sh | 2 +- .../main/java/org/openapitools/codegen/OpenAPINormalizer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/generate-samples.sh b/bin/generate-samples.sh index b282b313c5c2..f2bcd570cb68 100755 --- a/bin/generate-samples.sh +++ b/bin/generate-samples.sh @@ -66,7 +66,7 @@ else retcode=${PIPESTATUS[0]} fi -if [[ $retcode -ne 0 ]] || grep -q -i "exception" "$tmpfile"; then +if [[ $retcode -ne 0 ]] || grep -q -i "at org.openapitools" "$tmpfile"; then echo "Found exception(s) when running the generator(s) to update the samples." exit 1 fi diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index c91802e8e7fb..0bac66dd18dc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -722,7 +722,7 @@ protected boolean isSelfReference(String name, Schema subSchema) { */ public Schema normalizeSchema(Schema schema, Set visitedSchemas) { // normalize reference schema - if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { + if (StringUtils.isNotEmpty(schema.get$ref())) { normalizeReferenceSchema(schema); } From 29536fab8a1f1980f393b36421341492079764a0 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 22 Jan 2026 17:58:13 +0800 Subject: [PATCH 4/6] trigger build failure --- .../codegen/OpenAPINormalizer.java | 4 +- .../org/openapitools/client/apis/HeaderApi.kt | 92 ------------------- .../client/models/ApiStringEnumRef.kt | 64 ------------- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 4 +- .../Client/HostConfiguration.cs | 2 - .../Org.OpenAPITools/Model/CopyActivity.cs | 86 +++++++++++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net10/NullReferenceTypes/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../net10/Petstore/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net10/SourceGeneration/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 +++++++++++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net4.7/Petstore/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 +++++++++++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net4.8/Petstore/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 +++++++++++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net8/NullReferenceTypes/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../net8/Petstore/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net8/SourceGeneration/api/openapi.yaml | 36 +++----- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 +++++++++++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net10/Petstore/api/openapi.yaml | 36 +++----- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../httpclient/net9/Petstore/api/openapi.yaml | 36 +++----- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../standard2.0/Petstore/api/openapi.yaml | 36 +++----- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../net10/EnumMappings/api/openapi.yaml | 4 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../net4.7/Petstore/api/openapi.yaml | 4 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../net4.8/Petstore/api/openapi.yaml | 4 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../restsharp/net8/Petstore/api/openapi.yaml | 36 +++----- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../client/infrastructure/Serializer.kt | 17 ---- .../org/openapitools/client/models/Bird.kt | 46 ---------- 72 files changed, 944 insertions(+), 924 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index 0bac66dd18dc..dbe8c5beddd1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -573,6 +573,8 @@ protected void normalizeHeaders(Map headers) { // $ref: #/components/headers/Location Schema updatedHeader = normalizeSchema(h.getSchema(), new HashSet<>()); h.setSchema(updatedHeader); + throw new RuntimeException("trigger build failure"); + } } } @@ -722,7 +724,7 @@ protected boolean isSelfReference(String name, Schema subSchema) { */ public Schema normalizeSchema(Schema schema, Set visitedSchemas) { // normalize reference schema - if (StringUtils.isNotEmpty(schema.get$ref())) { + if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { normalizeReferenceSchema(schema); } diff --git a/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt b/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt index f5bef07b6a6d..e69de29bb2d1 100644 --- a/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt +++ b/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt @@ -1,92 +0,0 @@ -/** - * - * Please note: - * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * Do not edit this file manually. - * - */ - -@file:Suppress( - "ArrayInDataClass", - "EnumEntryName", - "RemoveRedundantQualifierName", - "UnusedImport" -) - -package org.openapitools.client.apis - -import com.fasterxml.jackson.annotation.JsonProperty - -import org.springframework.web.reactive.function.client.WebClient -import org.springframework.web.reactive.function.client.WebClientResponseException -import org.springframework.http.codec.json.Jackson2JsonDecoder -import org.springframework.http.codec.json.Jackson2JsonEncoder -import org.springframework.http.ResponseEntity -import org.springframework.http.MediaType -import reactor.core.publisher.Mono -import org.springframework.util.LinkedMultiValueMap - -import org.openapitools.client.models.StringEnumRef -import org.openapitools.client.infrastructure.* - -open class HeaderApi(client: WebClient) : ApiClient(client) { - - constructor(baseUrl: String) : this(WebClient.builder() - .baseUrl(baseUrl) - .codecs { - it.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON)) - it.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON)) - } - .build() - ) - - /** - * enum for parameter enumNonrefStringHeader - */ - enum class EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums(val value: kotlin.String) { - @JsonProperty(value = "success") success("success"), - @JsonProperty(value = "failure") failure("failure"), - @JsonProperty(value = "unclassified") unclassified("unclassified"), - } - - - @Throws(WebClientResponseException::class) - fun testHeaderIntegerBooleanStringEnums(integerHeader: kotlin.Int? = null, booleanHeader: kotlin.Boolean? = null, stringHeader: kotlin.String? = null, enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, enumRefStringHeader: StringEnumRef? = null): Mono { - return testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader = integerHeader, booleanHeader = booleanHeader, stringHeader = stringHeader, enumNonrefStringHeader = enumNonrefStringHeader, enumRefStringHeader = enumRefStringHeader) - .map { it.body!! } - } - - @Throws(WebClientResponseException::class) - fun testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader: kotlin.Int? = null, booleanHeader: kotlin.Boolean? = null, stringHeader: kotlin.String? = null, enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, enumRefStringHeader: StringEnumRef? = null): Mono> { - val localVariableConfig = testHeaderIntegerBooleanStringEnumsRequestConfig(integerHeader = integerHeader, booleanHeader = booleanHeader, stringHeader = stringHeader, enumNonrefStringHeader = enumNonrefStringHeader, enumRefStringHeader = enumRefStringHeader) - return request( - localVariableConfig - ) - } - - fun testHeaderIntegerBooleanStringEnumsRequestConfig(integerHeader: kotlin.Int? = null, booleanHeader: kotlin.Boolean? = null, stringHeader: kotlin.String? = null, enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, enumRefStringHeader: StringEnumRef? = null) : RequestConfig { - val localVariableBody = null - val localVariableQuery = mutableMapOf>() - val localVariableHeaders: MutableMap = mutableMapOf() - integerHeader?.apply { localVariableHeaders["integer_header"] = this.toString() } - booleanHeader?.apply { localVariableHeaders["boolean_header"] = this.toString() } - stringHeader?.apply { localVariableHeaders["string_header"] = this.toString() } - enumNonrefStringHeader?.apply { localVariableHeaders["enum_nonref_string_header"] = this.toString() } - enumRefStringHeader?.apply { localVariableHeaders["enum_ref_string_header"] = this.toString() } - localVariableHeaders["Accept"] = "text/plain" - - val params = mutableMapOf( - ) - - return RequestConfig( - method = RequestMethod.GET, - path = "/header/integer/boolean/string/enums", - params = params, - query = localVariableQuery, - headers = localVariableHeaders, - requiresAuthentication = false, - body = localVariableBody - ) - } - -} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt index d9971985a7ea..e69de29bb2d1 100644 --- a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt @@ -1,64 +0,0 @@ -/** - * - * Please note: - * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * Do not edit this file manually. - * - */ - -@file:Suppress( - "ArrayInDataClass", - "EnumEntryName", - "RemoveRedundantQualifierName", - "UnusedImport" -) - -package org.openapitools.client.models - - -import com.google.gson.annotations.SerializedName - -/** - * - * - * Values: SUCCESS,FAILURE,UNCLASSIFIED - */ - -enum class ApiStringEnumRef(val value: kotlin.String) { - - @SerializedName(value = "success") - SUCCESS("success"), - - @SerializedName(value = "failure") - FAILURE("failure"), - - @SerializedName(value = "unclassified") - UNCLASSIFIED("unclassified"); - - /** - * Override [toString()] to avoid using the enum variable name as the value, and instead use - * the actual value defined in the API spec file. - * - * This solves a problem when the variable name and its value are different, and ensures that - * the client sends the correct enum values to the server always. - */ - override fun toString(): kotlin.String = value - - companion object { - /** - * Converts the provided [data] to a [String] on success, null otherwise. - */ - fun encode(data: kotlin.Any?): kotlin.String? = if (data is ApiStringEnumRef) "$data" else null - - /** - * Returns a valid [ApiStringEnumRef] for [data], null otherwise. - */ - fun decode(data: kotlin.Any?): ApiStringEnumRef? = data?.let { - val normalizedData = "$it".lowercase() - values().firstOrNull { value -> - it == value || normalizedData == "$value".lowercase() - } - } - } -} - diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md index 626f40190a6d..eb13cef5182d 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **CopyActivityAllOfSchema** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] [[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/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 97b8745cc47b..0a0579ec3b92 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -158,8 +158,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCatAllOfPetType childCatAllOfPetType) return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); - if (obj is CopyActivityAllOfSchema copyActivityAllOfSchema) - return CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivityAllOfSchema); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); if (obj is EnumArraysJustSymbol enumArraysJustSymbol) diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index efaff580a5f9..2c2b9348011f 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -63,8 +63,6 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); - _jsonOptions.Converters.Add(new CopyActivityAllOfSchemaJsonConverter()); - _jsonOptions.Converters.Add(new CopyActivityAllOfSchemaNullableJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index de8390a77eb4..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,25 +36,77 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; - Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets CopyActivitytt + /// Defines Schema /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new CopyActivityAllOfSchema Schema { get; } + public new SchemaEnum Schema { get; } + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// Returns the string presentation of the object @@ -93,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; + Option schema = default; Option copyActivitytt = default; - Option schema = default; while (utf8JsonReader.Read()) { @@ -111,13 +163,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); break; default: break; @@ -125,18 +177,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -167,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 50db62858883..481171480f24 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs index f1139898f661..d2cbf27feffc 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -38,8 +38,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -97,12 +97,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -110,6 +104,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -147,8 +147,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -165,32 +165,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -221,9 +221,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index 1668434a783f..50ac7da73a2b 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -185,7 +185,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -199,6 +199,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -232,6 +235,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -249,13 +255,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index ad5599ac0126..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -95,12 +95,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -108,6 +102,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 50db62858883..481171480f24 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs index f7b7ff3f95b2..a4a704b58170 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -39,8 +39,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -98,12 +98,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -111,6 +105,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -148,8 +148,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -166,32 +166,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -222,9 +222,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index b6400a09e802..6ada96b312b5 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -186,7 +186,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -200,6 +200,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,6 +236,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -250,13 +256,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md index 626f40190a6d..eb13cef5182d 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **CopyActivityAllOfSchema** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] [[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/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index de8390a77eb4..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,25 +36,77 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; - Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets CopyActivitytt + /// Defines Schema /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new CopyActivityAllOfSchema Schema { get; } + public new SchemaEnum Schema { get; } + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// Returns the string presentation of the object @@ -93,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; + Option schema = default; Option copyActivitytt = default; - Option schema = default; while (utf8JsonReader.Read()) { @@ -111,13 +163,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); break; default: break; @@ -125,18 +177,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -167,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index e83b95303760..81f04e862bfe 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index ad5599ac0126..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -95,12 +95,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -108,6 +102,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index e83b95303760..81f04e862bfe 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md index 626f40190a6d..eb13cef5182d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **CopyActivityAllOfSchema** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] [[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/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index de8390a77eb4..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,25 +36,77 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; - Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets CopyActivitytt + /// Defines Schema /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new CopyActivityAllOfSchema Schema { get; } + public new SchemaEnum Schema { get; } + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// Returns the string presentation of the object @@ -93,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; + Option schema = default; Option copyActivitytt = default; - Option schema = default; while (utf8JsonReader.Read()) { @@ -111,13 +163,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); break; default: break; @@ -125,18 +177,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -167,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index e83b95303760..81f04e862bfe 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index ad5599ac0126..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -95,12 +95,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -108,6 +102,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index e83b95303760..81f04e862bfe 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md index 626f40190a6d..eb13cef5182d 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **CopyActivityAllOfSchema** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] [[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/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index de8390a77eb4..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,25 +36,77 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; - Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets CopyActivitytt + /// Defines Schema /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new CopyActivityAllOfSchema Schema { get; } + public new SchemaEnum Schema { get; } + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// Returns the string presentation of the object @@ -93,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; + Option schema = default; Option copyActivitytt = default; - Option schema = default; while (utf8JsonReader.Read()) { @@ -111,13 +163,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); break; default: break; @@ -125,18 +177,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -167,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 50db62858883..481171480f24 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs index f1139898f661..d2cbf27feffc 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -38,8 +38,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -97,12 +97,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -110,6 +104,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -147,8 +147,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -165,32 +165,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -221,9 +221,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index 1668434a783f..50ac7da73a2b 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -185,7 +185,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -199,6 +199,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -232,6 +235,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -249,13 +255,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index ad5599ac0126..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -95,12 +95,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -108,6 +102,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 50db62858883..481171480f24 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs index f7b7ff3f95b2..a4a704b58170 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -39,8 +39,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -98,12 +98,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -111,6 +105,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -148,8 +148,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -166,32 +166,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -222,9 +222,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index b6400a09e802..6ada96b312b5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -186,7 +186,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -200,6 +200,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,6 +236,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -250,13 +256,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md index 626f40190a6d..eb13cef5182d 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **CopyActivityAllOfSchema** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] [[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/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index de8390a77eb4..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,25 +36,77 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; - Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets CopyActivitytt + /// Defines Schema /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new CopyActivityAllOfSchema Schema { get; } + public new SchemaEnum Schema { get; } + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// Returns the string presentation of the object @@ -93,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; + Option schema = default; Option copyActivitytt = default; - Option schema = default; while (utf8JsonReader.Read()) { @@ -111,13 +163,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); break; default: break; @@ -125,18 +177,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -167,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 50db62858883..481171480f24 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs index f1139898f661..d2cbf27feffc 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -38,8 +38,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -97,12 +97,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -110,6 +104,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -147,8 +147,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -165,32 +165,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -221,9 +221,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index 1668434a783f..50ac7da73a2b 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -185,7 +185,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -199,6 +199,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -232,6 +235,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -249,13 +255,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index ad5599ac0126..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -95,12 +95,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -108,6 +102,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 50db62858883..481171480f24 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs index f7b7ff3f95b2..a4a704b58170 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -39,8 +39,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -98,12 +98,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -111,6 +105,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -148,8 +148,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -166,32 +166,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -222,9 +222,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index b6400a09e802..6ada96b312b5 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -186,7 +186,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -200,6 +200,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,6 +236,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -250,13 +256,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index ad5599ac0126..7a8ae9371f73 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - CopyActivitytt = copyActivitytt; Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); + CopyActivitytt = copyActivitytt; OnCreated(); } @@ -95,12 +95,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// The discriminator /// @@ -108,6 +102,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option copyActivitytt = default; Option schema = default; + Option copyActivitytt = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; default: break; } } } - if (!copyActivitytt.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (!schema.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (copyActivitytt.IsSet && copyActivitytt.Value == null) - throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); if (schema.IsSet && schema.Value == null) throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index e83b95303760..81f04e862bfe 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,6 +197,9 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + if (shapeOrNull.IsSet && shapeOrNull.Value == null) + throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); + if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -230,6 +233,9 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) + throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -247,13 +253,10 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - if (drawing.ShapeOrNullOption.Value != null) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } - else - writer.WriteNull("shapeOrNull"); + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 575712f265f0..ffc3620b9cba 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -58,7 +58,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 575712f265f0..ffc3620b9cba 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -58,7 +58,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 575712f265f0..ffc3620b9cba 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -58,7 +58,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml index 886c93019332..e44d1cd61058 100644 --- a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml @@ -2440,8 +2440,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2490,8 +2490,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: diff --git a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml index 886c93019332..e44d1cd61058 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml @@ -2440,8 +2440,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2490,8 +2490,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: diff --git a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml index 886c93019332..e44d1cd61058 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml @@ -2440,8 +2440,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2490,8 +2490,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: diff --git a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml index d8106a5755fc..5b4ccb1ffbab 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType - nullable: true oneOf: + - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,20 +2832,17 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt - type: object - example: null + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt type: object - example: null EntityBase: discriminator: mapping: @@ -2884,13 +2881,10 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - - properties: - code: - $ref: "#/components/schemas/TestResultCode" - type: object - example: null + properties: + code: + $ref: "#/components/schemas/TestResultCode" type: object - example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs index d7fa71ed6efe..0851f6c8dc9e 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs @@ -91,7 +91,7 @@ public bool ShouldSerializeMainShape() /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get{ return _ShapeOrNull;} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index f9918311cf5f..17610d81aa58 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 80783430664b..e69de29bb2d1 100644 --- a/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -1,17 +0,0 @@ -package org.openapitools.client.infrastructure - -import com.fasterxml.jackson.databind.DeserializationFeature -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.SerializationFeature -import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper - -object Serializer { - @JvmStatic - val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper() - .findAndRegisterModules() - .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) - .configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true) - .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) -} diff --git a/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt b/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt index dfa9d858b04c..e69de29bb2d1 100644 --- a/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt +++ b/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt @@ -1,46 +0,0 @@ -/** - * - * Please note: - * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * Do not edit this file manually. - * - */ - -@file:Suppress( - "ArrayInDataClass", - "EnumEntryName", - "RemoveRedundantQualifierName", - "UnusedImport" -) - -package org.openapitools.client.models - -import org.openapitools.client.models.Animal - -import kotlinx.serialization.* -import kotlinx.serialization.descriptors.* -import kotlinx.serialization.encoding.* - -/** - * - * - * @param id - * @param featherType - * @param optionalProperty - */ -@Serializable - -@SerialName(value = "BIRD") -data class Bird ( - - @SerialName(value = "id") @Required override val id: kotlin.String, - - @SerialName(value = "featherType") @Required val featherType: kotlin.String, - - @SerialName(value = "optional_property") override val optionalProperty: kotlin.Double? = null - -) : Animal() { - - -} - From 443ff4f2e61fb1b6d8875d47ba70e212146555f2 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 22 Jan 2026 18:40:06 +0800 Subject: [PATCH 5/6] Revert "trigger build failure" This reverts commit 29536fab8a1f1980f393b36421341492079764a0. --- .../codegen/OpenAPINormalizer.java | 4 +- .../org/openapitools/client/apis/HeaderApi.kt | 92 +++++++++++++++++++ .../client/models/ApiStringEnumRef.kt | 64 +++++++++++++ .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 4 +- .../Client/HostConfiguration.cs | 2 + .../Org.OpenAPITools/Model/CopyActivity.cs | 86 ++++------------- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net10/NullReferenceTypes/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../net10/Petstore/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net10/SourceGeneration/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 ++++------------- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net4.7/Petstore/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 ++++------------- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net4.8/Petstore/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 ++++------------- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net8/NullReferenceTypes/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../net8/Petstore/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net8/SourceGeneration/api/openapi.yaml | 36 +++++--- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../FormModels/docs/models/CopyActivity.md | 2 +- .../Org.OpenAPITools/Model/CopyActivity.cs | 86 ++++------------- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 19 ++-- .../Org.OpenAPITools/Model/CopyActivity.cs | 36 ++++---- .../src/Org.OpenAPITools/Model/Drawing.cs | 17 ++-- .../net10/Petstore/api/openapi.yaml | 36 +++++--- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../httpclient/net9/Petstore/api/openapi.yaml | 36 +++++--- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../standard2.0/Petstore/api/openapi.yaml | 36 +++++--- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../net10/EnumMappings/api/openapi.yaml | 4 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../net4.7/Petstore/api/openapi.yaml | 4 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../net4.8/Petstore/api/openapi.yaml | 4 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../restsharp/net8/Petstore/api/openapi.yaml | 36 +++++--- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 2 +- .../client/infrastructure/Serializer.kt | 17 ++++ .../org/openapitools/client/models/Bird.kt | 46 ++++++++++ 72 files changed, 924 insertions(+), 944 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index dbe8c5beddd1..0bac66dd18dc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -573,8 +573,6 @@ protected void normalizeHeaders(Map headers) { // $ref: #/components/headers/Location Schema updatedHeader = normalizeSchema(h.getSchema(), new HashSet<>()); h.setSchema(updatedHeader); - throw new RuntimeException("trigger build failure"); - } } } @@ -724,7 +722,7 @@ protected boolean isSelfReference(String name, Schema subSchema) { */ public Schema normalizeSchema(Schema schema, Set visitedSchemas) { // normalize reference schema - if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { + if (StringUtils.isNotEmpty(schema.get$ref())) { normalizeReferenceSchema(schema); } diff --git a/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt b/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt index e69de29bb2d1..f5bef07b6a6d 100644 --- a/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt +++ b/samples/client/echo_api/kotlin-jvm-spring-3-webclient/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt @@ -0,0 +1,92 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import com.fasterxml.jackson.annotation.JsonProperty + +import org.springframework.web.reactive.function.client.WebClient +import org.springframework.web.reactive.function.client.WebClientResponseException +import org.springframework.http.codec.json.Jackson2JsonDecoder +import org.springframework.http.codec.json.Jackson2JsonEncoder +import org.springframework.http.ResponseEntity +import org.springframework.http.MediaType +import reactor.core.publisher.Mono +import org.springframework.util.LinkedMultiValueMap + +import org.openapitools.client.models.StringEnumRef +import org.openapitools.client.infrastructure.* + +open class HeaderApi(client: WebClient) : ApiClient(client) { + + constructor(baseUrl: String) : this(WebClient.builder() + .baseUrl(baseUrl) + .codecs { + it.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON)) + it.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON)) + } + .build() + ) + + /** + * enum for parameter enumNonrefStringHeader + */ + enum class EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums(val value: kotlin.String) { + @JsonProperty(value = "success") success("success"), + @JsonProperty(value = "failure") failure("failure"), + @JsonProperty(value = "unclassified") unclassified("unclassified"), + } + + + @Throws(WebClientResponseException::class) + fun testHeaderIntegerBooleanStringEnums(integerHeader: kotlin.Int? = null, booleanHeader: kotlin.Boolean? = null, stringHeader: kotlin.String? = null, enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, enumRefStringHeader: StringEnumRef? = null): Mono { + return testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader = integerHeader, booleanHeader = booleanHeader, stringHeader = stringHeader, enumNonrefStringHeader = enumNonrefStringHeader, enumRefStringHeader = enumRefStringHeader) + .map { it.body!! } + } + + @Throws(WebClientResponseException::class) + fun testHeaderIntegerBooleanStringEnumsWithHttpInfo(integerHeader: kotlin.Int? = null, booleanHeader: kotlin.Boolean? = null, stringHeader: kotlin.String? = null, enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, enumRefStringHeader: StringEnumRef? = null): Mono> { + val localVariableConfig = testHeaderIntegerBooleanStringEnumsRequestConfig(integerHeader = integerHeader, booleanHeader = booleanHeader, stringHeader = stringHeader, enumNonrefStringHeader = enumNonrefStringHeader, enumRefStringHeader = enumRefStringHeader) + return request( + localVariableConfig + ) + } + + fun testHeaderIntegerBooleanStringEnumsRequestConfig(integerHeader: kotlin.Int? = null, booleanHeader: kotlin.Boolean? = null, stringHeader: kotlin.String? = null, enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, enumRefStringHeader: StringEnumRef? = null) : RequestConfig { + val localVariableBody = null + val localVariableQuery = mutableMapOf>() + val localVariableHeaders: MutableMap = mutableMapOf() + integerHeader?.apply { localVariableHeaders["integer_header"] = this.toString() } + booleanHeader?.apply { localVariableHeaders["boolean_header"] = this.toString() } + stringHeader?.apply { localVariableHeaders["string_header"] = this.toString() } + enumNonrefStringHeader?.apply { localVariableHeaders["enum_nonref_string_header"] = this.toString() } + enumRefStringHeader?.apply { localVariableHeaders["enum_ref_string_header"] = this.toString() } + localVariableHeaders["Accept"] = "text/plain" + + val params = mutableMapOf( + ) + + return RequestConfig( + method = RequestMethod.GET, + path = "/header/integer/boolean/string/enums", + params = params, + query = localVariableQuery, + headers = localVariableHeaders, + requiresAuthentication = false, + body = localVariableBody + ) + } + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt index e69de29bb2d1..d9971985a7ea 100644 --- a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt @@ -0,0 +1,64 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * Values: SUCCESS,FAILURE,UNCLASSIFIED + */ + +enum class ApiStringEnumRef(val value: kotlin.String) { + + @SerializedName(value = "success") + SUCCESS("success"), + + @SerializedName(value = "failure") + FAILURE("failure"), + + @SerializedName(value = "unclassified") + UNCLASSIFIED("unclassified"); + + /** + * Override [toString()] to avoid using the enum variable name as the value, and instead use + * the actual value defined in the API spec file. + * + * This solves a problem when the variable name and its value are different, and ensures that + * the client sends the correct enum values to the server always. + */ + override fun toString(): kotlin.String = value + + companion object { + /** + * Converts the provided [data] to a [String] on success, null otherwise. + */ + fun encode(data: kotlin.Any?): kotlin.String? = if (data is ApiStringEnumRef) "$data" else null + + /** + * Returns a valid [ApiStringEnumRef] for [data], null otherwise. + */ + fun decode(data: kotlin.Any?): ApiStringEnumRef? = data?.let { + val normalizedData = "$it".lowercase() + values().firstOrNull { value -> + it == value || normalizedData == "$value".lowercase() + } + } + } +} + diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md index eb13cef5182d..626f40190a6d 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**Schema** | **CopyActivityAllOfSchema** | | [[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/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 0a0579ec3b92..97b8745cc47b 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -158,8 +158,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCatAllOfPetType childCatAllOfPetType) return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); - if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) - return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); + if (obj is CopyActivityAllOfSchema copyActivityAllOfSchema) + return CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivityAllOfSchema); if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); if (obj is EnumArraysJustSymbol enumArraysJustSymbol) diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index 2c2b9348011f..efaff580a5f9 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -63,6 +63,8 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityAllOfSchemaJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityAllOfSchemaNullableJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..de8390a77eb4 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,77 +36,25 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Defines Schema - /// - public enum SchemaEnum - { - /// - /// Enum ScopeActivity for value: ScopeActivity - /// - ScopeActivity = 1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static SchemaEnum SchemaEnumFromString(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - return null; - } - - /// - /// Converts the to the json value + /// Gets or Sets CopyActivitytt /// - /// - /// - /// - public static string SchemaEnumToJsonValue(SchemaEnum value) - { - if (value == SchemaEnum.ScopeActivity) - return "ScopeActivity"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new SchemaEnum Schema { get; } - - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public new CopyActivityAllOfSchema Schema { get; } /// /// Returns the string presentation of the object @@ -145,8 +93,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,13 +111,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); - break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); + schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); break; default: break; @@ -177,18 +125,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +167,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 481171480f24..50db62858883 100644 --- a/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs index d2cbf27feffc..f1139898f661 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -38,8 +38,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -97,6 +97,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -104,12 +110,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -147,8 +147,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -165,32 +165,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -221,9 +221,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index 50ac7da73a2b..1668434a783f 100644 --- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -185,7 +185,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -199,9 +199,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -235,9 +232,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -255,10 +249,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..ad5599ac0126 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -95,6 +95,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -102,12 +108,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 481171480f24..50db62858883 100644 --- a/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs index a4a704b58170..f7b7ff3f95b2 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -39,8 +39,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -98,6 +98,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -105,12 +111,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -148,8 +148,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -166,32 +166,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -222,9 +222,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index 6ada96b312b5..b6400a09e802 100644 --- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -186,7 +186,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -200,9 +200,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -236,9 +233,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -256,10 +250,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md index eb13cef5182d..626f40190a6d 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**Schema** | **CopyActivityAllOfSchema** | | [[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/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..de8390a77eb4 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,77 +36,25 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Defines Schema - /// - public enum SchemaEnum - { - /// - /// Enum ScopeActivity for value: ScopeActivity - /// - ScopeActivity = 1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static SchemaEnum SchemaEnumFromString(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - return null; - } - - /// - /// Converts the to the json value + /// Gets or Sets CopyActivitytt /// - /// - /// - /// - public static string SchemaEnumToJsonValue(SchemaEnum value) - { - if (value == SchemaEnum.ScopeActivity) - return "ScopeActivity"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new SchemaEnum Schema { get; } - - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public new CopyActivityAllOfSchema Schema { get; } /// /// Returns the string presentation of the object @@ -145,8 +93,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,13 +111,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); - break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); + schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); break; default: break; @@ -177,18 +125,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +167,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 81f04e862bfe..e83b95303760 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..ad5599ac0126 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -95,6 +95,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -102,12 +108,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 81f04e862bfe..e83b95303760 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md index eb13cef5182d..626f40190a6d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**Schema** | **CopyActivityAllOfSchema** | | [[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/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..de8390a77eb4 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,77 +36,25 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Defines Schema - /// - public enum SchemaEnum - { - /// - /// Enum ScopeActivity for value: ScopeActivity - /// - ScopeActivity = 1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static SchemaEnum SchemaEnumFromString(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - return null; - } - - /// - /// Converts the to the json value + /// Gets or Sets CopyActivitytt /// - /// - /// - /// - public static string SchemaEnumToJsonValue(SchemaEnum value) - { - if (value == SchemaEnum.ScopeActivity) - return "ScopeActivity"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new SchemaEnum Schema { get; } - - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public new CopyActivityAllOfSchema Schema { get; } /// /// Returns the string presentation of the object @@ -145,8 +93,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,13 +111,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); - break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); + schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); break; default: break; @@ -177,18 +125,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +167,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 81f04e862bfe..e83b95303760 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..ad5599ac0126 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -95,6 +95,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -102,12 +108,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 81f04e862bfe..e83b95303760 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md index eb13cef5182d..626f40190a6d 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**Schema** | **CopyActivityAllOfSchema** | | [[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/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..de8390a77eb4 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,77 +36,25 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Defines Schema - /// - public enum SchemaEnum - { - /// - /// Enum ScopeActivity for value: ScopeActivity - /// - ScopeActivity = 1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static SchemaEnum SchemaEnumFromString(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - return null; - } - - /// - /// Converts the to the json value + /// Gets or Sets CopyActivitytt /// - /// - /// - /// - public static string SchemaEnumToJsonValue(SchemaEnum value) - { - if (value == SchemaEnum.ScopeActivity) - return "ScopeActivity"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new SchemaEnum Schema { get; } - - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public new CopyActivityAllOfSchema Schema { get; } /// /// Returns the string presentation of the object @@ -145,8 +93,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,13 +111,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); - break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); + schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); break; default: break; @@ -177,18 +125,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +167,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 481171480f24..50db62858883 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs index d2cbf27feffc..f1139898f661 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -38,8 +38,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -97,6 +97,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -104,12 +110,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -147,8 +147,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -165,32 +165,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -221,9 +221,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index 50ac7da73a2b..1668434a783f 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -185,7 +185,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -199,9 +199,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -235,9 +232,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -255,10 +249,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..ad5599ac0126 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -95,6 +95,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -102,12 +108,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 481171480f24..50db62858883 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs index a4a704b58170..f7b7ff3f95b2 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -39,8 +39,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -98,6 +98,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -105,12 +111,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -148,8 +148,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -166,32 +166,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -222,9 +222,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index 6ada96b312b5..b6400a09e802 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -186,7 +186,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -200,9 +200,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -236,9 +233,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -256,10 +250,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md index eb13cef5182d..626f40190a6d 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CopyActivitytt** | **string** | | -**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**Schema** | **CopyActivityAllOfSchema** | | [[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/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..de8390a77eb4 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,77 +36,25 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (CopyActivityAllOfSchema)Enum.Parse(typeof(CopyActivityAllOfSchema), this.GetType().Name); OnCreated(); } partial void OnCreated(); /// - /// Defines Schema - /// - public enum SchemaEnum - { - /// - /// Enum ScopeActivity for value: ScopeActivity - /// - ScopeActivity = 1 - } - - /// - /// Returns a - /// - /// - /// - /// - public static SchemaEnum SchemaEnumFromString(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); - } - - /// - /// Returns a - /// - /// - /// - public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) - { - if (value.Equals("ScopeActivity")) - return SchemaEnum.ScopeActivity; - - return null; - } - - /// - /// Converts the to the json value + /// Gets or Sets CopyActivitytt /// - /// - /// - /// - public static string SchemaEnumToJsonValue(SchemaEnum value) - { - if (value == SchemaEnum.ScopeActivity) - return "ScopeActivity"; - - throw new NotImplementedException($"Value could not be handled: '{value}'"); - } + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } /// /// The discriminator /// [JsonIgnore] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - public new SchemaEnum Schema { get; } - - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } + public new CopyActivityAllOfSchema Schema { get; } /// /// Returns the string presentation of the object @@ -145,8 +93,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,13 +111,13 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) - schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); - break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); + schema = new Option(CopyActivityAllOfSchemaValueConverter.FromStringOrDefault(schemaRawValue)); break; default: break; @@ -177,18 +125,18 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +167,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivityAllOfSchemaValueConverter.ToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 481171480f24..50db62858883 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs index d2cbf27feffc..f1139898f661 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -38,8 +38,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -97,6 +97,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -104,12 +110,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -147,8 +147,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -165,32 +165,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -221,9 +221,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index 50ac7da73a2b..1668434a783f 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -185,7 +185,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -199,9 +199,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -235,9 +232,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -255,10 +249,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..ad5599ac0126 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -95,6 +95,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -102,12 +108,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 481171480f24..50db62858883 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs index a4a704b58170..f7b7ff3f95b2 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -39,8 +39,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -98,6 +98,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -105,12 +111,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -148,8 +148,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -166,32 +166,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; case "$schema": string? schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()!); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value!); } @@ -222,9 +222,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index 6ada96b312b5..b6400a09e802 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -186,7 +186,7 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapeOrNull": - shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); break; case "shapes": shapes = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); @@ -200,9 +200,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -236,9 +233,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -256,10 +250,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs index 7a8ae9371f73..ad5599ac0126 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -36,8 +36,8 @@ public partial class CopyActivity : EntityBase, IValidatableObject [JsonConstructor] public CopyActivity(string copyActivitytt) : base() { - Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); CopyActivitytt = copyActivitytt; + Schema = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), this.GetType().Name); OnCreated(); } @@ -95,6 +95,12 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + /// /// The discriminator /// @@ -102,12 +108,6 @@ public static string SchemaEnumToJsonValue(SchemaEnum value) [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] public new SchemaEnum Schema { get; } - /// - /// Gets or Sets CopyActivitytt - /// - [JsonPropertyName("copyActivitytt")] - public string CopyActivitytt { get; set; } - /// /// Returns the string presentation of the object /// @@ -145,8 +145,8 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo JsonTokenType startingTokenType = utf8JsonReader.TokenType; - Option schema = default; Option copyActivitytt = default; + Option schema = default; while (utf8JsonReader.Read()) { @@ -163,32 +163,32 @@ public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeTo switch (localVarJsonPropertyName) { + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; case "$schema": string schemaRawValue = utf8JsonReader.GetString(); if (schemaRawValue != null) schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); break; - case "copyActivitytt": - copyActivitytt = new Option(utf8JsonReader.GetString()); - break; default: break; } } } - if (!schema.IsSet) - throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); - if (!copyActivitytt.IsSet) throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); - if (schema.IsSet && schema.Value == null) - throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); if (copyActivitytt.IsSet && copyActivitytt.Value == null) throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + return new CopyActivity(copyActivitytt.Value); } @@ -219,9 +219,9 @@ public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, Js if (copyActivity.CopyActivitytt == null) throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); - writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); - writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 81f04e862bfe..e83b95303760 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -197,9 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve if (mainShape.IsSet && mainShape.Value == null) throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); - if (shapeOrNull.IsSet && shapeOrNull.Value == null) - throw new ArgumentNullException(nameof(shapeOrNull), "Property is not nullable for class Drawing."); - if (shapes.IsSet && shapes.Value == null) throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); @@ -233,9 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); - if (drawing.ShapeOrNullOption.IsSet && drawing.ShapeOrNull == null) - throw new ArgumentNullException(nameof(drawing.ShapeOrNull), "Property is required for class Drawing."); - if (drawing.ShapesOption.IsSet && drawing.Shapes == null) throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); @@ -253,10 +247,13 @@ public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializ else writer.WriteNull("nullableShape"); if (drawing.ShapeOrNullOption.IsSet) - { - writer.WritePropertyName("shapeOrNull"); - JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); - } + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); if (drawing.ShapesOption.IsSet) { writer.WritePropertyName("shapes"); diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index ffc3620b9cba..575712f265f0 100644 --- a/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/httpclient/net10/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -58,7 +58,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index ffc3620b9cba..575712f265f0 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -58,7 +58,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index ffc3620b9cba..575712f265f0 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -58,7 +58,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml index e44d1cd61058..886c93019332 100644 --- a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/api/openapi.yaml @@ -2440,8 +2440,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2490,8 +2490,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: diff --git a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net10/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml index e44d1cd61058..886c93019332 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/api/openapi.yaml @@ -2440,8 +2440,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2490,8 +2490,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: diff --git a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml index e44d1cd61058..886c93019332 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/api/openapi.yaml @@ -2440,8 +2440,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2490,8 +2490,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: diff --git a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml index 5b4ccb1ffbab..d8106a5755fc 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml @@ -2497,8 +2497,8 @@ components: type: string fruitReq: additionalProperties: false + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/appleReq" - $ref: "#/components/schemas/bananaReq" appleReq: @@ -2547,8 +2547,8 @@ components: in OAS schema >= 3.1. discriminator: propertyName: shapeType + nullable: true oneOf: - - type: "null" - $ref: "#/components/schemas/Triangle" - $ref: "#/components/schemas/Quadrilateral" NullableShape: @@ -2832,17 +2832,20 @@ components: CopyActivity: allOf: - $ref: "#/components/schemas/EntityBase" - properties: - $schema: - enum: - - ScopeActivity - type: string - copyActivitytt: - type: string - required: - - $schema - - copyActivitytt + - properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + example: null type: object + example: null EntityBase: discriminator: mapping: @@ -2881,10 +2884,13 @@ components: TestResult: allOf: - $ref: "#/components/schemas/Result" - properties: - code: - $ref: "#/components/schemas/TestResultCode" + - properties: + code: + $ref: "#/components/schemas/TestResultCode" + type: object + example: null type: object + example: null TestResultCode: description: Result code enum: diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs index 0851f6c8dc9e..d7fa71ed6efe 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs @@ -91,7 +91,7 @@ public bool ShouldSerializeMainShape() /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get{ return _ShapeOrNull;} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 17610d81aa58..f9918311cf5f 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -57,7 +57,7 @@ public Drawing(Shape mainShape = default, ShapeOrNull shapeOrNull = default, Nul /// /// Gets or Sets ShapeOrNull /// - [DataMember(Name = "shapeOrNull", EmitDefaultValue = false)] + [DataMember(Name = "shapeOrNull", EmitDefaultValue = true)] public ShapeOrNull ShapeOrNull { get; set; } /// diff --git a/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index e69de29bb2d1..80783430664b 100644 --- a/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper + +object Serializer { + @JvmStatic + val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper() + .findAndRegisterModules() + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) +} diff --git a/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt b/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt index e69de29bb2d1..dfa9d858b04c 100644 --- a/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt +++ b/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/models/Bird.kt @@ -0,0 +1,46 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import org.openapitools.client.models.Animal + +import kotlinx.serialization.* +import kotlinx.serialization.descriptors.* +import kotlinx.serialization.encoding.* + +/** + * + * + * @param id + * @param featherType + * @param optionalProperty + */ +@Serializable + +@SerialName(value = "BIRD") +data class Bird ( + + @SerialName(value = "id") @Required override val id: kotlin.String, + + @SerialName(value = "featherType") @Required val featherType: kotlin.String, + + @SerialName(value = "optional_property") override val optionalProperty: kotlin.Double? = null + +) : Animal() { + + +} + From 81e4e60bf937b73d1466a8ee0bcc0996d10fd417 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 22 Jan 2026 18:40:57 +0800 Subject: [PATCH 6/6] add back null check --- .../main/java/org/openapitools/codegen/OpenAPINormalizer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index 0bac66dd18dc..c91802e8e7fb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -722,7 +722,7 @@ protected boolean isSelfReference(String name, Schema subSchema) { */ public Schema normalizeSchema(Schema schema, Set visitedSchemas) { // normalize reference schema - if (StringUtils.isNotEmpty(schema.get$ref())) { + if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) { normalizeReferenceSchema(schema); }