{ "openapi": "3.0.0", "info": { "title": "Actix JWT API Documentation", "version": "1.0.0", "description": "JWT authentication API built with Actix Web" }, "servers": [ { "url": "http://127.0.0.1:8080", "description": "Development server" } ], "paths": { "/user/encode-token/{id}": { "get": { "tags": ["Authentication"], "summary": "Encode JWT token for user", "description": "Creates a JWT token for a user with the given ID", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "User ID to encode in the token" } ], "responses": { "200": { "description": "Token successfully created", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Successfully created account" }, "token": { "type": "string", "example": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." } } } } } } } } }, "/user/decode-token": { "post": { "tags": ["Authentication"], "summary": "Decode JWT token", "description": "Decodes and validates a JWT token", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string", "description": "JWT token to decode", "example": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." } }, "required": ["token"] } } } }, "responses": { "200": { "description": "Token successfully decoded", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Successfully Logged in." }, "id": { "type": "integer", "example": 123 } } } } } }, "401": { "description": "Invalid token", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Invalid token" } } } } } } } } }, "/user/protected": { "get": { "tags": ["Authentication"], "summary": "Access protected route", "description": "Access a protected route that requires valid JWT authentication", "security": [ { "bearerAuth": [] } ], "responses": { "200": { "description": "Access granted", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Authorized" } } } } } }, "401": { "description": "Unauthorized - Invalid or missing token", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Unauthorized" } } } } } } } } } }, "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } }