【发布时间】:2021-03-29 23:14:03
【问题描述】:
我正在使用 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 的对象中:
{
"schema": {
"title": "SchemaModel",
"type": "object",
"additionalProperties": false,
"properties": {
"caseId": {
"title": "Case Id",
"type": [
"null",
"string"
],
"description": "desc.",
}
}
}
}
如何通过 NJsonSchema c# 模式生成器做到这一点?
【问题讨论】:
标签: c# njsonschema