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 πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

apexswag

v1.0.5

Published

πŸ•ΆοΈ Generate beautiful Swagger/OpenAPI documentation from Salesforce Apex REST classes with one command

Readme

ApexSwag πŸ•ΆοΈ

Giving your Apex REST endpoints the swagger they deserve.

npm version License: MIT

ApexSwag is a Salesforce CLI plugin that transforms your @RestResource classes into beautiful, interactive OpenAPI 3.0 documentation β€” with a single command.

Created by Nishant Mohapatra


Prerequisites

Before installing ApexSwag, make sure you have the following:

1. Node.js (v18 or higher)

Download and install from nodejs.org

# Verify installation
node --version  # Should show v18.x.x or higher

2. Salesforce CLI

The Salesforce CLI (sf) is required. Install it using npm:

# Install Salesforce CLI globally
npm install -g @salesforce/cli

# Verify installation
sf --version

Or download from Salesforce CLI Setup Guide

3. Salesforce Org Access

You need access to a Salesforce org with Apex REST classes. This can be:


Installation

# Install ApexSwag plugin
sf plugins install apexswag

From Source (Development)

git clone https://github.com/nkmongit/apexswag.git
cd apexswag
npm install
npm run build
sf plugins link .

First-Time Setup

If this is your first time using ApexSwag, follow these steps:

Step 1: Authenticate Your Salesforce Org

# Open browser to log in to your Salesforce org
sf org login web

This opens your browser. Log in to your Salesforce org and authorize the CLI.

Step 2: Verify Connection

# List connected orgs
sf org list

You should see your org in the list.

Step 3: Run ApexSwag

# Generate documentation
sf apexswag generate

ApexSwag will scan your org for @RestResource classes and open the documentation UI.


Features

| Feature | Description | |---------|-------------| | πŸš€ Auto Discovery | Scans your Salesforce Org for @RestResource classes | | πŸ“– ApexDoc Parsing | Extracts @description, @param, @return, and @tag annotations | | πŸ” Security Schemas | OAuth2 and Bearer authentication definitions | | ⚠️ Error Responses | Standard 400/401/403/404/500 response schemas | | πŸ“ Smart Examples | Auto-generated examples based on field names | | 🏷️ Tag Grouping | Group endpoints using @tag annotations | | πŸ”„ Dynamic Schemas | Fetch SObject field metadata including custom objects | | πŸ’» Interactive UI | Modern React-based documentation interface | | πŸ“¦ Postman Export | Export as Postman Collection v2.1 | | πŸ’Ύ OpenAPI Export | Export JSON spec for CI/CD pipelines | | πŸ‘€ Watch Mode | Auto-reload when classes change |


Usage

Quick Start

# Interactive mode - select org and classes
sf apexswag generate

# Specify org and port
sf apexswag generate -o my-org -p 8080

# Export OpenAPI spec
sf apexswag generate --export -f api-spec.json

# Export Postman collection
sf apexswag generate --postman -f collection.json

# Watch mode
sf apexswag generate --watch

# Dynamic SObject schemas
sf apexswag generate --dynamic-sobjects

Command Flags

| Flag | Short | Description | Default | |------|-------|-------------|---------| | --target-org | -o | Target Salesforce Org | Interactive | | --port | -p | Server port | 3000 | | --export | -e | Export OpenAPI JSON | false | | --postman | | Export Postman Collection | false | | --output-file | -f | Output file path | openapi.json | | --class-names | -c | Comma-separated class names | All | | --watch | -w | Watch mode | false | | --dynamic-sobjects | | Fetch SObject schemas | false | | --no-security | | Exclude security definitions | false | | --no-errors | | Exclude error responses | false | | --no-examples | | Exclude example values | false |


ApexDoc Support

Annotations

/**
 * @description Creates a new Widget
 * @param name The widget name
 * @param count Number of items
 * @return The created Widget ID
 * @tag Widgets
 */
@HttpPost
global static String createWidget(String name, Integer count) { ... }

Inner Classes

global class RequestWrapper {
    public String name;
    public Integer age;
}

@HttpPost
global static void doPost(RequestWrapper req) { ... }

Generates schema with smart examples:

{ "name": "Acme Corporation", "age": 25 }

Troubleshooting

"No Salesforce orgs connected"

Run these commands:

sf org login web        # Authenticate an org
sf org list             # Verify it appears
sf apexswag generate    # Try again

"No @RestResource classes found"

Make sure your org has Apex classes with the @RestResource annotation:

@RestResource(urlMapping='/myEndpoint/*')
global class MyRestClass {
    @HttpGet
    global static String doGet() {
        return 'Hello World';
    }
}

Port already in use

Specify a different port:

sf apexswag generate -p 8080

Project Structure

apexswag/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ commands/apexswag/    # CLI command
β”‚   └── utils/                # Core utilities
β”‚       β”œβ”€β”€ parser.ts         # Apex parsing
β”‚       β”œβ”€β”€ openapi.ts        # OpenAPI generation
β”‚       β”œβ”€β”€ server.ts         # Documentation server
β”‚       └── sobjectService.ts # SObject schema fetching
β”œβ”€β”€ ui/                       # React documentation UI
└── test/                     # Test suite

License

MIT Β© Nishant Mohapatra


Made with ❀️ for the Salesforce community