This repository contains the OpenAPI specification for the Approvio backend, the tooling to generate the TypeScript API client, and TypeScript validators for the generated models using fp-ts.
openapi.yaml: Main entry point for the OpenAPI 3.0 specification.openapi/: Directory containing split OpenAPI specification files referenced by the mainopenapi.yaml.src/: Source code directory.src/validators/: TypeScript validators for the generated OpenAPI models usingfp-ts/Either.src/utils/: Utility functions, including custom Jest matchers for testing validators.
test/: Test directory containing unit tests for the validators.generated/: Auto-generated output directory containing the TypeScript API client models and code.
-
Install Dependencies:
yarn install
-
Generate API Client:
This command will generate the TypeScript API client in the
generated/openapidirectory.yarn generate:api
The generated API client can be consumed by other TypeScript/JavaScript projects.
To lint the openapi.yaml file and check for adherence to best practices and defined rules:
yarn lint:apiTo link this package for local development in another project (e.g., approvio-frontend):
-
Navigate to your consuming project (e.g.,
approvio-frontend):cd ../approvio-frontend -
Link the
approvio-apipackage:yarn link "<path-to-approvio-api>"
Now, your consuming project will use the locally linked version of @approvio/api.
This package is automatically published to NPM when the version in package.json is incremented and merged into the main branch.
The GitHub Workflow performs the following steps:
- Detects changes in the
mainbranch. - Compares the version in
package.jsonwith the latest version published on NPM. - If the version is newer, it builds the project and publishes it automatically.
If you need to publish manually:
- Ensure you are logged in to NPM:
npm login - Run the publish command:
npm publish --access public