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
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:
50
src/models/config.py
Normal file
50
src/models/config.py
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user