You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(api): import API models directly in 34 packages - #5530
Follow-up to #5509. Switch model references in 34 packages to api/models and api/v3/models. Importing a generated model through the server package also pulls its HTTP dependencies into the Go package graph. Importing the model directly removes that dependency and avoids a potential import cycle when the server needs to import the consumer.
Notes for reviewer
Compared go list -deps -tags=dynamic before and after. The legacy server package drops out of the dependency graph for 32 packages. The v3 server package drops out for the other two, api/v3/handlers/billingcommon and api/v3/handlers/tax.
Model imports use apiv1models and apiv3models. Two tests still exercise the v3 router or load its OpenAPI spec. They use apiv3 for those operations and apiv3models for the payloads.
Ran package tests, Go vet, and golangci-lint for the 34 packages. The database-backed tests ran with PostgreSQL and the notification suite ran with Svix. The collector and e2e modules compiled, and make mod produced no changes.
Confidence Score: 5/5
This import-only refactor appears safe to merge.
Summary
Switches model references across 34 packages to api/models and api/v3/models, avoiding unnecessary dependencies on generated HTTP servers.
API consumers use generated model packages without importing server packages for types.
Updated billing, customer, subscription, notification, product catalog, meter, entitlement, and other API integrations to use the generated API models.
Existing request and response formats, conversion behavior, and handler functionality remain unchanged.
Tests
Updated related tests and fixtures to use the corresponding generated models; existing scenarios and assertions are preserved.
No actionable comments were generated in the recent review.
Walkthrough
This pull request updates V1 and V3 HTTP handlers, conversion functions, and tests to use types from generated API model packages. The summaries report no changes to the described field mappings, validation, handler flow, or error behavior.
Changes: V3 billing, event, and notification models
Layer / File(s)
Summary
V3 billing converters and handlers api/v3/handlers/billingcommon/*, api/v3/handlers/billinginvoices/*, api/v3/handlers/customers/charges/*
Billing totals, invoices, charges, cost basis, request types, and related enums now use api/v3/models. Invoice sort-field conversion now uses api/models order values. Existing conversion mappings and error handling remain unchanged.
V3 events, notification, and tax models api/v3/handlers/events/*, api/v3/handlers/notification/*, api/v3/handlers/tax/*
Event, notification, and tax handlers and converters now use generated V1 or V3 model types. Existing conversion cases, validation, filters, and error paths remain unchanged. Their tests use the corresponding model types.
V3 model test updates test/credits/charges_api_realizations_test.go, test/app/stripe/customerbilling*_v3_test.go
The tests use generated V3 model types for billing responses, charge realizations, and related assertions. The tested scenarios and expected values remain unchanged.
V1 handlers and shared mappings
Layer / File(s)
Summary
App, customer, and portal handlers openmeter/app/httpdriver/*, openmeter/app/stripe/httpdriver/*, openmeter/customer/httpdriver/*, openmeter/portal/*
App, marketplace, Stripe, customer, and portal request and response types now come from api/models. Existing handler and mapping behavior remains unchanged. Related billing-profile and app-install tests use generated model types.
Entitlement and grant handlers openmeter/credit/driver/*, openmeter/entitlement/driver/*, test/notification/*, test/credits/charges_api_realizations_test.go
Entitlement and grant handlers, parsers, and mapping functions now use V1 models. Test fixtures and assertions use the generated models, with existing operations and expected values retained.
Other V1 HTTP handlers and mappings openmeter/info/httpdriver/*, openmeter/ingest/httpdriver/*, openmeter/meter/httphandler/*, openmeter/meterevent/httphandler/*, openmeter/notification/httpdriver/*, openmeter/progressmanager/httpdriver/*, openmeter/subject/httphandler/*, pkg/models/http/*
Currency, ingest, meter, metering-event, notification, progress, subject, metadata, and annotation HTTP types now come from api/models. Existing conversions and handler flow remain unchanged.
Product catalog and subscription handlers openmeter/productcatalog/*, openmeter/productcatalog/subscription/http/*, openmeter/subscription/addon/http/*
Product, plan, subscription, and add-on request and response types now use V1 generated models. Existing mapping, validation, and handler behavior remain unchanged. Related tests use the generated types.
This change swaps import paths so that handlers use generated model packages directly. It is not expected to change runtime behavior. No concrete merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "refactor(api): import API models directly in 34 packages" matches the main change. The PR replaces imports of server packages (api/v3, api) with direct imports of generated models from api/…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "refactor(api): import API models directly in 34 packages" matches the main change. The PR replaces imports of server packages (api/v3, api) with direct imports of generated models from api/models and api/v3/models across 34 packages. The title names the refactor, the affected area, and the scope. It does not mention the goal of removing HTTP dependencies from the dependency graph, which is acceptable because the title does not need to cover every detail.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
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
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.
Overview
Follow-up to #5509. Switch model references in 34 packages to
api/modelsandapi/v3/models. Importing a generated model through the server package also pulls its HTTP dependencies into the Go package graph. Importing the model directly removes that dependency and avoids a potential import cycle when the server needs to import the consumer.Notes for reviewer
go list -deps -tags=dynamicbefore and after. The legacy server package drops out of the dependency graph for 32 packages. The v3 server package drops out for the other two,api/v3/handlers/billingcommonandapi/v3/handlers/tax.apiv1modelsandapiv3models. Two tests still exercise the v3 router or load its OpenAPI spec. They useapiv3for those operations andapiv3modelsfor the payloads.make modproduced no changes.

Confidence Score: 5/5
This import-only refactor appears safe to merge.Summary
Switches model references across 34 packages to
api/modelsandapi/v3/models, avoiding unnecessary dependencies on generated HTTP servers.Reviews (1) · Last reviewed commit: "refactor(api): use model packages in pla..." · Reviewed by Greptile
Summary by CodeRabbit