Translations
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
'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
return [
'books' => ['store' => [
'summary' => 'Add a book.',
'description' => 'The price is in euros.',
]],
'tags' => ['books' => 'Books'],
];
return [
'books' => ['store' => [
'summary' => 'Ajouter un livre.',
'description' => 'Le prix est en euros.',
]],
'tags' => ['books' => 'Livres'],
];
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:
// 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.