Skip to main content
info fills the info block of the generated document. It is the only required plugin option.
payload.config.ts
info is an OpenAPI Info Object. The plugin copies every field into the spec.
info.title and info.version are required. The plugin throws on boot if either is missing.

Localized description

info.description works like a Payload label. Give a string, an object keyed by language, or a function that gets { t, i18n }. The plugin resolves it against the docs language:
payload.config.ts

Servers

The servers field of the spec tells clients and the “Try it” button which base URL to call. The plugin picks it in this order:
  1. servers as a function. The plugin calls it on every spec request with { req }.
  2. servers as an array.
  3. The request Host header, but only when it is in trustedHosts.
  4. serverURL from your Payload config.
  5. Nothing. The spec has an empty servers list, and clients use the URL they loaded the spec from.
payload.config.ts
A function can choose the servers per request:
payload.config.ts
The document is still cached. Only servers is set per request.

Trusted hosts

The Host header comes from the client, so the plugin does not trust it by default. If it did, anyone could send a fake Host and get a spec that points “Try it” at their own server. To serve one spec under several host names, list them in trustedHosts:
payload.config.ts
A request whose Host is in the list gets that host as its server, with https, or http for localhost and 127.*. Any other host falls back to serverURL. The match ignores case and includes the port. trustedHosts has no effect when servers is set.

Static files

A file on disk has no request. The CLI uses the --server flag, then servers as an array, then serverURL. See Generate.