-
Notifications
You must be signed in to change notification settings - Fork 21
HYPERFLEET-1033 - feat: consume OpenAPI schemas from hyperfleet-api-spec Go module #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 2 commits into
openshift-hyperfleet:main
from
mliptak0:HYPERFLEET-1033
May 15, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,17 @@ | ||
| # Claude Code Guidelines for OpenAPI | ||
|
|
||
| ## Two openapi.yaml Files | ||
| See [README.md](README.md) for the full reference on how schemas are imported, generated, and used for validation. | ||
|
|
||
| 1. **Source**: `openapi.yaml` in this directory (32KB, uses `$ref`) — generated by TypeSpec from a separate `hyperfleet-api-spec` repo. This is the source of truth for this repository. | ||
| 2. **Generated**: `pkg/api/openapi/api/openapi.yaml` (44KB, fully resolved) — produced by `make generate`, embedded in binary via `//go:embed` | ||
| ## Key Rules | ||
|
|
||
| **Never edit either file directly.** The source comes from TypeSpec; the generated one is overwritten by `make generate`. | ||
| - **Never edit** `openapi.yaml` or `pkg/api/openapi/openapi.gen.go` — both are overwritten by `make generate`. | ||
| - **Never copy** the spec file manually — `make generate` extracts it from the Go module cache automatically. | ||
| - **To change the schema**, update TypeSpec in `hyperfleet-api-spec`, publish a new release, bump the version in `go.mod`, then run `make generate-all`. | ||
|
|
||
| ## Code Generation | ||
| ## Quick Commands | ||
|
|
||
| Tool: **oapi-codegen** (not openapi-generator-cli) | ||
| Config: `oapi-codegen.yaml` in this directory | ||
|
|
||
| ``` | ||
| make generate # Regenerates pkg/api/openapi/ from openapi/openapi.yaml | ||
| make generate-all # generate + generate-mocks | ||
| ```shell | ||
| make generate # Extract schema from spec module, then run oapi-codegen | ||
| make generate-mocks # Regenerate mock implementations | ||
| make generate-all # Both of the above | ||
| ``` | ||
|
|
||
| Generation produces: | ||
| - `pkg/api/openapi/openapi.gen.go` — Go model structs + client + embedded spec | ||
|
|
||
| ## Config Details | ||
|
|
||
| From `oapi-codegen.yaml`: | ||
| - Package: `openapi` | ||
| - Output: `pkg/api/openapi/openapi.gen.go` | ||
| - Generates: models (yes), chi-server (no), client (yes), embedded-spec (yes) | ||
| - Compatibility: `old-merge-schemas: true` (inlines allOf), `old-aliasing: true` (type defs not aliases) | ||
|
|
||
| ## Updating the API | ||
|
|
||
| 1. Update TypeSpec definitions in `hyperfleet-api-spec` repo | ||
| 2. Copy generated `openapi.yaml` to this directory | ||
| 3. Run `make generate-all` | ||
| 4. Update handlers/services/DAOs for any new or changed fields |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed you added embed.FS in schemas/schemas.go in the spec repo, but here we're copying via go list -m + cp instead of reading through it. The ticket also mentions hack/extract-schema.go reading from specschemas. Did something change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update the Jira ticket, good point