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/profile/password: patch: operationId: updatePassword requestBody: $ref: '#/components/requestBodies/PatchPassword' responses: '200': description: Password updated '400': $ref: '#/components/responses/ErrorMsg' '500': $ref: '#/components/responses/ErrorMsg' /admin/users: get: operationId: getUsers responses: '200': $ref: '#/components/responses/GetUsers' '500': $ref: '#/components/responses/ErrorMsg' post: summary: Create a new user requestBody: $ref: '#/components/requestBodies/PostUsers' responses: '200': description: User created '400': $ref: '#/components/responses/ErrorMsg' '500': $ref: '#/components/responses/ErrorMsg' delete: operationId: deleteUsers parameters: - $ref: '#/components/parameters/userIds' responses: '200': description: All users deleted '500': $ref: '#/components/responses/ErrorMsg' /admin/users/{userId}: parameters: - $ref: '#/components/parameters/userId' patch: operationId: updateUser requestBody: $ref: '#/components/requestBodies/PatchUser' responses: '200': description: User updated '400': $ref: '#/components/responses/ErrorMsg' '500': $ref: '#/components/responses/ErrorMsg' /admin/login: post: summary: Login requestBody: $ref: '#/components/requestBodies/PostLogin' responses: '200': $ref: '#/components/responses/AuthToken' '400': $ref: '#/components/responses/ErrorMsg' '500': $ref: '#/components/responses/ErrorMsg' /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' /articles: get: operationId: getArticles responses: '200': $ref: '#/components/responses/GetArticles' '500': $ref: '#/components/responses/ErrorMsg' /articles/{articleRef}: get: operationId: getArticle parameters: - $ref: '#/components/parameters/articleRef' - name: track in: query required: false description: >- When true (the default) the server records a view for this request. Pass false when the caller fetches articles server-side and reports views itself through POST /articles/{articleRef}/views, so readers are not counted twice. schema: type: boolean default: true responses: '200': $ref: '#/components/responses/GetArticle' '404': $ref: '#/components/responses/ErrorMsg' '500': $ref: '#/components/responses/ErrorMsg' /articles/{articleRef}/views: post: operationId: trackArticleView description: >- Records one view/click for the article. Fields absent from the body are taken from the HTTP request itself (client IP, User-Agent, Referer), which is the right default when the reader's browser calls this endpoint directly. Platforms that render articles server-side should pass the original reader's data in the body instead. parameters: - $ref: '#/components/parameters/articleRef' requestBody: $ref: '#/components/requestBodies/TrackView' responses: '204': description: View recorded '404': $ref: '#/components/responses/ErrorMsg' '500': $ref: '#/components/responses/ErrorMsg' /rss: get: operationId: getRss responses: '200': $ref: '#/components/responses/GetRss' '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 articleRef: name: articleRef in: path required: true description: >- Article permalink slug. Numeric ids are still accepted so links published before permalinks existed keep resolving; the response always carries the canonical slug. schema: type: string requestBodies: PatchPassword: required: true content: application/json: schema: $ref: '#/components/schemas/PatchPassword' PostUsers: required: true content: application/json: schema: $ref: '#/components/schemas/PostUsers' PatchUser: required: true content: application/json: schema: $ref: '#/components/schemas/PatchUser' PostLogin: required: true content: application/json: schema: $ref: '#/components/schemas/PostLogin' 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' TrackView: required: false content: application/json: schema: $ref: '#/components/schemas/TrackView' responses: ErrorMsg: description: Error message content: application/json: schema: {$ref: '#/components/schemas/ErrorMsg', type: object, properties: {error: {type: string}}, required: [error]} GetUsers: description: List of users content: application/json: schema: $ref: '#/components/schemas/Users' AuthToken: description: Login response content: application/json: schema: $ref: '#/components/schemas/AuthToken' 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] GetArticle: description: Article content: application/json: schema: type: object properties: data: $ref: '#/components/schemas/Article' required: [data] GetRss: description: RSS feed content: application/xml: schema: $ref: '#/components/schemas/RssFeed' schemas: ErrorMsg: type: object properties: error: {type: string} required: [error] User: type: object properties: id: type: number format: int64 x-go-type: int nick: type: string email: type: string userType: type: string required: [id, name, email, userType] UserType: type: string enum: - ADMIN - CONTENT_CREATOR Users: type: array items: $ref: '#/components/schemas/User' PostUsers: type: object properties: nick: type: string email: type: string userType: $ref: '#/components/schemas/UserType' required: [nick, email, userType] PatchUser: type: object properties: nick: type: string email: type: string userType: $ref: '#/components/schemas/UserType' required: [nick, email, userType] PatchPassword: type: object properties: password: type: string required: [password] PostLogin: type: object properties: email: type: string password: type: string required: [email, password] AuthToken: type: object properties: token: type: string expiresAt: type: string format: date-time required: [token, expiresAt] 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} author: type: string required: [id, slug, title, body, tags, author, description, 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] TrackView: type: object description: >- Optional overrides for a recorded view. Use them when the tracking request is made server-to-server on behalf of a reader; otherwise omit the body and the values are read from the HTTP request. properties: clientIp: type: string description: The reader's IP address userAgent: type: string description: The reader's User-Agent referrer: type: string description: The page that linked to the article country: type: string description: "ISO 3166-1 alpha-2 country code, if the platform resolved it" city: type: string description: "City name, if the platform resolved it" RssFeed: type: object x-go-type: feeds.Feed x-go-package: github.com/gorilla/feeds securitySchemes: {} security: []