Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
swagger-parameters
Advanced tools
Readme
Validate and parse request data using swagger parameters arrays
swagger-parameters turns your Swagger/OpenAPI parameters into a full JSON schema that can be used to parse and validate HTTP request data. The library is fully server-agnostic. You're responsible for converting your request paths and queries into key-value data. swagger-parameters will perform validation and type coercion and return a copy of your parsed data (if valid).
$ npm install --save swagger-parameters
var Parser = require('swagger-parameters')
// var Schema = require('swagger-parameters/schema')
// /users/{id}/orders?page={page}
var parse = Parser([
{
name: 'id',
in: 'path',
type: 'integer',
required: true
},
{
name: 'page',
in: 'query',
default: 1,
type: 'integer'
},
{
name: 'token',
in: 'header',
required: true
}
])
parse({
path: {id: '1'},
query: {page: '5'},
headers: {token: 't'}
}, function (err, data) {
if (err) throw err
console.log(data)
//=> {path: {id: 1}, query: {page: 5}, headers: {token: 't'}}
})
Parser(parameters, [data])
-> function<parse>
Type: array[object]
Default: []
An array of Swagger/OpenAPI parameter definition.
Required
Type: object
Data that can be resolved by $ref
parameters.
parse(data, callback)
-> undefined
Required
Type: object
A {path, query, headers}
object, each with key-value data.
Required
Type: function
Arguments: err, data
A callback to be called with a validation error or a parsed copy of the data. Validation errors will have an errors
property which is an array of JSON schema error objects from ajv.
MIT © Ben Drucker
FAQs
Validate and parse request data using swagger parameters arrays
The npm package swagger-parameters receives a total of 206 weekly downloads. As such, swagger-parameters popularity was classified as not popular.
We found that swagger-parameters 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.