From e2b73a56b4a7a17d226e5698d545d1e42eaf7201 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/config.py | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/models/config.py diff --git a/src/models/config.py b/src/models/config.py new file mode 100644 index 0000000..a82de63 --- /dev/null +++ b/src/models/config.py @@ -0,0 +1,50 @@ +from typing import Optional +from pydantic import BaseModel, Field + + +class ServerConfig(BaseModel): + port: int = Field(default=8000, description="Port to run the mock server on") + host: str = Field(default="0.0.0.0", description="Host address to bind to") + reload: bool = Field(default=False, description="Enable auto-reload on file changes") + log_level: str = Field(default="info", description="Logging level") + tunnel: bool = Field(default=True, description="Enable ngrok tunnel") + offline: bool = Field(default=False, description="Run in offline mode (no tunnel)") + endpoints_file: str = Field(default="endpoints.yaml", description="Path to endpoints definition file") + ngrok_authtoken: Optional[str] = Field(default=None, description="ngrok authentication token") + cors_origins: Optional[list[str]] = Field(default=None, description="CORS allowed origins") + + class Config: + json_schema_extra = { + "example": { + "port": 8000, + "host": "0.0.0.0", + "reload": True, + "log_level": "info", + "tunnel": True, + "offline": False, + "endpoints_file": "endpoints.yaml", + "ngrok_authtoken": None, + "cors_origins": ["*"] + } + } + + +class ProjectConfig(BaseModel): + name: str = Field(..., description="Project name") + version: str = Field(default="1.0.0", description="Project version") + description: Optional[str] = Field(default=None, description="Project description") + server: ServerConfig = Field(default_factory=ServerConfig, description="Server configuration") + + class Config: + json_schema_extra = { + "example": { + "name": "my-mock-api", + "version": "1.0.0", + "description": "My API mock project", + "server": { + "port": 8000, + "host": "0.0.0.0", + "tunnel": True + } + } + }