openapi: 3.0.0 info: title: API version: 0.0.1 servers: - url: '{env}/api/v1' variables: env: default: http://localhost:8080 enum: - http://localhost:8080 paths: /admin/articles: get: operationId: getArticles responses: '200': {$ref: '#/components/responses/GetArticles'} '500': {$ref: '#/components/responses/ErrorMsg'} post: operationId: createArticle requestBody: {$ref: '#/components/requestBodies/PostArticle'} responses: '200': {description: Article created} '400': {$ref: '#/components/responses/ErrorMsg'} '409': {$ref: '#/components/responses/ErrorMsg'} '500': {$ref: '#/components/responses/ErrorMsg'} delete: operationId: deleteArticles parameters: - $ref: '#/components/parameters/articleIds' responses: '200': {description: All article deleted} '500': {$ref: '#/components/responses/ErrorMsg'} /admin/article/{articleId}: patch: operationId: updateArticle parameters: - $ref: '#/components/parameters/articleId' requestBody: {$ref: '#/components/requestBodies/PatchArticle'} responses: '200': {description: Article updated} '400': $ref: '#/components/responses/ErrorMsg' '404': $ref: '#/components/responses/ErrorMsg' '409': $ref: '#/components/responses/ErrorMsg' '500': {$ref: '#/components/responses/ErrorMsg'} /admin/article/{articleId}/publish: post: operationId: publishArticle parameters: - $ref: '#/components/parameters/articleId' responses: '200': {description: Article published status flipped} '500': {$ref: '#/components/responses/ErrorMsg'} /admin/articles/analytics: get: operationId: getArticlesAnalytics parameters: - name: days in: query required: false schema: type: integer default: 30 responses: '200': {$ref: '#/components/responses/GetArticlesAnalytics'} '500': {$ref: '#/components/responses/ErrorMsg'} /admin/article/{articleId}/analytics: get: operationId: getArticleAnalytics parameters: - $ref: '#/components/parameters/articleId' - name: days in: query required: false schema: type: integer default: 30 responses: '200': {$ref: '#/components/responses/GetArticleAnalytics'} '500': {$ref: '#/components/responses/ErrorMsg'} /admin/article/generate: post: operationId: generateArticle requestBody: {$ref: '#/components/requestBodies/PostArticleGenerate'} responses: '200': {$ref: '#/components/responses/RespGeneratedArticle'} '500': {$ref: '#/components/responses/ErrorMsg'} /admin/article/stats: get: operationId: getArticleStats responses: '200': {$ref: '#/components/responses/GetArticleStats'} '500': {$ref: '#/components/responses/ErrorMsg'} components: parameters: userIds: name: userIds in: query required: true schema: type: array items: type: string userId: name: userId in: path required: true schema: type: string articleId: name: articleId in: path required: true schema: type: integer format: int64 x-go-type: int articleIds: name: articleIds in: query required: true schema: type: array items: type: integer format: int64 x-go-type: int requestBodies: PostArticle: required: true content: application/json: schema: {$ref: '#/components/schemas/PostArticle'} PatchArticle: required: true content: application/json: schema: {$ref: '#/components/schemas/PatchArticle'} PostArticleGenerate: required: true content: application/json: schema: {$ref: '#/components/schemas/PostArticleGenerate'} responses: ErrorMsg: description: Error message content: application/json: schema: {$ref: '#/components/schemas/ErrorMsg'} GetArticles: description: List of articles content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/Articles'} required: [data] RespGeneratedArticle: description: Article generated content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/GeneratedArticle'} required: [data] GetArticleStats: description: Article stats content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/ArticleStats'} required: [data] GetArticlesAnalytics: description: Analytics for all articles content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/ArticlesAnalytics'} required: [data] GetArticleAnalytics: description: Analytics for a specific article content: application/json: schema: type: object properties: data: {$ref: '#/components/schemas/ArticleAnalytics'} required: [data] schemas: ErrorMsg: type: object properties: error: {type: string} required: [error] Article: type: object properties: id: {type: number, format: int64, x-go-type: int} slug: {type: string, description: Canonical permalink segment} title: {type: string} body: {type: string} description: {type: string} tags: {type: array, items: {type: string}} released: {type: boolean} viewCount: {type: number, format: int64, x-go-type: int, description: Lifetime recorded views} createdAt: {type: string, format: date-time} updatedAt: {type: string, format: date-time} required: [id, slug, title, body, tags, description, released, viewCount, createdAt, updatedAt] Articles: type: array items: {$ref: '#/components/schemas/Article'} PostArticle: type: object properties: title: {type: string} body: {type: string} description: {type: string} tags: {type: array, items: {type: string}} released: {type: boolean} slug: type: string description: >- Desired permalink. Normalised server-side; omit or leave empty to derive one from the title. Rejected with 409 when already taken. required: [title, body, tags, description, released] PatchArticle: type: object properties: title: {type: string} body: {type: string} description: {type: string} tags: {type: array, items: {type: string}} released: {type: boolean} slug: type: string description: >- Desired permalink. Normalised server-side; omit or leave empty to derive one from the title. Rejected with 409 when already taken. required: [title, body, tags, description, released] PostArticleGenerate: type: object properties: topic: {type: string} htmlStyles: {$ref: '#/components/schemas/HtmlStyleType'} required: [topic, htmlStyles] GeneratedArticle: type: object properties: title: {type: string} body: {type: string} description: {type: string} required: [title, body, description] HtmlStyleType: type: string enum: [RAW_HTML, TAILWIND_CSS] ArticleStats: type: object properties: total: {type: number, format: int64, x-go-type: int} released: {type: number, format: int64, x-go-type: int} required: [total, released] ArticleAnalytics: type: object properties: articleId: {type: number, format: int64, x-go-type: int} totalViews: {type: number, format: int64, x-go-type: int} uniqueViews: {type: number, format: int64, x-go-type: int} viewsByDay: {type: array, items: {$ref: '#/components/schemas/ViewsByDay'}} topReferers: {type: array, items: {$ref: '#/components/schemas/RefererStats'}} topCountries: {type: array, items: {$ref: '#/components/schemas/CountryStats'}} topUserAgents: {type: array, items: {$ref: '#/components/schemas/UserAgentStats'}} recentViews: {type: array, items: {type: string, format: date-time}} required: [articleId, totalViews, uniqueViews, viewsByDay, topReferers, topCountries, topUserAgents, recentViews] ArticlesAnalytics: type: object description: Per-article analytics keyed by article id in decimal form ("42"). additionalProperties: $ref: '#/components/schemas/ArticleAnalytics' ViewsByDay: type: object properties: date: {type: string, format: date-time} count: {type: number, format: int64, x-go-type: int} required: [date, count] RefererStats: type: object properties: referer: {type: string} count: {type: number, format: int64, x-go-type: int} required: [referer, count] CountryStats: type: object properties: country: {type: string} count: {type: number, format: int64, x-go-type: int} required: [country, count] UserAgentStats: type: object properties: userAgent: {type: string} count: {type: number, format: int64, x-go-type: int} required: [userAgent, count] securitySchemes: {} security: []