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

swagger-schema

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-schema - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

29

environment.js

@@ -26,2 +26,3 @@ /**

// defaults
options = lodash.defaults(options || {}, {

@@ -31,5 +32,6 @@ setup: true,

this.schema = jjv();
this.coerceSchema = jjv();
this.schemas = [this.schema, this.coerceSchema];
this.env = jjv();
this.env.defaultOptions.checkRequired = true;
this.env.defaultOptions.useDefault = true;
this.env.defaultOptions.useCoerce = false;

@@ -40,3 +42,3 @@ if (options.setup) this.setup();

Environment.prototype.setup = function() {
this.coerceSchema.addTypeCoercion('array', function(v) {
this.env.addTypeCoercion('array', function(v) {
if (!Array.isArray(v)) {

@@ -48,3 +50,3 @@ return typeof v === 'undefined' ? [] : [v];

this.coerceSchema.addTypeCoercion('integer', function(v) {
this.env.addTypeCoercion('integer', function(v) {
if (typeof v === 'string' && v.match(/^\-?\d+$/)) {

@@ -56,3 +58,3 @@ return parseInt(v, 10);

this.coerceSchema.addTypeCoercion('number', function(v) {
this.env.addTypeCoercion('number', function(v) {
if (typeof v === 'string' && v.match(/^(\d+|\d*\.\d+|\d+\.\d*)$/)) {

@@ -64,3 +66,3 @@ return parseFloat(v);

this.coerceSchema.addTypeCoercion('boolean', function(v) {
this.env.addTypeCoercion('boolean', function(v) {
if (typeof v === 'string') {

@@ -79,6 +81,9 @@ return ['', '0', 'false', 'no'].indexOf(v) < 0;

options = options || {};
if (options.coerce) {
return this.coerceSchema.validate(schema, data, options);
if (options.hasOwnProperty('coerce')) {
options.useCoerce = options.coerce;
delete options.coerce;
}
return this.schema.validate(schema, data, options);
return this.env.validate(schema, data, options);
};

@@ -105,5 +110,3 @@

Environment.prototype.addSchema = function(name, data) {
this.schemas.forEach(function(env) {
env.addSchema(name, data);
});
this.env.addSchema(name, data);
};

@@ -110,0 +113,0 @@

{
"name": "swagger-schema",
"version": "0.8.0",
"version": "0.9.0",
"description": "Swagger schema helpers",
"dependencies": {
"jjv": "0.3.4",
"lodash": "*"
"jjv": "1.0.0",
"lodash": "^2.4.1"
},

@@ -9,0 +9,0 @@ "devDependencies": {

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