Quick answer: A Redocly custom decorator is JavaScript you ship in a local plugin to change an OpenAPI description while it bundles. The OpenAPI file itself stays open and portable, so the format does not lock you in; the lock-in sits in the plugin's visitor interface and the config that grows around it. Keep decorators thin, lean on standard Overlays where you can, and keep your source readable without them.

What a custom decorator actually is

Redocly walks a document with the visitor pattern. A plugin is a JavaScript module that can export rules, preprocessors, and decorators, and each visitor key matches a node type you confirm with redocly inspect-node-types. A rule calls report and leaves the document alone. A decorator mutates the node it visits, so the change shows up in the bundled output rather than as a lint message.

Plugins load only by a local relative path. Importing one from a URL is not supported, which keeps arbitrary code from running during a build, and it also means the plugin source lives in your own repository, not in a hosted account. You turn a decorator on in redocly.yaml under the plugin id, with options if it accepts them:

plugins:
  - ./plugins/tag-sorting.js
decorators:
  tag-sorting/alphabetical: on

Rules, decorators, and Overlays do different jobs

Tool Changes the document Format Pick it when
Rule No, reports a problem YAML or plugin JS Enforcing a standard
Built-in decorator Yes, at bundle time Config in YAML Common transforms such as remove-x-internal
Custom decorator Yes, with your own logic Plugin JS A transform no built-in or Overlay can express
Overlay Yes, before decorators run Standard Overlay file Targeted updates a spec already defines

Overlays apply first, and a decorator sees the result. A common pair marks operations with x-internal in an Overlay and then lets the built-in remove-x-internal decorator drop them from the public bundle.

Where the lock-in really lives

The OpenAPI description is a standard format any tool can parse, so the data is not the trap. The coupling is in the code that touches Redocly's type tree. A decorator depends on the visitor hooks, the node types inspect-node-types reports, and the way the plugin is wired in redocly.yaml. Those are Redocly's extension points, not part of the OpenAPI standard, and a plugin written against them will not run unchanged in another tool.

That is a narrower risk than a hosted database, but it is real. The more a build depends on custom decorators to produce a correct result, the more work a move becomes. A clean source that reads correctly on its own is what a different workspace, including Powerduck, can open without running any plugin.

Keeping the exit door open

A few habits keep the coupling shallow. Reach for a standard Overlay before writing JavaScript, since Overlays follow a cross-tool specification and survive a tool change. When a transform genuinely needs code, put the logic in a plain function that takes a plain JavaScript object and returns one, with no Redocly types in its signature. The decorator then stays a thin adapter that the visitor calls, and a future tool only needs a new adapter over the same logic.

Keep every transform in the bundle layer rather than baking it into the source, so the checked-in OpenAPI stays valid on its own. Commit the plugins and config alongside the spec instead of leaving the setup in a hosted state. The broader trade-offs behind these choices sit in the comparison hub.

Frequently asked questions

Does writing custom decorators lock me into Redocly? The OpenAPI data stays open, but the plugin interface is coupling. Decorators written against Redocly node types do not run in another tool without a rewrite, so keep them thin and isolate the logic.

Should I use an Overlay or a custom decorator? Use an Overlay for targeted updates it can express, because it is a standard format. Use a custom decorator only for logic an Overlay cannot carry, such as a transform computed across many nodes.

What is the difference between a rule and a decorator? A rule reports a problem and leaves the document unchanged. A decorator mutates the node and changes the bundled output.

Where should the plugin code live? In your own repository, referenced by a local relative path in redocly.yaml. URL imports are not supported, and version-controlling the plugin keeps the build reproducible.

The bottom line

OpenAPI gives you portable data; the extension layer is where you choose how much to couple. Treat custom decorators as a last resort behind Overlays and built-ins, keep the source correct without them, and push real logic into tool-agnostic functions with thin visitors on top. The team that skips that discipline does not get trapped by its API files; it gets trapped by the transforms it can no longer run anywhere else.