Skip to content
Snippets Groups Projects
Commit 52aa1815 authored by Anjan Kaur's avatar Anjan Kaur
Browse files

Adding support of custom meta schema

parent 7a82330d
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,8 @@ $ node index.js ...@@ -31,7 +31,8 @@ $ node index.js
# -d, --input path to directory containing all JSON Schemas or a single JSON Schema file. This will be considered as the baseURL [required] # -d, --input path to directory containing all JSON Schemas or a single JSON Schema file. This will be considered as the baseURL [required]
# -f, --isFile pass if input is a single file path # -f, --isFile pass if input is a single file path
# -o, --out path to output directory (default: ./out) # -o, --out path to output directory (default: ./out)
# -s, --schema-out pass to output JSON Schema files including description and validated examples in the _new folder at output directory # -x, --schema-out pass to output JSON Schema files including description and validated examples in the _new folder at output directory
# -s, --metaSchema pass it followed by path to Custom meta schema to validate other schemas
# run task # run task
... ...
......
...@@ -78,8 +78,10 @@ var argv = require('optimist') ...@@ -78,8 +78,10 @@ var argv = require('optimist')
.describe('o', 'path to output directory (default: ./out)') .describe('o', 'path to output directory (default: ./out)')
.alias('m', 'meta') .alias('m', 'meta')
.describe('m','add metadata elements to .md files Eg -m template=reference. Multiple values can be added by repeating the flag Eg: -m template=reference -m hide-nav=true') .describe('m','add metadata elements to .md files Eg -m template=reference. Multiple values can be added by repeating the flag Eg: -m template=reference -m hide-nav=true')
.alias('s', 'schema-out') .alias('s','metaSchema')
.describe('s', 'pass to output JSON Schema files including description and validated examples in the _new folder at output directory') .describe('s', 'Custom meta schema path to validate schemas')
.alias('x', 'schema-out')
.describe('x', 'pass to output JSON Schema files including description and validated examples in the _new folder at output directory')
.argv; .argv;
if (!argv.d) { if (!argv.d) {
...@@ -103,12 +105,16 @@ if (argv.m) { ...@@ -103,12 +105,16 @@ if (argv.m) {
}); });
} }
else { else {
var meta=argv.m.split("="); var meta=(argv.m).split("=");
if(meta.length == 2) if(meta.length == 2)
metaElements[meta[0]]=meta[1]; metaElements[meta[0]]=meta[1];
} }
} }
if(argv.s){
ajv.addMetaSchema(require(path.resolve(argv.s)));
}
var baseURL = path.resolve(fileDir); var baseURL = path.resolve(fileDir);
logger.info('output directory: %s', outDir); logger.info('output directory: %s', outDir);
logger.info('processing %s...', schemaPath); logger.info('processing %s...', schemaPath);
... ...
......
...@@ -156,9 +156,8 @@ function displayStringIfExists(object,key,str){ ...@@ -156,9 +156,8 @@ function displayStringIfExists(object,key,str){
<% if(schema.properties){ %> <% if(schema.properties){ %>
## Properties ## Properties
<% Object.keys(schema.properties).map((prop) => { var value= schema.properties[prop]; %> <% Object.keys(schema.properties).map((prop) => { var value= schema.properties[prop]; HelperFunctions.nestLevel = -1; %>
### <%- HelperFunctions.linkProperty(prop) %><%- HelperFunctions.isRequired(prop,schema.required) %><%- include('innerSchema', {nschema: value, HelperFunctions:HelperFunctions,flag:true,nchild:0}) %> ### <%- HelperFunctions.linkProperty(prop) %><%- HelperFunctions.isRequired(prop,schema.required) %><%- include('innerSchema', {nschema: value, HelperFunctions:HelperFunctions,flag:true,nchild:0}) %><% });} %>
<% });} %>
<% if(schema.definitions){ %> <% if(schema.definitions){ %>
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment