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.
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
Theservers field of the spec tells clients and the “Try it” button which base URL to call. The plugin picks it in this order:
serversas a function. The plugin calls it on every spec request with{ req }.serversas an array.- The request
Hostheader, but only when it is intrustedHosts. serverURLfrom your Payload config.- Nothing. The spec has an empty
serverslist, and clients use the URL they loaded the spec from.
payload.config.ts
payload.config.ts
servers is set per request.
Trusted hosts
TheHost 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
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.