Usage Guide

Directive

To use JSON-Schema-Builder in your application inject json-schema into your module.

angular.module('myapp', ['json-schema'])
Next use json-schema directive in you html.
<div json-schema data="data" definitions="definitions"></div>
This module supports $ref and to specify the $ref models you can use the definitions attribute in the directive as shown above. Define an aboject that contains the list of models that you want to display as option for $ref as
$scope.definitions = {
    address:{
        "type": "object",
        "properties": {
            "addressLine1": {
                "type": "string"
            },
            "addressLine2": {
                "type": "string"
            },
            "postCode": {
                "type": "string"
            },
            "country": {
                "type": "string"
            }
        },
        "required": [
            "addressLine1",
            "addressLine2",
            "postCode",
            "country"
        ]
    }
};
                
Now when you select $ref as the type you will get a dropdown with #/definitions/address

Service

This library also exposes a service JsonSchema which you can inject into your controller and use.
angular.module('app', ['json-schema'])
    .controller('MyController', MyController);

MyController.$inject = ['$scope', 'JsonSchema'];
function schemaCtrler($scope, JsonSchema) {
    ......
}
            
Some of the functions available in the service are

This module was initially developed to be used with APIC and has been extensively used in the Chrome app for APIC