我正在使用 NJsonSchema 从 c# 类生成 JasonSchema。我可以创建这个架构:
{
"title": "SchemaModel",
"type": "object",
"additionalProperties": false,
"properties": {
"caseId": {
"title": "Case Id",
"type": [
"null",
"string"
],
"description": "desc.",
}
}
}
通过使用:
var settings = new JsonSchemaGeneratorSettings
{
DefaultPropertyNameHandling = PropertyNameHandling.CamelCase
};
var generator = new JsonSchemaGenerator(settings);
var schema = generator.Generate(typeof(SchemaModel));
但我需要将其包装在一个名为模式的对象中:
{
"schema": {
"title": "SchemaModel",
"type": "object",
"additionalProperties": false,
"properties": {
"caseId": {
"title": "Case Id",
"type": [
"null",
"string"
],
"description": "desc.",
}
}
}
}
我如何通过 NJsonSchema c# 模式生成器做到这一点?