Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Reviews Endpoints
* Product reviews and ratings endpoints
*/
import type { ApiEndpoint } from '@/types/api-docs';
export const reviewsEndpoints: ApiEndpoint[] = [
{
id: 'reviews-list',
method: 'GET',
path: '/api/reviews',
summary: 'List product reviews',
description: 'Returns reviews for a product',
category: 'reviews',
requiresAuth: false,
parameters: [
{ name: 'productId', type: 'number', required: true, location: 'query', description: 'Product ID' },
{ name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
{ name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page' },
],
responses: [
{
status: 200,
description: 'List of reviews',
example: {
success: true,
data: {
reviews: [
{ id: 1, productId: 101, rating: 5, title: 'Great product!', content: 'Love it!', userName: 'John', createdAt: '2024-01-15T10:00:00Z' },
],
averageRating: 4.5,
totalReviews: 25,
pagination: { page: 1, limit: 10, total: 25, totalPages: 3 },
},
},
},
],
},
{
id: 'reviews-create',
method: 'POST',
path: '/api/reviews',
summary: 'Create review',
description: 'Creates a new product review',
category: 'reviews',
requiresAuth: true,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'productId', type: 'number', required: true, description: 'Product ID' },
{ name: 'rating', type: 'number', required: true, description: 'Rating (1-5)' },
{ name: 'title', type: 'string', required: false, description: 'Review title' },
{ name: 'content', type: 'string', required: true, description: 'Review content' },
],
},
responses: [
{
status: 201,
description: 'Review created',
example: {
success: true,
data: { id: 1, productId: 101, rating: 5, title: 'Great!', content: 'Love it!', createdAt: '2024-01-15T10:00:00Z' },
},
},
{
status: 400,
description: 'Already reviewed this product',
example: { success: false, error: { code: 'VALIDATION_ERROR', message: 'You have already reviewed this product' } },
},
{
status: 401,
description: 'Not authenticated',
example: { success: false, error: { code: 'UNAUTHORIZED', message: 'Authentication required' } },
},
],
},
{
id: 'reviews-update',
method: 'PUT',
path: '/api/reviews/{reviewId}',
summary: 'Update review',
description: 'Updates an existing review',
category: 'reviews',
requiresAuth: true,
parameters: [
{ name: 'reviewId', type: 'number', required: true, location: 'path', description: 'Review ID' },
],
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'rating', type: 'number', required: false, description: 'Rating (1-5)' },
{ name: 'title', type: 'string', required: false, description: 'Review title' },
{ name: 'content', type: 'string', required: false, description: 'Review content' },
],
},
responses: [
{
status: 200,
description: 'Review updated',
example: { success: true, data: { id: 1, rating: 4, title: 'Updated title', content: 'Updated review' } },
},
{
status: 404,
description: 'Review not found',
example: { success: false, error: { code: 'NOT_FOUND', message: 'Review not found' } },
},
],
},
{
id: 'reviews-delete',
method: 'DELETE',
path: '/api/reviews/{reviewId}',
summary: 'Delete review',
description: 'Deletes a review',
category: 'reviews',
requiresAuth: true,
parameters: [
{ name: 'reviewId', type: 'number', required: true, location: 'path', description: 'Review ID' },
],
responses: [
{
status: 200,
description: 'Review deleted',
example: { success: true, data: { message: 'Review deleted successfully' } },
},
{
status: 404,
description: 'Review not found',
example: { success: false, error: { code: 'NOT_FOUND', message: 'Review not found' } },
},
],
},
{
id: 'product-reviews-list',
method: 'GET',
path: '/api/products/{id}/reviews',
summary: 'Get product reviews with stats',
description: 'Returns reviews for a specific product with rating statistics and distribution',
category: 'reviews',
requiresAuth: false,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Product ID' },
{ name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
{ name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page (max 50)' },
{ name: 'sortBy', type: 'string', required: false, location: 'query', description: 'Sort order', enum: ['recent', 'helpful', 'rating_high', 'rating_low'] },
{ name: 'rating', type: 'number', required: false, location: 'query', description: 'Filter by rating (1-5)' },
],
responses: [
{
status: 200,
description: 'Reviews with stats',
example: {
success: true,
data: {
reviews: [],
stats: { averageRating: 4.5, totalReviews: 100, distribution: { '1': 5, '2': 10, '3': 15, '4': 30, '5': 40 } },
pagination: { page: 1, limit: 10, total: 100 },
},
},
},
{ status: 400, description: 'Invalid product ID or parameters' },
],
},
{
id: 'product-reviews-create',
method: 'POST',
path: '/api/products/{id}/reviews',
summary: 'Submit product review',
description: 'Submits a review for a specific product',
category: 'reviews',
requiresAuth: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Product ID' },
],
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'rating', type: 'number', required: true, description: 'Rating (1-5)' },
{ name: 'comment', type: 'string', required: false, description: 'Review comment (10-2000 chars)' },
],
example: { rating: 5, comment: 'Great product! Highly recommended.' },
},
responses: [
{ status: 201, description: 'Review submitted' },
{ status: 400, description: 'Validation failed' },
{ status: 401, description: 'Authentication required' },
{ status: 404, description: 'Product not found' },
{ status: 409, description: 'Already reviewed this product' },
],
},
];
|