feat(docs): add admin-only GET endpoint to list archived episodes with Swagger documentation

This commit is contained in:
Nik Afiq 2025-12-17 23:07:08 +09:00
parent 17f60c9ccb
commit 77c0c1586b
3 changed files with 226 additions and 0 deletions

View File

@ -16,6 +16,39 @@ const docTemplate = `{
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/archive": {
"get": {
"description": "List all rows from ` + "`" + `current_archive` + "`" + ` (admin only).",
"produces": [
"application/json"
],
"tags": [
"archive"
],
"summary": "List archive",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/httpapi.ArchiveResponse"
}
}
},
"403": {
"description": "admin only",
"schema": {
"$ref": "#/definitions/httpapi.HTTPError"
}
},
"500": {
"description": "list failed",
"schema": {
"$ref": "#/definitions/httpapi.HTTPError"
}
}
}
},
"post": {
"description": "Move one or many IDs from ` + "`" + `current` + "`" + ` to ` + "`" + `current_archive` + "`" + `.",
"consumes": [
@ -406,6 +439,47 @@ const docTemplate = `{
}
},
"definitions": {
"httpapi.ArchiveResponse": {
"type": "object",
"properties": {
"current_ep": {
"type": "boolean",
"example": false
},
"date_archived": {
"type": "string",
"example": "2024-03-01T15:04:05Z"
},
"date_created": {
"type": "string",
"example": "2024-02-01T15:04:05Z"
},
"ep_num": {
"type": "integer",
"example": 1
},
"ep_title": {
"type": "string",
"example": "Pilot"
},
"id": {
"type": "integer",
"example": 123
},
"playback_length": {
"type": "string",
"example": "00:24:00"
},
"season_name": {
"type": "string",
"example": "Season 1"
},
"start_time": {
"type": "string",
"example": "10:00:00"
}
}
},
"httpapi.CreateShowReq": {
"type": "object",
"required": [
@ -544,6 +618,15 @@ const docTemplate = `{
"httpapi.FirebaseOAuthRes": {
"type": "object",
"properties": {
"admin": {
"type": "boolean",
"example": true
},
"custom_claims": {
"description": "CustomClaims echoes back custom claims; only include non-sensitive claims.",
"type": "object",
"additionalProperties": true
},
"email": {
"type": "string",
"example": "user@example.com"

View File

@ -14,6 +14,39 @@
"basePath": "/",
"paths": {
"/api/v1/archive": {
"get": {
"description": "List all rows from `current_archive` (admin only).",
"produces": [
"application/json"
],
"tags": [
"archive"
],
"summary": "List archive",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/httpapi.ArchiveResponse"
}
}
},
"403": {
"description": "admin only",
"schema": {
"$ref": "#/definitions/httpapi.HTTPError"
}
},
"500": {
"description": "list failed",
"schema": {
"$ref": "#/definitions/httpapi.HTTPError"
}
}
}
},
"post": {
"description": "Move one or many IDs from `current` to `current_archive`.",
"consumes": [
@ -404,6 +437,47 @@
}
},
"definitions": {
"httpapi.ArchiveResponse": {
"type": "object",
"properties": {
"current_ep": {
"type": "boolean",
"example": false
},
"date_archived": {
"type": "string",
"example": "2024-03-01T15:04:05Z"
},
"date_created": {
"type": "string",
"example": "2024-02-01T15:04:05Z"
},
"ep_num": {
"type": "integer",
"example": 1
},
"ep_title": {
"type": "string",
"example": "Pilot"
},
"id": {
"type": "integer",
"example": 123
},
"playback_length": {
"type": "string",
"example": "00:24:00"
},
"season_name": {
"type": "string",
"example": "Season 1"
},
"start_time": {
"type": "string",
"example": "10:00:00"
}
}
},
"httpapi.CreateShowReq": {
"type": "object",
"required": [
@ -542,6 +616,15 @@
"httpapi.FirebaseOAuthRes": {
"type": "object",
"properties": {
"admin": {
"type": "boolean",
"example": true
},
"custom_claims": {
"description": "CustomClaims echoes back custom claims; only include non-sensitive claims.",
"type": "object",
"additionalProperties": true
},
"email": {
"type": "string",
"example": "user@example.com"

View File

@ -1,5 +1,35 @@
basePath: /
definitions:
httpapi.ArchiveResponse:
properties:
current_ep:
example: false
type: boolean
date_archived:
example: "2024-03-01T15:04:05Z"
type: string
date_created:
example: "2024-02-01T15:04:05Z"
type: string
ep_num:
example: 1
type: integer
ep_title:
example: Pilot
type: string
id:
example: 123
type: integer
playback_length:
example: "00:24:00"
type: string
season_name:
example: Season 1
type: string
start_time:
example: "10:00:00"
type: string
type: object
httpapi.CreateShowReq:
properties:
ep_num:
@ -99,6 +129,14 @@ definitions:
type: object
httpapi.FirebaseOAuthRes:
properties:
admin:
example: true
type: boolean
custom_claims:
additionalProperties: true
description: CustomClaims echoes back custom claims; only include non-sensitive
claims.
type: object
email:
example: user@example.com
type: string
@ -169,6 +207,28 @@ info:
version: "1.0"
paths:
/api/v1/archive:
get:
description: List all rows from `current_archive` (admin only).
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/httpapi.ArchiveResponse'
type: array
"403":
description: admin only
schema:
$ref: '#/definitions/httpapi.HTTPError'
"500":
description: list failed
schema:
$ref: '#/definitions/httpapi.HTTPError'
summary: List archive
tags:
- archive
post:
consumes:
- application/json