This project hosts the TypeSpec files to generate the HyperFleet OpenAPI specifications. The repository is organized to support multiple service variants (core, GCP, etc.) while sharing common models and interfaces.
Access directly to the latest generated contract:
- core: https://openshift-hyperfleet.github.io/hyperfleet-api-spec/
- GCP: https://openshift-hyperfleet.github.io/hyperfleet-api-spec/gcp.html
The repository is organized with root-level configuration files and three main directories:
main.tsp- Main TypeSpec entry point that imports all service definitionsaliases.tsp- Provider alias configuration file (re-linked to switch between providers)aliases-core.tsp- Core provider aliases (definesClusterSpecasCoreClusterSpecwhich isRecord<unknown>)aliases-gcp.tsp- GCP provider aliases (definesClusterSpecasGCPClusterSpec)tspconfig.yaml- TypeSpec compiler configuration
Contains shared models used by all service variants:
models/clusters/- Cluster resource definitions (interfaces and base models)models/statuses/- Status resource definitions for clusters and nodepoolsmodels/nodepools/- NodePool resource definitionsmodels/compatibility/- Compatibility endpointsmodels/common/- Common models and types (APIResource, Error, QueryParams, etc.)
Contains core provider-specific model definitions:
models-core/cluster/model.tsp- DefinesCoreClusterSpecasRecord<unknown>(generic)
Contains GCP provider-specific model definitions:
models-gcp/cluster/model.tsp- DefinesGCPClusterSpecwith GCP-specific properties
Contains service definitions that generate the OpenAPI specifications:
services/clusters.tsp- Cluster resource endpointsservices/statuses.tsp- Status resource endpointsservices/nodepools.tsp- NodePool resource endpointsservices/compatibility.tsp- Compatibility endpoints
The repository uses a single main.tsp entry point. To generate either the core API or GCP API, you need to re-link the aliases.tsp file to point to the desired provider aliases file.
The easiest way to build the OpenAPI schema is using the provided build-schema.sh script:
# Build Core API
./build-schema.sh core
# Build GCP API
./build-schema.sh gcpThe script automatically:
- Validates the provider parameter
- Re-links
aliases.tspto the appropriate provider aliases file - Compiles the TypeSpec to generate the OpenAPI schema
- Outputs the result to
schemas/{provider}/openapi.yaml(e.g.,schemas/core/openapi.yamlorschemas/gcp/openapi.yaml)
Extending to new providers: Simply create aliases-{provider}.tsp and the script will automatically detect and support it.
If you prefer to build manually:
-
Re-link
aliases.tsptoaliases-core.tsp:ln -sf aliases-core.tsp aliases.tsp
-
Compile the TypeSpec:
tsp compile main.tsp
Output:
tsp-output/schema/openapi.yaml
-
Re-link
aliases.tsptoaliases-gcp.tsp:ln -sf aliases-gcp.tsp aliases.tsp
-
Compile the TypeSpec:
tsp compile main.tsp
Output:
tsp-output/schema/openapi.yaml
Note: The aliases.tsp file controls which provider-specific ClusterSpec definition is used throughout the service definitions. By re-linking it to either aliases-core.tsp or aliases-gcp.tsp, you switch between the generic Record<unknown> spec and the GCP-specific GCPClusterSpec.
The HyperFleet API provides simple CRUD operations for managing cluster resources and their status history:
- Simple CRUD only: No business logic, no event creation
- Sentinel operator: Handles all orchestration logic
- Adapters: Handle the specifics of managing provider-specific specs
To add a new provider (e.g., AWS):
-
Create provider model directory:
models-aws/cluster/model.tspmodel AWSClusterSpec { awsProperty1: string; awsProperty2: string; }
-
Create provider aliases file:
aliases-aws.tspimport "./models-aws/cluster/model.tsp"; alias ClusterSpec = AWSClusterSpec;
-
To generate the AWS API, re-link
aliases.tsp:ln -sf aliases-aws.tsp aliases.tsp tsp compile main.tsp
To add a new service (e.g., with additional endpoints):
-
Create a new service file:
services/new-service.tspimport "@typespec/http"; import "@typespec/openapi"; import "../models/common/model.tsp"; // ... other imports as needed namespace HyperFleet; @route("/new-resource") interface NewService { // ... endpoint definitions }
-
Import the new service in
main.tsp:import "./services/new-service.tsp";
@typespec/compiler- TypeSpec compiler@typespec/http- HTTP protocol support@typespec/openapi- OpenAPI decorators@typespec/openapi3- OpenAPI 3.0 emitter
The repository works with different contracts (core and GCP) but a single Typespec main.tsp.
This is accomplished by maintaining an aliases.tsp file that holds the "active" concrete types to use (core or GCP).
- When working on the core API, the
aliases.tsppoints toaliases-core.tsp - When working on the GCP API, the
aliases.tsppoints toaliases-gcp.tsp
The downside of this is that it confuses the Typespec extension:
- For the "non-active" type files, the plugin may show errors as not defined types
- Since we duplicate aliases, the plugin may display an error of a type being duplicated
But, both the build-schema.sh script using the tsp CLI command as the plugin option to "Emit from Typespec" work fine.