Skip to content

Missing JSON Serialization Implementation #3

@EdCharbeneau

Description

@EdCharbeneau

Missing JSON Serialization Implementation: The GraphNodesQueryJsonConverter.Write() method was empty (auto-generated stub), causing all union type properties to be serialized with their default null values instead of only serializing the active property. This resulted in invalid JSON being sent to the API.

            // GraphNodesQuery is a oneOf type - serialize only the non-null property
            if (graphNodesQuery.AndGraphNodesQuery != null)
            {
                JsonSerializer.Serialize(writer, graphNodesQuery.AndGraphNodesQuery, jsonSerializerOptions);
            }
            else if (graphNodesQuery.OrGraphNodesQuery != null)
            {
                JsonSerializer.Serialize(writer, graphNodesQuery.OrGraphNodesQuery, jsonSerializerOptions);
            }
            else if (graphNodesQuery.NotGraphNodesQuery != null)
            {
                JsonSerializer.Serialize(writer, graphNodesQuery.NotGraphNodesQuery, jsonSerializerOptions);
            }
            else if (graphNodesQuery.AnyNode != null)
            {
                JsonSerializer.Serialize(writer, graphNodesQuery.AnyNode, jsonSerializerOptions);
            }
            else if (graphNodesQuery.NucliadbModelsGraphRequestsGenerated != null)
            {
                JsonSerializer.Serialize(writer, graphNodesQuery.NucliadbModelsGraphRequestsGenerated, jsonSerializerOptions);
            }
            else
            {
                // Empty object for empty query
                writer.WriteStartObject();
                writer.WriteEndObject();
            }

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions