feat: add response examples to all hackathon and QR swagger endpoints
Each endpoint now shows a realistic JSON example (data wrapper + version) so developers can see the exact response shape without calling the API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e1bc336baa
commit
d014a94ea4
@@ -20,7 +20,20 @@ use crate::qr::{
|
||||
path = "/v1/qr/campaigns",
|
||||
request_body = CreateCampaignRequest,
|
||||
responses(
|
||||
(status = 201, description = "Create a QR campaign"),
|
||||
(status = 201, description = "Create a QR campaign",
|
||||
example = json!({
|
||||
"data": {
|
||||
"id": "e5f6a7b8-c9d0-1234-efab-345678901234",
|
||||
"name": "Imphnen Hackathon 2025",
|
||||
"url": "https://imphnen.dev/register",
|
||||
"is_active": false,
|
||||
"created_by": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"expires_at": "2025-12-31T23:59:59Z",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-01T00:00:00Z"
|
||||
},
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
@@ -47,7 +60,22 @@ pub async fn create_campaign_handler(
|
||||
get,
|
||||
path = "/v1/qr/campaigns",
|
||||
responses(
|
||||
(status = 200, description = "Admin: list all QR campaigns"),
|
||||
(status = 200, description = "Admin: list all QR campaigns",
|
||||
example = json!({
|
||||
"data": [
|
||||
{
|
||||
"id": "e5f6a7b8-c9d0-1234-efab-345678901234",
|
||||
"name": "Imphnen Hackathon 2025",
|
||||
"url": "https://imphnen.dev/register",
|
||||
"is_active": true,
|
||||
"created_by": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"expires_at": "2025-12-31T23:59:59Z",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-05T00:00:00Z"
|
||||
}
|
||||
],
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
@@ -72,7 +100,20 @@ pub async fn list_campaigns_handler(
|
||||
path = "/v1/qr/campaigns/{id}/activate",
|
||||
params(("id" = Uuid, Path, description = "Campaign ID")),
|
||||
responses(
|
||||
(status = 200, description = "Admin: activate a campaign"),
|
||||
(status = 200, description = "Admin: activate a campaign (deactivates all others)",
|
||||
example = json!({
|
||||
"data": {
|
||||
"id": "e5f6a7b8-c9d0-1234-efab-345678901234",
|
||||
"name": "Imphnen Hackathon 2025",
|
||||
"url": "https://imphnen.dev/register",
|
||||
"is_active": true,
|
||||
"created_by": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"expires_at": "2025-12-31T23:59:59Z",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-05T10:00:00Z"
|
||||
},
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
@@ -98,7 +139,8 @@ pub async fn activate_campaign_handler(
|
||||
path = "/v1/qr/campaigns/{id}",
|
||||
params(("id" = Uuid, Path, description = "Campaign ID")),
|
||||
responses(
|
||||
(status = 200, description = "Admin: delete a campaign"),
|
||||
(status = 200, description = "Admin: delete a campaign",
|
||||
example = json!({"message": "Campaign deleted successfully", "version": "0.3.0"})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
@@ -126,7 +168,9 @@ pub async fn delete_campaign_handler(
|
||||
post,
|
||||
path = "/v1/qr/campaigns/process-image",
|
||||
responses(
|
||||
(status = 200, description = "Process QR code image (multipart/form-data with 'file' field)"),
|
||||
(status = 200, description = "Process QR code image — send multipart/form-data with field 'file'. Returns PNG image bytes.",
|
||||
content_type = "image/png"),
|
||||
(status = 400, description = "No file provided or invalid image"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "QR - Campaigns",
|
||||
|
||||
@@ -19,7 +19,19 @@ use crate::qr::{
|
||||
get,
|
||||
path = "/v1/qr/users/me",
|
||||
responses(
|
||||
(status = 200, description = "Get my QR user profile"),
|
||||
(status = 200, description = "Get my QR user profile",
|
||||
example = json!({
|
||||
"data": {
|
||||
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"email": "user@example.com",
|
||||
"name": "Budi Santoso",
|
||||
"role": "user",
|
||||
"provider": "google",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-01T00:00:00Z"
|
||||
},
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
@@ -38,7 +50,19 @@ pub async fn get_me_handler(
|
||||
path = "/v1/qr/users/me",
|
||||
request_body = UpdateProfileRequest,
|
||||
responses(
|
||||
(status = 200, description = "Update my QR user profile"),
|
||||
(status = 200, description = "Update my QR user profile",
|
||||
example = json!({
|
||||
"data": {
|
||||
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"email": "updated@example.com",
|
||||
"name": "Budi Santoso Updated",
|
||||
"role": "user",
|
||||
"provider": "google",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-15T00:00:00Z"
|
||||
},
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
@@ -61,7 +85,30 @@ pub async fn update_me_handler(
|
||||
get,
|
||||
path = "/v1/qr/users",
|
||||
responses(
|
||||
(status = 200, description = "Admin: list all QR users"),
|
||||
(status = 200, description = "Admin: list all QR users",
|
||||
example = json!({
|
||||
"data": [
|
||||
{
|
||||
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"email": "user@example.com",
|
||||
"name": "Budi Santoso",
|
||||
"role": "user",
|
||||
"provider": "google",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-01T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "4gb96g75-6828-5673-c4gd-3d074g77bgb7",
|
||||
"email": "admin@example.com",
|
||||
"name": "Admin User",
|
||||
"role": "admin",
|
||||
"provider": "google",
|
||||
"created_at": "2024-12-01T00:00:00Z",
|
||||
"updated_at": "2024-12-01T00:00:00Z"
|
||||
}
|
||||
],
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
@@ -87,7 +134,19 @@ pub async fn list_users_handler(
|
||||
params(("id" = Uuid, Path, description = "User ID")),
|
||||
request_body = UpdateRoleRequest,
|
||||
responses(
|
||||
(status = 200, description = "Admin: update user role"),
|
||||
(status = 200, description = "Admin: update user role",
|
||||
example = json!({
|
||||
"data": {
|
||||
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"email": "user@example.com",
|
||||
"name": "Budi Santoso",
|
||||
"role": "admin",
|
||||
"provider": "google",
|
||||
"created_at": "2025-01-01T00:00:00Z",
|
||||
"updated_at": "2025-01-20T00:00:00Z"
|
||||
},
|
||||
"version": "0.3.0"
|
||||
})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
@@ -114,7 +173,8 @@ pub async fn update_role_handler(
|
||||
path = "/v1/qr/users/{id}",
|
||||
params(("id" = Uuid, Path, description = "User ID")),
|
||||
responses(
|
||||
(status = 200, description = "Admin: delete QR user"),
|
||||
(status = 200, description = "Admin: delete QR user",
|
||||
example = json!({"message": "User deleted successfully", "version": "0.3.0"})),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user