{"_id":"@globocom/loopback-jsonschema","_rev":"40-ccd3900ac6f914632f620d01cbbe7ed4","name":"@globocom/loopback-jsonschema","description":"JSON Schema support for Loopback","dist-tags":{"latest":"5.0.12"},"versions":{"5.0.8":{"name":"@globocom/loopback-jsonschema","version":"5.0.8","description":"JSON Schema support for Loopback","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/globocom/loopback-jsonschema.git"},"author":{"name":"Backstage","email":"backstage@corp.globo.com"},"license":"MIT","bugs":{"url":"https://github.com/globocom/loopback-jsonschema/issues"},"homepage":"https://github.com/globocom/loopback-jsonschema","dependencies":{"async":"^0.9.0","cors":"2.x","debug":"","errorhandler":"1.x","fast-url-parser":"^1.1.3","json-path":"","jsvgcom":"4.2.6","lodash":"3.x","q":"1.x","stack-trace":"","traverse":"","tv4":"","tv4-formats":"","type-is":"1.x.x","winston":"0.x"},"peerDependencies":{"loopback":"2.x"},"devDependencies":{"chai":"1.9.x","loopback":"2.x","mocha":"1.x","mocha-sinon":"","sinon":"^2.1.0","sinon-chai":"2.x","supertest":""},"gitHead":"3f304a2555f35bfa57e97b3ed94d47474f445e6a","_id":"@globocom/loopback-jsonschema@5.0.8","_npmVersion":"5.5.1","_nodeVersion":"7.7.4","_npmUser":{"name":"raphamorim","email":"rapha850@gmail.com"},"dist":{"integrity":"sha512-XLH8yv4soNcf8kl2QFA0Xjiwzuou/6Pf/+K0lV1/M4SKVkZnc0Qj4S1F6JhD23ODOVWEVU6gXrlxTsja/rKf3Q==","shasum":"4c59fc184d19ef19628d73c3d1621b30b208e261","tarball":"https://registry.npmjs.org/@globocom/loopback-jsonschema/-/loopback-jsonschema-5.0.8.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDkUFgdje6ZcSOrkQyg2grMOqzXGcDrVpPgNA8+oZNSaAiBw89IauwR456bNYicg+0isH5UT5jNAIF1DnHBc1AD0/A=="}]},"maintainers":[{"name":"raphamorim","email":"rapha850@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-jsonschema-5.0.8.tgz_1508866026851_0.23820044402964413"},"directories":{}},"5.0.9":{"name":"@globocom/loopback-jsonschema","version":"5.0.9","description":"JSON Schema support for Loopback","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/globocom/loopback-jsonschema.git"},"author":{"name":"Backstage","email":"backstage@corp.globo.com"},"license":"MIT","bugs":{"url":"https://github.com/globocom/loopback-jsonschema/issues"},"homepage":"https://github.com/globocom/loopback-jsonschema","dependencies":{"async":"^0.9.0","cors":"2.x","debug":"","errorhandler":"1.x","fast-url-parser":"^1.1.3","json-path":"","jsvgcom":"4.2.6","lodash":"3.x","q":"1.x","stack-trace":"","traverse":"","tv4":"","tv4-formats":"","type-is":"1.x.x","winston":"0.x"},"peerDependencies":{"loopback":"2.x"},"devDependencies":{"chai":"1.9.x","loopback":"2.x","mocha":"1.x","mocha-sinon":"","sinon":"^2.1.0","sinon-chai":"2.x","supertest":""},"gitHead":"1e7fa43ca110c5e7d41337bdf96602af0b72b713","_id":"@globocom/loopback-jsonschema@5.0.9","_npmVersion":"5.6.0","_nodeVersion":"8.3.0","_npmUser":{"name":"mateuspontes","email":"mateuspo10@gmail.com"},"dist":{"integrity":"sha512-heVbV9WiTfN5yZd276rXCSJtu5J3roL51k0JCmLOEfC309Oj9/xl28znEGZ1coKdxwEjXtcM8NyVglK0gzTMgA==","shasum":"3889ead14b97e89bb41f413333a80d632ef7eeea","tarball":"https://registry.npmjs.org/@globocom/loopback-jsonschema/-/loopback-jsonschema-5.0.9.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHB7xiXVB6hVFKQLg3kPn6WtwV8NTCEm+bKea5+KDUPVAiEAyHQZq5G71mPn5cbYe/S1Qlbuyhh8aRVcHxQDV2GNZ+g="}]},"maintainers":[{"email":"mateuspo10@gmail.com","name":"mateuspontes"},{"email":"maycon.dionisio@gmail.com","name":"mdionisio"},{"email":"wilsonpjunior@gmail.com","name":"wpjunior"},{"email":"guilhermevierno@gmail.com","name":"vierno"},{"email":"heitor-silva@hotmail.com","name":"heitorsilva"},{"email":"rafaelfragosom@gmail.com","name":"rafaelfragosom"},{"email":"rico.bl@gmail.com","name":"ricobl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-jsonschema-5.0.9.tgz_1515764838623_0.041484100511297584"},"directories":{}},"5.0.10":{"name":"@globocom/loopback-jsonschema","version":"5.0.10","description":"JSON Schema support for Loopback","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/globocom/loopback-jsonschema.git"},"author":{"name":"Backstage","email":"backstage@corp.globo.com"},"license":"MIT","bugs":{"url":"https://github.com/globocom/loopback-jsonschema/issues"},"homepage":"https://github.com/globocom/loopback-jsonschema","dependencies":{"async":"^0.9.0","cors":"2.x","debug":"","errorhandler":"1.x","fast-url-parser":"^1.1.3","json-path":"","jsvgcom":"4.2.6","lodash":"3.x","q":"1.x","stack-trace":"","traverse":"","tv4":"","tv4-formats":"","type-is":"1.x.x","winston":"0.x"},"peerDependencies":{"loopback":"2.x"},"devDependencies":{"chai":"1.9.x","loopback":"2.x","mocha":"1.x","mocha-sinon":"","sinon":"^2.1.0","sinon-chai":"2.x","supertest":""},"gitHead":"c687ede5c954a67e9cae43f2afcd4a18c8827147","_id":"@globocom/loopback-jsonschema@5.0.10","_shasum":"60e890195e35a23f962e672f90e0275b3da26711","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.4","_npmUser":{"name":"mateuspontes","email":"mateuspo10@gmail.com"},"dist":{"shasum":"60e890195e35a23f962e672f90e0275b3da26711","tarball":"https://registry.npmjs.org/@globocom/loopback-jsonschema/-/loopback-jsonschema-5.0.10.tgz","integrity":"sha512-p1uZC70ofL20U/HXjl0LO5xqKmwOhxo7tuwacfJNempoxL/yD72XxhV552hvWueVjIAwdfqSHlNaTttLSXZ1IQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDgAlV4BSraiMcAoSqjV+jby9Gj5KxrM8g6ZbgcfHB6+wIhAJsun8xHKibcvI/B/zkemV+PTt9Iq0z0iuPaR1KhOqDP"}]},"maintainers":[{"email":"mateuspo10@gmail.com","name":"mateuspontes"},{"email":"maycon.dionisio@gmail.com","name":"mdionisio"},{"email":"wilsonpjunior@gmail.com","name":"wpjunior"},{"email":"guilhermevierno@gmail.com","name":"vierno"},{"email":"heitor-silva@hotmail.com","name":"heitorsilva"},{"email":"rafaelfragosom@gmail.com","name":"rafaelfragosom"},{"email":"rico.bl@gmail.com","name":"ricobl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-jsonschema-5.0.10.tgz_1516023967338_0.46254148916341364"},"directories":{}},"5.0.11":{"name":"@globocom/loopback-jsonschema","version":"5.0.11","description":"JSON Schema support for Loopback","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/globocom/loopback-jsonschema.git"},"author":{"name":"Backstage","email":"backstage@corp.globo.com"},"license":"MIT","bugs":{"url":"https://github.com/globocom/loopback-jsonschema/issues"},"homepage":"https://github.com/globocom/loopback-jsonschema","dependencies":{"async":"^0.9.0","cors":"2.x","debug":"","errorhandler":"1.x","fast-url-parser":"^1.1.3","json-path":"","jsvgcom":"4.2.6","lodash":"3.x","q":"1.x","stack-trace":"","traverse":"","tv4":"","tv4-formats":"","type-is":"1.x.x","winston":"0.x"},"peerDependencies":{"loopback":"2.x"},"devDependencies":{"chai":"1.9.x","loopback":"2.x","mocha":"1.x","mocha-sinon":"","sinon":"^2.1.0","sinon-chai":"2.x","supertest":""},"gitHead":"7955ddb0a70bb10a7cc7d7d8d683fe5f9d1cf9f4","_id":"@globocom/loopback-jsonschema@5.0.11","_npmVersion":"5.5.1","_nodeVersion":"8.9.1","_npmUser":{"name":"mdionisio","email":"maycon.dionisio@gmail.com"},"dist":{"integrity":"sha512-uuCXlQYCz1W3/xvsJS052WqzosZvbHgdAFwpCbSRFtlZRoYeXb66WQEroYtXCxJEt2MKt9fs7gqjsXZIk6WRJg==","shasum":"1bef7dc9187cbac29dc5ead4a8549b3630c564de","tarball":"https://registry.npmjs.org/@globocom/loopback-jsonschema/-/loopback-jsonschema-5.0.11.tgz","fileCount":65,"unpackedSize":307505,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa11H3CRA9TVsSAnZWagAA1JEQAJ8X9XdVOmSNzYOfEg4+\naaCz1dsrx6GhwKUM/lMMiDQdfBzMiz245rClnenFgOnRwSxhn11wTLly4moW\nt5FYwls+OS/wl1UhoiZefQHtg7+ILpQGCWEWMRjMlRMaUU9DTeRmsqp/D9+Q\nMpQb1jpVmzN3jfTAuUEUGZlSvS1B/Bm8ZZLkaZxN8dOGYJzQZS0hwfhYNvBU\nS9rtqLBuWymVl7fkVHEcb7qaAHOk9C9Hw/LZ33mKcx8ZYgyqMSFUNgGFNlLI\nLrOTRsLTb14StOcvOAm/ugwD2ITOvq7ZcoxjVijFX3YngkuAloyFlsUvBzgx\nK7Dc/k1PcZlMXNwDNkILaMmv3De14rK5Xq+W2+qy3kwFFZ4SkzdiGJYCovcJ\nXqbYZ/pMYvghqdqeyMAEIueYXFe0rVZMU0PCy+IUz425n4eNGYMkWcG0JTWA\n3j8AHbJbLKkGCf5VTqe//+L2jED+x8b+DeTLdOf10eeCVAxJ7qHhP8+RIjvW\n1IXssQJRGhwK2W9Yt/Emcbque4zzQIajMdyH5SAoU8gP9Ojd1cH4rvi62inN\n7oZ4LBQa9EBVKIMWc905Hm9Is23Q0xlZ4F2z6PprTMsSIOEF60uj3Nt6Fn4M\n2vifwk1pu2mUFgmIRiXoPvpXfRP2FuZCzEuhYjOP1w7yoBtogWTFwJqH0gfW\nBt9E\r\n=LGYf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDF/PdV65lbP82xBAZuXGM7mVWMygG052XHVS//inyWQgIgJSA8048ijGNUVdZJ0/cG7GmcPgdcN9OZXzeYK00XHTA="}]},"maintainers":[{"email":"heitor-silva@hotmail.com","name":"heitorsilva"},{"email":"mateuspo10@gmail.com","name":"mateuspontes"},{"email":"maycon.dionisio@gmail.com","name":"mdionisio"},{"email":"metal@alucinados.com","name":"metal"},{"email":"rico.bl@gmail.com","name":"ricobl"},{"email":"guilhermevierno@gmail.com","name":"vierno"},{"email":"wilsonpjunior@gmail.com","name":"wpjunior"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-jsonschema_5.0.11_1524060661241_0.6506229487764896"},"_hasShrinkwrap":false},"5.0.12":{"name":"@globocom/loopback-jsonschema","version":"5.0.12","description":"JSON Schema support for Loopback","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/globocom/loopback-jsonschema.git"},"author":{"name":"Backstage","email":"backstage@corp.globo.com"},"license":"MIT","bugs":{"url":"https://github.com/globocom/loopback-jsonschema/issues"},"homepage":"https://github.com/globocom/loopback-jsonschema","dependencies":{"async":"^0.9.0","cors":"2.x","debug":"","errorhandler":"1.x","fast-url-parser":"^1.1.3","json-path":"","jsvgcom":"4.2.6","lodash":"3.x","q":"1.x","stack-trace":"","traverse":"","tv4":"","tv4-formats":"","type-is":"1.x.x","winston":"0.x"},"peerDependencies":{"loopback":"2.x"},"devDependencies":{"chai":"1.9.x","loopback":"2.x","mocha":"1.x","mocha-sinon":"","sinon":"^2.1.0","sinon-chai":"2.x","supertest":""},"gitHead":"9a042ff9a9f4a7990551124f18d87d84ba7435f0","_id":"@globocom/loopback-jsonschema@5.0.12","_npmVersion":"5.8.0","_nodeVersion":"8.9.1","_npmUser":{"name":"mateuspontes","email":"mateuspo10@gmail.com"},"dist":{"integrity":"sha512-HHzFskwN97sG4R4zYkmD/BWuMJHYkyzUyjXUUWAZSi2JJfFXVQZeeP40swfSY/7QvvN1P4OO7jpqFdiNI2vGlg==","shasum":"1126cb11970b7966ef98a2fbeb8068562e0360b6","tarball":"https://registry.npmjs.org/@globocom/loopback-jsonschema/-/loopback-jsonschema-5.0.12.tgz","fileCount":66,"unpackedSize":309080,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa+fc5CRA9TVsSAnZWagAAqtAP/jneZkj+tYyGUXLVguke\nAJrB7Xc3p3HgxeYKPZdyIkgC6hNnlHRGvJVkCqFw0na2LZFTUo69tKZm3ikD\ndkgkaV/3keMzzlEOPchsYKTXt8PJZy/RrmWt6fM2ppnCX8PdGDbF4nf86a5M\nmnp/p9ngGHYAyGj9VeV+0O/4u6sqbfp5PSVY81LMMwzk7X8atbIt82w+IvEd\nPs2iljphwWDXRhrYJQoFIku5DaZdLMKZL5mDJzfVapcSwpop1AdEJ/iS4mLC\nD1GICEcmhX7LBt5OfUF/aZLZqV2zIjg2ro0sBm4bdc6JoygSJOTDmBeyby4H\nhaY7vhe68hVzEwZ2ySVdYkmi3hDu1yV4/hIvjC8c1+CvwcuRj7icQchvGkfD\nJYDxFhYsMcClMtyRCf3u1h4NiyiHCDVskftxmmeTyrP6vjg7ifEwXPPumCYl\nrwaLCcYbh5YWZ52axN+3ooVU05vxP5bd4wiGwK1jluSkV2gATtbyA6cDgpJz\nZDLL5Lvlw8r1XOGcwV2tVjr3l99MdzNWw96oBVyDmjznqV3l0BiuTPHvIxpN\no0qNaHOxsMTL6ZcJWwSMoclI8diQ5aNNWp1akOAqqmQ1FLN33Misi/MWoFcM\ni97GMo1Zoh2vBBB7gvcysVZ3LqeohA2w5z9sI0BJOGYlKba1NSTMTpUoOHOq\nh3U4\r\n=mci8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDhwS++67s4+6JaYF8rHMeOMSjQLesmJUPDTWtN7hrc6gIhAJDi5R7J99AFYPKfWk0ZrOCCz75rZmg7qZ7fDRaG/4Jq"}]},"maintainers":[{"email":"heitor-silva@hotmail.com","name":"heitorsilva"},{"email":"mateuspo10@gmail.com","name":"mateuspontes"},{"email":"maycon.dionisio@gmail.com","name":"mdionisio"},{"email":"metal@alucinados.com","name":"metal"},{"email":"rico.bl@gmail.com","name":"ricobl"},{"email":"guilhermevierno@gmail.com","name":"vierno"},{"email":"wilsonpjunior@gmail.com","name":"wpjunior"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/loopback-jsonschema_5.0.12_1526331191318_0.5539408257945562"},"_hasShrinkwrap":false}},"readme":"# Loopback JSON Schema [![Build Status](https://travis-ci.org/backstage/loopback-jsonschema.png?branch=master)](https://travis-ci.org/backstage/loopback-jsonschema)\n\nAdds JSON Schema support to [LoopBack](https://github.com/strongloop/loopback).\n\n## Installing\n\n```\nnpm install @globocom/loopback-jsonschema\n```\n\n## Setup\n\n### Initializing\n\nAdd the following code after calling `app.boot();`\n\n```js\nvar loopbackJsonSchema = require('loopback-jsonschema');\nloopbackJsonSchema.init(app);\nloopbackJsonSchema.enableJsonSchemaMiddleware(app);\n```\n\n### Configuring a DataSource\n\nAdd a `loopbackJsonSchemaDb` entry to the `datasources.json` file with your data source configuration. If no `loopbackJsonSchemaDb` entry is found, we fallback to using the default memory data source.\n\n### Overriding the default base model\n\nBy default, Loopback's `Model` is used as the base for dynamically defined models. It is possible to override this by passing a custom implementation to the `init` function:\n\n```js\nloopbackJsonSchema.init(app, { Model: MyCustomModel });\n```\n\n### Hook: beforeRegisterLoopbackModel\n\nImmediately before registering a Loopback model from an item schema, the method `ItemSchema#beforeRegisterLoopbackModel(app, JsonSchemaModel, callback)` is called. This hook can be used for any customizations that are needed before a model is registered.\n\n### Overriding the default collection schema\n\nIt is possible to override the default collection schema by passing a custom `CollectionSchema` implementation to the `init` function:\n\n```js\nloopbackJsonSchema.init(app, { CollectionSchemaClass: MyCustomCollectionSchema });\n```\n\n```js\nvar util = require('util');\nvar CollectionSchema = require('loopback-jsonschema/lib/domain/collection-schema');\n\nfunction MyCustomCollectionSchema() {\n    CollectionSchema.apply(this, Array.prototype.slice.call(arguments));\n};\n\nutil.inherits(MyCustomCollectionSchema, CollectionSchema);\n// It's required to set the value of \"pluralModelName\". This value will be used on the headers. You can still use the default value (see below).\nMyCustomCollectionSchema.pluralModelName = MyCustomCollectionSchema.super_.pluralModelName;\n\n// Override functions to customize the default collection schema.\n```\n\nHave a look at https://github.com/globocom/loopback-jsonschema/blob/master/lib/domain/collection-schema.js for available functions to override.\n\n## Using\n\n### Dynamically defining Loopback models from a JSON Schema\n\nTo dynamically define a new Loopback model just create a new instance of the ItemSchema model provided by loopback-jsonschema. Doing this via the REST interface is as simples as POSTing a valid JSON Schema, as follows:\n\n```json\n# person.json\n{\n  \"type\": \"object\",\n  \"title\": \"Person\",\n  \"collectionTitle\": \"People\",\n  \"collectionName\": \"people\",\n  \"properties\": {\n    ...\n  }\n}\n```\n\n```bash\n# Create a Person model from a JSON Schema\ncurl -i -XPOST -H \"Content-Type: application/json\" http://example.org/api/item-schemas -T person.json\n```\n\nThe people collection will then be available at `http://example.org/api/people`.\n\n### Item and Collection schemas\n\nOnce a Loopback model has been defined, Item and Collection schemas describing a single item and a collection of items, respectively, are automatically available.\n\n#### Item Schema example\n\n```bash\n$ curl -i http://example.org/api/item-schemas/people\nHTTP/1.1 200 OK\nX-Powered-By: Express\nContent-Type: application/json; charset=utf-8\nContent-Length: 577\nETag: \"-912870715\"\nDate: Mon, 19 May 2014 19:07:14 GMT\nConnection: keep-alive\n\n{\n  \"id\": \"537530ea27f8870b63f2d886\",\n  \"type\": \"object\",\n  \"title\": \"Person\",\n  \"collectionTitle\": \"People\",\n  \"collectionName\": \"people\",\n  \"links\": [\n    {\n      \"rel\": \"self\",\n      \"href\": \"http://example.org/api/people/{id}\"\n    },\n    {\n      \"rel\": \"item\",\n      \"href\": \"http://example.org/api/people/{id}\"\n    },\n    {\n      \"rel\": \"update\",\n      \"method\": \"PUT\",\n      \"href\": \"http://example.org/api/people/{id}\"\n    },\n    {\n      \"rel\": \"delete\",\n      \"method\": \"DELETE\",\n      \"href\": \"http://example.org/api/people/{id}\"\n    }\n  ],\n  \"$schema\": \"http://json-schema.org/draft-04/hyper-schema#\"\n}\n```\n\n#### Collection Schema example\n\n```bash\n$ curl -i http://example.org/api/collection-schemas/people\nHTTP/1.1 200 OK\nX-Powered-By: Express\nContent-Type: application/schema+json; charset=utf-8\nContent-Length: 373\nETag: \"-833543453\"\nDate: Wed, 11 Jun 2014 20:10:41 GMT\nConnection: keep-alive\n\n{\n  \"$schema\": \"http://json-schema.org/draft-04/hyper-schema#\",\n  \"title\": \"People\",\n  \"type\": \"array\",\n  \"items\": {\n    \"$ref\": \"http://example.org/api/item-schemas/people\"\n  },\n  \"links\": [\n    {\n      \"rel\": \"self\",\n      \"href\": \"http://example.org/api/people\"\n    },\n    {\n      \"rel\": \"add\",\n      \"method\": \"POST\",\n      \"href\": \"http://example.org/api/people\",\n      \"schema\": {\n        \"$ref\": \"http://example.org/api/item-schemas/people\"\n      }\n    },\n    {\n      \"rel\": \"previous\",\n      \"href\": \"http://example.org/api/people?filter[limit]={limit}&filter[offset]={previousOffset}{&paginateQs*}\"\n    },\n    {\n      \"rel\": \"next\",\n      \"href\": \"http://example.org/api/people?filter[limit]={limit}&filter[offset]={nextOffset}{&paginateQs*}\"\n    },\n    {\n      \"rel\": \"page\",\n      \"href\": \"http://example.org/api/people?filter[limit]={limit}&filter[offset]={offset}{&paginateQs*}\"\n    },\n    {\n      \"rel\": \"order\",\n      \"href\": \"http://example.org/api/people?filter[order]={orderAttribute} {orderDirection}{&orderQs*}\"\n    }\n  ]\n}\n```\n\n### Default values and read-only properties\n\nIt's possible to use `readOnly` property to indicate that the instance property should not be changed (if it has a value of boolean true).\n\nIt's possible to use `default` property to indicate that when the instance property is not passed the default value will be used.\n\nIf the schema indicates that the property has both `readOnly: true` and `default` values defined, the default value will be used.\n\nFor example:\n\n```json\n{\n    \"title\": \"Bikes Rules\",\n    \"type\": \"object\",\n    \"$schema\": \"http://json-schema.org/draft-04/hyper-schema#\",\n    \"collectionName\": \"bikes\",\n    \"name\": \"My Awesome Bikes!\",\n    \"properties\": {\n        \"brand\": {\n            \"description\": \"Brand of the bike\",\n            \"default\": \"kawasaki\",\n            \"type\": \"string\"\n        },\n        \"cc\": {\n            \"description\": \"Cubic Centimeters\",\n            \"default\": \"120\",\n            \"readOnly\": true,\n            \"type\": \"integer\"\n        },\n        \"name\": {\n            \"description\": \"Name of the bike\",\n            \"readOnly\": false,\n            \"type\": \"string\"\n        }\n    }\n}\n```\n\n```bash\ncurl -XPOST -H \"Content-Type: application/json\" http://example.org/api/bikes -d'\n{\n    \"cc\": 350,\n    \"name\": \"Ninja\"\n}'\n```\n\nThe output will be:\n```json\n{\n    id: \"5460b29652fe613c00f23f75\",\n    created: \"2014-11-10T12:41:58.344Z\",\n    modified: \"2014-11-10T12:41:58.344Z\",\n    name: \"Ninja\",\n    brand: \"kawasaki\",\n    cc: 120\n}\n```\n\n\n### Default links\n\nItem and collection schemas have a default set of links which correspond to the basic CRUD operations supported by Loopback.\n\n### Including custom links in an item schema\n\nIt is possible to include custom links in an item schema. To do so, just include them in the `links` property of the **item schema** used to define a Loopback model:\n\n```json\n{\n  \"type\": \"object\",\n  ...\n  \"properties\": {\n    ...\n  },\n  \"links\": [\n    {\n      \"rel\": \"my-custom-item-schema-link\",\n      \"href\": \"http://example.org/my/custom/item-schema-link\"\n    }\n  ]\n}\n```\n\n### Including custom links in a collection schema\n\nIt is possible to include custom links in a collection schema. To do so, just include them in the `collectionLinks` property of the **item schema** used to define a Loopback model:\n\n```json\n{\n  \"type\": \"object\",\n  ...\n  \"properties\": {\n    ...\n  },\n  \"collectionLinks\": [\n    {\n      \"rel\": \"my-custom-collection-schema-link\",\n      \"href\": \"http://example.org/my/custom/collection-schema-link\"\n    }\n  ]\n}\n```\n\n### Instance/Schema correlation\n\nEvery request for an instance is automatically correlated to its schema according to the [recommendation of the JSON Schema spec](http://json-schema.org/latest/json-schema-core.html#anchor33).\n\n### Instance Validation\n\nOnce a Item Schema has been defined all instances created or updated will be validated according the schema. In case of validation error loopback-jsonschema will return an error message following loopback error message format.\n\nThis module supports both drafts: Draft-4(default) and Draft-3. The error messages and codes try to follow the messages/codes returned by the module [tv4](https://github.com/geraintluff/tv4).\n\nIf you want to use draft-3, you need to override the `$schema` property, for instance:\n\n```json\n{\n  \"$schema\": \"http://json-schema.org/draft-03/hyper-schema#\",\n  \"type\": \"object\",\n  ...\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\",\n      \"title\": \"Full name\"\n     }\n   ...\n  }\n}\n\n```\n\n### Indexes\n\nIt's possible to create indexes by adding a key called `indexes`.\n\nSee [Indexes](http://docs.strongloop.com/display/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Indexes) in Loopback documentation for more information.\n\n```json\n{\n    \"type\": \"object\",\n    \"title\": \"Task\",\n    \"collectionTitle\": \"To-Do List\",\n    \"collectionName\": \"tasks\",\n    \"properties\": {\n        \"title\": {\n          \"title\": \"Title\",\n          \"type\": \"string\"\n        },\n        \"slug\": {\n          \"title\": \"Slug\",\n          \"type\": \"string\"\n        },\n        \"value\": {\n          \"title\": \"Value\",\n          \"type\": \"integer\"\n        }\n    },\n    \"indexes\": {\n        \"title_value_index\": {\n            \"keys\": {\"title\": 1, \"value\": -1}\n        },\n        \"title_index\": {\"title\": 1},\n        \"slug_index\": {\n            \"keys\": {\"slug\": 1},\n            \"options\": {\"unique\": true}\n        }\n    }\n}\n\n```\n\n\n\n\n## Sample App\n\nAn example running LoopBack with this module: https://github.com/globocom/loopback-jsonschema-example\n\n## Disclaimer\n\nThis project is very much in an alpha stage at the moment. But it is being actively developed. Contributions (code, documentation, issues, etc.) are very welcome.\n\n## References\n\nhttp://json-schema.org/\n","maintainers":[{"email":"celso.inacio@g.globo","name":"celso.inacio_globo"},{"email":"lemes0090@gmail.com","name":"matheus.lemes"},{"email":"fabiogsrj.2007@gmail.com","name":"fabiogsrj"},{"email":"igorgiusti@gmail.com","name":"igorgiusti"},{"email":"metal@alucinados.com","name":"metal"},{"email":"wilsonpjunior@gmail.com","name":"wpjunior"},{"email":"maycon.dionisio@gmail.com","name":"mdionisio"},{"email":"sergiojcamposjr@gmail.com","name":"sergiojorge"},{"email":"lousander13@gmail.com","name":"lousander"},{"email":"motagavino@gmail.com","name":"andre.gavino"},{"email":"mvcartagenes@gmail.com","name":"markiing"}],"time":{"modified":"2023-10-24T20:59:25.967Z","created":"2017-10-24T17:27:07.029Z","5.0.8":"2017-10-24T17:27:07.029Z","5.0.9":"2018-01-12T13:47:18.794Z","5.0.10":"2018-01-15T13:46:07.529Z","5.0.11":"2018-04-18T14:11:01.428Z","5.0.12":"2018-05-14T20:53:11.402Z"},"homepage":"https://github.com/globocom/loopback-jsonschema","repository":{"type":"git","url":"git://github.com/globocom/loopback-jsonschema.git"},"author":{"name":"Backstage","email":"backstage@corp.globo.com"},"bugs":{"url":"https://github.com/globocom/loopback-jsonschema/issues"},"license":"MIT","readmeFilename":"README.md"}