Skip to content

feat(api): update v3 spec - #4640

Merged
tothandras merged 1 commit into
mainfrom
fix/spec-duplicates
Jul 3, 2026
Merged

tothandras merged 1 commit into
mainfrom
fix/spec-duplicates

Conversation

@tothandras

@tothandras tothandras commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Expanded support for several billing, tax, and customer credit endpoints in the public API spec.
    • Updated API reference formats for add-ons, features, tax codes, and related billing objects.
  • Bug Fixes

    • Improved API schema generation by removing unsupported vendor metadata from generated OpenAPI output.
    • Refined filter/operator schemas for comma-delimited fields to better match expected request shapes.
  • Chores

    • Updated build and workspace configuration for newer tooling and patches.
  • Tests

    • Adjusted automated and end-to-end tests to align with the updated API reference shapes.

@tothandras
tothandras requested a review from a team as a code owner July 3, 2026 11:43
@tothandras tothandras added the release-note/bug-fix Release note: Bug Fixes label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR replaces *ReferenceItem wrapper types with *Reference types for feature, tax code, and addon fields across v3 API handlers and e2e tests, switches several TypeSpec operation @extension decorators from InternalExtension to UnstableExtension, updates the spec build Makefile and pnpm workspace patches, and simplifies comma-delimited filter schemas.

Changes

Reference type migration

Layer / File(s) Summary
Handler conversion logic
api/v3/handlers/addons/convert.go, api/v3/handlers/plans/convert.go, api/v3/handlers/plans/planaddons/convert.go
Feature, tax code, and addon fields now use FeatureReference, TaxCodeReference, and AddonReference instead of the *Item variants.
Unit test updates
api/v3/handlers/plans/convert_test.go
Test expectations updated to match the new reference types.
E2E test fixtures
e2e/addons_v3_test.go, e2e/billinginvoice_override_test.go, e2e/plan_entitlement_template_v3_test.go, e2e/v3helpers_test.go
Rate card fixtures and test helpers construct Feature fields using the new FeatureReference type.

Estimated code review effort: 2 (Simple) | ~15 minutes

TypeSpec extension decorators

Layer / File(s) Summary
Charges and credits operations
api/spec/packages/aip/src/customers/charges/operations.tsp, api/spec/packages/aip/src/customers/credits/operations.tsp
Multiple list/create/get operations switch @extension from Shared.InternalExtension to Shared.UnstableExtension.
Defaults and tax code operations
api/spec/packages/aip/src/defaults/operations.tsp, api/spec/packages/aip/src/tax/operations.tsp
Organization default tax code operations switch extension marker; tax code operations drop the duplicate InternalExtension decorator, keeping only UnstableExtension.

Estimated code review effort: 1 (Trivial) | ~10 minutes

Spec build pipeline and schema cleanup

Layer / File(s) Summary
Build pipeline and dependency patches
api/spec/Makefile, api/spec/packages/legacy/package.json, api/spec/pnpm-workspace.yaml
The generate target strips x-go-type/x-go-type-import fields; adds @typespec/streams dependency; updates patchedDependencies and allowBuilds (esbuild now allowed).
Filter operator schema simplification
api/v3/test/openapi.test.yaml
Removes items and ArrayEncoding.commaDelimited metadata from oeq/ocontains operators across numeric, string, and ULID filters.

Estimated code review effort: 1 (Trivial) | ~8 minutes

Possibly related PRs

Suggested labels: area/api

Suggested reviewers: chrisgacsal

Hey, this one's basically a tidy-up sweep — swapping wrapper types for cleaner references, flipping some extension flags, and trimming a bit of schema fat. Nothing scary here, just consistent housekeeping across the board! 🧹✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main change: updates to the v3 API spec and related conversion/test wiring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/spec-duplicates

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

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR promotes a set of previously internal-only v3 API endpoints (customer charges, credits, tax codes, and organization defaults) to externally visible by removing x-internal: true markers, while keeping all of them behind x-unstable: true. It also cleans up three schema names (*ReferenceItem → *Reference) and removes incorrectly placed items/format fields from string-typed filter properties.

  • Removes @extension(Shared.InternalExtension, true) from 14 endpoints across charges, credits, tax, and defaults TypeSpec files; all corresponding Go handlers, e2e tests, and generated api.gen.go/openapi.yaml are updated consistently.
  • Renames AddonReferenceItem, FeatureReferenceItem, and TaxCodeReferenceItem to AddonReference, FeatureReference, and TaxCodeReference throughout the spec and all Go code.
  • Updates the @typespec/[email protected] patch to now-version-pinned form, adds an x-inline extension filter, and introduces a Makefile yq step to strip x-go-type/x-go-type-import vendor extensions from generated output.

Confidence Score: 4/5

Safe to merge — changes are consistently applied across spec, generated Go bindings, handlers, and e2e tests; the renamed schemas and de-internalized endpoints all remain gated behind x-unstable.

The rename of *ReferenceItem → *Reference schemas is reflected in every usage site (handlers, tests, e2e, generated code), and the filter-schema cleanup is correct. The single stale comment referencing the old type name is the only rough edge.

The api/spec/patches/@[email protected] file is large (850 lines of compiled JS dist) and cannot be easily audited line-by-line; the functional delta (adding the x-inline skip) is small and readable, but reviewers may want to re-verify the patch hash in pnpm-lock.yaml matches what was actually generated locally.

Important Files Changed

Filename Overview
api/v3/openapi.yaml Generated output reflecting: removal of x-internal from ~14 endpoints; renaming of *ReferenceItem schemas to *Reference; removal of invalid items+format fields from string-typed filter properties
api/v3/api.gen.go Regenerated Go bindings reflecting renamed schemas; all struct renames are consistent with the spec changes
api/spec/patches/@[email protected] New versioned patch adding x-inline extension filtering to attachExtensions; large (~850 lines) compiled JS dist
api/spec/Makefile Adds yq post-processing step to strip x-go-type and x-go-type-import vendor extensions before bundling
api/spec/pnpm-workspace.yaml Version-pins the openapi3 patch reference; changes esbuild from blocked to allowed in allowBuilds
e2e/addons_v3_test.go Updates FeatureReferenceItem → FeatureReference in test usage; stale comment at line 285 still references old type name

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[TypeSpec .tsp sources] -->|pnpm generate| B[TypeSpec compiler + patched @typespec/openapi3]
    B -->|emit| C[output/definitions/.../openapi.MeteringAndBilling.yaml]
    C -->|Makefile: yq strip x-go-type*| D[Cleaned intermediate YAML]
    D -->|openapi bundle| E[api/v3/openapi.yaml]
    E -->|oapi-codegen| F[api/v3/api.gen.go]

    subgraph VisibilityChanges ["Visibility changes"]
        G["x-internal removed from 14 endpoints:\ncharges, credits, tax-codes, defaults"]
    end

    subgraph Renames ["Schema renames"]
        H["*ReferenceItem → *Reference (3 types)"]
    end

    subgraph FilterFix ["Filter schema fix"]
        I["Removed invalid items+format from\nstring-typed oeq/ocontains fields"]
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[TypeSpec .tsp sources] -->|pnpm generate| B[TypeSpec compiler + patched @typespec/openapi3]
    B -->|emit| C[output/definitions/.../openapi.MeteringAndBilling.yaml]
    C -->|Makefile: yq strip x-go-type*| D[Cleaned intermediate YAML]
    D -->|openapi bundle| E[api/v3/openapi.yaml]
    E -->|oapi-codegen| F[api/v3/api.gen.go]

    subgraph VisibilityChanges ["Visibility changes"]
        G["x-internal removed from 14 endpoints:\ncharges, credits, tax-codes, defaults"]
    end

    subgraph Renames ["Schema renames"]
        H["*ReferenceItem → *Reference (3 types)"]
    end

    subgraph FilterFix ["Filter schema fix"]
        I["Removed invalid items+format from\nstring-typed oeq/ocontains fields"]
    end
Loading

Comments Outside Diff (1)

  1. e2e/addons_v3_test.go, line 285-286 (link)

    P2 Stale type name in comment — the code on the next line already uses the renamed FeatureReference, but the comment still references the old FeatureReferenceItem name.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: e2e/addons_v3_test.go
    Line: 285-286
    
    Comment:
    Stale type name in comment — the code on the next line already uses the renamed `FeatureReference`, but the comment still references the old `FeatureReferenceItem` name.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

    Fix in Claude Code Fix in Codex

Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
e2e/addons_v3_test.go:285-286
Stale type name in comment — the code on the next line already uses the renamed `FeatureReference`, but the comment still references the old `FeatureReferenceItem` name.

```suggestion
// id/key-mismatch aren't expressible in the v3 schema: FeatureReference
// on a rate card has only Id, no Key. The archived-feature case needs
```

Reviews (1): Last reviewed commit: "feat(api): update v3 spec" | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/spec/pnpm-workspace.yaml (1)

21-28: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Comment is now out of sync with the config.

The comment right above still says "core-js/esbuild/protobufjs were never allowed and stay denied so an install does not silently start running their postinstall scripts." but esbuild was just flipped to true on the line below. Anyone reading the comment would assume esbuild is still blocked — worth updating the wording so it doesn't mislead the next reader (and reviewer) about the actual security posture here.

✏️ Suggested comment fix
 # pnpm 11 replaces onlyBuiltDependencies with an explicit allow/deny map.
-# Preserve the prior allowlist: only `@typespec/http-client-python` may run its
-# build script; core-js/esbuild/protobufjs were never allowed and stay denied
-# so an install does not silently start running their postinstall scripts.
+# Preserve the prior allowlist plus esbuild (needed for its postinstall
+# binary download); core-js/protobufjs remain denied so an install does not
+# silently start running their postinstall scripts.
 allowBuilds:
   '`@typespec/http-client-python`': true
   esbuild: true
   core-js: false
   protobufjs: false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/spec/pnpm-workspace.yaml` around lines 21 - 28, Update the explanatory
comment above allowBuilds so it matches the actual pnpm-workspace.yaml policy:
esbuild is explicitly allowed, while core-js remains denied. Keep the note
aligned with the allowBuilds entries in pnpm-workspace.yaml and refer to the
existing package names (`@typespec/http-client-python`, esbuild, core-js) so the
next reader is not misled about which build scripts may run.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/spec/Makefile`:
- Around line 22-27: The legacy OpenAPI outputs are being copied without
removing Go vendor extensions, so the published specs can still contain
x-go-type and x-go-type-import. Update the Makefile workflow around the legacy
OpenAPI generation/copy steps to strip those extensions from both
openapi.OpenMeter.yaml and openapi.OpenMeterCloud.yaml before copying, using the
same yq-based cleanup already applied for the MeteringAndBilling output.

---

Outside diff comments:
In `@api/spec/pnpm-workspace.yaml`:
- Around line 21-28: Update the explanatory comment above allowBuilds so it
matches the actual pnpm-workspace.yaml policy: esbuild is explicitly allowed,
while core-js remains denied. Keep the note aligned with the allowBuilds entries
in pnpm-workspace.yaml and refer to the existing package names
(`@typespec/http-client-python`, esbuild, core-js) so the next reader is not
misled about which build scripts may run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5a95ca11-8f36-4e13-ad50-85fe9507d207

📥 Commits

Reviewing files that changed from the base of the PR and between afec0f5 and 96cd901.

⛔ Files ignored due to path filters (3)
  • api/spec/patches/@[email protected] is excluded by !api/spec/patches/**
  • api/spec/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (17)
  • api/spec/Makefile
  • api/spec/packages/aip/src/customers/charges/operations.tsp
  • api/spec/packages/aip/src/customers/credits/operations.tsp
  • api/spec/packages/aip/src/defaults/operations.tsp
  • api/spec/packages/aip/src/tax/operations.tsp
  • api/spec/packages/legacy/package.json
  • api/spec/pnpm-workspace.yaml
  • api/v3/api.gen.go
  • api/v3/handlers/addons/convert.go
  • api/v3/handlers/plans/convert.go
  • api/v3/handlers/plans/convert_test.go
  • api/v3/handlers/plans/planaddons/convert.go
  • api/v3/test/openapi.test.yaml
  • e2e/addons_v3_test.go
  • e2e/billinginvoice_override_test.go
  • e2e/plan_entitlement_template_v3_test.go
  • e2e/v3helpers_test.go
💤 Files with no reviewable changes (5)
  • api/spec/packages/aip/src/customers/charges/operations.tsp
  • api/spec/packages/aip/src/tax/operations.tsp
  • api/spec/packages/aip/src/defaults/operations.tsp
  • api/spec/packages/aip/src/customers/credits/operations.tsp
  • api/v3/test/openapi.test.yaml

Comment thread api/spec/Makefile Resolved
@tothandras
tothandras enabled auto-merge (squash) July 3, 2026 12:12
@tothandras
tothandras merged commit f7f3d35 into main Jul 3, 2026
29 of 31 checks passed
@tothandras
tothandras deleted the fix/spec-duplicates branch July 3, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants