Skip to content

Conversation

@rh-amarin
Copy link
Collaborator

@rh-amarin rh-amarin commented Jan 9, 2026

This PR changes the openapi.yaml definition to avoid errors for go type generators different than the Java official one

e.g. using allOf+base properties for inheritance causes errors for different generators (oapi-codegen, ogen)
microsoft/typespec#826

These generators can read allOf in the openapi.yaml, but not in the form that typespec.io produces it, so the openapi.yaml had to be post-processed. This makes for a worse experience using Typespec, so I opted to remove the use of extends and make the schema definitions more "plain"

The comments above structs was also causing some issues with the generators, they can use them, but create more complex structures in go types code.

Updated version to v1.0.2

Summary by CodeRabbit

Release Notes - Version 1.0.2

  • Chores

    • Bumped API version to 1.0.2
    • Standardized public schemas for consistency
  • New Features

    • Added/standardized global search/pagination parameters for list endpoints
  • Documentation

    • Exposed explicit resource metadata (id, href, kind, labels, name, spec) across resources
    • Clarified pagination fields (kind, page, size, total) and flattened status/condition representations

✏️ Tip: You can customize this high-level summary in your review settings.

@openshift-ci openshift-ci bot requested review from ciaranRoche and jsell-rh January 9, 2026 10:20
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Walkthrough

The PR updates the API specification version from 1.0.1 to 1.0.2 and performs a systematic structural refactoring of data model definitions across TypeSpec and OpenAPI schemas. Model inheritance patterns are converted to composition using spread syntax throughout TypeSpec files. Common models gain generics (List), while OpenAPI schemas are flattened by replacing allOf-based inheritance with explicit field declarations. Pagination metadata is standardized across list schemas. Status and condition representations are reorganized with explicit fields. Changes affect Cluster, NodePool, and AdapterStatus resource definitions and their related request/response and list models.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

lgtm, approved

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: refactoring to adopt oapi-codegen by removing inheritance patterns and simplifying schema definitions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e2460a and 46284c2.

📒 Files selected for processing (6)
  • main.tsp
  • models/clusters/model.tsp
  • models/statuses/model.tsp
  • schemas/core/openapi.yaml
  • schemas/gcp/openapi.yaml
  • schemas/gcp/swagger.yaml
🔇 Additional comments (53)
models/statuses/model.tsp (5)

47-50: LGTM! Correct use of composition pattern.

The change from inheritance (extends ConditionBase) to composition (...ConditionBase) aligns with the PR objective of avoiding allOf patterns that cause issues with oapi-codegen and ogen generators.


57-75: LGTM! ResourceCondition correctly spreads base fields.

The composition pattern properly includes ConditionBase fields while adding the resource-specific fields (observed_generation, created_time, last_updated_time).


125-144: LGTM! AdapterStatus composition is correct.

The spread of AdapterStatusBase combined with additional fields (conditions, created_time, last_report_time) follows the intended pattern.


150-159: LGTM! AdapterStatusCreateRequest composition is correct.

Properly spreads AdapterStatusBase and adds request-specific fields (observed_time, conditions).


165-167: LGTM! Generic List composition.

Using ...List<AdapterStatus> is a clean way to get pagination metadata without explicit field declarations.

schemas/core/openapi.yaml (14)

1-4: LGTM! Version bump to 1.0.2.

Version increment is appropriate for this structural refactoring that may affect generated client code.


427-455: LGTM! AdapterCondition flattened correctly.

The explicit field declarations replace the previous allOf with ConditionBase reference, which resolves compatibility issues with Go code generators.


456-548: LGTM! AdapterStatus schema properly flattened.

All fields from AdapterStatusBase are now explicitly declared. The example is comprehensive and matches the schema structure.


627-680: LGTM! AdapterStatusList with explicit pagination.

The pagination fields (kind, page, size, total) are now explicitly declared instead of referencing a base List schema.


695-783: LGTM! Cluster schema flattened with explicit fields.

All resource metadata fields (id, kind, href, labels, name, spec) are now explicitly declared. The example demonstrates the complete structure.


784-818: LGTM! ClusterCreateRequest with explicit fields.

The schema correctly includes optional fields (id, kind, href, labels) alongside required fields (name, spec).


819-842: LGTM! ClusterList with explicit pagination fields.

Consistent with other List schemas in this PR.


849-859: LGTM! ClusterStatus references ResourcePhase directly.

Replacing allOf with a direct $ref simplifies the schema for code generators.


946-1041: LGTM! NodePool schema flattened with explicit fields.

Consistent approach with the Cluster schema refactoring.


1042-1075: LGTM! NodePoolCreateRequest with explicit fields.


1076-1131: LGTM! NodePoolCreateResponse with explicit fields.


1132-1155: LGTM! NodePoolList with explicit pagination fields.


1162-1172: LGTM! NodePoolStatus references ResourcePhase directly.


1219-1264: LGTM! ResourceCondition with explicit fields.

All fields from ConditionBase are now explicitly declared with their descriptions intact.

main.tsp (1)

22-23: LGTM! Version bump to 1.0.2.

The TypeSpec source version matches the generated OpenAPI version.

models/clusters/model.tsp (4)

5-17: LGTM! ClusterBase uses composition.

The spread syntax ...APIResource replaces inheritance, which will generate flat schemas without allOf.


55-66: LGTM! Cluster model uses composition.

Correctly spreads both ClusterBase and APICreatedResource to compose the full Cluster model.


69-71: LGTM! ClusterCreateRequest uses composition.


73-75: LGTM! ClusterList uses generic List composition.

schemas/gcp/swagger.yaml (15)

18-19: LGTM! Version bump to 1.0.2.

Consistent with other schema files.


30-38: LGTM! SearchParams added to getClusters endpoint.


469-493: LGTM! AdapterCondition with explicit fields.

Swagger 2.0 equivalent of the OpenAPI 3.0 changes.


532-588: LGTM! AdapterStatus with explicit fields.


626-642: LGTM! AdapterStatusList with explicit pagination.


751-790: LGTM! Cluster with explicit fields.


818-844: LGTM! ClusterCreateRequest with explicit fields.


851-867: LGTM! ClusterList with explicit pagination.


964-965: LGTM! ClusterStatus references ResourcePhase directly.


1119-1140: LGTM! NodePool with explicit fields.


1189-1190: LGTM! NodePoolCreateRequest spec reference.


1232-1251: LGTM! NodePoolCreateResponse with explicit fields.


1259-1275: LGTM! NodePoolList with explicit pagination.


1373-1374: LGTM! NodePoolStatus references ResourcePhase directly.


1420-1459: LGTM! ResourceCondition with explicit fields.

schemas/gcp/openapi.yaml (14)

1-4: LGTM! Version bump to 1.0.2.


361-389: LGTM! AdapterCondition with explicit fields.

Consistent with core/openapi.yaml changes.


390-482: LGTM! AdapterStatus with explicit fields.


483-536: LGTM! AdapterStatusList with explicit pagination.


574-681: LGTM! Cluster with explicit fields.


682-735: LGTM! ClusterCreateRequest with explicit fields.


736-759: LGTM! ClusterList with explicit pagination.


816-817: LGTM! ClusterStatus references ResourcePhase directly.


903-1017: LGTM! NodePool with explicit fields.


1018-1070: LGTM! NodePoolCreateRequest with explicit fields.


1071-1126: LGTM! NodePoolCreateResponse with explicit fields.


1127-1150: LGTM! NodePoolList with explicit pagination.


1207-1217: LGTM! NodePoolStatus references ResourcePhase directly.


1271-1316: LGTM! ResourceCondition with explicit fields.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@ciaranRoche ciaranRoche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, just some minor comments

additionalProperties: {}
description: Adapter-specific data (structure varies by adapter type)
description: Base fields shared by AdapterStatus and AdapterStatusCreateRequest
AdapterStatusCreateRequest:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AdapterStatusCreateRequest and ConditionRequest schemas were removed from gcp/openapi.yaml when eliminating the allOf inheritance pattern, but their flattened versions weren't added back.

These schemas exist in core/openapi.yaml (lines 546-628) but are missing from the GCP spec. Since the GCP spec also has the POST /clusters/{cluster_id}/statuses endpoint, it needs these schemas.

Suggested fix: Copy the flattened AdapterStatusCreateRequest and ConditionRequest schemas from core/openapi.yaml to gcp/openapi.yaml.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no POST /clusters/{cluster_id}/statuses endpoint in the GCP contract, since to the final user of the GCP contract, they don't need to POST to statuses, only the adapters do, and for that, they use the core contract.

Or did I misunderstand your comment?

@rafabene
Copy link

Several important documentation comments were removed during the refactoring:

  1. ClusterBase.spec and NodePoolBase.spec - Lost the explanation about CLM not unmarshalling specs
  2. ClusterStatus.phase and NodePoolStatus.phase - Lost the explanation about native database column behavior
  3. ConditionBase.status - Lost the "Condition status" description

These comments provide valuable context about system behavior. Consider preserving them even when changing from extends to spread syntax.

Example fix for spec:

/** Cluster specification - CLM stores and forwards to adapters without unmarshalling */
spec: ClusterSpec;

- adapter
- observed_generation
type: object
AdapterStatusCreateRequest:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as gcp/openapi.yaml - the gcp/swagger.yaml file is also missing the flattened versions of:

  • AdapterStatusCreateRequest
  • ConditionRequest

These schemas were removed when eliminating inheritance but not replaced with their flattened equivalents.

The core/openapi.yaml has these schemas properly flattened, so please ensure consistency across all spec files.

@rh-amarin
Copy link
Collaborator Author

Several important documentation comments were removed during the refactoring:

  1. ClusterBase.spec and NodePoolBase.spec - Lost the explanation about CLM not unmarshalling specs
  2. ClusterStatus.phase and NodePoolStatus.phase - Lost the explanation about native database column behavior
  3. ConditionBase.status - Lost the "Condition status" description

These comments provide valuable context about system behavior. Consider preserving them even when changing from extends to spread syntax.

Example fix for spec:

/** Cluster specification - CLM stores and forwards to adapters without unmarshalling */
spec: ClusterSpec;

I commented to a similar ask from Ciaran, some descriptions introduced some change to the openapi.yaml generated that didn't go well for the generators.

But, in either case, I think we will be revisiting the documentation of our API in later stages, to polish what goes really into the public OpenAPI contract.

e.g. It makes little sense to document anything about a database column in an API spec, or unmarshalling details

Copy link

@ciaranRoche ciaranRoche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Jan 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ciaranRoche

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 21cd118 into openshift-hyperfleet:main Jan 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants