Translating a specification
This guide is for producing roles: a member of a backend team publishing from the browser, or a pipeline using the API-dex CLI. At the end, a consumer who switches the portal to another language reads your API's titles, summaries and descriptions in that language, and the specification you published stays byte-for-byte unchanged.
How translated specifications work
Translations live outside the specification. You publish one canonical specification as usual, plus one overlay file per language that holds only the translated text. An overlay is a standard OpenAPI Overlay 1.x document: a list of actions, each pointing at a location in the specification with a JSONPath target and supplying the text to update.
API-dex stores the overlays next to the specification and merges the matching one in when a consumer opens the specification. The stored specification is never modified.
- Supported languages:
en-GB,nl-NL,de-DE,fr-FR,es-ES,se-SEandar-SA. - Translate descriptive text only: titles, summaries and descriptions of the API, its tags, operations, parameters, responses and schema properties. Leave paths, operation IDs, parameter names and schema structure untouched, so the documented API always matches the one you published.
- Partial translations are fine. Anything an overlay does not translate keeps its original text. Nothing appears blank.
Write an overlay
One file per language. The example below translates a small pet-store API into Dutch.
overlay: 1.0.0
info:
title: Dutch translation
version: 1.0.0
actions:
- target: $.info
update:
title: Huisdierenwinkel API
description: Nederlandse beschrijving.
- target: $.tags[0]
update:
description: Huisdier bewerkingen
- target: $.paths['/pets'].get
update:
summary: Huisdieren weergeven
description: Geeft alle huisdieren terug.
- target: $.paths['/pets'].get.parameters[0]
update:
description: Hoeveel items te retourneren.
- target: $.paths['/pets'].get.responses['200']
update:
description: Een lijst met huisdieren.
- target: $.components.schemas.Pet.properties.name
update:
description: De naam van het huisdier.API-dex validates each overlay on upload: it must be an object with an overlay version of 1.x, at least one action, and a JSONPath target plus update or remove on every action. JSON and YAML are both accepted.
Publish from the browser
Open Upload spec
Select the environment, open APIs and start an upload. The Upload spec page has four steps: Destination, Specification, Overlays, Review.
Choose the destination and the specification
Pick the product, or the category whose products share the specification, then drop the OpenAPI file.
Attach overlays
In the Overlays step, select Attach overlay for each language you have a file for. The step is optional: without overlays, every portal language shows the same specification. Overlays attached to a category specification apply to every product in that category.
To make translations mandatory for this upload, turn on Require an overlay for every portal language.
Review and publish
The Review step lists the destination, the file and the attached overlays. Select Publish.
WARNING
A new specification version does not inherit the previous version's overlays. When the specification already has translations, the Overlays step lists them and asks you to keep or replace each language. The upload is blocked while a published language would be dropped.
Publish from a pipeline
Declare the overlays in the API-dex CLI manifest, next to the specification they translate:
products:
- name: pets-api
openapi: openapi.yaml
overlays:
- locale: nl-NL
path: overlays/nl-NL.yaml
- locale: de-DE
path: overlays/de-DE.yaml
categories:
- name: payments
openapi: payments.yaml
overlays: # applies to every product inheriting this spec
- locale: nl-NL
path: overlays/payments-nl-NL.yaml
products:
- name: refunds-api
inheritSpec: trueThen run the usual upload:
apidex-cli upload-spec --environment <environment-id> manifest.yamlThe CLI refuses an upload that would silently drop a translation the portal already has for that specification. Declare the overlay in the manifest, or remove the translations first (see below).
To check overlays before uploading, for example in the specification repository's CI:
apidex-cli validate manifest.yaml --require-locales nl-NL,de-DEThis validates every overlay file and fails when a specification lacks an overlay for one of the required languages.
Remove translations
Administrators and CI/CD accounts remove all translations of a specification with the platform API:
DELETE /api/specs/{specId}/overlaysThe specification is served in its original language for every portal language from the next read. To replace a single language instead, upload a new overlay for that language; other languages are left alone.
What consumers see
- The specification renders in the portal language the consumer has selected. Where no overlay exists for that language, API-dex falls back to the same language in another region (
nlservesnl-NL), then to the original text. - Switching the portal language reloads the specification in place.
- Downloading the specification gives the language on screen. Because only descriptive text is translated, the file still describes the same API and works in any OpenAPI tool.
Related topics
- Exposing your API
- Reference: API catalog, including the translation overlay endpoints
- Manage settings, where administrators choose the portal languages