How can I parse the following schema using NJsonSchema? Is it valid to use "default": true?
var problemJsonSchema = """
{
"title": "JSONSchema",
"default": {},
"oneOf": [{
"$ref": "#/definitions/JSONSchemaObject"
},
{
"$ref": "#/definitions/JSONSchemaBoolean"
}
],
"definitions": {
"JSONSchemaBoolean": {
"title": "JSONSchemaBoolean",
"description": "Always valid if true. Never valid if false. Is constant.",
"type": "boolean"
},
"JSONSchemaObject": {
"title": "JSONSchemaObject",
"type": "object",
"properties": {
"$id": {
"type": "string"
},
"default": true
}
}
}
}
""";
var metaSchema = JsonSchema.FromJsonAsync(problemJsonSchema).Result;
This code throws with error,
One or more errors occurred. (Unexpected initial token 'Boolean' when populating object. Expected JSON object or array. Path 'definitions.JSONSchemaObject.properties.default', line 21, position 27.)
You need to define the type of the property (like you did with id) and a default value as true.