This repository generates the HyperFleet Template OpenAPI specification from TypeSpec definitions. It imports shared models and services from the hyperfleet-api-spec core repository as the hyperfleet npm package, and adds Template-specific models (cluster spec, channels, versions) and their service endpoints.
Build commands:
npm run build # Generate Template OpenAPI 3.0 + Swagger 2.0
./build-schema.sh # Same as npm run buildSwagger UI (GitHub Pages):
index.htmlloadsschemas/template/openapi.yamlvia raw.githubusercontent.com (swagger-ui-dist 5.32.6 from jsDelivr)- Published at https://openshift-hyperfleet.github.io/hyperfleet-api-spec-template/
Validation workflow:
npm install # Install dependencies (includes hyperfleet package)
./build-schema.sh # Build Template OpenAPI 3.0
ls -l schemas/template/openapi.yaml # Confirm output existsTemplate-specific TypeSpec imports shared definitions via the hyperfleet npm package:
// main.tsp
import "hyperfleet/shared/services/clusters.tsp";
import "hyperfleet/shared/services/statuses.tsp";
import "hyperfleet/shared/services/nodepools.tsp";
import "hyperfleet/shared/services/resources.tsp";The hyperfleet package is sourced from the core repo branch/tag in package.json:
"hyperfleet": "github:openshift-hyperfleet/hyperfleet-api-spec#v1.0.18"To use a local core checkout during development, use npm link or a local path:
"hyperfleet": "file:../hyperfleet-api-spec"| Concern | Location |
|---|---|
| Cluster/nodepool/status/resource CRUD routes | Core repo (hyperfleet package) |
TemplateClusterSpec fields |
models/cluster/model.tsp |
| Template nodepool fields | models/nodepool/model.tsp |
| Channels and versions models | models/channel/, models/version/ |
| Channels and versions service endpoints | services/channels.tsp, services/versions.tsp |
| Generated output | schemas/template/openapi.yaml (committed) |
The internal status and force-delete endpoints come from the core shared contract. This repo generates the public Template API contract only (no internal adapter endpoints).
Imports first, namespace second:
import "@typespec/http";
import "hyperfleet/shared/models/common/model.tsp";
import "../models/cluster/model.tsp";
namespace HyperFleet;Model naming:
- Template resources:
TemplateClusterSpec,ReleaseSpec,ChannelSpec,VersionSpec - Lists:
ChannelList,VersionList - Requests:
ChannelCreateRequest,ChannelPatchRequest
models/{resource}/
├── model.tsp # Model definitions
├── example_{resource}.tsp # GET example constant
├── example_post.tsp # POST example constant
└── example_patch.tsp # PATCH example constant
services/
└── {resource}.tsp # Service endpoints
DO NOT:
- Modify generated files in
schemas/ortsp-output-template/directly - Add shared/core models here — they belong in the core repo's
shared/directory - Commit
node_modules/or build artifacts
DO:
- Run
./build-schema.shand commitschemas/template/openapi.yamlwith your changes - Run
./build-schema.sh --swaggerand commitschemas/template/swagger.yamlwhen releasing - Keep TypeSpec files focused (one resource per service file)
- Update
package.jsonto pin a new core version when consuming new shared models
// models/cluster/model.tsp
model ReleaseSpec {
// ... existing fields ...
newField?: string;
}Rebuild: npm run build
// services/channels.tsp
namespace HyperFleet;
@route("/channels")
interface Channels {
// ... existing endpoints ...
@get
@route("/{id}/summary")
getSummary(@path id: string): ChannelSummary | Error;
}Rebuild: npm run build
- Create model:
// models/policy/model.tsp
import "@typespec/http";
import "hyperfleet/shared/models/common/model.tsp";
namespace HyperFleet;
model PolicySpec {
rules: string[];
}- Create service:
// services/policies.tsp
import "@typespec/http";
import "@typespec/openapi";
import "hyperfleet/shared/models/common/model.tsp";
import "../models/policy/model.tsp";
namespace HyperFleet;
@route("/policies")
interface Policies {
@get list(): PolicySpec[] | Error;
}- Import both in
main.tsp:
import "./models/policy/model.tsp";
import "./services/policies.tsp";- Build:
npm run build
- Edit
package.json:
"hyperfleet": "github:openshift-hyperfleet/hyperfleet-api-spec#v1.0.19"- Reinstall and rebuild:
npm install
npm run buildWhen bumping the version in main.tsp, always update CHANGELOG.md:
- Keep
## [Unreleased]at the top, then add a new version section as## [X.Y.Z] - YYYY-MM-DD - List changes under appropriate headings (
Added,Changed,Fixed,Removed) - Update the comparison links at the bottom of the file
- Follow Keep a Changelog format
Before submitting changes:
- Dependencies installed:
npm install - Template schema builds:
./build-schema.sh - Template Swagger builds:
./build-schema.sh --swagger - Schema files generated:
ls schemas/template/openapi.yaml schemas/template/swagger.yaml - No TypeSpec compilation errors (check output)
- Schema passes linting:
spectral lint schemas/template/openapi.yaml - Changes committed including schema updates
- PR description references related issue
The build-schema.sh script:
- Runs
node_modules/.bin/tsp compile main.tsp --output-dir tsp-output-template - Moves output to
schemas/template/openapi.yaml - (Optional with
--swagger) Converts to OpenAPI 2.0 viaapi-spec-converter→schemas/template/swagger.yaml
Output locations:
- TypeSpec temp:
tsp-output-template/schema/openapi.yaml(auto-deleted) - Final:
schemas/template/openapi.yamlandschemas/template/swagger.yaml(committed)
Releases are fully automated via GitHub Actions (.github/workflows/release.yml).
On every push to main, the release workflow:
- Extracts the version from the
@infodecorator inmain.tsp - Skips if a tag for that version already exists
- Builds both schema formats (
openapi.yamlandswagger.yaml) - Creates an annotated Git tag (
vX.Y.Z) - Publishes a GitHub Release with
template-openapi.yamlandtemplate-swagger.yamlattached
The CI workflow enforces that the version in main.tsp is bumped from the latest release tag before a PR can be merged.
To release a new version, bump the version in main.tsp and merge to main.
- Core spec repo: https://github.com/openshift-hyperfleet/hyperfleet-api-spec
- Architecture repo: https://github.com/openshift-hyperfleet/architecture
- Main API implementation: https://github.com/openshift-hyperfleet/hyperfleet-api