Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-json-schema - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

schema/Address.bottomup.json

2

example.js

@@ -9,3 +9,3 @@ var jsonschema = require('./index');

};
User.prototype.attributes = ["name", "email", "password", "address:Address", "active:enum Active,Inactive"];
User.prototype.attributes = ["name", "email", "password", "address:Address[]", "active:enum Active,Inactive"];
User.prototype.extend = {};

@@ -12,0 +12,0 @@ User.prototype.extend.staffUser = ["staffId", "department"];

@@ -12,12 +12,14 @@ var fs = require('fs'), helper = require('./commons');

if (typeInstance.extend[q]) {
return q.capitalize() + type.capitalize() + options.ext;
return q.capitalize() + type.capitalize();
}
} else {
return type.capitalize() + options.ext;
return type.capitalize();
}
}
}
return type.capitalize() + options.ext;
return type.capitalize();
};
var generator = function (instance, name) {

@@ -43,18 +45,3 @@

schema.properties[name].description = description + name;
if (type.toLowerCase() === "enum") {
schema.properties[name].enum = element.enum;
} else {
schema.properties[name].type = type.toLowerCase();
if (type.toLowerCase() === "number") {
schema.properties[name].minimum = 0;
}
if (type.toLowerCase() === "date") {
schema.properties[name].type = "string";
schema.properties[name].format = "date";
}
if (!helper.isDefaultType(schema.properties[name].type.toLowerCase())) {
schema.properties[name].type = "object";
schema.properties[name]["$ref"] = findReference(type, category);
}
}
helper.handleTypes(schema, name, type, element, category, options, findReference);
}

@@ -61,0 +48,0 @@ return schema;

@@ -13,6 +13,13 @@ if (String.prototype.capitalize === undefined) {

}
if (String.prototype.endsWith === undefined) {
String.prototype.endsWith = function (text) {
text = text.replace(".", "\\.");
text = text.replace("[", "\\[");
text = text.replace("]", "\\]");
return new RegExp(text+"$").test(this)
};
}
var varType = /([a-zA-Z]+):([A-Za-z\s,_\[\]]+)/;
var varType = /([a-zA-Z]+):([A-Za-z\s,_]+)/;
var isDefaultType = function (typeName) {

@@ -55,2 +62,26 @@ var jsonTypes = ['integer', 'number', 'object', 'array', 'boolean', 'string'];

var handleTypes = function(schema, name, type, element, category, options, refFinder) {
if (type.toLowerCase() === "enum") {
schema.properties[name].enum = element.enum;
} else {
schema.properties[name].type = type.toLowerCase();
if (type.toLowerCase() === "number") {
schema.properties[name].minimum = 0;
}
if (type.toLowerCase() === "date") {
schema.properties[name].type = "string";
schema.properties[name].format = "date";
}
if (!isDefaultType(schema.properties[name].type.toLowerCase())) {
var refType = refFinder(type, category);
if (refType.endsWith("[]")) {
schema.properties[name].type = "array";
schema.properties[name]["items"] = {"$ref": refType.slice(0, refType.length - 2) + options.ext};
} else {
schema.properties[name].type = "object";
schema.properties[name]["$ref"] = refType + options.ext;
}
}
}
};

@@ -60,3 +91,4 @@ module.exports = {

inspect: inspect,
cleanser: cleanser
cleanser: cleanser,
handleTypes: handleTypes
};

@@ -5,2 +5,6 @@ var fs = require('fs'), helper = require('./commons');

var findReference = function (type) {
return type.capitalize();
};
var generator = function (instance, name) {

@@ -25,18 +29,3 @@

schema.properties[name].description = description + name;
if (type.toLowerCase() === "enum") {
schema.properties[name].enum = element.enum;
} else {
schema.properties[name].type = type.toLowerCase();
if (type.toLowerCase() === "number") {
schema.properties[name].minimum = 0;
}
if (type.toLowerCase() === "date") {
schema.properties[name].type = "string";
schema.properties[name].format = "date";
}
if (!helper.isDefaultType(schema.properties[name].type.toLowerCase())) {
schema.properties[name].type = 'object';
schema.properties[name]["$ref"] = type.capitalize() + options.ext;
}
}
helper.handleTypes(schema, name, type, element, '', options, findReference)
}

@@ -43,0 +32,0 @@ };

{
"name": "js-json-schema",
"version": "0.0.2",
"version": "0.0.3",
"description": "create json schema from javascript configuration",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc