Each client package is generated from one or more OpenAPI specs. Specs are defined in project.json:
"specs": {
"default": "https://console.redhat.com/api/<service>/v1/openapi.json",
"v2": "https://console.redhat.com/api/<service>/v2/openapi.yaml"
}defaultkey exports endpoints at the package root- Other keys (e.g.,
v2) export to a subdirectory matching the key name - Spec URLs must use
console.redhat.com(notcloud.redhat.com, which returns 404) - Both JSON and YAML specs are supported
- Specs are validated before generation via
openapi-generator-cli validate
OpenAPI Spec (URL or local file)
|
v
openapi-generator-cli validate
|
v
openapi-generator-cli generate (custom Java generator JAR)
|
v
postProcess.sh (sed cleanups: OneOf types, whitespace)
|
v
Generated TypeScript in packages/<client>/src/
The custom generator (typescript-axios-webpack-module-federation) creates one folder per endpoint for webpack tree-shaking. Consumers import individual endpoints:
// Tree-shakeable import (preferred)
import { GetGroup } from '@redhat-cloud-services/rbac-client/GetGroup';
// Full import (pulls everything)
import { GetGroup } from '@redhat-cloud-services/rbac-client';packages/<client>/src/
index.ts # Re-exports all endpoints
api.ts # Pre-configured APIFactory instance
types/index.ts # All model type definitions
GetGroup/index.ts # Per-endpoint module
CreateRole/index.ts
...
Do NOT manually edit files in src/ — they are overwritten on every npm run generate. Changes to generated output must be made in:
- Mustache templates:
src/main/resources/typescript-axios-webpack-module-federation/ - Post-process script:
postProcess.sh - Generator Java source:
src/main/java/.../TypescriptAxiosWebpackModuleFederationGenerator.java
Every client is built in two formats:
| Format | Output Dir | Config | Module |
|---|---|---|---|
| CJS | dist/ |
tsconfig.cjs.json |
CommonJS |
| ESM | dist/esm/ |
tsconfig.esm.json |
ESNext (ES2021 target) |
Package exports use conditional exports:
"exports": {
".": { "types": "./index.d.ts", "import": "./esm/index.js", "default": "./index.js" }
}- Run
npm run create-clientand enter the service name - Add spec URLs to the generated
project.json - Run
npm run generateto createsrc/ - Run
npm run buildto createdist/ - Add integration tests if the service has stable APIs
All clients depend on @redhat-cloud-services/javascript-clients-shared:
APIFactory— creates pre-configured Axios instances- Base interceptors for request/response handling
- Configuration utilities
Changes to shared affect all client packages. Test thoroughly.
The sync-apis.yml GitHub Action runs nightly (or manually) to pull latest specs, regenerate all clients, and open a PR for review. Regenerated code is committed — review diffs for breaking changes.