{ "openapi": "3.0.0", "info": { "title": "Admin, District, and User API", "version": "1.0.0", "description": "API for admin, district, and user operations" }, "paths": { "/admin/login": { "post": { "summary": "Admin login", "tags": [ "Admin" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginRequest" } } } }, "responses": { "200": { "description": "Successful login", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/admin/profile": { "get": { "summary": "Get admin profile", "tags": [ "Admin" ], "security": [ { "BearerAuth": [] } ], "responses": { "200": { "description": "Successful retrieval of admin profile", "content": { "application/json": { "schema": { "type": "object", "properties": { "admin": { "type": "object" } } } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } }, "put": { "summary": "Edit admin profile", "tags": [ "Admin" ], "security": [ { "BearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "worker": { "type": "string" }, "available": { "type": "boolean" } } } } } }, "responses": { "201": { "description": "Profile updated successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "403": { "$ref": "#/components/responses/ForbiddenError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/admin/map": { "post": { "summary": "Map operation (details not provided)", "tags": [ "Admin" ], "responses": { "200": { "description": "Successful operation" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/admin/search": { "post": { "summary": "Search operation (details not provided)", "tags": [ "Admin" ], "responses": { "200": { "description": "Successful operation" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/district/login": { "post": { "summary": "District admin login", "tags": [ "District" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginRequest" } } } }, "responses": { "200": { "description": "Successful login", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/district/emergency": { "get": { "summary": "Get emergency cases", "tags": [ "District" ], "responses": { "200": { "description": "Successful retrieval of emergency cases", "content": { "application/json": { "schema": { "type": "object" } } } }, "403": { "$ref": "#/components/responses/ForbiddenError" } } } }, "/district/register": { "post": { "summary": "Register a new admin (not for District Admin registration)", "tags": [ "District" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RegisterAdminRequest" } } } }, "responses": { "201": { "description": "Admin successfully created", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "403": { "description": "User already exists", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/district/map": { "post": { "summary": "Map operation for district (details not provided)", "tags": [ "District" ], "responses": { "200": { "description": "Successful operation" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/user/sendotp": { "post": { "summary": "Send OTP to user", "tags": [ "User" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SendOTPRequest" } } } }, "responses": { "200": { "description": "OTP sent successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/user/verifyotp": { "post": { "summary": "Verify OTP", "tags": [ "User" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VerifyOTPRequest" } } } }, "responses": { "200": { "description": "OTP verified successfully", "content": { "application/json": { "schema": { "type": "string" } } } }, "400": { "$ref": "#/components/responses/BadRequestError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/user/emergency": { "post": { "summary": "Post emergency case", "tags": [ "User" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EmergencyCaseRequest" } } } }, "responses": { "201": { "description": "Emergency case created successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "400": { "$ref": "#/components/responses/BadRequestError" }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/user/profile": { "get": { "summary": "Get user profile", "tags": [ "User" ], "responses": { "200": { "description": "Successful retrieval of user profile", "content": { "application/json": { "schema": { "type": "object", "properties": { "user": { "type": "object", "properties": { "name": { "type": "string" }, "number": { "type": "string" } } } } } } } }, "400": { "$ref": "#/components/responses/BadRequestError" }, "500": { "$ref": "#/components/responses/ServerError" } } }, "put": { "summary": "Update user profile", "tags": [ "User" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpdateUserRequest" } } } }, "responses": { "200": { "description": "Profile updated successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "400": { "$ref": "#/components/responses/BadRequestError" }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/user/contact": { "post": { "summary": "Post contact information", "tags": [ "User" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ContactRequest" } } } }, "responses": { "201": { "description": "Contact information saved successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "400": { "$ref": "#/components/responses/BadRequestError" }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "500": { "$ref": "#/components/responses/ServerError" } } } }, "/user/map": { "post": { "summary": "Map operation for user (details not provided)", "tags": [ "User" ], "responses": { "200": { "description": "Successful operation" }, "500": { "$ref": "#/components/responses/ServerError" } } } } }, "components": { "schemas": { "LoginRequest": { "type": "object", "properties": { "email": { "type": "string", "format": "email" }, "password": { "type": "string", "format": "password" } }, "required": [ "email", "password" ] }, "LoginResponse": { "type": "object", "properties": { "msg": { "type": "string" }, "token": { "type": "string" } } }, "RegisterAdminRequest": { "type": "object", "properties": { "name": { "type": "string" }, "number": { "type": "string" }, "email": { "type": "string", "format": "email" }, "password": { "type": "string", "format": "password" }, "latitude": { "type": "number" }, "longitude": { "type": "number" } }, "required": [ "name", "number", "email", "password", "latitude", "longitude" ] }, "SendOTPRequest": { "type": "object", "properties": { "number": { "type": "string" } }, "required": [ "number" ] }, "VerifyOTPRequest": { "type": "object", "properties": { "otp": { "type": "string" }, "number": { "type": "string" } }, "required": [ "otp", "number" ] }, "EmergencyCaseRequest": { "type": "object", "properties": { "cause": { "type": "string" }, "latitude": { "type": "number" }, "longitude": { "type": "number" } }, "required": [ "cause", "latitude", "longitude" ] }, "UpdateUserRequest": { "type": "object", "properties": { "name": { "type": "string" } }, "required": [ "name" ] }, "ContactRequest": { "type": "object", "properties": { "name": { "type": "string" }, "number": { "type": "string" }, "description": { "type": "string" }, "userId": { "type": "string" } }, "required": [ "name", "number", "description", "userId" ] } }, "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }, "responses": { "UnauthorizedError": { "description": "Unauthorized", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "ForbiddenError": { "description": "Forbidden", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "BadRequestError": { "description": "Bad Request", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "ServerError": { "description": "Server error", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } }