{ "swagger": "2.0", "info": { "description": "This is an auto-generated API Docs.", "title": "API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "email": "your@mail.com" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "basePath": "/api", "paths": { "/v1/book": { "put": { "security": [ { "ApiKeyAuth": [] } ], "description": "Update book.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Book" ], "summary": "update book", "parameters": [ { "description": "Book ID", "name": "id", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "Title", "name": "title", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "Author", "name": "author", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "User ID", "name": "user_id", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "Book status", "name": "book_status", "in": "body", "required": true, "schema": { "type": "integer" } }, { "description": "Book attributes", "name": "book_attrs", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.BookAttrs" } } ], "responses": { "202": { "description": "ok", "schema": { "type": "string" } } } }, "post": { "security": [ { "ApiKeyAuth": [] } ], "description": "Create a new book.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Book" ], "summary": "create a new book", "parameters": [ { "description": "Title", "name": "title", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "Author", "name": "author", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "User ID", "name": "user_id", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "Book attributes", "name": "book_attrs", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.BookAttrs" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.Book" } } } }, "delete": { "security": [ { "ApiKeyAuth": [] } ], "description": "Delete book by given ID.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Book" ], "summary": "delete book by given ID", "parameters": [ { "description": "Book ID", "name": "id", "in": "body", "required": true, "schema": { "type": "string" } } ], "responses": { "204": { "description": "ok", "schema": { "type": "string" } } } } }, "/v1/book/{id}": { "get": { "description": "Get book by given ID.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Book" ], "summary": "get book by given ID", "parameters": [ { "type": "string", "description": "Book ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.Book" } } } } }, "/v1/books": { "get": { "description": "Get all exists books.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Books" ], "summary": "get all exists books", "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { "$ref": "#/definitions/models.Book" } } } } } }, "/v1/token/renew": { "post": { "security": [ { "ApiKeyAuth": [] } ], "description": "Renew access and refresh tokens.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Token" ], "summary": "renew access and refresh tokens", "parameters": [ { "description": "Refresh token", "name": "refresh_token", "in": "body", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "ok", "schema": { "type": "string" } } } } }, "/v1/user/sign/in": { "post": { "description": "Auth user and return access and refresh token.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "User" ], "summary": "auth user and return access and refresh token", "parameters": [ { "description": "User Email", "name": "email", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "User Password", "name": "password", "in": "body", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "ok", "schema": { "type": "string" } } } } }, "/v1/user/sign/out": { "post": { "security": [ { "ApiKeyAuth": [] } ], "description": "De-authorize user and delete refresh token from Redis.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "User" ], "summary": "de-authorize user and delete refresh token from Redis", "responses": { "204": { "description": "ok", "schema": { "type": "string" } } } } }, "/v1/user/sign/up": { "post": { "description": "Create a new user.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "User" ], "summary": "create a new user", "parameters": [ { "description": "Email", "name": "email", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "Password", "name": "password", "in": "body", "required": true, "schema": { "type": "string" } }, { "description": "User role", "name": "user_role", "in": "body", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.User" } } } } } }, "definitions": { "models.Book": { "type": "object", "required": [ "author", "book_attrs", "book_status", "id", "title", "user_id" ], "properties": { "author": { "type": "string" }, "book_attrs": { "$ref": "#/definitions/models.BookAttrs" }, "book_status": { "type": "integer" }, "created_at": { "type": "string" }, "id": { "type": "string" }, "title": { "type": "string" }, "updated_at": { "type": "string" }, "user_id": { "type": "string" } } }, "models.BookAttrs": { "type": "object", "properties": { "description": { "type": "string" }, "picture": { "type": "string" }, "rating": { "type": "integer" } } }, "models.User": { "type": "object", "required": [ "email", "id", "password_hash", "user_role", "user_status" ], "properties": { "created_at": { "type": "string" }, "email": { "type": "string" }, "id": { "type": "string" }, "password_hash": { "type": "string" }, "updated_at": { "type": "string" }, "user_role": { "type": "string" }, "user_status": { "type": "integer" } } } }, "securityDefinitions": { "ApiKeyAuth": { "type": "apiKey", "name": "Authorization", "in": "header" } } }