Support a new language
This repository leverages openapi-generator to generate API clients.
See the Setup repository guide to
setup the repository tooling
.
If not done already, install openapi-generator
Find a template to start withβ
Provided templates should be a good starting point to generate a client but make sure to implement the Algolia requirements to make it work properly.
You can pick a default template on the openapi-generator's "generators" page
Extract the template locallyβ
openapi-generator author template -g <YOUR_TEMPLATE_NAME> -o templates/<YOUR_API_CLIENT_NAME>
Example for the JavaScript client with the typescript-node
template:
openapi-generator author template -g typescript-node -o templates/javascript/
Update the generator configβ
Add each client in the file openapitools.json
, following the others client structure.
See
add a new client
for informations regarding this file
Algolia requirementsβ
Strip codeβ
The generator includes a lot of features that won't be used with the Algolia engine:
- Multiple authentication methods:
appId
/apiKey
are the only authentication methods, located in the requests headers. - Built-in transporters: A retry strategy is required to target the DSNs of an
appId
, along with other transporter details listed below. - File support, payload format etc.: Requests only require
JSON
support to communicate with the engine.
DX is key, make sure to provide a linter and formatting tools, with consistent method usage based on the language.
Init methodβ
By default, OpenAPI will put the AppId
and ApiKey
in every method parameters, but the clients to be initialized with those values and put them in the header of every requests, with the right hosts.
The constructor of the client can be edited (from the .mustache
files) to accept and store those values.
Retry strategyβ
The retry strategy cannot be generated and needs to be implemented outside of the generated client folder. You can achieve this by creating a utils
(or any naming that you find relevant) folder and add a transporter and retry strategy logic to it.
Different client hostsβ
Some Algolia clients (search and recommend) targets the default appId host (${appId}-dsn.algolia.net
, ${appId}.algolia.net
, etc.), while clients like personalization
have their own regional host
(eu
| us
| de
).
As the generator does not support reading servers
in a spec file, hosts methods and variables are extracted with a custom script and create variables for you to use in the mustache templates, read more here.
Requestersβ
TODO: informations
Loggerβ
TODO: informations
DXβ
We require the generated API clients to have an up-to-date usage with their ecosystem, make sure to provide correct tooling to lint and format generated code.