UNPKG

medusa-plugin-product-reviews-kvy

Version:

Plugins Product Reviews for Medusa ecommerce server.

377 lines (374 loc) 9.84 kB
{ "swagger": "2.0", "info": { "version": "1.0.0", "title": "Medusa Plugin Product Review API", "description": "API for managing plugin product review in Medusa" }, "basePath": "/", "schemes": ["http", "https"], "paths": { "/store/products/{productId}/reviews": { "post": { "summary": "Create a review for a product", "description": "Allows a verified user to post a review for a specific product", "tags": ["Product Review"], "parameters": [ { "name": "productId", "in": "path", "description": "ID of the product to post a review for", "required": true, "type": "string" }, { "name": "ReviewInput", "in": "body", "description": "Review data to be added", "required": true, "schema": { "$ref": "#/definitions/ReviewInput" } } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/ProductReview" } } } } }, "/store/products/{id}/reviews": { "get": { "summary": "Get product reviews by product ID", "description": "Returns reviews for a specific product", "parameters": [ { "name": "id", "in": "path", "description": "ID of the product to retrieve reviews for", "required": true, "type": "string" }, { "name": "page", "in": "query", "description": "Page number", "required": true, "type": "string" }, { "name": "limit", "in": "query", "description": "Number of reviews per page", "required": true, "type": "string" }, { "name": "approved", "in": "query", "description": "Filter by approval status (true/false)", "required": false, "type": "string" } ], "responses": { "200": { "description": "Successful operation", "schema": { "type": "object", "properties": { "reviews": { "type": "array", "items": { "$ref": "#/definitions/ProductReview" } }, "total": { "type": "number" } } } } }, "tags": ["Product Review"] } }, "/store/orders/{orderId}/reviews": { "get": { "summary": "Get reviews by order ID", "description": "Returns reviews for a specific order", "parameters": [ { "name": "orderId", "in": "path", "description": "ID of the order to retrieve reviews for", "required": true, "type": "string" } ], "responses": { "200": { "description": "Successful operation", "schema": { "type": "array", "items": { "$ref": "#/definitions/ProductReview" } } } }, "tags": ["Product Review"] } }, "/store/products/{id}/average-reviews": { "get": { "summary": "Get average reviews by product ID", "description": "Returns average reviews for a specific product based on approval status", "parameters": [ { "name": "id", "in": "path", "description": "ID of the product to retrieve average reviews for", "required": true, "type": "string" }, { "name": "approved", "in": "query", "description": "Filter by approval status (all/true)", "required": true, "type": "string", "enum": ["all", "true"] } ], "responses": { "200": { "description": "Successful operation", "schema": { "type": "object", "properties": { "reviews": { "type": "array", "items": { "$ref": "#/definitions/ProductReview" } }, "total": { "type": "number" }, "average": { "type": "number" } } } } }, "tags": ["Product Review"] } }, "/admin/products/{productId}/reviews/{reviewId}/approve": { "put": { "summary": "Approve a product review", "description": "Approve or disapprove a specific product review by ID.", "tags": ["Admin"], "parameters": [ { "name": "productId", "in": "path", "description": "ID of the product", "required": true, "type": "string" }, { "name": "reviewId", "in": "path", "description": "ID of the review", "required": true, "type": "string" }, { "name": "Approved", "in": "body", "description": "Whether the review should be approved or not", "required": true, "schema": { "$ref": "#/definitions/Approved" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/ProductReview" } } } }, "delete": { "summary": "Delete a product review", "description": "Delete a specific product review by ID.", "tags": ["Admin"], "parameters": [ { "name": "productId", "in": "path", "description": "ID of the product", "required": true, "type": "string" }, { "name": "reviewId", "in": "path", "description": "ID of the review", "required": true, "type": "string" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/ProductReview" } }, "404": { "description": "Not Found" }, "500": { "description": "Internal Server Error" } } } } }, "definitions": { "ProductReview": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "stars": { "type": "number" }, "content": { "type": "string" }, "medias": { "type": "array", "items": { "$ref": "#/definitions/Image" } }, "approved": { "type": "boolean" }, "product_id": { "type": "string" }, "customer_id": { "type": "string" }, "order_id": { "type": "string" }, "product": { "type": "object" }, "customer": { "type": "object" }, "order": { "type": "object" } } }, "Approved": { "type": "object", "properties": { "approved": { "type": "boolean" } } }, "Image": { "title": "Image", "description": "Images holds a reference to a URL at which the image file can be found.", "type": "object", "required": [ "created_at", "deleted_at", "id", "metadata", "updated_at", "url" ], "properties": { "id": { "type": "string", "description": "The image's ID", "example": "img_01G749BFYR6T8JTVW6SGW3K3E6" }, "url": { "description": "The URL at which the image file can be found.", "type": "string", "format": "uri" }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", "format": "date-time" }, "updated_at": { "description": "The date with timezone at which the resource was updated.", "type": "string", "format": "date-time" }, "deleted_at": { "description": "The date with timezone at which the resource was deleted.", "type": "string", "format": "date-time" }, "metadata": { "description": "An optional key-value map with additional details", "type": "object", "example": { "car": "white" } } } }, "ReviewInput": { "type": "object", "properties": { "name": { "type": "string" }, "orderId": { "type": "string" }, "content": { "type": "string" }, "stars": { "type": "number" }, "medias": { "type": "array", "items": { "$ref": "#/definitions/Image" } } }, "required": ["name", "orderId", "content", "stars", "medias"] } } }