Generating JSON schema from C# class

前端 未结 3 696
梦毁少年i
梦毁少年i 2020-12-28 14:34

Is there any way to programmatically generate a JSON schema from a C# class?

Something which we can do manually using http://www.jsonschema.net/

3条回答
  •  隐瞒了意图╮
    2020-12-28 14:43

    JsonSchemaGenerator js = new JsonSchemaGenerator();
    var schema = js.Generate(typeof(Person));
    schema.Title = typeof(Person).Name;
    using (StreamWriter fileWriter = File.CreateText(filePath))
    {
          fileWriter.WriteLine(schema);
    }
    

提交回复
热议问题