npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

swagger-parameters

v1.3.2

Published

Validate and parse request data using swagger parameters arrays

Downloads

510

Readme

swagger-parameters Build Status

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).

Install

$ npm install --save swagger-parameters

Usage

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'}}
})

API

Parser(parameters, [data]) -> function<parse>

parameters

Type: array[object]
Default: []

An array of Swagger/OpenAPI parameter definition.

data

Required
Type: object

Data that can be resolved by $ref parameters.

parse(data, callback) -> undefined

data

Required
Type: object

A {path, query, headers} object, each with key-value data.

callback

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.

License

MIT © Ben Drucker