Repository navigation
chore(api): add aip schema bundle - #3646
Conversation
📝 WalkthroughWalkthroughReplaces AIP-focused spec workflow with a v3 OpenAPI pipeline: linting now covers multiple spec files, adds a v3 bundling step, updates TypeSpec routes/auth, adjusts package.json exports/scripts to v3, and introduces oapi-codegen config plus generated Go bindings for the v3 API. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
api/spec/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlapi/v3/openapi.yamlis excluded by!**/openapi.yamlgo.modis excluded by!**/*.modgo.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (8)
Makefile(1 hunks)api/spec/Makefile(1 hunks)api/spec/package.json(2 hunks)api/spec/src/v3/konnect.tsp(2 hunks)api/spec/src/v3/openmeter.tsp(1 hunks)api/v3/api.gen.go(1 hunks)api/v3/api.go(1 hunks)api/v3/codegen.yaml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.tsp
⚙️ CodeRabbit configuration file
**/*.tsp: Review the TypeSpec code for conformity with TypeSpec best practices. When recommending changes also consider the fact that multiple codegeneration toolchains depend on the TypeSpec code, each of which have their idiosyncrasies and bugs.The declared API should be accurate, in parity with the actual implementation, and easy to understand for the user.
Files:
api/spec/src/v3/openmeter.tspapi/spec/src/v3/konnect.tsp
**/*.go
⚙️ CodeRabbit configuration file
**/*.go: In general when reviewing the Golang code make readability and maintainability a priority, even potentially suggest restructuring the code to improve them.Performance should be a priority in critical code paths. Anything related to event ingestion, message processing, database operations (regardless of database) should be vetted for potential performance bottlenecks.
Files:
api/v3/api.goapi/v3/api.gen.go
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: openmeterio/openmeter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T15:10:24.409Z
Learning: Generate API clients and OpenAPI spec via `make gen-api` from TypeSpec definitions
📚 Learning: 2025-11-25T15:10:24.409Z
Learnt from: CR
Repo: openmeterio/openmeter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T15:10:24.409Z
Learning: Use Makefile commands for common development tasks like running tests, generating code, and linting
Applied to files:
Makefileapi/spec/Makefile
📚 Learning: 2025-11-25T15:10:24.409Z
Learnt from: CR
Repo: openmeterio/openmeter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T15:10:24.409Z
Learning: Generate API clients and OpenAPI spec via `make gen-api` from TypeSpec definitions
Applied to files:
api/spec/Makefile
📚 Learning: 2025-11-25T15:10:24.409Z
Learnt from: CR
Repo: openmeterio/openmeter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T15:10:24.409Z
Learning: Never manually edit generated directories including `api/client` (generated from TypeSpec), `api/openapi.yaml`, `**/ent/db` (generated from ent schema), `**/wire_gen.go` (generated from wire.go), and `tools/migrate/migrations` (generated migrations)
Applied to files:
api/v3/api.goapi/v3/codegen.yamlapi/v3/api.gen.go
📚 Learning: 2025-11-25T15:10:24.409Z
Learnt from: CR
Repo: openmeterio/openmeter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T15:10:24.409Z
Learning: Generate Go code via `make generate` to produce database access code from ent schema and dependency injection wire code
Applied to files:
api/v3/codegen.yaml
📚 Learning: 2025-03-07T12:17:43.129Z
Learnt from: GAlexIHU
Repo: openmeterio/openmeter PR: 2383
File: openmeter/entitlement/metered/lateevents_test.go:37-45
Timestamp: 2025-03-07T12:17:43.129Z
Learning: In the OpenMeter codebase, test files like `openmeter/entitlement/metered/lateevents_test.go` may use variables like `meterSlug` and `namespace` without explicit declarations visible in the same file. This appears to be an accepted pattern in their test structure.
Applied to files:
api/v3/api.gen.go
🪛 GitHub Actions: CI
api/spec/src/v3/konnect.tsp
[error] 1-1: Prettier formatting check failed. Run 'prettier --write' to fix code style issues in this file.
🔇 Additional comments (6)
Makefile (1)
171-175: Nice: v3 OpenAPI added to lint coverageIncluding
api/v3/openapi.yamlinspectral lintkeeps the new bundled spec under the same quality gate as the existing ones. No issues from my side.api/spec/package.json (1)
5-17: V3 compile/bundle wiring looks consistent; just sanity‑check the bundle pathThe updated
compilepipeline (openapi → v3 → client), newcompile:v3,bundle:v3, and the./v3export all line up with the new v3 workflow and the api/spec Makefile. Thepnpm run bundle:v3 -o ../v3/openapi.yamlcall should correctly pass the extra-oto theopenapiCLI.Might be worth a quick local run of:
pnpm compilepnpm run bundle:v3 -o ../v3/openapi.yamlto confirm the entrypoint path and output match what
api/v3/api.goexpects.Also applies to: 23-25, 27-38
api/spec/Makefile (1)
3-10: Good call adding v3 bundling to the spec generate flowThe extra
pnpm run bundle:v3 -o ../v3/openapi.yamlstep neatly connects the TypeSpec compile to the v3 OpenAPI bundle thatapi/v3consumes, without changing the existing cloud / classic outputs.Looks solid to me.
api/spec/src/v3/openmeter.tsp (1)
24-35: Route change to/metering/eventslooks consistent with v3 serverSwitching the
MeteringEventsEndpointsroute to/metering/eventsmatches the v3 server wiring (chi route uses/metering/events) and keeps it aligned across TypeSpec and generated Go.Just make sure any existing v3 consumers (if any) are aware of the path tweak, since it’s not backward compatible with
/metering-events.api/v3/codegen.yaml (1)
1-16: Codegen config lines up with the generated v3 serverThe config (chi server + models + embedded spec,
package: v3,output: ./api.gen.go, nullable types, etc.) matches what’s inapi.gen.goand should be a solid baseline for the v3 surface.After any future spec changes, just remember to re-run the generator via the
go:generatehook / your usual pipeline soapi.gen.gostays in sync.api/v3/api.gen.go (1)
1-726: Treat this as generated code; looks aligned with the v3/metering/eventsspecThis file is clearly generator output (header + structure) and wires up the
/metering/eventsendpoint plus the embedded spec and helpers. It lines up with the v3 routes you defined in TypeSpec.All good from my side—just keep changes flowing through the spec + codegen pipeline rather than editing this file directly.
| //go:generate go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=codegen.yaml ./openapi.yaml | ||
| package v3 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Check the current state of api/v3/api.go
head -n 5 api/v3/api.goRepository: openmeterio/openmeter
Length of output: 191
🏁 Script executed:
# Search for other go:generate directives in the codebase for comparison
rg -n "//go:generate" --type=goRepository: openmeterio/openmeter
Length of output: 1540
🌐 Web query:
oapi-codegen go:generate invocation example documentation
💡 Result:
Short example and notes
- Add a tools file so the generator is tracked by go modules (tools import):
//go:build tools
// +build tools
package tools
import _ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
(Use this so go mod tidy keeps the generator dependency.) [1]
- Example go:generate invocation (run from the package where you want generated code):
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
If you install the binary instead, the shorter form works:
//go:generate oapi-codegen --config=config.yaml ../../api.yaml
The generator accepts a YAML (or JSON) config (package, generate targets, output, import-mapping, etc.). See the repo README and examples for config schema and flags. [1][2]
Sources:
[1] oapi-codegen examples (tools.go + go:generate usage).
[2] oapi-codegen README / usage and configuration details.
Fix go:generate invocation – use go run instead of go tool
The current directive is:
//go:generate go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=codegen.yaml ./openapi.yamlgo tool does not accept import paths; it only works with built-in tools (like cover, vet) or pre-installed binaries. This directive will fail when running go generate. The official oapi-codegen documentation recommends using go run instead:
-//go:generate go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=codegen.yaml ./openapi.yaml
+//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=codegen.yaml ./openapi.yamlThe same issue exists in api/api.go line 1 and should be fixed there as well.
🤖 Prompt for AI Agents
In api/v3/api.go lines 1-2 (and also update api/api.go line 1), the go:generate
directive incorrectly uses "go tool" with an import path which fails; replace
the directive to use "go run" to run the oapi-codegen command with the same
flags (e.g., use "go run
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=codegen.yaml
./openapi.yaml") so go generate will run the tool correctly; make the identical
change in api/api.go.
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.