Skip to content
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

Add draft3 walkers tests based on the specification examples #88

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/node/walker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = (walker, root, path) => {
for (const key of Object.keys(value[keyword])) {
accumulator.push(...module.exports(definition.walker, root, path.concat([keyword, key])))
}
} else if (type === 'value' && !Array.isArray(value[keyword])) {
} else if (type === 'value' && !Array.isArray(value[keyword]) && typeof value[keyword] !== 'string') {
accumulator.push(...module.exports(definition.walker, root, path.concat([keyword])))
}
}
Expand Down
231 changes: 231 additions & 0 deletions test/walkers/jsonschema-draft3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
[
{
"name": "boolean true",
"schema": true,
"trail": [
{
"type": "jsonschema-draft3",
"path": []
}
]
},
{
"name": "boolean false",
"schema": false,
"trail": [
{
"type": "jsonschema-draft3",
"path": []
}
]
},
{
"name": "https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-3",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"name": "Product",
"properties": {
"id": {
"type": "number",
"description": "Product identifier",
"required": true
},
"name": {
"description": "Name of the product",
"type": "string",
"required": true
},
"price": {
"required": true,
"type": "number",
"minimum": 0,
"required": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
},
"links": [
{
"rel": "full",
"href": "{id}"
},
{
"rel": "comments",
"href": "comments/?id={id}"
}
]
},
"trail": [
{
"type": "jsonschema-draft3",
"path": []
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "id" ]
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "name" ]
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "price" ]
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "tags" ]
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "tags", "items" ]
}
]
},
{
"name": "https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-5",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"description": "A person",
"type": "object",
"properties": {
"name": { "type": "string" },
"age": {
"type": "integer",
"maximum": 125
}
}
},
"trail": [
{
"type": "jsonschema-draft3",
"path": []
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "name" ]
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "age" ]
}
]
},
{
"name": "https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-5.26 (1)",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"description": "An adult",
"properties": { "age": { "minimum": 21 } },
"extends": "person"
},
"trail": [
{
"type": "jsonschema-draft3",
"path": []
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "age" ]
}
]
},
{
"name": "https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-5.26 (2)",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"description": "Extended schema",
"properties": { "deprecated": { "type": "boolean" } },
"extends": "http://json-schema.org/draft-03/schema"
},
"trail": [
{
"type": "jsonschema-draft3",
"path": []
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "deprecated" ]
}
]
},
{
"name": "https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/104f9f98f782d258eab6b2a760f9dca41739cebe/tests/draft3/extends.json (1)",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"properties": { "bar": {"type": "integer", "required": true } },
"extends": {
"properties": {
"foo": { "type": "string", "required": true }
}
}
},
"trail": [
{
"type": "jsonschema-draft3",
"path": []
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "bar" ]
},
{
"type": "jsonschema-draft3",
"path": [ "extends" ]
},
{
"type": "jsonschema-draft3",
"path": [ "extends", "properties", "foo" ]
}
]
},
{
"name": "https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/104f9f98f782d258eab6b2a760f9dca41739cebe/tests/draft3/extends.json (2)",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"properties": { "bar": { "type": "integer", "required": true } },
"extends": [
{
"properties": {
"foo": { "type": "string", "required": true }
}
},
{
"properties": {
"baz": { "type": "null", "required": true }
}
}
]
},
"trail": [
{
"type": "jsonschema-draft3",
"path": []
},
{
"type": "jsonschema-draft3",
"path": [ "properties", "bar" ]
},
{
"type": "jsonschema-draft3",
"path": [ "extends", 0 ]
},
{
"type": "jsonschema-draft3",
"path": [ "extends", 0, "properties", "foo" ]
},
{
"type": "jsonschema-draft3",
"path": [ "extends", 1 ]
},
{
"type": "jsonschema-draft3",
"path": [ "extends", 1, "properties", "baz" ]
}
]
}
]
2 changes: 1 addition & 1 deletion walkers/jsonschema-draft3.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"extends": {
"vocabulary": "http://json-schema.org/draft-03/schema#",
"type": "value",
"type": [ "array", "value" ],
"walker": "jsonschema-draft3"
}
}