Documents

Translations

Generate one document per language, with summaries, descriptions and tags written as translation keys.

With languages, each document is generated once per locale. The summaries, the descriptions and the tags of the operations may be translation keys of your application: each document has them in its language.

Configure the languages

config/openapi.php
'languages' => ['en', 'fr'],

Empty (the default), there is one document per entry of documents, in the locale of the application.

Write translation keys

Use a key where you would write the text: in the PHPDoc, in #[Operation] or in #[Tag].

/**
 * docs.books.store.summary
 *
 * docs.books.store.description
 */
#[Tag('docs.tags.books')]
public function store(StoreBookRequest $request): BookResource

A text that is not a key, or a key without translation in a locale, is written as it is. The name of a tag is translated; the description of #[Tag] is not.

File names

{locale} in output.file places the language in the file name:

config/openapi.php
// openapi/v1.en.json, openapi/v1.fr.json
'output' => ['file' => '{document}.{locale}.json'],

Without {locale}, the locale is added before the extension: openapi-v1.json becomes openapi-v1.en.json and openapi-v1.fr.json.

Commands

openapi:generate writes every document in every language. --stdout needs a single document and a single language.