Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generate JSON schema endpoints for your LoopBack models

NotificationsYou must be signed in to change notification settings

chrisandrews7/loopback-jsonschema-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusCoverage Statusnpm version

Generates JSON schemas for yourLoopBack models

Installing

npm install loopback-jsonschema-generator

Setup

Initialising

Add the following configuration tocomponent-config.js inside your loopback project

{"loopback-jsonschema-generator": {},"..."}

Configuration options

  • schema - JSON Schema specification
  • url - Url to access each JSON schema endpoint, defaults to 'json-schema'
{"loopback-jsonschema-generator": {"schema":"http://json-schema.org/draft-04/schema","url":"json-schema"  },"..."}

Using

Define a model inside loopback as normal

# products.json{"name":"Products","base":"PersistedModel","properties": {"name": {"type":"string","title":"Name","required":true        }    },"validations": [],"relations": {},"acls": [],"methods": {}}

Access the generated JSON schema url

http://yourapi.com/api/products/json-schema

{"$schema":"http://json-schema.org/draft-04/schema#","title":"Products","type":"object","properties": {"name": {"type":"string","title":"Name"      }    },"required": ["name"    ]}

Programmatic access to the json schema

A property is added onto each model undermodel.jsonSchema

// Model filemodule.exports=function(Products){constjsonSchema=Products.jsonSchema;//...};

References

http://json-schema.org/


[8]ページ先頭

©2009-2025 Movatter.jp