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

@speakeasy-api/openapi-linter-types

v1.17.1

Published

TypeScript types for writing custom OpenAPI linter rules

Readme

@speakeasy-api/openapi-linter-types

TypeScript types for writing custom OpenAPI linter rules.

Installation

npm install @speakeasy-api/openapi-linter-types

Usage

Create a TypeScript file with your custom rule:

import { Rule, registerRule, createValidationError } from '@speakeasy-api/openapi-linter-types';
import type { Context, DocumentInfo, RuleConfig, Severity, ValidationError } from '@speakeasy-api/openapi-linter-types';

class RequireOperationSummary extends Rule {
  id(): string { return 'custom-require-operation-summary'; }
  category(): string { return 'style'; }
  description(): string { return 'All operations must have a summary.'; }
  summary(): string { return 'Operations must have summary'; }
  defaultSeverity(): Severity { return 'warning'; }

  run(ctx: Context, docInfo: DocumentInfo, config: RuleConfig): ValidationError[] {
    const errors: ValidationError[] = [];

    for (const opNode of docInfo.index.operations) {
      const op = opNode.node;
      if (!op.getSummary()) {
        errors.push(createValidationError(
          config.getSeverity(this.defaultSeverity()),
          this.id(),
          'Operation is missing a summary',
          op.getRootNode()
        ));
      }
    }

    return errors;
  }
}

registerRule(new RequireOperationSummary());

Rule Base Class

Extend the Rule base class to create custom rules. The following methods must be implemented:

| Method | Description | |--------|-------------| | id() | Unique identifier for the rule (e.g., custom-require-summary) | | category() | Category for grouping rules (e.g., style, security, naming) | | description() | Full description of what the rule checks | | summary() | Short summary for display | | run(ctx, docInfo, config) | Main rule logic that returns validation errors |

Optional methods with defaults:

| Method | Default | Description | |--------|---------|-------------| | link() | '' | URL to rule documentation | | defaultSeverity() | 'warning' | Default severity ('error', 'warning', 'hint') | | versions() | null | OpenAPI versions this rule applies to (e.g., ['3.0', '3.1']) |

Document Access

The DocumentInfo object provides access to the parsed OpenAPI document:

// The OpenAPI document root
docInfo.document

// File location
docInfo.location

// Pre-computed index with collections for efficient iteration
docInfo.index.operations         // All operations
docInfo.index.componentSchemas   // All component schemas
docInfo.index.inlineSchemas      // All inline schemas
docInfo.index.parameters         // All parameters (inline + component)
docInfo.index.requestBodies      // All request bodies
docInfo.index.responses          // All responses
docInfo.index.headers            // All headers
docInfo.index.securitySchemes    // All security schemes
// ... and many more collections

Creating Validation Errors

Use createValidationError() to create properly formatted errors:

import { createValidationError } from '@speakeasy-api/openapi-linter-types';

const error = createValidationError(
  'warning',                    // severity
  'custom-my-rule',            // rule ID
  'Description of the issue',  // message
  node.getRootNode()           // YAML node for location
);

Console Logging

The console global is available for debugging:

console.log('Processing operation:', op.getOperationID());
console.warn('Missing recommended field');
console.error('Invalid configuration');

Configuration

Configure custom rules in your lint.yaml:

extends: recommended

custom_rules:
  paths:
    - ./rules/*.ts
    - ./rules/security/*.ts

rules:
  - id: custom-require-operation-summary
    severity: error

API Notes

  • Field and method names use lowercase JavaScript conventions (e.g., getSummary(), not GetSummary())
  • All Go struct fields and methods are automatically exposed to JavaScript
  • Arrays from the Index use JavaScript array methods (.forEach(), .map(), etc.)

License

Apache-2.0