
Api Testing Observability Api Mock
Stand up scenario-driven FastAPI mock servers so solo builders can test clients and agents against stable APIs before production dependencies exist.
Overview
API Testing Observability API Mock is an agent skill for the Ship phase that implements scenario-aware FastAPI mock servers for integration and client testing.
Install
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill api-testing-observability-api-mockWhat is this skill?
- FastAPI-based MockAPIServer with middleware, dynamic routes, and scenario switching
- StateManager and ScenarioManager patterns for reproducible mock behavior
- HTTP middleware that tags responses with X-Mock-Server and active scenario headers
- Playbook-style setup: load definitions, initialize scenarios, run with uvicorn
- Supports async request handling for realistic API client and agent test flows
Adoption & trust: 442 installs on skills.sh; 40.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You cannot run reliable API or agent tests because upstream services are missing, rate-limited, or unstable in local and CI environments.
Who is it for?
Solo builders or tiny teams integrating against REST-style APIs who need deterministic local and CI behavior before launch.
Skip if: Teams that only need static JSON fixtures in unit tests with no server semantics, or production API gateway configuration with no test harness.
When should I use this skill?
You need a structured mock server implementation (routes, scenarios, middleware) before running API or agent integration tests.
What do I get? / Deliverables
After following the playbook you have a runnable mock server with scenarios, middleware, and dynamic routes that your test suite and agents can target like a real API.
- MockAPIServer setup with middleware and dynamic routes
- Scenario and state management configuration for mock responses
- Runnable mock API process suitable for test and agent targets
Recommended Skills
Journey fit
API mocking is a pre-release quality gate: it belongs on the Ship shelf under testing because it replaces or shadows real backends while integration and E2E suites run. Testing is the canonical subphase for mock infrastructure, response stubs, and observability headers—not backend implementation of the live API itself.
How it compares
Use for a runnable mock service playbook—not as a one-off Postman collection or as production API observability tooling alone.
Common Questions / FAQ
Who is api-testing-observability-api-mock for?
Indie developers and agent users shipping API-backed products who need mock infrastructure aligned with real HTTP semantics, scenarios, and trace-friendly headers.
When should I use api-testing-observability-api-mock?
During Ship testing when wiring integration tests, agent tool calls, or client SDKs against APIs that are not ready or are too expensive to call in CI.
Is api-testing-observability-api-mock safe to install?
Treat it as community procedural guidance; review the Security Audits panel on this Prism page and inspect any generated server code before exposing network listeners.
SKILL.md
READMESKILL.md - Api Testing Observability Api Mock
# API Mocking Implementation Playbook This file contains detailed patterns, checklists, and code samples referenced by the skill. ## Detailed Steps ### 1. Mock Server Setup Create comprehensive mock server infrastructure: **Mock Server Framework** ```python from typing import Dict, List, Any, Optional import json import asyncio from datetime import datetime from fastapi import FastAPI, Request, Response import uvicorn class MockAPIServer: def __init__(self, config: Dict[str, Any]): self.app = FastAPI(title="Mock API Server") self.routes = {} self.middleware = [] self.state_manager = StateManager() self.scenario_manager = ScenarioManager() def setup_mock_server(self): """Setup comprehensive mock server""" # Configure middleware self._setup_middleware() # Load mock definitions self._load_mock_definitions() # Setup dynamic routes self._setup_dynamic_routes() # Initialize scenarios self._initialize_scenarios() return self.app def _setup_middleware(self): """Configure server middleware""" @self.app.middleware("http") async def add_mock_headers(request: Request, call_next): response = await call_next(request) response.headers["X-Mock-Server"] = "true" response.headers["X-Mock-Scenario"] = self.scenario_manager.current_scenario return response @self.app.middleware("http") async def simulate_latency(request: Request, call_next): # Simulate network latency latency = self._calculate_latency(request.url.path) await asyncio.sleep(latency / 1000) # Convert to seconds response = await call_next(request) return response @self.app.middleware("http") async def track_requests(request: Request, call_next): # Track request for verification self.state_manager.track_request({ 'method': request.method, 'path': str(request.url.path), 'headers': dict(request.headers), 'timestamp': datetime.now() }) response = await call_next(request) return response def _setup_dynamic_routes(self): """Setup dynamic route handling""" @self.app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"]) async def handle_mock_request(path: str, request: Request): # Find matching mock mock = self._find_matching_mock(request.method, path, request) if not mock: return Response( content=json.dumps({"error": "No mock found for this endpoint"}), status_code=404, media_type="application/json" ) # Process mock response response_data = await self._process_mock_response(mock, request) return Response( content=json.dumps(response_data['body']), status_code=response_data['status'], headers=response_data['headers'], media_type="application/json" ) async def _process_mock_response(self, mock: Dict[str, Any], request: Request): """Process and generate mock response""" # Check for conditional responses if mock.get('conditions'): for condition in mock['conditions']: if self._evaluate_condition(condition, request): return await self._generate_response(condition['response'], request) # Use default response return await self._generate_response(mock['response'], request) def _generate_response(self, response_template: Dict[str, Any], request: Request): """Generate response from template""" response = { 'status': response_template.get('status', 200),