|
- {
- "openapi": "3.1.0",
- "info": {
- "title": "rust-template",
- "description": "Axum API server",
- "license": {
- "name": "MIT",
- "identifier": "MIT"
- },
- "version": "0.1.0"
- },
- "paths": {
- "/api/v1/items": {
- "get": {
- "tags": [
- "items"
- ],
- "summary": "List items, newest first.",
- "operationId": "list_items",
- "parameters": [
- {
- "name": "page",
- "in": "query",
- "description": "1-based page index.",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int32",
- "minimum": 0
- }
- },
- {
- "name": "per_page",
- "in": "query",
- "description": "Page size (max 100).",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int32",
- "minimum": 0
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Paged item list",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ItemPage"
- }
- }
- }
- }
- }
- },
- "post": {
- "tags": [
- "items"
- ],
- "summary": "Create an item.",
- "operationId": "create_item",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/CreateItemRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "201": {
- "description": "Created item",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ItemResponse"
- }
- }
- }
- },
- "400": {
- "description": "Validation error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- }
- },
- "/api/v1/items/{id}": {
- "get": {
- "tags": [
- "items"
- ],
- "summary": "Fetch a single item.",
- "operationId": "get_item",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "description": "Item id",
- "required": true,
- "schema": {
- "type": "string",
- "format": "uuid"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Item",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ItemResponse"
- }
- }
- }
- },
- "404": {
- "description": "Missing item",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- },
- "delete": {
- "tags": [
- "items"
- ],
- "summary": "Delete an item.",
- "operationId": "delete_item",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "description": "Item id",
- "required": true,
- "schema": {
- "type": "string",
- "format": "uuid"
- }
- }
- ],
- "responses": {
- "204": {
- "description": "Deleted"
- },
- "404": {
- "description": "Missing item",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- },
- "patch": {
- "tags": [
- "items"
- ],
- "summary": "Replace selected item fields.",
- "operationId": "update_item",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "description": "Item id",
- "required": true,
- "schema": {
- "type": "string",
- "format": "uuid"
- }
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/UpdateItemRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Updated item",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ItemResponse"
- }
- }
- }
- },
- "404": {
- "description": "Missing item",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- }
- },
- "/api/v1/llm/ws": {
- "get": {
- "tags": [
- "llm"
- ],
- "description": "WebSocket upgrade. After 101, send LlmRequest as one text frame. Server sends LlmWsEvent frames.",
- "operationId": "send",
- "responses": {
- "101": {
- "description": "Switching Protocols"
- }
- }
- }
- },
- "/api/v1/queries/list": {
- "get": {
- "tags": [
- "queries"
- ],
- "description": "Get all saved queries",
- "operationId": "get_queries",
- "parameters": [
- {
- "name": "limit",
- "in": "query",
- "description": "Maximum number of queries to return",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Fetched LLM queries",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/SavedQueriesResponse"
- }
- }
- }
- },
- "400": {
- "description": "Validation error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- }
- },
- "/api/v1/queries/{id}": {
- "get": {
- "tags": [
- "queries"
- ],
- "description": "Get a single saved query by ID",
- "operationId": "get_query",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "string",
- "format": "uuid"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Fetched LLM query",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/LlmQueryDetail"
- }
- }
- }
- },
- "400": {
- "description": "Validation error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- },
- "404": {
- "description": "Query not found",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- }
- },
- "/health/live": {
- "get": {
- "tags": [
- "health"
- ],
- "summary": "Liveness probe. Process is up.",
- "operationId": "live",
- "responses": {
- "200": {
- "description": "Process is running",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HealthResponse"
- }
- }
- }
- }
- }
- }
- },
- "/health/ready": {
- "get": {
- "tags": [
- "health"
- ],
- "summary": "Readiness probe. Database is reachable.",
- "operationId": "ready",
- "responses": {
- "200": {
- "description": "Database is reachable",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ReadyResponse"
- }
- }
- }
- },
- "500": {
- "description": "Database is unreachable",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorBody"
- }
- }
- }
- }
- }
- }
- }
- },
- "components": {
- "schemas": {
- "CreateItemRequest": {
- "type": "object",
- "required": [
- "name"
- ],
- "properties": {
- "description": {
- "type": [
- "string",
- "null"
- ]
- },
- "name": {
- "type": "string"
- }
- }
- },
- "ErrorBody": {
- "type": "object",
- "description": "Stable JSON error envelope returned by every handler.",
- "required": [
- "error"
- ],
- "properties": {
- "error": {
- "$ref": "#/components/schemas/ErrorDetail"
- }
- }
- },
- "ErrorDetail": {
- "type": "object",
- "required": [
- "status",
- "code",
- "message"
- ],
- "properties": {
- "code": {
- "type": "string"
- },
- "message": {
- "type": "string"
- },
- "status": {
- "type": "integer",
- "format": "int32",
- "minimum": 0
- },
- "trace_id": {
- "type": [
- "string",
- "null"
- ]
- }
- }
- },
- "HealthResponse": {
- "type": "object",
- "required": [
- "status",
- "service"
- ],
- "properties": {
- "service": {
- "type": "string"
- },
- "status": {
- "type": "string"
- }
- }
- },
- "ItemPage": {
- "type": "object",
- "required": [
- "items",
- "page",
- "per_page",
- "total"
- ],
- "properties": {
- "items": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ItemResponse"
- }
- },
- "page": {
- "type": "integer",
- "format": "int32",
- "minimum": 0
- },
- "per_page": {
- "type": "integer",
- "format": "int32",
- "minimum": 0
- },
- "total": {
- "type": "integer",
- "format": "int64"
- }
- }
- },
- "ItemResponse": {
- "type": "object",
- "required": [
- "id",
- "name",
- "created_at",
- "updated_at"
- ],
- "properties": {
- "created_at": {
- "type": "string",
- "format": "date-time"
- },
- "description": {
- "type": [
- "string",
- "null"
- ]
- },
- "id": {
- "type": "string",
- "format": "uuid"
- },
- "name": {
- "type": "string"
- },
- "updated_at": {
- "type": "string",
- "format": "date-time"
- }
- }
- },
- "LlmQuery": {
- "type": "object",
- "required": [
- "id",
- "title"
- ],
- "properties": {
- "id": {
- "type": "string",
- "format": "uuid"
- },
- "title": {
- "type": "string"
- }
- }
- },
- "LlmQueryDetail": {
- "type": "object",
- "required": [
- "id",
- "title",
- "messages"
- ],
- "properties": {
- "id": {
- "type": "string",
- "format": "uuid"
- },
- "messages": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "title": {
- "type": "string"
- }
- }
- },
- "ReadyResponse": {
- "type": "object",
- "required": [
- "status",
- "database"
- ],
- "properties": {
- "database": {
- "type": "string"
- },
- "status": {
- "type": "string"
- }
- }
- },
- "SavedQueriesResponse": {
- "type": "object",
- "required": [
- "queries"
- ],
- "properties": {
- "queries": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/LlmQuery"
- }
- }
- }
- },
- "UpdateItemRequest": {
- "type": "object",
- "properties": {
- "description": {
- "type": [
- "string",
- "null"
- ]
- },
- "name": {
- "type": [
- "string",
- "null"
- ]
- }
- }
- }
- }
- },
- "tags": [
- {
- "name": "health",
- "description": "Liveness and readiness"
- },
- {
- "name": "items",
- "description": "Example CRUD resource"
- }
- ]
- }
|