Build API Clients¶
This guide explains how API clients are automatically generated and compiled within the Hyperledger Cacti ecosystem.
Prerequisites¶
- A working Cacti development environment.
- A successful execution of
yarn configure.
Steps¶
-
Understand the generation process You do not need to perform any manual steps to have the API Client sources generated and compiled. The API client code is automatically generated from the respective
openapi.jsonfile of each package that exposes web services (e.g., REST, SocketIO, gRPC). -
Review the core client package There is a dedicated
@hyperledger-cacti/cactus-api-clientpackage that contains common functionality shared across all API clients. This serves as a foundation, functioning similarly to abstract classes for sub-class implementations. -
Build the backend The generation and compilation process is handled as part of the backend build task. You can trigger this manually or rely on the CI script:
Alternatively, you can run the CI script: -
Verify the generated code Each
openapi.jsonfile produces its own API client via the code generator. These clients include relevant model definitions, such as interfaces describing the request and response bodies for all possible operations, as well as validation constraints.
Expected Outcome¶
API clients are automatically built and compiled, running seamlessly in both browser and NodeJS environments without maintaining separate codebases.