Having useful documentation is important. But let’s face it: writing documentation isn’t exactly a developer’s favorite activity. It is often time-consuming and tedious process involving manual updates across different formats or platforms. This can lead to:
Can we do better then ? I think we can:
The key to good documentation is generate it based on schema or code, with the former way having more advantages in the long run.
Customization. API documentation is usually a part of bigger developer portals, which includes human-written guides, tutorials and examples of usage. Therefore, the documentation must allow either easy embedding itself to a larger portal, or easy embedding additional content to itself.
Usability. Many documentation generators fall short by omitting essential features that developers rely on for efficient API interaction. These missing elements include:
API Genie supports multi-language documentation out of the box. Here’s a step-by-step guide on how to generate one:
Run the apigenie i18n
Command: First, you’ll need to extract all translatable
text strings from your OpenAPI schema. Open a terminal window and navigate to
your project directory where the OpenAPI schema resides. Then, execute the
following command:
apigenie i18n my-openapi-schema.yaml -o translations.pl.json
The apigenie i18n
command will generate a JSON or YAML file containing all
the text elements identified for translation. This file uses a specific format,
where each key is a JSON Pointer referencing the specific location of the text
string within your OpenAPI schema. The corresponding value is the original text
that needs to be translated.
{
"$/paths/users/get/summary": "Get User Details",
"$/paths/users~1{userId}/get/summary": "Get User by ID",
// ... more key-value pairs ...
}
Each translator will receive the translations.json file and replace the original values (e.g., “Get User Details”) with their translated equivalents in their respective language.
Generate Documentation with Language Files: Now, when generating your
API documentation with API Genie, you can specify these translated files.
Use the apigenie generate doc html command with the --i18n
flag to include
them:
apigenie generate doc html --i18n en=translations_en.json --i18n fr=translations_fr.json
In this example, en
and fr
represent the language identifiers for English
and French, respectively. You can specify multiple languages with additional
--i18n
flags.
By following these steps, API Genie will generate your API documentation in the specified languages, making it accessible to a wider developer audience.