Dev.to WebDev 🛠 Dev 👁 0 📖 4 min read

Sharing an OpenAPI Style Guide Across Teams and Repos

Quick answer: Treat the style guide as a single redocly.yaml kept under version control, then have every repository import that same file instead of carrying its own copy. Start from the built-in recommended ruleset, ove

Quick answer: Treat the style guide as a single redocly.yaml kept under version control, then have every repository import that same file instead of carrying its own copy. Start from the built-in recommended ruleset, override only the rules your organization cares about, and publish the guide as a versioned package so teams pull a known revision rather than whatever was last pasted into a folder.

What a shared style guide actually is

The style guide is not a prose document that sits in a wiki. In Redocly, the working guide is the configuration file itself: the extends list picks a base ruleset, the rules object sets severity and options, and the plugins list pulls in any custom logic. When there is no config file, the CLI falls back to recommended, so adding a file without an explicit base changes behavior; keep extends at the top and treat anything after it as an override.

The same file is read by the CLI, the CI pipeline, and the editor extension, which is why a config in the repo works better than a standards page people have to remember. The rule that fails a build is the same rule an author sees inline while typing, so the feedback does not depend on which tool someone opened.

Build on the bundled rules, not from zero

The CLI ships more than ninety built-in rules covering most structural and security problems, so a maintainable guide changes severity on those first and adds new rules only for organization-specific standards. When you do need a custom check, reach for a configurable rule in YAML before writing a JavaScript plugin. A configurable rule names a subject and asserts on it, which is easy to read in a review.

rules:
  rule/operation-description:
    subject:
      type: Operation
      property: description
    assertions:
      defined: true
      minLength: 30
      pattern: /\.$/
    message: Operation descriptions need at least 30 characters and end with a period.
    severity: warn

Reserve a JavaScript plugin for logic the assertion syntax cannot express. Plugins are imported by a local path relative to the config, not by URL, because they execute code; if you distribute one through npm, reference it through its node_modules path rather than relying on automatic name resolution.

Severity levels and what they do

Setting every rule to error on day one produces a wall of noise that teaches people to ignore the output. Tier the rules so the gate stays meaningful.

Severity Blocks the merge Best used for Example
Error Yes Broken structure and security gaps Missing security scheme
Warn No Style and consistency the team is adopting Short description, tag order
Off No A rule that does not fit a specific surface Relaxed rule on a legacy API

A useful pattern is to introduce a new standard as warn, let the team clean up existing specs, then flip it to error once the baseline is green. That keeps the build honest without freezing work on a pile of inherited violations.

Sharing one file without version drift

Copying the config into every repository looks simple but guarantees drift, as each copy gets edited independently. Put the master file in a dedicated standards repository or publish it as a reusable package, and reference it from extends by path or public URL. Pin the version in each consuming repo. A single unpinned URL means one rule change can turn many pipelines red at once, so teams should upgrade the guide deliberately rather than inheriting every change the moment it lands.

The apis block handles the case where one config governs several surfaces. Point each entry at its own root and override only the rules that differ, so a legacy interface can stay loose while new APIs remain strict without forking the whole guide. For broader context on where these choices fit, see the comparison hub.

Frequently asked questions

Can one config cover both public and internal APIs? Yes. Define separate entries in the apis block with their own rules and decorators, and use the internal entry to strip marked content before publishing the public bundle.

How do I stop teams from just turning rules off? Keep new rules as warnings first, and write a short reason alongside each custom rule. People disable checks they see as arbitrary; a rule with a clear purpose is much more likely to stay on.

Do custom plugins need to be in every repo? They need to be reachable through a local path. Distribute them as dependencies and point the config at the installed location, since the CLI does not resolve plugin names on its own.

The bottom line

A shared style guide works because it has one home and a clear severity plan: extend the built-in rules, express organization checks in YAML, and publish the file as a pinned package that every repo imports. Lint keeps the descriptions consistent, yet it is a static check on the document and cannot confirm how the running service behaves; verifying that behavior takes request-level scenario tests, which is the work Powerduck centers on alongside code review.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.