New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not validate from external schema #38
Comments
user.schema.json {
"title": "User Object",
"description": "User Object used in FCT website app",
"definitions": {
"integer": {
"type": "number",
"multipleOf": 1
},
"identifierInt": {
"type": "number",
"multipleOf": 1,
"minimum": 0
}
},
"type": "object",
"required": [
"id",
"alias",
"role",
"avatar"
],
"properties": {
"id": {
"description": "Source ID of the user (numeric)",
"$ref": "#/definitions/identifierInt"
},
"alias": {
"description": "User alias to be displayed on the website",
"type": "string"
},
"role": {
"description": "User role in the FCT site, in the format for display on the website",
"type": "string"
},
"avatar": {
"description": "absolute or relative link to user's avatar image (usable in <img src=...> attribute)",
"type": "string",
"format": "uri"
}
}
} |
comment.schema.json {
"title": "Comment",
"description": "Comment object schema",
"definitions": {
"integer": {
"type": "number",
"multipleOf": 1,
"minimum": 0
}
},
"type": "object",
"required": [
"id",
"user",
"text",
"datetime"
],
"properties": {
"id": {
"description": "Source identifier of the comment item (database table key)",
"$ref": "#/definitions/integer"
},
"questionId": {
"description": "Source identifier (database key) of the related question",
"$ref": "#/definitions/integer"
},
"repliesTo": {
"description": "Source identifier of the comment being replied to",
"$ref": "#/definitions/integer"
},
"user": {
"description": "User object containing data of the user who entered the comment",
"$ref": "user.schema.json"
},
"text": {
"description": "Text of the question",
"type": "string"
},
"datetime": {
"description": "Question timestamp (entry time)",
"type": "string",
"format": "datetime"
}
}
} |
ajv-cli does not look up files on the file system unless you tell it about them - you need to use -r option. What is the command you use to compile schema? |
|
as I wrote, you need to use -r option:
and user.schema.json needs to have id attribute. Ajv itself allows adding schema id as a second parameter of .addSchema method, but ajv-cli only supports id attribute as part of the schema. |
I understand that this is not a feature of the software, but I wonder what is then the meaning of having command line automation tool and $ref references if I have to find and declare all external schemas manually... |
You can -r the whole folder using glob patterns |
When I try to compile the attached schema
comment.schema.json
, it fails with error messageBoth
comment.schema.json
anduser.schema.json
are located in the same directory, where also ajv is invoked.The same schema validates with jayschema (which is what is to be expected because the respective $ref value does not contain any # character, so it does not refer to the current schema document).
I also tried "./user.schema.json" with the same result: does not validate in ajv but it does in jayschema.
The text was updated successfully, but these errors were encountered: