Skip to content

Conversation

@chrisgacsal
Copy link
Collaborator

@chrisgacsal chrisgacsal commented Mar 24, 2025

Overview

Extend API spec with basic support for Addons. The spec in not finalized as there are missing parts which are required to be part of the spec in order to make Addons fully functional, expect follow-up changes.

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive set of API endpoints for full addon management, including creation, retrieval, updating, soft deletion, publishing, and archiving.
    • Added advanced filtering options with pagination and ordering for refined addon listings.
  • Enhancements

    • Upgraded addon details with improved status, type, and effective date tracking for a more robust management experience.
    • Added new data schemas to standardize addon management.
  • Bug Fixes

    • Corrected naming conventions for date fields to ensure consistency across the API.
    • Standardized field names in enums for clarity and consistency.

@chrisgacsal chrisgacsal self-assigned this Mar 24, 2025
@chrisgacsal chrisgacsal requested a review from tothandras March 24, 2025 13:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

📝 Walkthrough

Walkthrough

The changes introduce extensive support for managing addons through the API and the TypeScript-based product catalog. The OpenAPI specification now includes endpoints for listing, creating, updating, retrieving, deleting, archiving, and publishing addons, along with detailed data schemas and response handling. New TypeScript modules define addon models, enumerations, and ordering options, while an interface for addon operations enhances routing. Additionally, an import statement integrates these modules, ensuring cohesive functionality between the API and the product catalog domain.

Changes

File Change Summary
api/openapi.yaml Added multiple addon endpoints (list, create, update, get, delete, archive, publish), new data schemas (Addon, AddonCreate, AddonPaginatedResponse, AddonReplaceUpdate), enumerations (AddonStatus, AddonInstanceType), and additional query parameters for filtering and pagination.
api/spec/src/productcatalog/addon.tsp Introduced a new TypeScript module defining the addon model, enums (AddonStatus, AddonInstanceType, AddonOrderBy), and properties (version, currency, effective dates, rateCards) for the product catalog.
api/spec/src/productcatalog/main.tsp Added an import statement for the addon.tsp module to include addon definitions in the namespace.
api/spec/src/productcatalog/routes.tsp Added a new Addons interface with methods for listing, creating, updating, retrieving, deleting, publishing, and archiving addons, complete with error handling for common scenarios.
api/client/go/client.gen.go Renamed constant CreateAt to CreatedAt for consistency; removed string literals from swaggerSpec.
api/client/javascript/src/client/schemas.ts Renamed field PlanOrderBy.create_at to PlanOrderBy.created_at.
api/openapi.cloud.yaml Renamed field create_at in PlanOrderBy to created_at.
api/spec/src/productcatalog/plan.tsp Updated enum value for createdAt from "create_at" to "created_at".
openmeter/server/router/addon.go Introduced a new file defining a Router struct with methods for managing addons through a RESTful API, currently returning http.StatusNotImplemented.
openmeter/server/router/router.go Modified import statement for the plan package to remove aliasing, maintaining functionality.
.spectral.yaml Added two new rules (path-params, oas3-unused-component) set to off in the configuration file.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@chrisgacsal chrisgacsal force-pushed the feat/addons-api branch 2 times, most recently from c817889 to 71fa2ca Compare March 24, 2025 21:56
@chrisgacsal chrisgacsal marked this pull request as ready for review March 24, 2025 21:56
@chrisgacsal chrisgacsal requested a review from a team as a code owner March 24, 2025 21:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (13)
api/spec/src/productcatalog/addon.tsp (2)

24-28: Minor grammar fix in documentation.

The doc says “more then once” instead of “more than once”. Consider correcting to ensure clarity.

- * Single instance addons can be added to subscription only once while addons with multiple type can be added more then once.
+ * Single instance addons can be added to a subscription only once, while addons with the "multiple" type can be added more than once.

66-68: Minor doc mismatch referencing “plan” instead of “addon”.

The doc string states “When not specified, the plan is effective indefinitely,” but this file is for addons. Consider updating to avoid confusion.

- * The date and time when the plan is no longer effective. When not specified, the plan is effective indefinitely.
+ * The date and time when the addon is no longer effective. When not specified, the addon is effective indefinitely.
api/spec/src/productcatalog/routes.tsp (6)

224-231: Use “an addon” for proper grammar.

“Create a addon” → “Create an addon.”

- @summary("Create a addon")
+ @summary("Create an addon")

235-242: Use “an addon” for proper grammar.

“Update a addon” → “Update an addon.”

- @summary("Update a addon")
+ @summary("Update an addon")

269-275: Use “an addon” for proper grammar.

“Once a addon is deleted...” → “Once an addon is deleted...”


279-286: Use “an addon” for proper grammar.

“Publish a addon version” → “Publish an addon version.”


290-297: Use “an addon” for proper grammar.

“Archive a addon version” → “Archive an addon version.”


302-314: Use “an addon” for proper grammar.

“Create a new draft version from addon” → “Create a new draft version from an addon.”

api/openapi.yaml (5)

36-38: Clarify Tag Changes for Apps and Addons
The removal of the “Apps” tag (line 36–37) while still retaining an /api/v1/apps endpoint at the end (line 671) may cause confusion. Please confirm that this change is intentional and that the tags are being restructured consistently across the API specification.


305-373: Review /api/v1/addons/{addonId} - Update (PUT) and Retrieval (GET) Endpoints
• The PUT endpoint for updating an addon properly requires the addonId path parameter and references the AddonReplaceUpdate schema.
• In the GET endpoint (starting at line 380), the summary currently reads “Get plan” (line 382) even though the description and context refer to an addon. Consider updating the summary to “Get addon” for consistency.
A suggested diff for the GET summary:

-      summary: Get plan
+      summary: Get addon

9471-9591: Review Addon Schema Definition
The Addon schema is comprehensive and includes all necessary properties. However, the description (“Addon provide a template for extending Plans.”, line 9591) could be rephrased for clarity (e.g. “Addons provide a template for extending plans”).


9644-9653: Ensure Naming Consistency in AddonOrderBy Enum
The AddonOrderBy enum values include id, key, type, version, create_at, and updated_at. Note that elsewhere in the schema properties the naming convention uses camelCase (e.g., createdAt, updatedAt). For consistency, consider updating these enum values to createdAt and updatedAt.


9725-9732: Review AddonType Schema and Grammar
The AddonType schema is defined correctly with allowed values single and multiple. Please correct the minor grammatical error in the description (“more then once” should be “more than once”).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc336a1 and 71fa2ca.

📒 Files selected for processing (4)
  • api/openapi.yaml (3 hunks)
  • api/spec/src/productcatalog/addon.tsp (1 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CI
  • GitHub Check: Developer environment
  • GitHub Check: Lint
  • GitHub Check: Test
  • GitHub Check: Analyze (go)
🔇 Additional comments (14)
api/spec/src/productcatalog/main.tsp (1)

16-16: No concerns with the new import statement.

Importing ./addon.tsp cleanly integrates addon definitions into the product catalog.

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

13-18: Inconsistent status enumeration with doc mentioning “scheduled”.

The doc comments (lines 75–79) reference a “scheduled” status, but only draft, active, and archived exist in the enum. Confirm whether “scheduled” should be added or removed from the documentation.

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

163-219: Looks good overall.

The new list method parameters mirror the established pattern from Plans. No format issues or inconsistencies noted.

api/openapi.yaml (11)

39-164: Review GET /api/v1/addons Endpoint Design
The GET endpoint for /api/v1/addons is very comprehensive with well-defined query parameters (e.g., includeDeleted, id, key, keyVersion, status, currency, as well as pagination and ordering). Please verify that the referenced ordering parameters (#/components/parameters/AddonOrderByOrdering.order and ...orderBy) are defined correctly in the components section.


167-229: Review POST /api/v1/addons Endpoint
The creation endpoint correctly specifies an empty parameters array, defines the response for status code 201, and uses a requestBody referencing the AddonCreate schema. This design appears sound.


230-304: Review POST /api/v1/addons/{addonIdOrKey}/next Endpoint
The new draft creation endpoint is clearly defined, with validation on the addonIdOrKey parameter and detailed response statuses. Ensure that the business rule—returning an error when there is already a draft or if the ID/key is not the latest published version—is implemented in the service logic.


464-530: Review DELETE /api/v1/addons/{addonId} Endpoint
The DELETE operation is defined to perform a soft delete and returns a 204 status on success. The descriptions and response schemas are clear. Confirm that the irreversible nature of the deletion is documented elsewhere if needed.


531-601: Review POST /api/v1/addons/{addonId}/archive Endpoint
The archive endpoint includes detailed response handling for various client and server errors, which is excellent. Ensure that archiving behavior (and any subsequent state transitions) is handled correctly on the backend.


602-670: Review POST /api/v1/addons/{addonId}/publish Endpoint
The publish endpoint is consistent with the other operations, with clearly defined responses. There are no issues noted here.


671-671: Verify /api/v1/apps Endpoint Inclusion
The diff ends with definition of /api/v1/apps (line 671). Given the earlier removal of the “Apps” tag, please verify that including this endpoint remains intentional and aligns with the intended API grouping.


9592-9643: Review AddonCreate Schema
The AddonCreate schema is well-defined with the required fields for addon creation. It aligns with the design of the other operations.


9654-9717: Review Paginated and Update Schemas
The definitions for AddonPaginatedResponse and AddonReplaceUpdate are consistent with standard patterns and look solid.


9717-9724: Review AddonStatus Schema
The AddonStatus schema clearly defines the allowed status values (draft, active, archived). No issues found.


9732-9734: Review Address Schema Fragment
The diff ends with a partial Address schema (lines 9732–9734). If this is intentional and will be extended in a follow-up change, please confirm; otherwise, complete its definition to avoid ambiguity.

@chrisgacsal chrisgacsal added release-note/ignore Ignore this change when generating release notes release-note/feature Release note: Exciting New Features labels Mar 25, 2025
@chrisgacsal chrisgacsal force-pushed the feat/addons-api branch 2 times, most recently from 9bc99b6 to 19997da Compare March 25, 2025 05:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (10)
openmeter/server/router/addon.go (2)

15-19: Minor grammatical issue in comment.

There's a small grammatical issue in the comment.

- // Create a addon
+ // Create an addon

39-43: Minor grammatical issue in comment.

There's a small grammatical issue in the comment.

- // Update a addon
+ // Update an addon
api/spec/src/productcatalog/routes.tsp (3)

221-230: Minor grammatical issue in summary.

There's a small grammatical issue in the summary.

- @summary("Create a addon")
+ @summary("Create an addon")

232-241: Minor grammatical issue in summary.

There's a small grammatical issue in the summary.

- @summary("Update a addon")
+ @summary("Update an addon")

264-274: Delete operation has documentation inconsistency.

The documentation for the delete operation refers to "addon" in one place and "a addon" in another place.

  /**
   * Soft delete addon by id.
   *
-  * Once a addon is deleted it cannot be undeleted.
+  * Once an addon is deleted it cannot be undeleted.
   */
api/openapi.yaml (5)

39-227: Endpoints for Listing and Creating Addons: Ensure Consistent Documentation and Filtering Parameters
The GET and POST endpoints for /api/v1/addons are comprehensive. The filtering parameters (e.g., includeDeleted, id, key, keyVersion, status, and currency), as well as the pagination and order-by references, are well defined. Please verify that the regex patterns and examples (such as for ULID) precisely reflect your business requirements and that any intended examples (like query usage) are clear to API consumers.


379-460: Addon Retrieval Endpoint: Check Duplicate x-go-type and Inclusion of Latest Version
The GET endpoint for /api/v1/addons/{addonId} includes a useful includeLatest query parameter, allowing clients to request the most recent version. Notice that the x-go-type attribute is specified twice for the addonId parameter; if this redundancy is not required by your code generation or validation tools, consider consolidating it.


9717-9732: AddonStatus and AddonType Enums: Descriptive and Correct
The AddonStatus enum (draft, active, archived) and the AddonType enum (single, multiple) are well defined. Note a minor typo in the AddonType description—consider changing "more then once" to "more than once" for clarity.


9732-9734: Address Schema: Verify Completeness
The Address schema appears to be in an incomplete state, with only the type and start of the properties defined. If this schema is to be used, please ensure its full definition is provided or add a TODO note for follow-up development.


16466-16472: Plan Order By Options: Consistency in Naming Convention
The update to the order-by options for plans introduces created_at (and implicitly updated_at), which differ in naming style compared to camelCase used elsewhere (e.g., createdAt). Please confirm that the naming convention for sorting parameters is consistent across your API specification.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71fa2ca and 19997da.

📒 Files selected for processing (10)
  • api/client/go/client.gen.go (2 hunks)
  • api/client/javascript/src/client/schemas.ts (1 hunks)
  • api/openapi.cloud.yaml (1 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/addon.tsp (1 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/plan.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
  • openmeter/server/router/addon.go (1 hunks)
  • openmeter/server/router/router.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • openmeter/server/router/router.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • api/spec/src/productcatalog/main.tsp
  • api/spec/src/productcatalog/addon.tsp
🧰 Additional context used
🧬 Code Definitions (1)
openmeter/server/router/addon.go (1)
openmeter/server/router/router.go (1)
  • Router (171-191)
🔇 Additional comments (29)
api/client/javascript/src/client/schemas.ts (1)

6361-6361: Good correction for consistency.

The change from create_at to created_at fixes a typo and brings this field naming in line with standard timestamp field naming patterns. This consistency improvement aligns with the changes made in other files mentioned in the summary (openapi.yaml, plan.tsp, and client.gen.go).

api/openapi.cloud.yaml (1)

15473-15479: Consistent Naming Convention Update

The renaming of create_at to created_at in the list of order-by options for plans greatly improves clarity and consistency. This change aligns with similar updates across related API specification files, ensuring that both the backend and client libraries maintain a uniform schema.

Action points:

  • Verification: Double-check that all references to this field in both backend and client implementations (e.g., in client.gen.go, schemas.ts, and plan.tsp) have been updated accordingly.
  • Documentation: Update any accompanying documentation or inline comments to reflect this corrected naming.
api/spec/src/productcatalog/plan.tsp (1)

255-255: Good fix for consistency in field naming.

The change from "create_at" to "created_at" corrects the string value for the createdAt field in the PlanOrderBy enum. This ensures consistent naming conventions across the API, which is particularly important when extending it with new features like Addons.

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

461-467: Consistent naming convention update

The constant name has been updated from CreateAt to CreatedAt to use the standard past participle form, which is more aligned with typical API field naming conventions. This change improves API consistency.


32080-32495: Updates to the embedded swagger specification

The encoded swagger specification has been updated, likely to reflect the same naming convention change from "create_at" to "created_at" and possibly to include the new Addon support mentioned in the PR objectives.

Since this is generated code, the changes look appropriate based on the upstream API specification changes.

openmeter/server/router/addon.go (6)

1-8: Package declaration and imports look good.

The imports are correctly defined and the package name follows the project's convention.


9-13: Method skeleton for ListAddons looks good.

The comment matches the corresponding endpoint definition with the correct HTTP method (GET) and path (/api/v1/addons).


21-25: Method skeleton for NextAddon looks good.

The comment and method signature correctly match the endpoint definition.


27-31: Method skeleton for DeleteAddon looks good.

The comment and method signature correctly match the endpoint definition.


33-37: Method skeleton for GetAddon looks good.

The comment and method signature correctly match the endpoint definition.


45-55: Method skeletons for ArchiveAddon and PublishAddon look good.

The comments and method signatures correctly match the endpoint definitions.

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

163-165: Route and tag definitions look good.

The route path and tag definition are appropriate for the addon resource.


166-219: List operation is well-defined.

The list operation includes appropriate query parameters for filtering, pagination, and ordering. The documentation is clear and provides useful examples.


243-262: Get operation is well-defined.

The get operation includes appropriate path and query parameters with clear documentation.


276-296: Publish and Archive operations look good.

Both operations are well-defined with appropriate path parameters and return types.


298-313: Next operation is well-defined.

The next operation includes appropriate path parameters and clear documentation about constraints.

api/openapi.yaml (13)

228-302: New Draft Addon Endpoint: Validate Parameter and Behavior
The endpoint /api/v1/addons/{addonIdOrKey}/next is clearly documented and specifies that an error should be returned if there is already a draft or if the provided identifier does not reference the latest published version. Please double-check that the backend logic aligns with these conditions.


303-378: Addon Update Endpoint: Validate Schema and Parameter Consistency
The PUT endpoint for /api/v1/addons/{addonId} correctly uses a ULID-based pattern for the addonId parameter and references the AddonReplaceUpdate schema in its request body. Ensure that the schema’s constraints are fully enforced on the backend and that similar endpoints (for retrieval or deletion) use a consistent pattern.


461-527: Soft Delete Addon Endpoint: Clear and Concise Deletion Semantics
The DELETE endpoint for /api/v1/addons/{addonId} is defined with clear instructions for a soft delete, including an appropriate 204 response and detailed error responses. The description clearly states that deletion is irreversible, so no changes are suggested here.


528-597: Addon Archive Endpoint: Verify Response Schema and Error Codes
The archive endpoint (/api/v1/addons/{addonId}/archive) is documented to archive an addon version. The response definitions and error handling appear robust. Please confirm that the backend archival process strictly adheres to these specifications.


598-667: Addon Publish Endpoint: Validate Request Handling and Consistency
The publish endpoint (/api/v1/addons/{addonId}/publish) is consistent with the other endpoints in terms of request parameters, response codes, and error handling. Ensure that the implementation aligns with these definitions and that any business logic related to publishing is thoroughly tested.


667-669: Apps Endpoint: Confirm Backward Compatibility
The inclusion of the /api/v1/apps GET endpoint appears to support legacy or extended functionality. Please ensure that its behavior remains consistent with the rest of the API and that it does not conflict with the new addons endpoints.


8826-8842: Order By Parameters: Review Definition
The parameters AddonOrderByOrdering.order and AddonOrderByOrdering.orderBy are well defined, referencing appropriate schemas for sort order and order-by field respectively. Their definitions complement the filtering and sorting capabilities.


8843-8845: Incomplete Parameter Definition: BillingProfileCustomerOverrideOrderByOrdering.order
The parameter BillingProfileCustomerOverrideOrderByOrdering.order is missing a schema and additional metadata (such as description or default value). Please complete its definition or remove it if it is not required. This comment reiterates earlier feedback on the same issue.


9474-9592: Addon Schema: Structure and Validation
The new Addon schema is comprehensive—it defines required properties such as id, name, createdAt, updatedAt, key, version, type, currency, status, and rateCards with appropriate types, patterns, and read-only indicators. Verify that computed fields (e.g., status) are correctly derived on the backend.


9592-9644: AddonCreate Schema: Ensure Required Fields and Constraints
The AddonCreate schema mandates key fields like name, key, type, currency, and rateCards, and defines useful constraints (minLength, maxLength, pattern). Double-check that these restrictions align with your business rules and data validation logic.


9644-9654: AddonOrderBy Schema: Consistent Enumeration
The AddonOrderBy schema provides a clear enum for ordering options (id, key, type, version, created_at, updated_at). Ensure these options match the fields in your data store and are consistently used throughout your API endpoints.


9655-9680: AddonPaginatedResponse Schema: Paginated Response Definition
The AddonPaginatedResponse schema clearly defines the structure of paginated results, including totalCount, page, pageSize, and the array of items. Confirm that the pagination logic in your implementation returns these fields accurately.


9680-9717: AddonReplaceUpdate Schema: Validate Update Model Integrity
The AddonReplaceUpdate schema is designed to handle updates with required fields such as name, type, and rateCards. Ensure this schema is in sync with the fields allowed to be updated in your system and that any optional fields are handled gracefully.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
api/openapi.yaml (1)

8749-8771: ⚠️ Potential issue

Incomplete Parameter Definition Detected
The parameter BillingProfileCustomerOverrideOrderByOrdering.order (lines 8769–8771) is incomplete—it lacks a schema, description, and additional metadata. This mirrors previous feedback. Please complete the definition or remove the parameter if it’s not needed.

🧹 Nitpick comments (10)
openmeter/server/router/addon.go (2)

15-16: Consider correcting the article in the comment

The comment "Create a addon" would read better as "Create an addon" to match English grammar rules for words starting with vowels.

- // Create a addon
+ // Create an addon

33-37: Consider correcting the article in the comment

The comment "Update a addon" would read better as "Update an addon" to match English grammar rules for words starting with vowels.

- // Update a addon
+ // Update an addon
api/spec/src/productcatalog/routes.tsp (3)

226-227: Maintain consistent article usage for summaries

The create operation uses "Create an addon" while other operations use just "addon" without the article. Consider standardizing this across all operations.

- @summary("Create an addon")
+ @summary("Create addon")

Alternatively, add articles to all other operations for consistency.


279-280: Consider using "an" before "addon" in documentation

The documentation uses "a addon version" which would read better as "an addon version" to match English grammar rules.

- * Publish a addon version.
+ * Publish an addon version.

290-291: Consider using "an" before "addon" in documentation

The documentation uses "a addon version" which would read better as "an addon version" to match English grammar rules.

- * Archive a addon version.
+ * Archive an addon version.
api/openapi.yaml (5)

36-38: Verify and Clarify Tag Removal
The removal of the “Apps” tag (lines 36–37) raises the question of whether this tag is now obsolete or simply relocated. Please confirm that this change aligns with the updated API domain focus on addons.


167-225: Verify POST /api/v1/addons Endpoint Details
The POST endpoint is defined with a required request body using the AddonCreate schema. Consider adding examples or further annotations in the schema if possible to aid API consumers in providing correctly structured input.


9400-9517: Examine “Addon” Schema Consistency and Grammar
The Addon schema is well‑structured, with required fields, clear patterns (e.g., ULID for id), and descriptive examples. A couple of points for consideration:

  • The property names (e.g., createdAt, updatedAt) use camelCase while related ordering enums later use snake_case (e.g., created_at); verify this naming choice for consistency.
  • The description ("Addon provide a template for extending Plans") contains a minor grammatical error; consider changing to "Addon provides a template for extending Plans."

9570-9580: Validate “AddonOrderBy” Enum Naming
The AddonOrderBy enum lists order-by fields including created_at and updated_at. Please ensure that this snake_case naming is intentional and documented (especially as the schema itself uses camelCase for similar fields).


16392-16398: Review Plan Order By Options Consistency
The updated order-by options for plans now include created_at and updated_at (lines 16392–16398). Verify that the use of snake_case here is consistent with your overall API design, especially in contrast with camelCase used elsewhere.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19997da and a6e35f3.

📒 Files selected for processing (10)
  • api/client/go/client.gen.go (2 hunks)
  • api/client/javascript/src/client/schemas.ts (1 hunks)
  • api/openapi.cloud.yaml (1 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/addon.tsp (1 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/plan.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
  • openmeter/server/router/addon.go (1 hunks)
  • openmeter/server/router/router.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • api/openapi.cloud.yaml
🚧 Files skipped from review as they are similar to previous changes (6)
  • api/spec/src/productcatalog/plan.tsp
  • api/spec/src/productcatalog/main.tsp
  • openmeter/server/router/router.go
  • api/client/go/client.gen.go
  • api/spec/src/productcatalog/addon.tsp
  • api/client/javascript/src/client/schemas.ts
🧰 Additional context used
🧬 Code Definitions (1)
openmeter/server/router/addon.go (1)
openmeter/server/router/router.go (1)
  • Router (171-191)
🔇 Additional comments (17)
openmeter/server/router/addon.go (1)

11-49: Approve REST API stubs for addon operations

The implementation stubs for the addon REST API endpoints are correctly structured with appropriate HTTP methods, path parameters, and status codes. These stubs will allow the API to be registered and return "not implemented" until the full implementation is provided in a follow-up PR.

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

236-237: Explicit route annotations added for path parameters

Good job adding the explicit route annotations for path parameters. This makes the API definition more clear and ensures the path parameters are correctly processed.


247-249: Route annotation for get method prevents default routing behavior

The get method includes an explicit route annotation that may be redundant if the TypeSpec framework automatically handles the path parameter. However, since you've used this pattern consistently across all methods, this approach is acceptable.


163-299: Approve Addons interface definition

The Addons interface is well-structured and follows the same patterns as the Plans interface, making it consistent with the rest of the API. The CRUD operations, filtering capabilities, and versioning operations (publish, archive) are comprehensive and will provide a solid foundation for addon management.


217-219:

Details

✅ Verification successful

Ensure AddonOrderBy enum is defined

The query ordering parameter uses AddonOrderBy enum type, which should be defined in the addon types definition file.


🏁 Script executed:

#!/bin/bash
# Check if AddonOrderBy enum is defined
grep -r "enum AddonOrderBy" api/spec/

Length of output: 97


AddonOrderBy enum definition verified

The enum AddonOrderBy is defined in api/spec/src/productcatalog/addon.tsp as required, so no changes are needed here.


163-299:

Details

❓ Verification inconclusive

Consider adding a "next" method for addons

The Plans interface includes a next method for creating a new draft version from a plan, but this functionality appears to be missing from the Addons interface. If addons should have similar versioning capabilities as plans, consider adding a corresponding method.


🏁 Script executed:

#!/bin/bash
# Check if there's a reason for not including a "next" method in the Addons interface
cat api/spec/src/productcatalog/addon.tsp | grep -n "version\|draft"

Length of output: 281


API Versioning Consistency: Consider Implementing a "next" Method for Addons

In the current API specification, the addons definitions (as seen in api/spec/src/productcatalog/addon.tsp) include versioning details—such as draft and version properties—but no dedicated next method exists. Since the Plans interface provides a next method to create a new draft version, please review whether introducing a similar endpoint in the Addons interface would help maintain consistency across your product catalog versioning.

api/openapi.yaml (11)

39-115: Review GET /api/v1/addons Endpoint Definition
The new GET endpoint for addons is very comprehensive. The query parameters (e.g., includeDeleted, id, key, keyVersion, status, and currency) are well‑documented and include appropriate types, patterns, and descriptions. Please verify that the deep object style for the keyVersion parameter is correctly supported in your API framework.


229-256: Review GET /api/v1/addons/{addonIdOrKey} Endpoint
This endpoint correctly accepts a path parameter that can be either an ID or key, and the addition of the optional includeLatest query parameter is a good enhancement. Ensure that backend handling clearly differentiates the two lookup modes.


313-383: Examine PUT /api/v1/addons/{addonId} Endpoint
The update endpoint uses the AddonReplaceUpdate schema for the request body, which is consistent with the creation schema but tailored for update scenarios. Verify that server‐side validation properly enforces only the allowed changes per your business logic.


389-457: Confirm DELETE (Soft Delete) Implementation
The soft delete endpoint is well‑documented. The description clearly warns that deleted addons cannot be undeleted. Ensure that the downstream logic appropriately handles resource state after deletion.


457-527: Review Archive Endpoint Details
The archive endpoint (POST /api/v1/addons/{addonId}/archive) returns a 200 status with the archived addon. Confirm that the archiving business rules (e.g., version locking) are implemented as expected in the backend.


528-597: Review Publish Endpoint & Legacy /apps Endpoint Note
The publish endpoint (POST /api/v1/addons/{addonId}/publish) is defined with consistent response handling. Also, note that the snippet continues with an /api/v1/apps endpoint (line 597). Please verify that the coexistence of apps-related endpoints remains intentional given the addon focus of this PR.


9518-9570: Review “AddonCreate” Schema
The AddonCreate schema clearly specifies the required fields (name, key, type, currency, and rateCards) and provides proper constraints. This looks good and aligns with standard resource creation models.


9580-9606: Review “AddonPaginatedResponse” Schema
The paginated response is straightforward and includes all essential pagination details (totalCount, page, pageSize, and items). This implementation is clear and should function as intended.


9606-9643: Review “AddonReplaceUpdate” Schema
This schema properly outlines the fields necessary for updating an addon while reusing common definitions (e.g., AddonType). It appears consistent with the creation model.


9643-9658: Examine Enumeration Schemas for Addon Status and Type
The AddonStatus and AddonType enums are concise, listing valid states and types. They meet the specification requirements well.


9659-9660: Clarify “Address” Schema Fragment
The snippet for the Address schema (lines 9659–9660) appears incomplete. Please confirm whether this is an intentional placeholder for future work or if the full definition should be included.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
api/openapi.yaml (1)

8769-8771: 🛠️ Refactor suggestion

Incomplete Parameter Definition: BillingProfileCustomerOverrideOrderByOrdering.order
The parameter defined on lines 8769–8771 only includes name and in attributes without a schema, description, or additional metadata. This issue was noted in previous reviews. Please either complete the parameter’s definition or remove it if it is not needed.

🧹 Nitpick comments (13)
.spectral.yaml (1)

8-9: Consider making these rule exclusions temporary.

These rules (path-params and oas3-unused-component) are disabled, presumably to facilitate the initial development of addon functionality. Consider adding a TODO comment to re-enable them once the addon implementation is complete, as they help ensure API quality.

  # Disabled due to TypeSpec conversion
  oas3-valid-schema-example: off
  no-$ref-siblings: off
- path-params: off
- oas3-unused-component: off
+ # TODO: Temporarily disabled for addon development - re-enable after implementation is complete
+ path-params: off
+ oas3-unused-component: off
openmeter/server/router/addon.go (2)

15-17: Grammar fix: "a" should be "an" before "addon".

Correct the article usage in the comment for better readability.

- // Create a addon
+ // Create an addon
// (POST /api/v1/addons)

33-35: Grammar fix: "a" should be "an" before "addon".

Correct the article usage in the comment for better readability.

- // Update a addon
+ // Update an addon
// (PUT /api/v1/addons/{addonId})
api/spec/src/productcatalog/addon.tsp (3)

66-71: Copy-paste error in effectiveTo documentation.

The documentation refers to "plan" instead of "addon".

/**
-  * The date and time when the plan is no longer effective. When not specified, the plan is effective indefinitely.
+  * The date and time when the addon is no longer effective. When not specified, the addon is effective indefinitely.
   */

73-83: Copy-paste error in status documentation.

The documentation refers to "plan" instead of "addon".

/**
-  * The status of the plan.
+  * The status of the addon.
   * Computed based on the effective start and end dates:
   *  - draft = no effectiveFrom
   *  - active = effectiveFrom <= now < effectiveTo
   *  - archived  = effectiveTo <= now
   *  - scheduled = now < effectiveFrom < effectiveTo
   */

60-64: Copy-paste error in effectiveFrom documentation.

The documentation refers to "plan" instead of "addon".

/**
-  * The date and time when the addon becomes effective. When not specified, the plan is a draft.
+  * The date and time when the addon becomes effective. When not specified, the addon is a draft.
   */
api/spec/src/productcatalog/routes.tsp (3)

279-287: Grammar fix: "a" should be "an" before "addon".

Correct the article usage in the documentation for better readability.

/**
-  * Publish a addon version.
+  * Publish an addon version.
   */

290-298: Grammar fix: "a" should be "an" before "addon".

Correct the article usage in the documentation for better readability.

/**
-  * Archive a addon version.
+  * Archive an addon version.
   */

163-299: Consider adding 'next' method for consistency with Plans interface.

The Plans interface has a next method for creating a new draft version, but the Addons interface doesn't have an equivalent. Consider adding this method for feature parity and consistency.

You might want to add a method similar to:

/**
 * Create a new draft version from addon.
 * It returns error if there is already an addon in draft or addonId does not reference the latest published version.
 */
@post
@route("/{addonIdOrKey}/next")
@operationId("nextAddon")
@summary("New draft addon")
next(
  @extension("x-go-type", "string")
  @path
  addonIdOrKey: ULIDOrKey,
): {
  @statusCode _: 201;
  @body body: Addon;
} | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
api/openapi.yaml (4)

79-89: Review KeyVersion Parameter Schema
The keyVersion parameter is defined as an object whose additional properties are arrays of integers. Please double-check that this structure meets your filtering requirements and that the backend processing is equipped to handle it.


230-256: Enhance Clarity of Path Parameter Pattern for Addon Retrieval
The regex pattern used on line 242 for the addonIdOrKey path parameter merges two alternative formats. Consider using explicit grouping (e.g., parentheses) to clearly delineate the two supported formats. This can help avoid potential misinterpretations by users or downstream systems.


9400-9459: Solid Addon Schema Definition with Minor Grammatical Note
The Addon schema is well defined with required fields, validations, and examples. One minor suggestion: in the description (line 9517), “Addon provide a template for extending Plans” could be revised to “An addon provides a template for extending plans” for improved grammar and clarity.


9570-9578: Refine AddonInstanceType Description
The AddonInstanceType enum definition is clear; however, the description can be improved for clarity and correctness. For example, consider the following revision:

-        - Single instance addons can be added to subscription only once while addons with multiple type can be added more then once.
+        - Single instance addons can be added to a subscription only once, while addons of type "multiple" can be added more than once.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a6e35f3 and bbf24c0.

📒 Files selected for processing (11)
  • .spectral.yaml (1 hunks)
  • api/client/go/client.gen.go (2 hunks)
  • api/client/javascript/src/client/schemas.ts (1 hunks)
  • api/openapi.cloud.yaml (1 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/addon.tsp (1 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/plan.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
  • openmeter/server/router/addon.go (1 hunks)
  • openmeter/server/router/router.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • api/openapi.cloud.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • api/spec/src/productcatalog/main.tsp
  • openmeter/server/router/router.go
  • api/spec/src/productcatalog/plan.tsp
  • api/client/javascript/src/client/schemas.ts
  • api/client/go/client.gen.go
🧰 Additional context used
🧬 Code Definitions (1)
openmeter/server/router/addon.go (1)
openmeter/server/router/router.go (1)
  • Router (171-191)
🔇 Additional comments (17)
openmeter/server/router/addon.go (4)

27-31: Route comment doesn't match parameter name.

The route comment shows /api/v1/addons/{addonId} but the method signature uses addonIdOrKey as the parameter name.

// Get addon
- // (GET /api/v1/addons/{addonId})
+ // (GET /api/v1/addons/{addonIdOrKey})
func (a *Router) GetAddon(w http.ResponseWriter, r *http.Request, addonIdOrKey string, params api.GetAddonParams) {

1-49: Missing addonHandler in Router struct.

The Router methods have been added for addon operations, but the corresponding handler field may be missing in the Router struct definition.

I see from past review comments that you mentioned the addonHandler field will be introduced in a follow-up PR. That's a reasonable approach for this incremental implementation.


17-19:

Details

❌ Incorrect review comment

Request body parameter missing.

The CreateAddon method doesn't include a parameter to receive the request body, unlike typical REST API patterns where creation operations require request data. Consider adding a request parameter.


🏁 Script executed:

#!/bin/bash
# Check how other create methods are implemented
grep -n "func.*Create.*" openmeter/server/router/* | grep -v "addon.go"

Length of output: 2328


Clarification: The current method signature for CreateAddon is in line with our established REST API pattern.

  • In our codebase, create endpoints (e.g., CreateCustomer, CreateBillingProfile, etc.) follow the standard signature of (w http.ResponseWriter, r *http.Request), with the request body being accessed via r.Body rather than as an extra parameter.
  • Since other similar methods do not explicitly add a body parameter, the absence of one in CreateAddon is intentional. When the endpoint is fully implemented, any required body processing should occur by reading from r.Body.

Likely an incorrect or invalid review comment.


35-37:

Details

❌ Incorrect review comment

Request body parameter missing.

The UpdateAddon method doesn't include a parameter to receive the request body, unlike typical REST API patterns where update operations require request data. Consider adding a request parameter.


🏁 Script executed:

#!/bin/bash
# Check how other update methods are implemented
grep -n "func.*Update.*" openmeter/server/router/* | grep -v "addon.go"

Length of output: 1885


Clarification on Request Body Handling

The UpdateAddon method is intentionally designed to follow the established pattern used in other update endpoints (e.g., UpdateApp, UpdateCustomer, etc.). In these routes, rather than passing the request body as an explicit parameter, the incoming data is expected to be extracted from r.Body within the function. Therefore, no additional request body parameter is needed.

Likely an incorrect or invalid review comment.

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

102-102: Fixed typo from past review.

Good correction of the createdAt property to map to "created_at" instead of "create_at" as mentioned in a previous review.

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

226-227: Consistent with suggested fixes in addon.go.

Good usage of "an addon" in the summary, which is grammatically correct.


247-247: Route path redundancy fixed.

The explicit @route("/{addonIdOrKey}") is needed here since the parameter name differs from the default path segment name. The changes in response to the past review comment are correct.


270-270: Route path redundancy fixed.

The explicit @route("/{addonId}") is needed here to ensure the correct path parameter is used. The changes in response to the past review comment are correct.

api/openapi.yaml (9)

36-38: Clarify Endpoint Inclusion: Apps vs. Addons
The tag definition on lines 36–37 for "Apps" and the endpoint /api/v1/apps (lines 597–599) appear alongside the newly introduced Addons endpoints. Since this PR is focused on basic support for Addons, please confirm whether the Apps endpoint should remain in this file or be handled in a separate change.

Also applies to: 597-599


39-67: Solid GET /api/v1/addons Endpoint Definition
The GET /api/v1/addons endpoint includes comprehensive query parameters such as includeDeleted, id, key, and keyVersion. The use of arrays for filtering on attributes like id and key is clear, and the ULID pattern with example is well defined. Please verify that this design aligns with your intended filtering logic.


313-448: Consistent Definitions for Update, Delete, and Archive Endpoints
The PUT, DELETE, and archive operations for addons are comprehensively defined with detailed response handling and error scenarios. Ensure that these operations conform to the overall API error conventions and that the response schemas are correctly referenced across the specification.


527-595: Robust Publish Endpoint Specification
The publish addon endpoint is thoroughly specified with complete response codes and content definitions. Please verify that the schema references (e.g., for successful responses and errors) are current and consistent with the rest of the API.


9518-9569: Comprehensive AddonCreate Schema
The AddonCreate model clearly enforces essential fields (such as name, key, instanceType, currency, and rateCards) for creating an addon. Verify that any optional metadata validations are handled appropriately in the backend.


9579-9614: Ordering and Pagination Schemas Look Good
The AddonOrderBy enum and AddonPaginatedResponse schema adhere to common API pagination and ordering patterns. No concerns noted here.


9614-9651: Consistent Update Model for Addons
The AddonReplaceUpdate schema provides a clear model for update operations with required fields and proper validations. Please ensure that this matches the backend update logic for addons.


9651-9658: Clear Definition for AddonStatus
The AddonStatus schema, with its enumerated values (draft, active, and archived), is straightforward. Confirm that the backend correctly interprets these statuses based on the effective dates.


16392-16398: Review Ordering Options for Plans
The ordering options for plans are updated to include fields like created_at alongside id, key, version, and updated_at. Please verify that this ordering configuration is consistent with the intended sorting behavior for plan resources.

tothandras
tothandras previously approved these changes Mar 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
openmeter/server/router/addon.go (1)

27-31: ⚠️ Potential issue

Update route comment to match method signature

The route comment specifies /api/v1/addons/{addonId} but the method signature uses addonIdOrKey as the parameter name. This inconsistency could lead to confusion during implementation.

// Get addon
-// (GET /api/v1/addons/{addonId})
+// (GET /api/v1/addons/{addonIdOrKey})
func (a *Router) GetAddon(w http.ResponseWriter, r *http.Request, addonIdOrKey string, params api.GetAddonParams) {
api/openapi.yaml (2)

8749-8771: ⚠️ Potential issue

Incomplete Parameter Definition for BillingProfileCustomerOverrideOrderByOrdering.order
The parameter definition currently specifies only name and in without providing a schema, description, or additional metadata. This issue was flagged previously. Please either complete the definition or remove the parameter if it is not needed.


9659-9660: ⚠️ Potential issue

Incomplete Address Schema Definition
The Address schema is incomplete—it only shows the type and the start of a properties section. Please either provide the full schema details or remove the incomplete definition if it is not required.

🧹 Nitpick comments (10)
openmeter/server/router/addon.go (1)

1-8: Consider adding error handling imports

While the current implementation is simple, when you implement these handlers, you'll likely need error handling packages. Consider importing packages like "errors" or "fmt" for proper error handling in future implementations.

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

226-226: Inconsistent article usage in summary

In the create method summary, you use "Create an addon" while other methods use "Update addon", "Get addon", etc. without the article. Consider standardizing the summary text format across all methods.

  @post
  @operationId("createAddon")
- @summary("Create an addon")
+ @summary("Create addon")

280-280: Fix typo in comment

There's a minor grammatical issue in the comment for the publish method.

  /**
-  * Publish a addon version.
+  * Publish an addon version.
   */

291-291: Fix typo in comment

Similar grammatical issue in the archive method comment.

  /**
-  * Archive a addon version.
+  * Archive an addon version.
   */

267-270: Fix typo in comment

There's a minor issue in the delete method comment.

  /**
   * Soft delete addon by id.
   *
-  * Once a addon is deleted it cannot be undeleted.
+  * Once an addon is deleted it cannot be undeleted.
   */

163-300:

Details

❓ Verification inconclusive

Consider adding a next method for consistency with Plans

The Plans interface has a next method for creating new draft versions, but this functionality is missing from the Addons interface. If addons are expected to follow the same versioning model as plans, consider adding a similar method.


🏁 Script executed:

#!/bin/bash
# Check if addons will have a versioning model similar to plans

# Check if Addon model has version field
echo "Checking if Addon has version field..."
grep -n "version" api/spec/src/productcatalog/addon.tsp || echo "Version field not found in addon.tsp"

# Check if AddonStatus has similar states to PlanStatus
echo "Comparing status enums..."
grep -n "enum AddonStatus" -A 10 api/spec/src/productcatalog/addon.tsp
grep -n "enum PlanStatus" -A 10 api/spec/src/productcatalog/plan.tsp

Length of output: 968


Action Required: Align Versioning Endpoints for Consistency
The Addons interface already supports versioning with a defined version field (e.g., line 43 in the Addon model). However, unlike the Plans interface—which offers a next method for creating new draft versions—the Addons interface currently lacks this functionality. Please verify whether the Addons endpoint is intended to follow the same versioning model as Plans. If so, consider adding a next method to enable the creation of new draft addon versions. Also, note that while both models share similar status values (draft, active, archived), the Plans interface includes an additional "scheduled" state that might require further consideration.

api/openapi.yaml (4)

36-597: Comprehensive Addon Endpoints Implementation
The new endpoints for managing addons (including listing, creating, retrieving, updating, deleting, archiving, and publishing) are well-structured with clear parameter definitions and response specifications. Consider adding more examples in the parameter descriptions—especially for complex query parameters like keyVersion and status—to improve clarity for API consumers. Also, please verify that the inclusion of the /api/v1/apps endpoint in the same grouping is intentional and aligns with the overall API design.


9400-9518: Review Addon Schema Definition and Grammar
The Addon schema is comprehensive and includes detailed constraints, examples, and read-only markers. However, the description ("Addon provide a template for extending Plans") has a grammatical error; consider changing it to "Addon provides a template for extending Plans" for improved clarity.


9571-9578: Grammar Note in AddonInstanceType
The description for AddonInstanceType contains a minor grammatical error ("more then once" should be "more than once").


16392-16398: Consistency in Order By Options Naming
The order by options for plans include snake_case fields (created_at and updated_at), which may be inconsistent with the camelCase naming seen elsewhere in the API. Please verify that this naming convention is intentional and aligns with your overall API design guidelines.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbf24c0 and 64178e4.

📒 Files selected for processing (11)
  • .spectral.yaml (1 hunks)
  • api/client/go/client.gen.go (2 hunks)
  • api/client/javascript/src/client/schemas.ts (1 hunks)
  • api/openapi.cloud.yaml (1 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/addon.tsp (1 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/plan.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
  • openmeter/server/router/addon.go (1 hunks)
  • openmeter/server/router/router.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • api/openapi.cloud.yaml
🚧 Files skipped from review as they are similar to previous changes (7)
  • api/spec/src/productcatalog/main.tsp
  • .spectral.yaml
  • api/spec/src/productcatalog/plan.tsp
  • openmeter/server/router/router.go
  • api/spec/src/productcatalog/addon.tsp
  • api/client/go/client.gen.go
  • api/client/javascript/src/client/schemas.ts
🧰 Additional context used
🧬 Code Definitions (1)
openmeter/server/router/addon.go (1)
openmeter/server/router/router.go (1)
  • Router (171-191)
🔇 Additional comments (4)
openmeter/server/router/addon.go (1)

1-49:

Details

✅ Verification successful

Implementation of stub handlers aligns with API spec

The addon endpoints are properly stubbed with http.StatusNotImplemented responses, which is appropriate for this initial PR. All required handlers are present and match the API specification in routes.tsp.


🏁 Script executed:

#!/bin/bash
# Verify that all addon routes defined in the OpenAPI spec have corresponding handler methods

echo "Checking OpenAPI spec for addon routes..."
grep -n "/api/v1/addons" api/openapi.yaml

echo "Checking handlers in addon.go..."
grep -n "func (a \*Router)" openmeter/server/router/addon.go

Length of output: 1099


Stub endpoints fully align with the OpenAPI spec

The verification confirms that all addon endpoints in openmeter/server/router/addon.go are correctly stubbed with http.StatusNotImplemented responses. Specifically:

  • ListAddons handles GET /api/v1/addons
  • CreateAddon handles POST /api/v1/addons
  • GetAddon handles GET /api/v1/addons/{addonIdOrKey}
  • DeleteAddon, UpdateAddon handle DELETE/PUT /api/v1/addons/{addonId}
  • ArchiveAddon handles POST /api/v1/addons/{addonId}/archive
  • PublishAddon handles POST /api/v1/addons/{addonId}/publish

All routes defined in the OpenAPI spec have corresponding handler methods, so the implementation is correct.

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

163-300: Addon interface is well-structured following existing patterns

The Addons interface follows the same pattern as the Plans interface, maintaining consistency in the API design. The operations, parameters, and return types are appropriately defined for managing addons.


235-242: Use explicit route path for update method

You've explicitly added the route path for the update method, which is good. This makes the API more consistent and easier to understand.

api/openapi.yaml (1)

9579-9587: Consistency Check for AddonOrderBy Enum
The AddonOrderBy enum includes the option type, yet the Addon schema defines the property as instanceType. Please verify if this discrepancy is intentional or if the enum should be updated to use instanceType for consistency with the schema definition.

@chrisgacsal chrisgacsal force-pushed the feat/addons-api branch 2 times, most recently from acc3306 to b38930e Compare March 25, 2025 11:17
@chrisgacsal chrisgacsal requested a review from tothandras March 25, 2025 11:19
GAlexIHU
GAlexIHU previously approved these changes Mar 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
api/openapi.yaml (2)

8756-8778: ⚠️ Potential issue

Incomplete Parameter Definition for BillingProfile Override
While the definitions for AddonOrderByOrdering.order and AddonOrderByOrdering.orderBy are complete, the parameter BillingProfileCustomerOverrideOrderByOrdering.order is incomplete—it only includes the name and in properties without a schema, default, or description. This is similar to previous feedback on this parameter. Please complete its definition to ensure consistent behavior.


9404-9665: 🛠️ Refactor suggestion

Schema Definitions & Computed Status Clarification
The Addon schema and its related models (e.g., AddonCreate, AddonInstanceType, AddonPaginatedResponse, AddonReplaceUpdate) are comprehensively defined. However, note the following:

  • The computed logic for the status property specifies:
    • draft: when no effectiveFrom is provided,
    • active: when effectiveFrom <= now < effectiveTo, and
    • archived: when effectiveTo <= now.
      Previous guidance mentioned a possible scheduled status for future effective addons. If the intent is to distinguish future effective addons (i.e. "scheduled"), then either update the computed logic (and the accompanying description) or expand the AddonStatus enum to include scheduled.
  • In addition, the Address schema appears at the end without a complete definition. Please confirm whether it is intentionally included in this specification or if it is leftover from earlier work.

Likely an incorrect or invalid review comment.

🧹 Nitpick comments (7)
api/spec/src/productcatalog/addon.tsp (3)

20-23: Fix grammatical error in the documentation.

There's a small grammatical error in the addon type documentation.

 /**
  * The type of the addon.
- * Single instance addons can be added to subscription only once while addons with multiple type can be added more then once.
+ * Single instance addons can be added to subscription only once while addons with multiple type can be added more than once.
  */

46-47: Improve wording in the property documentation.

The documentation refers to "addons" (plural) while describing a property of a single addon instance.

 /**
- * The instanceType of the addons. Can be "single" or "multiple".
+ * The instanceType of the addon. Can be "single" or "multiple".
  */

73-82: Consider marking status as computed or read-only.

The status property is described as computed based on other properties but lacks explicit indicators that it's not to be provided during creation.

 /**
  * The status of the addon.
  * Computed based on the effective start and end dates:
  *  - draft = no effectiveFrom
  *  - active = effectiveFrom <= now < effectiveTo
  *  - archived  = effectiveTo <= now
  */
 @summary("Status")
 @visibility(Lifecycle.Read)
+@extension("x-computed", true)
 status: AddonStatus;
api/spec/src/productcatalog/routes.tsp (3)

270-273: Fix grammar in documentation.

There's a grammatical error in the comment for the delete method.

 /**
  * Soft delete addon by id.
  *
- * Once a addon is deleted it cannot be undeleted.
+ * Once an addon is deleted it cannot be undeleted.
  */

284-286: Fix grammar in documentation.

There's a grammatical error in the comment for the publish method.

 /**
- * Publish a addon version.
+ * Publish an addon version.
  */

296-298: Fix grammar in documentation.

There's a grammatical error in the comment for the archive method.

 /**
- * Archive a addon version.
+ * Archive an addon version.
  */
api/openapi.yaml (1)

16397-16403: Plan Ordering Options Verification
The ordering options for plans are listed as id, key, version, created_at, and updated_at. Ensure that these options are consistent with the naming conventions and that they fully reflect the fields available for ordering in the plans endpoint. A brief confirmation or update on this matter would help maintain consistency across the API.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64178e4 and 4d0b8a8.

📒 Files selected for processing (11)
  • .spectral.yaml (1 hunks)
  • api/client/go/client.gen.go (2 hunks)
  • api/client/javascript/src/client/schemas.ts (1 hunks)
  • api/openapi.cloud.yaml (1 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/addon.tsp (1 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/plan.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (1 hunks)
  • openmeter/server/router/addon.go (1 hunks)
  • openmeter/server/router/router.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • api/openapi.cloud.yaml
🚧 Files skipped from review as they are similar to previous changes (7)
  • .spectral.yaml
  • api/spec/src/productcatalog/main.tsp
  • api/spec/src/productcatalog/plan.tsp
  • openmeter/server/router/addon.go
  • api/client/go/client.gen.go
  • openmeter/server/router/router.go
  • api/client/javascript/src/client/schemas.ts
🔇 Additional comments (4)
api/spec/src/productcatalog/addon.tsp (1)

91-102: Implementation aligns with previous feedback.

The AddonOrderBy enum implementation correctly maps createdAt to "created_at", addressing feedback from a previous review.

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

163-220: Interface structure looks good.

The Addons interface provides a comprehensive set of operations and follows patterns established in the Plans interface. The use of @extension("x-internal", true) for all methods is a good practice for new API features that might evolve.


163-307: Consider adding a "next" method.

The Plans interface has a next method for creating a new draft version from a plan, but there's no equivalent in the Addons interface. Consider whether a similar method would be useful for addons to maintain consistency between the two interfaces.

Is there a reason why addons don't need a "next" method similar to plans?

api/openapi.yaml (1)

36-605: Comprehensive Addons Endpoints Definition
The new endpoints for managing addons (list, create, get, update, delete, archive, publish) are well defined with detailed query parameters, responses, and use of reusable components (e.g. pagination, ordering). Please verify that the use of the x-internal: true flag is intended for all these operations and that the examples (e.g. patterns, descriptions) strictly align with your API design guidelines.

@chrisgacsal chrisgacsal merged commit c3f9e56 into main Mar 25, 2025
25 checks passed
@chrisgacsal chrisgacsal deleted the feat/addons-api branch March 25, 2025 14:01
This was referenced Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/feature Release note: Exciting New Features release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants