glideapps/quicktype

[BUG]: generated C# code using SystemTextJson framework exports string enums as ints

Closed this issue · 1 comments

Context (Environment, Version, Language)

Input Format: JSON Schema
Output Language: C#
CLI, npm, or app.quicktype.io: NPM CLI
Version: 23.2.6

Description

When you have a schema with a string enum, for example:

title: Example
enum: [a, b, c]

The output for the C# generator, when using the SystemTextJson framework, is wrong. Somehow, all string enums are being serialized as integers. For example, QuickType.Example.A is serialized as 0 instead of as "a". This means things serialized with this generated code do not conform to the output schema!

Expected Behaviour / Output

For string enums, the string values of the enum should be serialized.

Current Behaviour / Output

For string enums, the internal integer of the enum is serialized.

It was because I didn't pass the provided settings object to the serializer. My bad! Closing this issue now.