Skip to content

GraphRelationsQuery.cs Missing JSON Serializer Implementation #5

@EdCharbeneau

Description

@EdCharbeneau

public override void Write(Utf8JsonWriter writer, GraphRelationsQuery graphRelationsQuery, JsonSerializerOptions jsonSerializerOptions)

Missing JSON Serializer Implementation: The Write(Utf8JsonWriter, Score, JsonSerializerOptions) method was empty (generated code bug), which caused the GraphRelationsQuery object to not be serialized properly when sent to the API. This resulted in invalid JSON and a "JSON decode error" from the server.

                       // GraphRelationsQuery is a oneOf type - serialize only the non-null property
            if (graphRelationsQuery.AndGraphRelationsQuery != null)
            {
                JsonSerializer.Serialize(writer, graphRelationsQuery.AndGraphRelationsQuery, jsonSerializerOptions);
            }
            else if (graphRelationsQuery.OrGraphRelationsQuery != null)
            {
                JsonSerializer.Serialize(writer, graphRelationsQuery.OrGraphRelationsQuery, jsonSerializerOptions);
            }
            else if (graphRelationsQuery.NotGraphRelationsQuery != null)
            {
                JsonSerializer.Serialize(writer, graphRelationsQuery.NotGraphRelationsQuery, jsonSerializerOptions);
            }
            else if (graphRelationsQuery.NucliadbModelsGraphRequestsRelation != null)
            {
                JsonSerializer.Serialize(writer, graphRelationsQuery.NucliadbModelsGraphRequestsRelation, jsonSerializerOptions);
            }
            else if (graphRelationsQuery.NucliadbModelsGraphRequestsGenerated != null)
            {
                JsonSerializer.Serialize(writer, graphRelationsQuery.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