From d909561a059fe9206c7a33af579abccfd98a372d Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 13:53:48 +0000 Subject: [PATCH] Initial upload: API Mock CLI v0.1.0 --- src/models/endpoint.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/models/endpoint.py diff --git a/src/models/endpoint.py b/src/models/endpoint.py new file mode 100644 index 0000000..5918b6b --- /dev/null +++ b/src/models/endpoint.py @@ -0,0 +1,38 @@ +from typing import Optional, Dict, Any, List +from pydantic import BaseModel, Field + + +class Endpoint(BaseModel): + path: str = Field(..., description="API endpoint path pattern, e.g., /api/users/{id}") + method: str = Field(default="GET", description="HTTP method: GET, POST, PUT, DELETE, PATCH") + name: Optional[str] = Field(default=None, description="Human-readable endpoint name") + description: Optional[str] = Field(default=None, description="Endpoint description") + response: Dict[str, Any] = Field(..., description="Default response configuration") + responses: Optional[Dict[str, Dict[str, Any]]] = Field( + default=None, description="Multiple response variants keyed by status code" + ) + validators: Optional[Dict[str, Any]] = Field(default=None, description="Request validation schema") + tags: Optional[List[str]] = Field(default=None, description="Tags for grouping endpoints") + enabled: bool = Field(default=True, description="Whether this endpoint is active") + + class Config: + json_schema_extra = { + "example": { + "path": "/api/users/{id}", + "method": "GET", + "name": "Get User", + "description": "Retrieve a user by ID", + "response": { + "status_code": 200, + "body": { + "id": "{{request.path.id}}", + "name": "John Doe", + "email": "john@example.com" + }, + "headers": { + "Content-Type": "application/json" + } + }, + "enabled": True + } + }