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 🙏

© 2024 – Pkg Stats / Ryan Hefner

swagger2-to-postmanv2

v2.1.0

Published

A module to convert swagger 2.0 specs to Postman Collection Format v2

Downloads

1,560

Readme

swagger2-Postman

Build Status

Converter for swagger 2.0 JSON to Postman Collection v2 Exports the following functions:

validate(JSON-or-string): Formats like RAML/cURL don't have a JSON representation. For others, JSON is preferred. The result should be an object: {result: true/false, reason: 'string'}. Reason must be populated if the result is false. This function will be used by the app to determine whether or not this converter can be used for the given input.

convert(JSON-or-string): Converts the input to a collection object. Conversion result should be an object: {result: true/false, reason: '', output:[{type: 'collection', data: <object>}] Reason must be populated if the result is false. Collection must be populated if result is true.

Conversion Schema

| Postman | Swagger2 | options | examples | | --- | --- | :---: | :---: | | collectionName | info.title | - | - | | description | info.description | - | - | | folderName | paths.path | - | - | | requestName| method.summary || method.operationId || request.url.raw(in postman) | default('operationId') -(requestName) enum[['operationId','summary','url'] | - | | request.method | path.method (all possible http methods) | - | - | | request.headers | params (in = header ) | - |here| | request.body | params (in = body or formBody) | default(true)-(schemaFaker)use json-schema-faker for body conversion | here | | request.url.raw | scheme(http or https) + '://' + host + basePath | - | - | | request.url.params | params (in = query)| - | here | | request.url.variables | params (in = path) | - | here | | Content-Type header | consumes | default(true) - add consumes to header | - | | Accept header | produces | default(true) - add produces to header | - | | apikey in (query or header) | securityDefinitions(type = apiKey) | - | - |

Header/Query/Path param conversion example

| swagger | postman | | --- | --- | | name: api-key description: session tokenin: headertype: integerdefault: defaultValue |{ "key": "api-key", "value": defaultValue, "description": "session token"}|

Body param conversion example

If in = body

| swagger | postman | | --- | --- | |name: role-iddescription: role identifier numberin: bodyschema: <schemaObject>|"body": { "mode": "raw", "raw": json-schema-faker(<schemaObject>)}|

If in = formData and consumes = application/x-www-form-urlencoded

| swagger | postman | | --- | --- | |name: role-iddescription: role identifier numberin: formDatadefault: defaultValue|"body": { "mode": "urlencoded", "urlencoded": [{  "key": "role-id",  "value": defaultValue,  "type": "text", }]}|

All parmas with above condition are added to urlencoded array.

If in = formData and consumes = multipart/form-data

| swagger | postman | | --- | --- | |name: role-iddescription: role identifier numberin: formDatadefault: defaultValue|"body": { "mode": "formdata", "formdata": [{  "key": "role-id",  "value": defaultValue,  "type": "text", }]}|

All parmas with above condition are added to formdata array.