Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
swagger-mock-parser
Advanced tools
A parser for swagger object properties ,mock data returned by chancejs
add fixedArray option,set this true ,array parser will return only one child array
detect and fix circular references in schema and return null object
add useExample option,set this true parser will return defined example first
break change: return string instead of throw error,objectParser canParse add "node.type == object" judge condition
An example for mocking swagger definition schema
// basic usage
var Parser = require('swagger-mock-parser')
var parser = new Parser();
var schema = definition.schema;
return parser.parse(schema);
// useExample option
var Parser = require('swagger-mock-parser')
// set useExample true will return every property's example which has already defined
var parser = new Parser({useExample: true});
var schema = {type: 'string', example: 'will return example first'}
return parser.parse(schema);
Swagger specifies only a few primitive types; for scenarios where specific chance methods are needed, use the x-chance-type
field.
...
definitions:
NewPet:
properties:
name:
type: string
x-chance-type: name
tag:
type: string
x-chance-type: guid
Most of the chance methods allow some fine-tuning of the returned data. For example, the integer method allows specification of minimum and maximum output values. These options can be configured in the Swagger YAML file with the x-chance-options
block:
...
definitions:
Pet:
allOf:
- $ref: '#/definitions/NewPet'
- required:
- id
properties:
id:
type: integer
format: int64
x-type-options:
min: 1
max: 1000
All of the primitive types defined in the Swagger specification are supported except for file
and password
. Currently, the format
property is ignored; use x-chance-type
instead. The server will error on any request with a type other than one of the primitive types if there is no valid x-chance-type also defined.
Although not a chance method, support has been added for returning fixed values using x-chance-type: fixed
. Any value given for the custom tag x-type-value
will be returned; below is an example where an object is returned:
status:
type: object
x-chance-type: fixed
x-type-value:
type: 'adopted'
FAQs
use chance.js to parse definition schema to mock data
The npm package swagger-mock-parser receives a total of 51 weekly downloads. As such, swagger-mock-parser popularity was classified as not popular.
We found that swagger-mock-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.