Initial upload: API Mock CLI v0.1.0
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / test (3.9) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / type-check (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-01-29 13:53:48 +00:00
parent e2b73a56b4
commit d909561a05

38
src/models/endpoint.py Normal file
View File

@@ -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
}
}