Код: Выделить всё
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "ghkvhjhvh",
"title": "gffghfjhg",
"description": "zzzzzx",
"type": "object",
"properties": {
"wbNumber": {
"description": "fjhgfhg ",
"type": "string"
},
"documents": {
"description": "ghfcg",
"type": "object",
"properties": {
"documentType": {
"description": "sdzfdgfxhg",
"type": "integer"
},
"file": {
"description": "gdxfghfhgj",
"type": "string",
"contentEncoding": "base64"
},
"fileName": {
"description": "dgfrhg",
"type": "string"
}
},
"required": [ "documentType", "file", "fileName" ]
}
},
"required": [ "wbNumber", "documents" ]
}
Код: Выделить всё
var json = File.ReadAllText(schemaDestination);
var schema = await JsonSchema.FromJsonAsync(json);
var genSettings = new CSharpGeneratorSettings
{
ClassStyle = CSharpClassStyle.Poco,
JsonLibrary = CSharpJsonLibrary.SystemTextJson,
};
var generator = new CSharpGenerator(schema, genSettings);
var res = generator.GenerateFile();
await File.WriteAllTextAsync($"{destinationDir}/{Path.GetFileNameWithoutExtension(schemaDestination)
.Humanize().Pascalize()}.cs", res);
Код: Выделить всё
namespace BusMesssage
{
using System = global::System;
}
Подробнее здесь: https://stackoverflow.com/questions/781 ... harp-class