FEAT: Added Swagger Docs
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 2m20s

This commit is contained in:
FahdShalhoub
2026-08-16 23:42:00 +03:00
parent cdc5315401
commit f26ea98b52
8 changed files with 1073 additions and 26 deletions
+352
View File
@@ -0,0 +1,352 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/categories": {
"get": {
"description": "Returns the fixed lookup set of categories a video can belong to. Values from this list are the only ones accepted in the ` + "`" + `categories` + "`" + ` field of POST /api/videos.",
"produces": [
"application/json"
],
"tags": [
"categories"
],
"summary": "List video categories",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.categoriesResponse"
}
},
"500": {
"description": "Categories could not be read from the database",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
}
}
}
},
"/api/videos": {
"post": {
"description": "Step 2 of the upload flow. Takes the storage key returned by POST /api/videos/presign — after the file has been PUT to the presigned URL — submits a MediaConvert transcoding job, and persists the video with its category links. The returned record has status \"processing\"; note that nothing currently updates that status once transcoding finishes.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"videos"
],
"summary": "Register an uploaded video",
"parameters": [
{
"description": "Video metadata plus the storage key from the presign step. title and key are required; categories must be values from GET /api/categories.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.completeRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/handlers.videoResponse"
}
},
"400": {
"description": "Request body was not valid JSON",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"422": {
"description": "title was empty, or key was missing or not a key issued by this API",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"500": {
"description": "Transcoding job could not be queued, or the video record could not be saved",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
}
}
}
},
"/api/videos/presign": {
"post": {
"description": "Step 1 of the upload flow. Returns a short-lived presigned S3 URL that the client PUTs the video file to directly, plus the storage key identifying it. Once the PUT succeeds, pass that same key to POST /api/videos to register the video and start transcoding. The file itself never passes through this API.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"videos"
],
"summary": "Create a presigned upload URL",
"parameters": [
{
"description": "Name and media type of the file to be uploaded. contentType must be a video/* type.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.presignRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.presignResponse"
}
},
"400": {
"description": "Request body was not valid JSON",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"422": {
"description": "contentType was not a video/* media type",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"500": {
"description": "Upload URL could not be issued",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
}
}
}
},
"/health": {
"get": {
"description": "Reports that the service is up and serving. Used as the ALB target group health check; it does not verify the database or S3 connections.",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Health check",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.healthResponse"
}
}
}
}
}
},
"definitions": {
"handlers.categoriesResponse": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"documentary",
"news"
]
}
}
},
"handlers.completeRequest": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"documentary",
"news"
]
},
"description": {
"type": "string",
"example": "A behind-the-scenes look at the evening bulletin."
},
"fileName": {
"type": "string",
"example": "interview-cut.mov"
},
"key": {
"type": "string",
"example": "videos/a1b2c3d4e5f6.mov"
},
"tags": {
"type": "string",
"example": "media, press, riyadh"
},
"title": {
"type": "string",
"example": "Inside the Newsroom"
}
}
},
"handlers.healthResponse": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "ok"
}
}
},
"handlers.presignRequest": {
"type": "object",
"properties": {
"contentType": {
"type": "string",
"example": "video/quicktime"
},
"fileName": {
"type": "string",
"example": "interview-cut.mov"
}
}
},
"handlers.presignResponse": {
"type": "object",
"properties": {
"key": {
"type": "string",
"example": "videos/a1b2c3d4e5f6.mov"
},
"uploadUrl": {
"type": "string",
"example": "https://raw-uploads-bucket.s3.amazonaws.com/videos/a1b2....mov?X-Amz-Signature=..."
}
}
},
"handlers.problemDetails": {
"type": "object",
"properties": {
"detail": {
"type": "string",
"example": "The 'title' field was absent or contained only whitespace. Every video needs a non-empty title."
},
"status": {
"type": "integer",
"example": 422
},
"title": {
"type": "string",
"example": "Title is required."
},
"type": {
"type": "string",
"example": "about:blank"
}
}
},
"handlers.videoResponse": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"documentary",
"news"
]
},
"createdAt": {
"type": "string"
},
"description": {
"type": "string",
"example": "A behind-the-scenes look at the evening bulletin."
},
"fileName": {
"type": "string",
"example": "interview-cut.mov"
},
"id": {
"type": "string",
"example": "0199f3a1-7c2e-7b21-9f0d-1a2b3c4d5e6f"
},
"mediaConvertJobId": {
"type": "string",
"example": "1755300000000-abcdef"
},
"sizeBytes": {
"type": "integer",
"example": 60
},
"status": {
"type": "string",
"example": "processing"
},
"storageKey": {
"type": "string",
"example": "videos/a1b2c3d4e5f6.mov"
},
"tags": {
"type": "string",
"example": "media, press, riyadh"
},
"title": {
"type": "string",
"example": "Inside the Newsroom"
},
"updatedAt": {
"type": "string"
}
}
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "",
BasePath: "/",
Schemes: []string{},
Title: "Thamanyah CMS API",
Description: "JSON API for ingesting videos into the Thamanyah catalogue. Uploads are two-step: presign, PUT the file straight to S3, then register the video to queue transcoding.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
+327
View File
@@ -0,0 +1,327 @@
{
"swagger": "2.0",
"info": {
"description": "JSON API for ingesting videos into the Thamanyah catalogue. Uploads are two-step: presign, PUT the file straight to S3, then register the video to queue transcoding.",
"title": "Thamanyah CMS API",
"contact": {},
"version": "1.0"
},
"basePath": "/",
"paths": {
"/api/categories": {
"get": {
"description": "Returns the fixed lookup set of categories a video can belong to. Values from this list are the only ones accepted in the `categories` field of POST /api/videos.",
"produces": [
"application/json"
],
"tags": [
"categories"
],
"summary": "List video categories",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.categoriesResponse"
}
},
"500": {
"description": "Categories could not be read from the database",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
}
}
}
},
"/api/videos": {
"post": {
"description": "Step 2 of the upload flow. Takes the storage key returned by POST /api/videos/presign — after the file has been PUT to the presigned URL — submits a MediaConvert transcoding job, and persists the video with its category links. The returned record has status \"processing\"; note that nothing currently updates that status once transcoding finishes.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"videos"
],
"summary": "Register an uploaded video",
"parameters": [
{
"description": "Video metadata plus the storage key from the presign step. title and key are required; categories must be values from GET /api/categories.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.completeRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/handlers.videoResponse"
}
},
"400": {
"description": "Request body was not valid JSON",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"422": {
"description": "title was empty, or key was missing or not a key issued by this API",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"500": {
"description": "Transcoding job could not be queued, or the video record could not be saved",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
}
}
}
},
"/api/videos/presign": {
"post": {
"description": "Step 1 of the upload flow. Returns a short-lived presigned S3 URL that the client PUTs the video file to directly, plus the storage key identifying it. Once the PUT succeeds, pass that same key to POST /api/videos to register the video and start transcoding. The file itself never passes through this API.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"videos"
],
"summary": "Create a presigned upload URL",
"parameters": [
{
"description": "Name and media type of the file to be uploaded. contentType must be a video/* type.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.presignRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.presignResponse"
}
},
"400": {
"description": "Request body was not valid JSON",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"422": {
"description": "contentType was not a video/* media type",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
},
"500": {
"description": "Upload URL could not be issued",
"schema": {
"$ref": "#/definitions/handlers.problemDetails"
}
}
}
}
},
"/health": {
"get": {
"description": "Reports that the service is up and serving. Used as the ALB target group health check; it does not verify the database or S3 connections.",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Health check",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.healthResponse"
}
}
}
}
}
},
"definitions": {
"handlers.categoriesResponse": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"documentary",
"news"
]
}
}
},
"handlers.completeRequest": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"documentary",
"news"
]
},
"description": {
"type": "string",
"example": "A behind-the-scenes look at the evening bulletin."
},
"fileName": {
"type": "string",
"example": "interview-cut.mov"
},
"key": {
"type": "string",
"example": "videos/a1b2c3d4e5f6.mov"
},
"tags": {
"type": "string",
"example": "media, press, riyadh"
},
"title": {
"type": "string",
"example": "Inside the Newsroom"
}
}
},
"handlers.healthResponse": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "ok"
}
}
},
"handlers.presignRequest": {
"type": "object",
"properties": {
"contentType": {
"type": "string",
"example": "video/quicktime"
},
"fileName": {
"type": "string",
"example": "interview-cut.mov"
}
}
},
"handlers.presignResponse": {
"type": "object",
"properties": {
"key": {
"type": "string",
"example": "videos/a1b2c3d4e5f6.mov"
},
"uploadUrl": {
"type": "string",
"example": "https://raw-uploads-bucket.s3.amazonaws.com/videos/a1b2....mov?X-Amz-Signature=..."
}
}
},
"handlers.problemDetails": {
"type": "object",
"properties": {
"detail": {
"type": "string",
"example": "The 'title' field was absent or contained only whitespace. Every video needs a non-empty title."
},
"status": {
"type": "integer",
"example": 422
},
"title": {
"type": "string",
"example": "Title is required."
},
"type": {
"type": "string",
"example": "about:blank"
}
}
},
"handlers.videoResponse": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"documentary",
"news"
]
},
"createdAt": {
"type": "string"
},
"description": {
"type": "string",
"example": "A behind-the-scenes look at the evening bulletin."
},
"fileName": {
"type": "string",
"example": "interview-cut.mov"
},
"id": {
"type": "string",
"example": "0199f3a1-7c2e-7b21-9f0d-1a2b3c4d5e6f"
},
"mediaConvertJobId": {
"type": "string",
"example": "1755300000000-abcdef"
},
"sizeBytes": {
"type": "integer",
"example": 60
},
"status": {
"type": "string",
"example": "processing"
},
"storageKey": {
"type": "string",
"example": "videos/a1b2c3d4e5f6.mov"
},
"tags": {
"type": "string",
"example": "media, press, riyadh"
},
"title": {
"type": "string",
"example": "Inside the Newsroom"
},
"updatedAt": {
"type": "string"
}
}
}
}
}
+240
View File
@@ -0,0 +1,240 @@
basePath: /
definitions:
handlers.categoriesResponse:
properties:
categories:
example:
- documentary
- news
items:
type: string
type: array
type: object
handlers.completeRequest:
properties:
categories:
example:
- documentary
- news
items:
type: string
type: array
description:
example: A behind-the-scenes look at the evening bulletin.
type: string
fileName:
example: interview-cut.mov
type: string
key:
example: videos/a1b2c3d4e5f6.mov
type: string
tags:
example: media, press, riyadh
type: string
title:
example: Inside the Newsroom
type: string
type: object
handlers.healthResponse:
properties:
status:
example: ok
type: string
type: object
handlers.presignRequest:
properties:
contentType:
example: video/quicktime
type: string
fileName:
example: interview-cut.mov
type: string
type: object
handlers.presignResponse:
properties:
key:
example: videos/a1b2c3d4e5f6.mov
type: string
uploadUrl:
example: https://raw-uploads-bucket.s3.amazonaws.com/videos/a1b2....mov?X-Amz-Signature=...
type: string
type: object
handlers.problemDetails:
properties:
detail:
example: The 'title' field was absent or contained only whitespace. Every
video needs a non-empty title.
type: string
status:
example: 422
type: integer
title:
example: Title is required.
type: string
type:
example: about:blank
type: string
type: object
handlers.videoResponse:
properties:
categories:
example:
- documentary
- news
items:
type: string
type: array
createdAt:
type: string
description:
example: A behind-the-scenes look at the evening bulletin.
type: string
fileName:
example: interview-cut.mov
type: string
id:
example: 0199f3a1-7c2e-7b21-9f0d-1a2b3c4d5e6f
type: string
mediaConvertJobId:
example: 1755300000000-abcdef
type: string
sizeBytes:
example: 60
type: integer
status:
example: processing
type: string
storageKey:
example: videos/a1b2c3d4e5f6.mov
type: string
tags:
example: media, press, riyadh
type: string
title:
example: Inside the Newsroom
type: string
updatedAt:
type: string
type: object
info:
contact: {}
description: 'JSON API for ingesting videos into the Thamanyah catalogue. Uploads
are two-step: presign, PUT the file straight to S3, then register the video to
queue transcoding.'
title: Thamanyah CMS API
version: "1.0"
paths:
/api/categories:
get:
description: Returns the fixed lookup set of categories a video can belong to.
Values from this list are the only ones accepted in the `categories` field
of POST /api/videos.
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.categoriesResponse'
"500":
description: Categories could not be read from the database
schema:
$ref: '#/definitions/handlers.problemDetails'
summary: List video categories
tags:
- categories
/api/videos:
post:
consumes:
- application/json
description: Step 2 of the upload flow. Takes the storage key returned by POST
/api/videos/presign — after the file has been PUT to the presigned URL — submits
a MediaConvert transcoding job, and persists the video with its category links.
The returned record has status "processing"; note that nothing currently updates
that status once transcoding finishes.
parameters:
- description: Video metadata plus the storage key from the presign step. title
and key are required; categories must be values from GET /api/categories.
in: body
name: request
required: true
schema:
$ref: '#/definitions/handlers.completeRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/handlers.videoResponse'
"400":
description: Request body was not valid JSON
schema:
$ref: '#/definitions/handlers.problemDetails'
"422":
description: title was empty, or key was missing or not a key issued by
this API
schema:
$ref: '#/definitions/handlers.problemDetails'
"500":
description: Transcoding job could not be queued, or the video record could
not be saved
schema:
$ref: '#/definitions/handlers.problemDetails'
summary: Register an uploaded video
tags:
- videos
/api/videos/presign:
post:
consumes:
- application/json
description: Step 1 of the upload flow. Returns a short-lived presigned S3 URL
that the client PUTs the video file to directly, plus the storage key identifying
it. Once the PUT succeeds, pass that same key to POST /api/videos to register
the video and start transcoding. The file itself never passes through this
API.
parameters:
- description: Name and media type of the file to be uploaded. contentType must
be a video/* type.
in: body
name: request
required: true
schema:
$ref: '#/definitions/handlers.presignRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.presignResponse'
"400":
description: Request body was not valid JSON
schema:
$ref: '#/definitions/handlers.problemDetails'
"422":
description: contentType was not a video/* media type
schema:
$ref: '#/definitions/handlers.problemDetails'
"500":
description: Upload URL could not be issued
schema:
$ref: '#/definitions/handlers.problemDetails'
summary: Create a presigned upload URL
tags:
- videos
/health:
get:
description: Reports that the service is up and serving. Used as the ALB target
group health check; it does not verify the database or S3 connections.
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.healthResponse'
summary: Health check
tags:
- system
swagger: "2.0"