Skip to content

[csharp][generichost] AnyOf serialization issue #23261

@devhl-labs

Description

@devhl-labs

P2: ColorOrNullJsonConverter only accepts/writes object-shaped JSON, so valid string or null representations for this union will throw or serialize incorrectly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/ColorOrNull.cs, line 111:

<comment>ColorOrNullJsonConverter only accepts/writes object-shaped JSON, so valid string or null representations for this union will throw or serialize incorrectly.</comment>

<file context>
@@ -0,0 +1,205 @@
+        {
+            int currentDepth = utf8JsonReader.CurrentDepth;
+
+            if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
+                throw new JsonException();
+
</file context>
Fix with Cubic

Originally posted by @cubic-dev-ai[bot] in #23260 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions