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.14 to 1.2.0

.travis.yml

14

dist/Parsers/ObjectParser.js

@@ -50,14 +50,14 @@ 'use strict';

for (var k in schema) {
// detect and break circular references in schema and return null object
// detect and break circular references in schema
if (hasCircular) {
schema[k] = {};
schema[k] = JSON.parse(JSON.stringify(schema[k]));
ret[k] = this.parser.parse(schema[k]);
hasCircular = false;
this.cache.pop();
break;
} else {
if (this.parser.options && this.parser.options.useObjectKey) {
schema[k]._objectKey = k;
}
ret[k] = this.parser.parse(schema[k]);
}
if (this.parser.options && this.parser.options.useObjectKey) {
schema[k]._objectKey = k;
}
ret[k] = this.parser.parse(schema[k]);
}

@@ -64,0 +64,0 @@ }

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

@@ -20,3 +20,5 @@ "keywords": [

"scripts": {
"build": "rm -rf dist/ && babel src --out-dir dist"
"build": "rm -rf dist/ && babel src --out-dir dist",
"test": "nyc ava test/index.js",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},

@@ -30,5 +32,9 @@ "author": "weihanqing",

"devDependencies": {
"ava": "^0.23.0",
"babel": "^5.6.14",
"babel-preset-es2015": "^6.9.0"
"babel-preset-es2015": "^6.9.0",
"coveralls": "^3.0.0",
"nyc": "^11.2.1",
"swagger-jsblade-swagger-parser": "^4.0.0-beta.2"
}
}

@@ -0,1 +1,4 @@

[![Build Status](https://travis-ci.org/whq731/swagger-mock-parser.svg?branch=master)](https://travis-ci.org/whq731/swagger-mock-parser)
[![Coverage Status](https://coveralls.io/repos/github/whq731/swagger-mock-parser/badge.svg?branch=master)](https://coveralls.io/github/whq731/swagger-mock-parser?branch=master)
# swagger-mock-parser

@@ -5,2 +8,5 @@ A parser for swagger object properties ,mock data returned by chancejs

## changeLog
### version 1.2.0
break change:
object parser use JSON.stringfy to break circular references in schema
### version 1.1.14

@@ -7,0 +13,0 @@ add useObjectKey option,set this true ,String parser will return the key name;

@@ -28,14 +28,14 @@ import Chance from 'chance';

for (var k in schema) {
// detect and break circular references in schema and return null object
if (hasCircular){
schema[k] = {};
// detect and break circular references in schema
if (hasCircular) {
schema[k] = JSON.parse(JSON.stringify(schema[k]));
ret[k] = this.parser.parse(schema[k]);
hasCircular = false;
this.cache.pop();
break;
} else {
if(this.parser.options && this.parser.options.useObjectKey){
schema[k]._objectKey = k;
}
ret[k] = this.parser.parse(schema[k]);
}
if(this.parser.options && this.parser.options.useObjectKey){
schema[k]._objectKey = k;
}
ret[k] = this.parser.parse(schema[k]);
}

@@ -42,0 +42,0 @@ }

@@ -0,5 +1,13 @@

var test = require('ava');
var Parser = require('../dist/Parser');
var parser = new Parser({fixedArray: true});
console.log('fixed Array:' + parser.parse({type: 'array', items: {type: 'string'}}));
parser = new Parser();
console.log('default random Array:' + parser.parse({type: 'array', items: {type: 'string'}}));
test('fixed Array', t => {
let parser = new Parser({fixedArray: true});
let res = parser.parse({type: 'array', items: {type: 'string'}});
t.is(Array.isArray(res) && res.length === 1, true);
});
test('default random Array', t => {
let parser = new Parser();
let res = parser.parse({type: 'array', items: {type: 'string'}});
t.is(Array.isArray(res), true);
});

Sorry, the diff of this file is not supported yet

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