OrbitDocs packages are coming to npm soon. Until then, run it from the GitHub repo →
SDKs, mock & lint

Lint your spec

Run Spectral's OpenAPI rules or your own ruleset on every extracted spec, and choose which severity fails the command.

orbitdocs lint runs Spectral on the specs OrbitDocs extracted. It finds problems that make docs, SDKs and the mock worse: missing operation ids, undefined tags, invalid examples, broken references. Without a ruleset of your own, it uses Spectral's recommended OpenAPI rules.

Run it

npx orbitdocs extract
npx orbitdocs lint
npx orbitdocs lint --api travel
  warn  travel paths./v1/flights.get  Operation must have non-empty "tags" array. operation-tags
  warn  travel info  Info object must have "contact" object. info-contact
✓ Lint: 0 error, 2 warn, 0 info, 0 hint

Each line shows the severity, the API, the path in the spec, the message and the rule. The command exits with code 1 when a problem at or above failOn is found.

FlagDefault
--api <id>every APILint one API.

orbitdocs lint reads openapi/<api>.json and doesn't extract. An API without a spec is skipped with a warning.

Choose what fails

orbitdocs.config.ts
import { defineConfig } from '@orbitdocs/next/config';

export default defineConfig({
  site: { title: 'Acme' },
  lint: { failOn: 'warn' },
});
failOnFails on
error (default)errors
warnerrors and warnings
infoerrors, warnings and info
hintany problem

Use your own ruleset

Point lint.ruleset at a Spectral ruleset file, relative to the docs app. It replaces the built-in rules, so extend Spectral's OpenAPI rules to keep them:

.spectral.yaml
extends: [[spectral:oas, recommended]]

rules:
  # Nest apps often skip these:
  info-contact: off
  operation-tags: warn

  # Every operation needs a description.
  operation-description: error

  # Paths use kebab-case.
  paths-kebab-case:
    description: Path segments are kebab-case.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: "^(/([a-z0-9-]+|\\{[a-zA-Z0-9]+\\}))+$"
orbitdocs.config.ts
lint: { ruleset: '.spectral.yaml', failOn: 'warn' },

Rulesets can extend other files and URLs, like any Spectral ruleset. If the file doesn't exist, the command fails with lint.ruleset: <path> not found.

Lint in CI

.github/workflows/docs.yml
      - run: npx orbitdocs extract
        working-directory: docs
      - run: npx orbitdocs lint
        working-directory: docs

The self-hosted platform can lint every spec revision too. See Spec registry.

Options

Prop

Type

Lint and completeness are different checks

Lint checks the spec against OpenAPI style rules. Completeness checks that each operation has the descriptions, examples and typed responses good docs need, and runs during orbitdocs extract and build.

Next steps

Last updated on

On this page