feat(billing): API contract-first — OpenAPI spec + generated client types - #75
Closed
izzywdev wants to merge 1 commit into
Closed
feat(billing): API contract-first — OpenAPI spec + generated client types#75izzywdev wants to merge 1 commit into
izzywdev wants to merge 1 commit into
Conversation
…+ generated client types [skip ci]
Owner
Author
|
Superseded: @fuzefront/billing-client (contract + schema) shipped to master via #88; the live billing-client is built and consumed by billing-ui. Reopen if a divergent spec is needed. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Billing contract (api-contract-first skill)
Authors the frozen OpenAPI 3.1 contract for billing-service and binds the typed client to it.
What
services/billing-service/openapi.yaml— OpenAPI 3.1 spec derived from the real route handlers (src/routes/*,src/app.ts), verified against the code:/plans,/subscriptions(POST/GET/PATCH/DELETE),/setup-intent,/credits,/webhooks/stripe,/health. Covers auth (internalTokenbearer =BILLING_INTERNAL_TOKEN), the public routes (plans + webhook), error shapes (validation 400 / unauthorized 401 / stripe 502 / not-found 404), and documents the async Kafka surface (billing.subscription.changed,billing.usage.recorded, trial-ending / payment-failed).services/billing-service/.spectral.yaml— spectral ruleset (extendsspectral:oas). Lint is clean (0 errors).@fuzefront/billing-client— generatedsrc/schema.ts(openapi-typescript) exported aspaths/components/operations; newsrc/contract.tsstatically asserts the hand-authored public types are byte-for-byte equivalent to the generated schema, so contract drift becomes atscerror. Addedgen:types+lint:contractnpm scripts and the codegen/lint devDeps.Verification
spectral lint openapi.yaml→No results with a severity of 'error' found!tsc --noEmiton billing-client passes with the contract-alignment guard (verified on Linux CI; the local Windows env has theos=linuxnpmrc pin that corrupts native installs).Mock server
npx @stoplight/prism-cli mock services/billing-service/openapi.yamlstands up a mock for UI/test streams.Per the skill, this is the contract PR — freeze/merge FIRST, then fan out backend/UI/test work gated only on the contract.
Base:
feature/billing-payments(PR #66).