https://learn.microsoft.com/dotnet/core/whats-new/dotnet-9/libraries#jsonschemaexporter


JSON.NET에서 테스트해봤을때는 StringEnumConverter에 대한 enum 스키마 생성이 지원되지 않았는데 얘는 잘 됨.


한가지 이상한점은 직렬화 옵션을 Default에서 파생시키지 않으면 에러가남. 읽기전용으로 만들어야된다 모라는데 의미를 잘 모르곘음


닷넷9에서 새로나올건데 명세상으로는 닷넷8도 지원으로 나옴. 하위호환시켜줄 예정인건지?




#r "nuget: System.Text.Json, 9.0.0-rc.2.24473.5"

using System.Text.Json;

using System.Text.Json.Schema;

using System.Text.Json.Serialization;

public enum e { a, b, c }

class hello{

    public e a { get; set; }

}


JsonSerializerOptions opt = new(JsonSerializerOptions.Default)

{

    WriteIndented = true,

    Converters = {new JsonStringEnumConverter()}

};

JsonSchemaExporter.GetJsonSchemaAsNode(opt, typeof(hello)).ToJsonString(opt)