ReadMe CLI

10.6.2 · active · verified Wed Apr 22

rdme is the official command-line interface (CLI) and GitHub Action for ReadMe, designed to streamline API documentation workflows. It enables users to manage and synchronize API definitions (supporting OpenAPI, Swagger, and Postman specifications) with their API reference documentation hosted on ReadMe.com. Beyond ReadMe-specific integrations, it provides robust API definition validation tools that can be used independently, without requiring a ReadMe account. The current stable version is v10.6.2, with active development indicated by frequent patch and minor releases, often with pre-release (`-next`) versions for upcoming features. A key differentiator is its dual functionality as both a local development tool and an automation agent for CI/CD environments, specifically via GitHub Actions. It has a notable distinction between v9 and v10 regarding compatibility with 'ReadMe Refactored' documentation experiences.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates programmatic usage of `rdme` for OpenAPI validation and general CLI execution, alongside typical command line installation and usage.

import { validate, run } from 'rdme';

async function quickstart() {
  console.log('--- Validating an OpenAPI specification programmatically ---');
  try {
    // Assuming 'openapi.yaml' exists in the current directory
    await validate(['openapi.yaml']); 
    console.log('OpenAPI specification is valid!');
  } catch (error) {
    console.error('Validation failed:', error.message);
    // For a real application, you might exit with an error code here.
  }

  console.log('\n--- Running a CLI command programmatically ---');
  try {
    // Simulate `rdme openapi validate openapi.yaml`
    // Note: 'run' may suppress console output for success by default,
    // or throw on error. Error handling is crucial.
    console.log('Attempting to run `rdme openapi validate` via `run()`...');
    await run(['openapi', 'validate', 'openapi.yaml']);
    console.log('CLI command executed successfully via `run()`.');
  } catch (error) {
    console.error('CLI command failed:', error.message);
  }

  console.log('\n--- Typical CLI usage via npm ---');
  console.log('To install globally: npm install -g rdme');
  console.log('Then, validate: rdme openapi validate openapi.yaml');
}

// Create a dummy openapi.yaml for demonstration purposes
import * as fs from 'node:fs';
if (!fs.existsSync('openapi.yaml')) {
  fs.writeFileSync('openapi.yaml', `
openapi: 3.0.0
info:
  title: My API
  version: 1.0.0
paths:
  /items:
    get:
      summary: Retrieve items
      responses:
        '200':
          description: A list of items
`)
}

quickstart();

view raw JSON →