add host and minglar admin APIs for registration, login, and retrieval of host details
This commit is contained in:
624
swagger.json
624
swagger.json
@@ -1,631 +1,27 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"paths": {},
|
||||
"info": {
|
||||
"title": "Minglar API",
|
||||
"description": "NestJS Backend for Minglar with AWS Lambda endpoints",
|
||||
"description": "NestJS Backend for Minglar with Lambda-ready endpoints",
|
||||
"version": "1.0.0",
|
||||
"contact": {
|
||||
"name": "API Support"
|
||||
}
|
||||
"contact": {}
|
||||
},
|
||||
"tags": [],
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://api.minglar.com",
|
||||
"description": "Production Server"
|
||||
},
|
||||
{
|
||||
"url": "http://localhost:3000",
|
||||
"description": "Local Development Server"
|
||||
"url": "http://localhost:3000/",
|
||||
"description": "Local Server"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "Host",
|
||||
"description": "Host management endpoints"
|
||||
},
|
||||
{
|
||||
"name": "Authentication",
|
||||
"description": "Authentication and authorization endpoints"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/host": {
|
||||
"get": {
|
||||
"tags": ["Host"],
|
||||
"summary": "Get all hosts",
|
||||
"description": "Retrieves a list of all host headers with basic information",
|
||||
"operationId": "getHosts",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/HostHeader"
|
||||
}
|
||||
},
|
||||
"example": [
|
||||
{
|
||||
"hostParent": "Example Host",
|
||||
"hostRefNumber": "HOST001",
|
||||
"hostStatusDisplay": "Active",
|
||||
"accountManager": "John Doe"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/host/registration": {
|
||||
"post": {
|
||||
"tags": ["Authentication"],
|
||||
"summary": "Register a new host",
|
||||
"description": "Initiates host registration by sending an OTP to the provided email address",
|
||||
"operationId": "registrationOfHost",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/RegistrationRequest"
|
||||
},
|
||||
"example": {
|
||||
"email": "host@example.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OTP sent successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/SuccessResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"message": "OTP sent successfully.",
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request - Email is required",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "Email is required",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 400,
|
||||
"description": "Email is required",
|
||||
"statusCode": 400
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "User already registered",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "User is already registered. Please login.",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 404,
|
||||
"description": "User is already registered. Please login.",
|
||||
"statusCode": 404
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/host/verify-otp": {
|
||||
"post": {
|
||||
"tags": ["Authentication"],
|
||||
"summary": "Verify OTP",
|
||||
"description": "Verifies the OTP sent to the user's email during registration",
|
||||
"operationId": "verifyOtp",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VerifyOtpRequest"
|
||||
},
|
||||
"example": {
|
||||
"email": "host@example.com",
|
||||
"otp": "123456"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OTP verified successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/SuccessResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"message": "OTP verified successfully",
|
||||
"data": null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request - Invalid OTP or missing fields",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"examples": {
|
||||
"missingFields": {
|
||||
"value": {
|
||||
"success": false,
|
||||
"message": "Email and OTP are required",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 400,
|
||||
"description": "Email and OTP are required",
|
||||
"statusCode": 400
|
||||
}
|
||||
}
|
||||
},
|
||||
"invalidOtp": {
|
||||
"value": {
|
||||
"success": false,
|
||||
"message": "Invalid OTP.",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 400,
|
||||
"description": "Invalid OTP.",
|
||||
"statusCode": 400
|
||||
}
|
||||
}
|
||||
},
|
||||
"expiredOtp": {
|
||||
"value": {
|
||||
"success": false,
|
||||
"message": "OTP has expired.",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 400,
|
||||
"description": "OTP has expired.",
|
||||
"statusCode": 400
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "User not found.",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 404,
|
||||
"description": "User not found.",
|
||||
"statusCode": 404
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/host/login": {
|
||||
"post": {
|
||||
"tags": ["Authentication"],
|
||||
"summary": "Login for host",
|
||||
"description": "Authenticates a host user and returns an access token",
|
||||
"operationId": "loginForHost",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/LoginRequest"
|
||||
},
|
||||
"example": {
|
||||
"emailAddress": "host@example.com",
|
||||
"userPassword": "password123"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Login successful",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/LoginResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": true,
|
||||
"message": "Login successful",
|
||||
"data": {
|
||||
"id": 1,
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"emailAddress": "host@example.com",
|
||||
"mobileNumber": "+1234567890",
|
||||
"isActive": true,
|
||||
"roleXid": 4,
|
||||
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request - Missing fields or failed login",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "Email and password are required",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 400,
|
||||
"description": "Email and password are required",
|
||||
"statusCode": 400
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized - Invalid credentials",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "Invalid credentials",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 401,
|
||||
"description": "Invalid credentials",
|
||||
"statusCode": 401
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden - Not a host user",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "Access denied. Not a host user.",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 403,
|
||||
"description": "Access denied. Not a host user.",
|
||||
"statusCode": 403
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "User not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
},
|
||||
"example": {
|
||||
"success": false,
|
||||
"message": "User not found",
|
||||
"data": null,
|
||||
"error": {
|
||||
"code": 404,
|
||||
"description": "User not found",
|
||||
"statusCode": 404
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"bearerAuth": {
|
||||
"type": "http",
|
||||
"bearer": {
|
||||
"scheme": "bearer",
|
||||
"bearerFormat": "JWT",
|
||||
"description": "JWT token obtained from login endpoint"
|
||||
"type": "http"
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"HostHeader": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"hostParent": {
|
||||
"type": "string",
|
||||
"description": "Host parent name",
|
||||
"example": "Example Host"
|
||||
},
|
||||
"hostRefNumber": {
|
||||
"type": "string",
|
||||
"description": "Host reference number",
|
||||
"example": "HOST001"
|
||||
},
|
||||
"hostStatusDisplay": {
|
||||
"type": "string",
|
||||
"description": "Host status display",
|
||||
"example": "Active"
|
||||
},
|
||||
"accountManager": {
|
||||
"type": "string",
|
||||
"description": "Account manager name",
|
||||
"example": "John Doe"
|
||||
}
|
||||
}
|
||||
},
|
||||
"RegistrationRequest": {
|
||||
"type": "object",
|
||||
"required": ["email"],
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"description": "Email address for registration",
|
||||
"example": "host@example.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
"VerifyOtpRequest": {
|
||||
"type": "object",
|
||||
"required": ["email", "otp"],
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"description": "Email address used during registration",
|
||||
"example": "host@example.com"
|
||||
},
|
||||
"otp": {
|
||||
"type": "string",
|
||||
"description": "6-digit OTP code sent to email",
|
||||
"pattern": "^[0-9]{6}$",
|
||||
"example": "123456"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LoginRequest": {
|
||||
"type": "object",
|
||||
"required": ["emailAddress", "userPassword"],
|
||||
"properties": {
|
||||
"emailAddress": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"description": "Host user email address",
|
||||
"example": "host@example.com"
|
||||
},
|
||||
"userPassword": {
|
||||
"type": "string",
|
||||
"format": "password",
|
||||
"description": "User password",
|
||||
"minLength": 8,
|
||||
"example": "password123"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LoginResponseData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"description": "User ID",
|
||||
"example": 1
|
||||
},
|
||||
"firstName": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "User first name",
|
||||
"example": "John"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "User last name",
|
||||
"example": "Doe"
|
||||
},
|
||||
"emailAddress": {
|
||||
"type": "string",
|
||||
"format": "email",
|
||||
"description": "User email address",
|
||||
"example": "host@example.com"
|
||||
},
|
||||
"mobileNumber": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "User mobile number",
|
||||
"example": "+1234567890"
|
||||
},
|
||||
"isActive": {
|
||||
"type": "boolean",
|
||||
"description": "User active status",
|
||||
"example": true
|
||||
},
|
||||
"roleXid": {
|
||||
"type": "integer",
|
||||
"description": "User role ID (4 for host)",
|
||||
"example": 4
|
||||
},
|
||||
"accessToken": {
|
||||
"type": "string",
|
||||
"description": "JWT access token for authentication",
|
||||
"example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
||||
}
|
||||
}
|
||||
},
|
||||
"LoginResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"example": "Login successful"
|
||||
},
|
||||
"data": {
|
||||
"$ref": "#/components/schemas/LoginResponseData"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SuccessResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"example": "Operation successful"
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"description": "Response data (can be null or empty object)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean",
|
||||
"example": false
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"description": "Error message",
|
||||
"example": "An error occurred"
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"nullable": true,
|
||||
"example": null
|
||||
},
|
||||
"error": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"description": "HTTP status code",
|
||||
"example": 400
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Error description",
|
||||
"example": "Bad request"
|
||||
},
|
||||
"statusCode": {
|
||||
"type": "integer",
|
||||
"description": "HTTP status code",
|
||||
"example": 400
|
||||
},
|
||||
"debug": {
|
||||
"type": "string",
|
||||
"description": "Debug information (only in non-production environments)",
|
||||
"example": "Stack trace..."
|
||||
}
|
||||
},
|
||||
"required": ["code", "description", "statusCode"]
|
||||
}
|
||||
},
|
||||
"required": ["success", "message", "data", "error"]
|
||||
}
|
||||
}
|
||||
"schemas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user