我可以成功地使用Newtonsoft.Json.Schema.Generation.JSchemaGenerator为给定的类生成有效的JSONSchema。 ,但是可以正常工作,但是第三方消费者要求拥有
"allOf": [ { "$ref": "#/definitions/ClassName" } ]
发出的JSON模式中的代码块。
我目前可以使输出显示为
{
"$id": "https://xxxxx/classname",
"definitions": {
"ClassName": {
"type": "object",
"properties": {
但是我需要它看起来像
{
"$id": "https://xxxxx/classname",
"allOf": [
{
"$ref": "#/definitions/ClassName"
}
],
"definitions": {
"ClassName": {
"type": "object",
"properties": {
有人知道我需要做些什么吗?仅引用了一个类。
当前,我让生成器使用如下代码:
var _jsonSchemaGenerator = new JSchemaGenerator();
_jsonSchemaGenerator.SchemaIdGenerationHandling = SchemaIdGenerationHandling.None;
_jsonSchemaGenerator.SchemaLocationHandling = SchemaLocationHandling.Definitions;
var schema = _jsonSchemaGenerator.Generate(typeof(T));
console.WriteLine(schema);
任何帮助将不胜感激。