OpenAPITools / OpenAPITools/openapi-generator
[csharp][generichost] AnyOf serialization issue
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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>
Originally posted by @cubic-dev-ai[bot] in https://github.com/OpenAPITools/openapi-generator/pull/23260#discussion_r2937210191
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/ColorOrNull.cs around line 111 and inspect ColorOrNullJsonConverter. Reproduce the handling of string and null JSON representations, then verify that valid union values no longer throw or serialize as object-only data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100