UNPKG

fluent-json-schema

Version:
157 lines (156 loc) 4.06 kB
[ { "description": "basic schema from z-schema benchmark (https://github.com/zaggino/z-schema)", "schema": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Product set", "type": "array", "items": { "title": "Product", "type": "object", "properties": { "uuid": { "description": "The unique identifier for a product", "type": "number" }, "name": { "type": "string" }, "price": { "type": "number", "exclusiveMinimum": 0 }, "tags": { "type": "array", "items": { "type": "string" }, "minItems": 1, "uniqueItems": true }, "dimensions": { "type": "object", "properties": { "length": { "type": "number" }, "width": { "type": "number" }, "height": { "type": "number" } }, "required": ["length", "width", "height"] }, "warehouseLocation": { "description": "Coordinates of the warehouse with the product", "type": "string" } }, "required": ["uuid", "name", "price"] } }, "tests": [ { "description": "valid array from z-schema benchmark", "data": [ { "id": 2, "name": "An ice sculpture", "price": 12.5, "tags": ["cold", "ice"], "dimensions": { "length": 7.0, "width": 12.0, "height": 9.5 }, "warehouseLocation": { "latitude": -78.75, "longitude": 20.4 } }, { "id": 3, "name": "A blue mouse", "price": 25.5, "dimensions": { "length": 3.1, "width": 1.0, "height": 1.0 }, "warehouseLocation": { "latitude": 54.4, "longitude": -32.7 } } ], "valid": true }, { "description": "not array", "data": 1, "valid": false }, { "description": "array of not onjects", "data": [1, 2, 3], "valid": false }, { "description": "missing required properties", "data": [{}], "valid": false }, { "description": "required property of wrong type", "data": [{ "id": 1, "name": "product", "price": "not valid" }], "valid": false }, { "description": "smallest valid product", "data": [{ "id": 1, "name": "product", "price": 100 }], "valid": true }, { "description": "tags should be array", "data": [{ "tags": {}, "id": 1, "name": "product", "price": 100 }], "valid": false }, { "description": "dimensions should be object", "data": [ { "dimensions": [], "id": 1, "name": "product", "price": 100 } ], "valid": false }, { "description": "valid product with tag", "data": [ { "tags": ["product"], "id": 1, "name": "product", "price": 100 } ], "valid": true }, { "description": "dimensions miss required properties", "data": [ { "dimensions": {}, "tags": ["product"], "id": 1, "name": "product", "price": 100 } ], "valid": false }, { "description": "valid product with tag and dimensions", "data": [ { "dimensions": { "length": 7, "width": 12, "height": 9.5 }, "tags": ["product"], "id": 1, "name": "product", "price": 100 } ], "valid": true } ] } ]