mirror of
https://github.com/ulitsaRaskolnikova/is-coursework.git
synced 2026-09-14 14:05:36 +05:00
585 lines
13 KiB
JSON
585 lines
13 KiB
JSON
{
|
|
"openapi": "3.0.3",
|
|
"info": {
|
|
"title": "Auth Service API",
|
|
"version": "1.0.0"
|
|
},
|
|
"paths": {
|
|
"/auth/register": {
|
|
"post": {
|
|
"summary": "Register user",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/RegisterRequest"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"201": {
|
|
"description": "User registered",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseUserResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Auth"
|
|
]
|
|
}
|
|
},
|
|
"/auth/login": {
|
|
"post": {
|
|
"summary": "Login user",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/LoginRequest"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Login response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseLoginResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Auth"
|
|
]
|
|
}
|
|
},
|
|
"/auth/verify-email": {
|
|
"get": {
|
|
"summary": "Verify email",
|
|
"parameters": [
|
|
{
|
|
"name": "token",
|
|
"in": "query",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Email verified",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseString"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Auth"
|
|
]
|
|
}
|
|
},
|
|
"/auth/resend-verification": {
|
|
"post": {
|
|
"summary": "Resend verification email",
|
|
"parameters": [
|
|
{
|
|
"name": "email",
|
|
"in": "query",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "email"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Verification email sent",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseString"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Auth"
|
|
]
|
|
}
|
|
},
|
|
"/auth/refresh": {
|
|
"post": {
|
|
"summary": "Refresh tokens",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/RefreshTokenRequest"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Tokens refreshed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseLoginResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Auth"
|
|
]
|
|
}
|
|
},
|
|
"/auth/health": {
|
|
"get": {
|
|
"summary": "Health check",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Service health",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseString"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Health"
|
|
]
|
|
}
|
|
},
|
|
"/auth/2fa/setup": {
|
|
"get": {
|
|
"summary": "Generate 2FA setup",
|
|
"responses": {
|
|
"200": {
|
|
"description": "2FA setup data",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseTwoFactorSetupResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"TwoFactor"
|
|
]
|
|
}
|
|
},
|
|
"/auth/2fa/enable": {
|
|
"post": {
|
|
"summary": "Enable 2FA",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/Enable2FAWithSecretRequest"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "2FA enabled",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseString"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"TwoFactor"
|
|
]
|
|
}
|
|
},
|
|
"/auth/2fa/disable": {
|
|
"post": {
|
|
"summary": "Disable 2FA",
|
|
"responses": {
|
|
"200": {
|
|
"description": "2FA disabled",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseString"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"TwoFactor"
|
|
]
|
|
}
|
|
},
|
|
"/auth/2fa/status": {
|
|
"get": {
|
|
"summary": "Get 2FA status",
|
|
"responses": {
|
|
"200": {
|
|
"description": "2FA status",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseBoolean"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"TwoFactor"
|
|
]
|
|
}
|
|
},
|
|
"/users/{id}": {
|
|
"get": {
|
|
"summary": "Get user by id",
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "User details",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/ApiResponseUserResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Users"
|
|
]
|
|
}
|
|
},
|
|
"/users/{id}/email": {
|
|
"get": {
|
|
"summary": "Get user email",
|
|
"parameters": [
|
|
{
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "User email",
|
|
"content": {
|
|
"text/plain": {
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
"Users"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"ApiError": {
|
|
"type": "object",
|
|
"properties": {
|
|
"code": {
|
|
"type": "string"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
},
|
|
"details": {
|
|
"type": "object",
|
|
"additionalProperties": true,
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"ApiResponseString": {
|
|
"type": "object",
|
|
"properties": {
|
|
"success": {
|
|
"type": "boolean"
|
|
},
|
|
"data": {
|
|
"type": "string"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"nullable": true
|
|
},
|
|
"error": {
|
|
"$ref": "#/components/schemas/ApiError",
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"ApiResponseBoolean": {
|
|
"type": "object",
|
|
"properties": {
|
|
"success": {
|
|
"type": "boolean"
|
|
},
|
|
"data": {
|
|
"type": "boolean"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"nullable": true
|
|
},
|
|
"error": {
|
|
"$ref": "#/components/schemas/ApiError",
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"ApiResponseLoginResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"success": {
|
|
"type": "boolean"
|
|
},
|
|
"data": {
|
|
"$ref": "#/components/schemas/LoginResponse"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"nullable": true
|
|
},
|
|
"error": {
|
|
"$ref": "#/components/schemas/ApiError",
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"ApiResponseUserResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"success": {
|
|
"type": "boolean"
|
|
},
|
|
"data": {
|
|
"$ref": "#/components/schemas/UserResponse"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"nullable": true
|
|
},
|
|
"error": {
|
|
"$ref": "#/components/schemas/ApiError",
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"ApiResponseTwoFactorSetupResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"success": {
|
|
"type": "boolean"
|
|
},
|
|
"data": {
|
|
"$ref": "#/components/schemas/TwoFactorSetupResponse"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"nullable": true
|
|
},
|
|
"error": {
|
|
"$ref": "#/components/schemas/ApiError",
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"LoginRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"email",
|
|
"password"
|
|
],
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"format": "email"
|
|
},
|
|
"password": {
|
|
"type": "string"
|
|
},
|
|
"totpCode": {
|
|
"type": "string",
|
|
"nullable": true
|
|
}
|
|
}
|
|
},
|
|
"RegisterRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"email",
|
|
"password"
|
|
],
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"format": "email"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"minLength": 8
|
|
}
|
|
}
|
|
},
|
|
"RefreshTokenRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"refreshToken"
|
|
],
|
|
"properties": {
|
|
"refreshToken": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"Enable2FAWithSecretRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"secret",
|
|
"code"
|
|
],
|
|
"properties": {
|
|
"secret": {
|
|
"type": "string"
|
|
},
|
|
"code": {
|
|
"type": "string",
|
|
"pattern": "^\\d{6}$"
|
|
}
|
|
}
|
|
},
|
|
"TwoFactorSetupResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"secret": {
|
|
"type": "string"
|
|
},
|
|
"qrCodeUrl": {
|
|
"type": "string"
|
|
},
|
|
"manualEntryKey": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"LoginResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"userId": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
},
|
|
"accessToken": {
|
|
"type": "string"
|
|
},
|
|
"refreshToken": {
|
|
"type": "string"
|
|
},
|
|
"email": {
|
|
"type": "string",
|
|
"format": "email"
|
|
}
|
|
}
|
|
},
|
|
"UserResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
},
|
|
"email": {
|
|
"type": "string",
|
|
"format": "email"
|
|
},
|
|
"createdAt": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"updatedAt": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tags": [
|
|
{
|
|
"name": "Auth",
|
|
"description": "Authentication and registration"
|
|
},
|
|
{
|
|
"name": "TwoFactor",
|
|
"description": "Two-factor authentication"
|
|
},
|
|
{
|
|
"name": "Users",
|
|
"description": "User lookup"
|
|
},
|
|
{
|
|
"name": "Health",
|
|
"description": "Service health"
|
|
}
|
|
]
|
|
}
|