Loopback JSON Schema Generator
Generates JSON schemas for your LoopBack models
Installing
npm install loopback-jsonschema-generator
Setup
Initialising
Add the following configuration to component-config.js
inside your loopback project
Configuration options
- schema - JSON Schema specification
- url - Url to access each JSON schema endpoint, defaults to 'json-schema'
Using
Define a model inside loopback as normal
# products.json
Access the generated JSON schema url
http://yourapi.com/api/products/json-schema
Programmatic access to the json schema
A property is added onto each model under model.jsonSchema
// Model filemodule { const jsonSchema = ProductsjsonSchema; //...};