У меня одна схема JSON с исх. Я пытаюсь разрешить все ссылки, используя JsonSchemaResolver
. Но, к сожалению, ссылка не разрешена и появляется ошибка, как показано ниже.
Я пытаюсь получить замещенный JSON, разрешив все ссылки.
Код:
var schemaFileContents = File.ReadAllText(schemaFileName);
JsonSchemaResolver resolver = new JsonSchemaResolver();
var result = JsonSchema.Parse(schemaFileContents, resolver);
Console.WriteLine(result);
Схема JSON:
{
"$schema": "YYYYYYY",
"id": "XXXXXX",
"title": "Current Employee Details",
"description": "XXXXXXXXXXXXX",
"type": "object",
"properties": {
"EMP": {
"title": "Employee ",
"description": "Details of the Employee",
"$ref": "#/definitions/Employee"
}},
"definitions": {
"EmployeeAddress": {
"title": "Address",
"description": "EmployeeAddress - Present Address",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"EmployeeAddress"
]
},
"address": {
"title": "Address",
"type": "string"
},
"postalCode": {
"title": "Postal Code",
"type": "string"
}
},
"required": [
"postalCode",
"address"
]
},
"Employee": {
"title": "Party",
"description": "Employee Details",
"type": "object",
"properties": {
"firstName": {
"title": "First name",
"type": "string"
},
"address": {
"title": "Employee Address",
"$ref": "#/definitions/EmployeeAddress"
}
},
"required": [
"firstName"
]
}
}
}
Ошибка:
Unhandled Exception: System.ArgumentException: Can not convert Array to Boolean.
at Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value)
at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessSchemaProperties(JObject schemaObject)
at Newtonsoft.Json.Schema.JsonSchemaBuilder.BuildSchema(JToken token)
at Newtonsoft.Json.Schema.JsonSchemaBuilder.ResolveReferences(JsonSchema schema)
at Newtonsoft.Json.Schema.JsonSchemaBuilder.ResolveReferences(JsonSchema schema)
at Newtonsoft.Json.Schema.JsonSchemaBuilder.Read(JsonReader reader)
at Newtonsoft.Json.Schema.JsonSchema.Read(JsonReader reader, JsonSchemaResolver resolver)
at Newtonsoft.Json.Schema.JsonSchema.Parse(String json, JsonSchemaResolver resolver)