Skip to content

refactor(api): import API models directly in 34 packages - #5530

Merged
chrisgacsal merged 1 commit into
mainfrom
refactor/api-model-imports
Nov 16, 2026
Merged

chrisgacsal merged 1 commit into
mainfrom
refactor/api-model-imports

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

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.

RetriggerView in GreptileConfidence 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.

Reviews (1) · Last reviewed commit: "refactor(api): use model packages in pla..." · Reviewed by Greptile

Summary by CodeRabbit

  • Refactor
    • 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.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Suggested reviewers: galexihu, turip, borosr

Merge Risk: Minimal · up to 8b092

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 11ece79 and 8b092b0.

Files selected for processing: 111

  • api/v3/handlers/billingcommon/convert.go
  • api/v3/handlers/billingcommon/convert_test.go
  • api/v3/handlers/billingcommon/costbasis.go
  • api/v3/handlers/billingcommon/costbasis_test.go
  • api/v3/handlers/billinginvoices/action.go
  • api/v3/handlers/billinginvoices/convert.go
  • api/v3/handlers/billinginvoices/convert_test.go
  • api/v3/handlers/billinginvoices/get.go
  • api/v3/handlers/billinginvoices/invoice_charges.go
  • api/v3/handlers/billinginvoices/invoice_charges_test.go
  • api/v3/handlers/billinginvoices/list.go
  • api/v3/handlers/billinginvoices/update.go
  • api/v3/handlers/customers/charges/convert.go
  • api/v3/handlers/customers/charges/convert_test.go
  • api/v3/handlers/customers/charges/create.go
  • api/v3/handlers/customers/charges/list.go
  • api/v3/handlers/customers/charges/list_charges.go
  • api/v3/handlers/customers/charges/list_test.go
  • api/v3/handlers/events/convert.go
  • api/v3/handlers/events/ingest.go
  • api/v3/handlers/events/list.go
  • api/v3/handlers/events/list_test.go
  • api/v3/handlers/notification/events/convert.go
  • api/v3/handlers/notification/events/convert_test.go
  • api/v3/handlers/notification/events/get.go
  • api/v3/handlers/notification/events/list.go
  • api/v3/handlers/notification/events/resend.go
  • api/v3/handlers/notification/rules/convert.go
  • api/v3/handlers/notification/rules/convert_test.go
  • api/v3/handlers/notification/rules/create.go
  • api/v3/handlers/notification/rules/get.go
  • api/v3/handlers/notification/rules/list.go
  • api/v3/handlers/notification/rules/test.go
  • api/v3/handlers/notification/rules/update.go
  • api/v3/handlers/tax/convert.go
  • api/v3/handlers/tax/convert_test.go
  • openmeter/app/httpdriver/app.go
  • openmeter/app/httpdriver/convert.go
  • openmeter/app/httpdriver/customer.go
  • openmeter/app/httpdriver/marketplace.go
  • openmeter/app/stripe/httpdriver/apikey.go
  • openmeter/app/stripe/httpdriver/checkout_session.go
  • openmeter/app/stripe/httpdriver/customer.go
  • openmeter/app/stripe/httpdriver/mapping.go
  • openmeter/app/stripe/httpdriver/webhook.go
  • openmeter/credit/driver/grant.go
  • openmeter/customer/httpdriver/apimapping.go
  • openmeter/customer/httpdriver/customer.go
  • openmeter/entitlement/driver/entitlement.go
  • openmeter/entitlement/driver/metered.go
  • openmeter/entitlement/driver/parser.go
  • openmeter/entitlement/driver/v2/customer.go
  • openmeter/entitlement/driver/v2/customer_metered.go
  • openmeter/entitlement/driver/v2/entitlement.go
  • openmeter/entitlement/driver/v2/mapping.go
  • openmeter/info/httpdriver/currencies.go
  • openmeter/ingest/httpdriver/ingest.go
  • openmeter/meter/httphandler/mapping.go
  • openmeter/meter/httphandler/meter.go
  • openmeter/meter/httphandler/query.go
  • openmeter/meter/httphandler/query_csv.go
  • openmeter/meterevent/httphandler/event.go
  • openmeter/meterevent/httphandler/event_v2.go
  • openmeter/meterevent/httphandler/mapping.go
  • openmeter/notification/httpdriver/channel.go
  • openmeter/notification/httpdriver/event.go
  • openmeter/notification/httpdriver/mapping.go
  • openmeter/notification/httpdriver/mapping_test.go
  • openmeter/notification/httpdriver/rule.go
  • openmeter/portal/authenticator/authenticator.go
  • openmeter/portal/httphandler/mapping.go
  • openmeter/portal/httphandler/portal.go
  • openmeter/productcatalog/addon/httpdriver/addon.go
  • openmeter/productcatalog/addon/httpdriver/addon_test.go
  • openmeter/productcatalog/addon/httpdriver/mapping.go
  • openmeter/productcatalog/driver/feature.go
  • openmeter/productcatalog/driver/parser.go
  • openmeter/productcatalog/http/mapping.go
  • openmeter/productcatalog/http/mapping_test.go
  • openmeter/productcatalog/plan/httpdriver/mapping.go
  • openmeter/productcatalog/plan/httpdriver/plan.go
  • openmeter/productcatalog/plan/httpdriver/plan_test.go
  • openmeter/productcatalog/planaddon/httpdriver/mapping.go
  • openmeter/productcatalog/planaddon/httpdriver/planaddon.go
  • openmeter/productcatalog/subscription/http/cancel.go
  • openmeter/productcatalog/subscription/http/change.go
  • openmeter/productcatalog/subscription/http/create.go
  • openmeter/productcatalog/subscription/http/edit.go
  • openmeter/productcatalog/subscription/http/edit_test.go
  • openmeter/productcatalog/subscription/http/get.go
  • openmeter/productcatalog/subscription/http/get_test.go
  • openmeter/productcatalog/subscription/http/mapping.go
  • openmeter/productcatalog/subscription/http/migrate.go
  • openmeter/progressmanager/httpdriver/progress.go
  • openmeter/subject/httphandler/mapping.go
  • openmeter/subject/httphandler/subject.go
  • openmeter/subscription/addon/http/create.go
  • openmeter/subscription/addon/http/get.go
  • openmeter/subscription/addon/http/list.go
  • openmeter/subscription/addon/http/mapping.go
  • openmeter/subscription/addon/http/update.go
  • pkg/models/http/annotation.go
  • pkg/models/http/metadata.go
  • test/app/stripe/appstripe.go
  • test/app/stripe/customerbilling_profile_v3_test.go
  • test/app/stripe/customerbilling_v3_test.go
  • test/billing/appinstall_test.go
  • test/billing/customeroverride_test.go
  • test/credits/charges_api_realizations_test.go
  • test/notification/consumer_balance.go
  • test/notification/event.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@chrisgacsal chrisgacsal self-assigned this Nov 16, 2026
@chrisgacsal chrisgacsal added the release-note/ignore Ignore this change when generating release notes label Nov 16, 2026
@chrisgacsal
chrisgacsal marked this pull request as ready for review November 16, 2026 09:00
@chrisgacsal
chrisgacsal requested a review from a team as a code owner November 16, 2026 09:00
@chrisgacsal
chrisgacsal merged commit 1b67154 into main Nov 16, 2026
35 of 36 checks passed
@chrisgacsal
chrisgacsal deleted the refactor/api-model-imports branch November 16, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants