Skip to content

chore(api): move features under Product Catalog - #3461

Merged
tothandras merged 1 commit into
mainfrom
feat/api-features-v2
Oct 3, 2025
Merged

tothandras merged 1 commit into
mainfrom
feat/api-features-v2

Conversation

@tothandras

@tothandras tothandras commented Oct 3, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • None
  • Documentation

    • Reclassified API tags from “Entitlements” to “Product Catalog” across endpoints, schemas, and examples.
    • Updated feature, subscription, and notification payload references to use Product Catalog Feature.
  • Refactor

    • Adopted route-level middleware for API request handling, standardizing parameter parsing and error responses.
  • Chores

    • Regenerated server and client artifacts to reflect updated OpenAPI specification and tagging.

@tothandras
tothandras requested a review from a team as a code owner October 3, 2025 16:45
@tothandras tothandras added the release-note/misc Miscellaneous changes label Oct 3, 2025
@coderabbitai

coderabbitai Bot commented Oct 3, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds middleware chaining to all HTTP route handlers in the generated server. Reclassifies OpenAPI tags from “Entitlements” to “Product Catalog.” Updates TypeSpec to move Features under Product Catalog and adjust references. Regenerates client/server artifacts to reflect tag and route/interface changes.

Changes

Cohort / File(s) Summary of changes
Server middleware integration
api/api.gen.go
Wraps each route handler in a middleware chain via ServerInterfaceWrapper.HandlerMiddlewares; standardizes parameter binding and error handling before invoking ServeHTTP. No interface signature changes.
OpenAPI tag reclassification
api/openapi.yaml, api/openapi.cloud.yaml
Replaces tags “Entitlements” with “Product Catalog” across affected paths and components; reorganizes documentation grouping without altering operations, parameters, or schemas.
Generated Go client spec bundle
api/client/go/client.gen.go
Updates embedded Swagger spec payload; decoding/loading logic and public function signatures unchanged.
TypeSpec: Product Catalog feature routes restructuring
api/spec/src/productcatalog/routes.tsp, api/spec/src/cloud/main.tsp, api/spec/src/productcatalog/features.tsp
Introduces OpenMeter.ProductCatalog.Features interface and routes for features; updates cloud namespace to expose Product Catalog features; removes prior Features interface under Entitlements/ProductCatalog file and aligns namespace to OpenMeter.ProductCatalog.
TypeSpec: Reference updates
api/spec/src/entitlements/main.tsp, api/spec/src/notification/entitlements.tsp, api/spec/src/productcatalog/subscription.tsp
Replaces feature type references from Entitlements.Feature to ProductCatalog.Feature; adjusts imports, removes unused TypeSpec decorators/usings where applicable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “chore(api): move features under Product Catalog” succinctly and accurately encapsulates the primary change in the pull request, which reorganizes feature-related endpoints, types, and namespaces from “Entitlements” to “Product Catalog” across the API surface. It is clear, concise, and focused on the main refactoring without extraneous details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/api-features-v2

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 and usage tips.

@tothandras
tothandras enabled auto-merge (squash) October 3, 2025 16:47

@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: 2

🧹 Nitpick comments (1)
api/spec/src/productcatalog/subscription.tsp (1)

282-293: Type updated to ProductCatalog.Feature is consistent; consider simplifying the reference.

Inside namespace OpenMeter.ProductCatalog, you can refer to the local type as Feature to reduce verbosity, mirroring how sibling namespaces are referenced for Entitlements.Entitlement. Optional style tweak.

-  feature: ProductCatalog.Feature;
+  feature: Feature;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36abde9 and e87dd87.

📒 Files selected for processing (10)
  • api/api.gen.go (1 hunks)
  • api/client/go/client.gen.go (1 hunks)
  • api/openapi.cloud.yaml (4 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/cloud/main.tsp (1 hunks)
  • api/spec/src/entitlements/main.tsp (1 hunks)
  • api/spec/src/notification/entitlements.tsp (1 hunks)
  • api/spec/src/productcatalog/features.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
  • api/spec/src/productcatalog/subscription.tsp (1 hunks)
🧰 Additional context used
🪛 Gitleaks (8.28.0)
api/client/go/client.gen.go

[high] 44225-44226: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ 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). (8)
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Migration Checks
  • GitHub Check: Code Generators
  • GitHub Check: Lint
  • GitHub Check: Test
  • GitHub Check: Build
  • GitHub Check: Analyze (go)
🔇 Additional comments (10)
api/api.gen.go (1)

20958-21207: This hunk contains only embedded data in a generated file.

The provided hunk consists of base64-encoded strings (lines 20958-21206) representing the embedded OpenAPI specification, followed by a closing brace and comment (lines 21207-21209). Since this is generated code and the hunk does not show the routing layer changes described in the AI summary (middleware wrapping, parameter parsing), there is nothing actionable to review here.

api/client/go/client.gen.go (1)

43983-44227: Gitleaks finding appears to be a false positive.

This blob is the regenerated gzipped+base64 OpenAPI spec, and the flagged substring is just encoded payload—not an actual credential. No action needed.

api/spec/src/notification/entitlements.tsp (1)

55-58: Approve code changes Feature type migration to OpenMeter.ProductCatalog.Feature is consistently applied across spec, mapping logic, and generated OpenAPI clients.

api/spec/src/entitlements/main.tsp (1)

11-11: Confirm no stale Entitlements.Feature references

rg found no matches for OpenMeter.Entitlements.Feature or import './feature.tsp'; please manually verify that no stale references remain.

api/spec/src/productcatalog/features.tsp (1)

8-8: LGTM! Namespace change aligns with PR objectives.

The namespace rename from OpenMeter.Entitlements to OpenMeter.ProductCatalog correctly reflects the reorganization of features under Product Catalog. The type definitions remain appropriately in this file while the interface routes have been moved to routes.tsp.

api/spec/src/productcatalog/routes.tsp (4)

9-11: LGTM! Interface definition follows conventions.

The Features interface is properly defined with the correct route and tag, consistent with other interfaces in this file.


36-48: LGTM! Well-documented create operation.

The create operation is correctly implemented with comprehensive documentation about metered vs static features and the immutability constraint.


50-58: LGTM! Standard get operation.

The get operation correctly retrieves a feature by ID with appropriate error handling.


60-72: LGTM! Well-documented archive operation.

The delete/archive operation includes excellent documentation about the archiving behavior and its implications for entitlements, which will help prevent common misunderstandings.

api/openapi.yaml (1)

4458-4458: Tag updates look consistent.

Renaming these route groupings to “Product Catalog” aligns with the PR objective. No further action needed.

Also applies to: 4518-4518, 4592-4592, 4659-4659

Comment on lines +246 to +249
@route("/api/v1/features")
@tag("Product Catalog")
interface Features extends OpenMeter.ProductCatalog.Features {}

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.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Move Features under Product Catalog looks good; please verify base interface and route uniqueness.

The route/tag align with the reclassification. Confirm the base OpenMeter.ProductCatalog.Features exists and there’s a single /api/v1/features route left in the spec.


🏁 Script executed:

#!/bin/bash
# Verify ProductCatalog.Features interface exists
rg -nPU '(?s)namespace\s+OpenMeter\.ProductCatalog\b.*?\binterface\s+Features\b' -C2

# Ensure there is only one /api/v1/features route across the repo
rg -n '@route\("/api/v1/features"\)' -C2

Length of output: 1342


Remove duplicate /api/v1/features route
OpenMeter.ProductCatalog.Features exists; there are two @route("/api/v1/features") definitions—remove the one in api/spec/src/productcatalog/routes.tsp to ensure only a single route remains.

🤖 Prompt for AI Agents
In api/spec/src/cloud/main.tsp around lines 246-249 there's a
@route("/api/v1/features") declaration that references
OpenMeter.ProductCatalog.Features; a duplicate route exists in
api/spec/src/productcatalog/routes.tsp—remove the duplicate route block in
api/spec/src/productcatalog/routes.tsp so only the declaration in
api/spec/src/cloud/main.tsp remains, ensure no other references to the removed
block remain, run the typecheck/build to confirm no unresolved imports or
collisions.

Comment on lines +25 to +29
/**
* Filter by meterGroupByFilters
*/
@query
includeArchived?: boolean = false,

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.

⚠️ Potential issue | 🟡 Minor

Fix incorrect parameter documentation.

The comment on lines 26-27 states "Filter by meterGroupByFilters" but the parameter is includeArchived, which controls whether archived features are included in the results.

Apply this diff to correct the documentation:

     /**
-     * Filter by meterGroupByFilters
+     * Include archived features in the response
      */
     @query
     includeArchived?: boolean = false,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Filter by meterGroupByFilters
*/
@query
includeArchived?: boolean = false,
/**
* Include archived features in the response
*/
@query
includeArchived?: boolean = false,
🤖 Prompt for AI Agents
In api/spec/src/productcatalog/routes.tsp around lines 25 to 29, the JSDoc
comment incorrectly says "Filter by meterGroupByFilters" for the includeArchived
parameter; update the comment to accurately describe includeArchived (e.g.,
"Include archived items in the results" or "Whether to include archived features
in the response") so the doc matches the parameter purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants