Repository navigation
chore(api): move features under Product Catalog - #3461
Conversation
📝 WalkthroughWalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 asFeatureto reduce verbosity, mirroring how sibling namespaces are referenced forEntitlements.Entitlement. Optional style tweak.- feature: ProductCatalog.Feature; + feature: Feature;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
rgfound no matches forOpenMeter.Entitlements.Featureorimport './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.EntitlementstoOpenMeter.ProductCatalogcorrectly reflects the reorganization of features under Product Catalog. The type definitions remain appropriately in this file while the interface routes have been moved toroutes.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
| @route("/api/v1/features") | ||
| @tag("Product Catalog") | ||
| interface Features extends OpenMeter.ProductCatalog.Features {} | ||
|
|
There was a problem hiding this comment.
🛠️ 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"\)' -C2Length 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.
| /** | ||
| * Filter by meterGroupByFilters | ||
| */ | ||
| @query | ||
| includeArchived?: boolean = false, |
There was a problem hiding this comment.
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.
| /** | |
| * 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.
Summary by CodeRabbit
New Features
Documentation
Refactor
Chores