{ "swagger": "2.0", "info": { "description": "Auth API to send text messages", "title": "textsender-auth", "contact": {}, "version": "1.0" }, "host": "localhost:9080", "basePath": "/api/v1", "paths": { "/login": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Login and be given an access token (requires JWT)", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "users" ], "summary": "Login", "parameters": [ { "description": "Data to obtain a token", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.LoginAccount" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handler.LoginResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handler.LoginResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handler.LoginResponse" } } } } }, "/register": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Create a user that can send texts (requires JWT)", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "users" ], "summary": "Register user", "parameters": [ { "description": "Data to add user", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.RegisterUser" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handler.RegisterResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handler.RegisterResponse" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/handler.RegisterResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handler.RegisterResponse" } } } } }, "/service/login": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Servce login and be given an access token (requires JWT)", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "service users" ], "summary": "Service login", "parameters": [ { "description": "Data to obtain a service token", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.ServiceLoginRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handler.ServiceLoginResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handler.ServiceLoginResponse" } } } } }, "/service/register": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Create a service user that can send texts (requires JWT)", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "service users" ], "summary": "Register service user", "parameters": [ { "description": "Data to add user", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.ServiceCreationRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handler.ServiceCreationResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handler.ServiceCreationResponse" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/handler.ServiceCreationResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handler.ServiceCreationResponse" } } } } }, "/token/refresh": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Refresh token endpoint (requires JWT)", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "refresh" ], "summary": "Obtain a refresh token", "parameters": [ { "description": "Data to refresh token", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/handler.RefreshRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/handler.RefreshResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/handler.RefreshResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/handler.RefreshResponse" } } } } } }, "definitions": { "handler.LoginAccount": { "type": "object", "properties": { "password": { "type": "string" }, "username": { "type": "string" } } }, "handler.LoginResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/token.Login" } }, "message": { "type": "string" } } }, "handler.RefreshRequest": { "type": "object", "properties": { "access_token": { "type": "string" } } }, "handler.RefreshResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/token.Login" } }, "message": { "type": "string" } } }, "handler.RegisterResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/handler.RegisterResponseItem" } }, "message": { "type": "string" } } }, "handler.RegisterResponseItem": { "type": "object", "properties": { "id": { "type": "string" }, "phone_number": { "type": "string" }, "username": { "type": "string" } } }, "handler.RegisterUser": { "type": "object", "properties": { "password": { "type": "string" }, "phone_number": { "type": "string" }, "username": { "type": "string" } } }, "handler.ServiceCreationRequest": { "type": "object", "properties": { "passphrase": { "type": "string" }, "username": { "type": "string" } } }, "handler.ServiceCreationResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/user.ServiceUser" } }, "message": { "type": "string" } } }, "handler.ServiceLoginRequest": { "type": "object", "properties": { "passphrase": { "type": "string" }, "username": { "type": "string" } } }, "handler.ServiceLoginResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/token.Login" } }, "message": { "type": "string" } } }, "token.Login": { "type": "object", "properties": { "access_token": { "type": "string" }, "expires_in": { "type": "integer" }, "token_type": { "type": "string" } } }, "user.ServiceUser": { "type": "object", "properties": { "date_created": { "type": "string" }, "id": { "type": "string" }, "passphrase": { "type": "string" }, "username": { "type": "string" } } } }, "securityDefinitions": { "BearerAuth": { "description": "JWT Bearer Token", "type": "apiKey", "name": "Authorization", "in": "header" } } }