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

oasify-postman

v1.0.9

Published

Convert Postman collections to OpenAPI specifications with example responses

Readme

Oasify Postman

Oasify Postman

npm version License: MIT Node.js OpenAPI

Convert Postman collections to OpenAPI specifications with example responses automatically injected.

✨ Features

  • 🔄 Convert Postman collections to OpenAPI 3.0 specifications
  • 📝 Automatic example injection from saved Postman responses
  • 🎯 Customizable API metadata (title, description, version, tags)
  • 📁 YAML output for easy integration with documentation tools
  • 🖥️ Command-line interface for quick conversions
  • 📚 Programmatic API for integration into build processes

📋 Table of Contents

📦 Installation

Local Installation (Library) - Recommended

npm install oasify-postman

Global Installation (CLI)

npm install -g oasify-postman

🎯 Demo

Before (Postman Collection): Raw JSON with saved responses After (OpenAPI Spec): Beautiful, interactive API documentation with examples

🚀 Quick Start

Programmatic Usage - Recommended

const { generateSwagger } = require('oasify-postman');

async function convertCollection() {
  try {
    await generateSwagger('collection.json', 'swagger.yaml', {
      defaultTag: 'API',
      info: {
        title: 'My API',
        description: 'My awesome API description',
        version: '1.0.0'
      }
    });
    console.log('✅ Conversion completed successfully!');
  } catch (error) {
    console.error('❌ Conversion failed:', error.message);
  }
}

convertCollection();

Command Line Usage

Basic conversion:

oasify-postman collection.json swagger.yaml

With custom API information:

oasify-postman -t "My Awesome API" -d "API for managing users and posts" -v "2.0.0" collection.json api.yaml

Quick test with example collection:

# Download example collection
curl -o example.json https://raw.githubusercontent.com/your-repo/example-collection.json

# Convert to OpenAPI
oasify-postman example.json api-docs.yaml

📖 CLI Options

| Option | Short | Description | Default | |--------|-------|-------------|---------| | --help | -h | Show help message | - | | --title | -t | API title | "API Documentation" | | --description | -d | API description | "API documentation generated from Postman collection" | | --version | -v | API version | "1.0.0" | | --tag | -g | Default tag for endpoints | "General" |

Usage Examples

# Basic conversion
oasify-postman my-api.json api.yaml

# Custom API information
oasify-postman -t "User Management API" -d "Complete user management system" -v "1.2.0" users.json users-api.yaml

# With custom default tag
oasify-postman -g "Users" -t "User API" users.json users.yaml

🔧 API Reference

generateSwagger(inputFile, outputFile, options)

Converts a Postman collection to OpenAPI specification.

Parameters

  • inputFile (string): Path to Postman collection JSON file
  • outputFile (string): Path to output OpenAPI YAML file
  • options (Object): Conversion options
    • defaultTag (string): Default tag for endpoints
    • info (Object): API information
      • title (string): API title
      • description (string): API description
      • version (string): API version

Returns

Promise that resolves when conversion is complete.

Example

const options = {
  defaultTag: 'Users',
  info: {
    title: 'User Management API',
    description: 'Complete user management system',
    version: '2.0.0'
  }
};

await generateSwagger('users.json', 'users-api.yaml', options);

injectExampleResponses(postmanFile, openapiFile)

Injects example responses from Postman collection into OpenAPI specification.

Parameters

  • postmanFile (string): Path to Postman collection file
  • openapiFile (string): Path to OpenAPI YAML file

Returns

Promise that resolves when injection is complete.

Example

await injectExampleResponses('collection.json', 'api.yaml');

📋 Requirements

  • Node.js 14.0.0 or higher
  • Postman collection with saved responses (for example injection)
  • Proper URL format in collection (e.g., "https://api.example.com/endpoint")

⚠️ Troubleshooting

Common Issues

❌ "Invalid URL format" error

  • Ensure your Postman collection has proper URL format
  • URLs should be complete (e.g., https://api.example.com/users not just /users)

❌ "No examples found" warning

  • Make sure your Postman collection has saved responses
  • Export collection with "Save responses" option enabled

❌ "Permission denied" error

  • Check file permissions for input/output files
  • Ensure you have write access to the output directory

Getting Help

  • 📖 Check the example collection for reference
  • 🐛 Report issues on GitHub
  • 💬 Ask questions in discussions

📝 Example Output

Before vs After

| Aspect | Postman Collection | OpenAPI Specification | |--------|-------------------|----------------------| | Format | JSON | YAML | | Examples | Saved responses | Injected examples | | Documentation | Basic | Interactive | | Integration | Manual | Auto-generated | | Standards | Proprietary | OpenAPI 3.0 |

Sample Output

Input Postman collection with saved responses generates an OpenAPI spec like:

openapi: 3.0.0
info:
  title: My API
  description: API documentation generated from Postman collection
  version: 1.0.0
paths:
  /users:
    get:
      tags:
        - General
      responses:
        '200':
          description: Example response for Get Users
          content:
            application/json:
              example:
                users:
                  - id: 1
                    name: "John Doe"
                    email: "[email protected]"

💡 Pro Tip: Your Postman collection should have proper URL format (e.g., "https://api.example.com/endpoint") for the converter to work correctly.

🤝 Contributing

We welcome contributions! Here's how you can help:

🚀 Quick Start

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🎯 Areas to Contribute

  • 🐛 Bug fixes
  • ✨ New features
  • 📚 Documentation improvements
  • 🧪 Test coverage
  • 🔧 Performance optimizations

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built on top of postman-to-openapi
  • Uses yamljs for YAML processing
  • Inspired by the need for better Postman-to-OpenAPI conversion tools