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

swagger-mock-parser

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-mock-parser - npm Package Compare versions

Comparing version 1.1.12 to 1.1.13

test/arrayTest.js

2

dist/Parsers/ArrayParser.js

@@ -45,3 +45,3 @@ 'use strict';

var iterations = chance.integer(options);
var iterations = this.parser.options && this.parser.options.fixedArray ? 1 : chance.integer(options);
var ret = [];

@@ -48,0 +48,0 @@

@@ -43,13 +43,18 @@ 'use strict';

schema = schema.properties;
this.cache.push(node);
for (var k in schema) {
// detect and fix circular references in schema and return null object
if (this.cache.filter(function (cacheObj) {
return node == cacheObj;
}).length > 2) {
ret[k] = {};
this.cache.pop();
return ret;
} else {
ret[k] = this.parser.parse(schema[k]);
this.cache.push(schema);
// if is not swagger object type return null object
if (schema) {
var hasCircular = this.cache.filter(function (cacheObj) {
return schema == cacheObj;
}).length > 1;
for (var k in schema) {
// detect and break circular references in schema and return null object
if (hasCircular) {
schema[k] = {};
hasCircular = false;
this.cache.pop();
break;
} else {
ret[k] = this.parser.parse(schema[k]);
}
}

@@ -56,0 +61,0 @@ }

{
"name": "swagger-mock-parser",
"version": "1.1.12",
"version": "1.1.13",
"description": "use chance.js to parse definition schema to mock data",

@@ -5,0 +5,0 @@ "keywords": [

# swagger-mock-parser
A parser for swagger object properties ,mock data returned by chancejs
##changeLog
version 1.1.8 change: add useExample option,set this true parser will return defined example first
version 1.1.7 break change: return string instead of throw error,objectParser canParse add "node.type == object" judge condition
## changeLog
### version 1.1.13
add fixedArray option,set this true ,array parser will return only one child array
### version 1.1.12
detect and fix circular references in schema and return null object
### version 1.1.8 ~ 1.1.11
add useExample option,set this true parser will return defined example first
### version 1.1.7
break change: return string instead of throw error,objectParser canParse add "node.type == object" judge condition
## usage

@@ -10,0 +18,0 @@

@@ -24,3 +24,3 @@ import Chance from 'chance';

let iterations = chance.integer(options);
let iterations = (this.parser.options && this.parser.options.fixedArray)? 1 : chance.integer(options) ;
let ret = [];

@@ -27,0 +27,0 @@

@@ -19,13 +19,20 @@ import Chance from 'chance';

var ret = {};
var schema = Object.assign({},node);
var schema = Object.assign({}, node);
schema = schema.properties;
this.cache.push(node);
for (var k in schema) {
// detect and fix circular references in schema and return null object
if (this.cache.filter(cacheObj => { return node == cacheObj}).length > 2) {
ret[k] = {};
this.cache.pop();
return ret;
} else {
ret[k] = this.parser.parse(schema[k]);
this.cache.push(schema);
// if is not swagger object type return null object
if (schema) {
var hasCircular = this.cache.filter(function (cacheObj) {
return schema == cacheObj;
}).length > 1
for (var k in schema) {
// detect and break circular references in schema and return null object
if (hasCircular){
schema[k] = {};
hasCircular = false;
this.cache.pop();
break;
} else {
ret[k] = this.parser.parse(schema[k]);
}
}

@@ -32,0 +39,0 @@ }

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