{ "swagger": "2.0", "info": { "description": "This is a simple Rest API Server Template that implements some basic User and Authentication patterns to help you get started and bootstrap your next project!.", "title": "Go API Templates", "contact": { "name": "Don't" }, "license": { "name": "MIT" }, "version": "1.0" }, "basePath": "/api", "paths": { "/status": { "get": { "produces": [ "application/json" ], "tags": [ "Base" ], "summary": "Retrieves the basic information about the API", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "$ref": "#/definitions/types.ApiSummary" } } } ] } } } } }, "/v1/admin/users": { "get": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "Admin: Users" ], "summary": "Gets all users from the database", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "type": "array", "items": { "$ref": "#/definitions/types.UserOut" } } } } ] } } } }, "post": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "Admin: Users" ], "summary": "Create a new user", "parameters": [ { "description": "User Data", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/types.UserCreate" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "$ref": "#/definitions/types.UserOut" } } } ] } } } } }, "/v1/admin/users/{id}": { "get": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "Admin: Users" ], "summary": "Get a user from the database", "parameters": [ { "type": "string", "description": "User ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "$ref": "#/definitions/types.UserOut" } } } ] } } } }, "put": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "Admin: Users" ], "summary": "Update a User", "parameters": [ { "type": "string", "description": "User ID", "name": "id", "in": "path", "required": true }, { "description": "User Data", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/types.UserUpdate" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "$ref": "#/definitions/types.UserOut" } } } ] } } } }, "delete": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "Admin: Users" ], "summary": "Delete a User", "parameters": [ { "type": "string", "description": "User ID", "name": "id", "in": "path", "required": true } ], "responses": { "204": { "description": "" } } } }, "/v1/users/login": { "post": { "consumes": [ "application/x-www-form-urlencoded", "application/json" ], "produces": [ "application/json" ], "tags": [ "Authentication" ], "summary": "User Login", "parameters": [ { "type": "string", "example": "admin@admin.com", "description": "string", "name": "username", "in": "formData" }, { "type": "string", "example": "admin", "description": "string", "name": "password", "in": "formData" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/types.TokenResponse" } } } } }, "/v1/users/logout": { "post": { "security": [ { "Bearer": [] } ], "tags": [ "Authentication" ], "summary": "User Logout", "responses": { "204": { "description": "" } } } }, "/v1/users/refresh": { "get": { "security": [ { "Bearer": [] } ], "description": "handleAuthRefresh returns a handler that will issue a new token from an existing token.\nThis does not validate that the user still exists within the database.", "tags": [ "Authentication" ], "summary": "User Token Refresh", "responses": { "200": { "description": "" } } } }, "/v1/users/self": { "get": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "User" ], "summary": "Get the current user", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "$ref": "#/definitions/types.UserOut" } } } ] } } } }, "put": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "User" ], "summary": "Update the current user", "parameters": [ { "description": "User Data", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/types.UserUpdate" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/server.Result" }, { "type": "object", "properties": { "item": { "$ref": "#/definitions/types.UserUpdate" } } } ] } } } } }, "/v1/users/self/password": { "put": { "security": [ { "Bearer": [] } ], "produces": [ "application/json" ], "tags": [ "User" ], "summary": "Update the current user's password // TODO:", "responses": { "204": { "description": "" } } } } }, "definitions": { "server.Result": { "type": "object", "properties": { "details": {}, "error": { "type": "boolean" }, "item": {}, "message": { "type": "string" } } }, "types.ApiSummary": { "type": "object", "properties": { "health": { "type": "boolean" }, "message": { "type": "string" }, "title": { "type": "string" }, "versions": { "type": "array", "items": { "type": "string" } } } }, "types.TokenResponse": { "type": "object", "properties": { "expiresAt": { "type": "string" }, "token": { "type": "string" } } }, "types.UserCreate": { "type": "object", "properties": { "email": { "type": "string" }, "isSuperuser": { "type": "boolean" }, "name": { "type": "string" }, "password": { "type": "string" } } }, "types.UserOut": { "type": "object", "properties": { "email": { "type": "string" }, "id": { "type": "string" }, "isSuperuser": { "type": "boolean" }, "name": { "type": "string" } } }, "types.UserUpdate": { "type": "object", "properties": { "email": { "type": "string" }, "name": { "type": "string" } } } }, "securityDefinitions": { "Bearer": { "description": "\"Type 'Bearer TOKEN' to correctly set the API Key\"", "type": "apiKey", "name": "Authorization", "in": "header" } } }