asyncapi / saunter

Saunter is a code-first AsyncAPI documentation generator for dotnet.
https://www.asyncapi.com/
MIT License
204 stars 58 forks source link

Use JsonConverter if on the key type if can #68

Closed NN--- closed 3 years ago

NN--- commented 3 years ago

Makes this code working:


[JsonConverter(typeof(OptionConverter))]
public class Option
{
    public string Value { get; set; }
}

public class P
{
    static void Main()
    {
        var d = new Dictionary<Option, string> {{new Option{Value = "abc"}, "abc"}};
        Console.WriteLine(JsonSerializer.Serialize(d,
            new JsonSerializerOptions
            {
                Converters =
                {
                    new DictionaryKeyToStringConverter()
                }
            }
            ));
    }
}
m-wild commented 3 years ago

Closing due to age/inactivity. This will likely be fixed by #60 anyway...