Automatic generation of multilingual documentation from an OpenAPI specification using VitePress
This project is a fork and derivative of vitepress-openapi by Enzo Notario.
We extend our gratitude to the original author and contributors for their excellent work. This project builds upon their foundation with additional features including multilingual support, enhanced documentation generation, and custom integrations.
Original Project: vitepress-openapi
Original Author: Enzo Notario
Note on Package Naming: This project uses the package
@dv.net/docs-vitepress-openapias a dependency, which is a modified version of the originalvitepress-openapipackage. We acknowledge that the naming similarity may cause confusion, and we are committed to maintaining clear attribution and distinction from the original project.
1๏ธโฃ Install dependencies
npm install2๏ธโฃ Prepare the OpenAPI specification
Place the openapi.json file into the scripts/ folder.
โ ๏ธ Important: The format must be OpenAPI 3.0.1๐ก To convert Swagger to OpenAPI use Swagger Editor
3๏ธโฃ Generate English translations
npm run docs:genTranslationRun this command when adding new endpoints or when changing names/descriptions.
4๏ธโฃ Translate section titles
Open and translate the titles in src/{locale}/t.json files for the required languages.
5๏ธโฃ Generate the documentation
npm run docs:genDoc6๏ธโฃ Build the project
npm run build7๏ธโฃ Run the dev server
npm run dev- ๐ฌ๐ง English (en)
- ๐ท๐บ Russian (ru)
- ๐ฉ๐ช Deutsch (de)
- ๐ช๐ธ Espaรฑol (es)
- ๐จ๐ณ ไธญๆ (zh)
- ๐ฐ๐ท ํ๊ตญ์ด (ko)
- ๐ฎ๐ณ เคนเคฟเคจเฅเคฆเฅ (hi)
- ๐ธ๐ฆ ุงูุนุฑุจูุฉ (ar)
1๏ธโฃ Register the language
Add the new language to scripts/regions.json:
{ "locale": "fr", "name": "Franรงais", "flag": "๐ซ๐ท" }2๏ธโฃ Generate translations
Repeat steps 3โ6 from the Quick Start section.
3๏ธโฃ Update mappings
Add the language configuration to .vitepress/mappers.ts.
4๏ธโฃ Translate UI elements
Add button translations to scripts/buttonText.ts.
5๏ธโฃ Create textual documentation
Add translated pages to the src/{lang}/ folder:
- ๐
installation/- Installation instructions - ๐
integration/- Integration guides - ๐
operations/- Operations description
Translate texts in the following files:
src/{lang}/titles.json- Section titlessrc/{lang}/defaultTranslate.json- Common translations
1๏ธโฃ Create a .env file on the server
Copy the template from .env.example:
cp .env.example .env2๏ธโฃ Fill in the environment variables
env VITE_GA_ID=G-XXXXXXXXXX
โน๏ธ Note: Analytics only works in production mode
| Command | Description |
|---|---|
npm run dev |
๐ฅ Start the dev server with hot reload |
npm run build |
๐ฆ Build the production version |
npm run docs:genTranslation |
๐ค Generate English translations from OpenAPI |
npm run docs:genDoc |
๐ Generate documentation for all languages |
npm run preview |
๐๏ธ Preview the production build |
This project is licensed under the MIT License - see the LICENSE file for details.
This project is a derivative work based on vitepress-openapi, which is also licensed under the MIT License. The original copyright notice and license terms are preserved in the LICENSE file.