""" FastAPI application for the API Contract Validator Environment. Exposes the ValidatorEnvironment over HTTP and WebSocket endpoints using ``openenv.core.env_server.http_server.create_app``. Endpoints created automatically: - GET / — Landing page (this module) - POST /reset — Reset the environment - POST /step — Execute an action - GET /state — Get current environment state - GET /health — Health check - WS /ws — WebSocket for persistent sessions - GET /docs — Swagger UI (interactive — try every endpoint) """ from fastapi.responses import HTMLResponse try: from openenv.core.env_server.http_server import create_app except Exception as exc: raise ImportError( "openenv is required. Install with: pip install openenv-core" ) from exc try: from ..models import ValidatorAction, ValidatorObservation from .environment import ValidatorEnvironment from .logging_setup import configure_logging except (ImportError, ModuleNotFoundError): import sys import os sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from models import ValidatorAction, ValidatorObservation from server.environment import ValidatorEnvironment from server.logging_setup import configure_logging configure_logging() app = create_app( ValidatorEnvironment, ValidatorAction, ValidatorObservation, env_name="api_contract_validator", max_concurrent_envs=10, ) _LANDING_HTML = """
An OpenEnv RL environment that trains agents to detect API contract violations, trace downstream blast radius across microservices, and propose backward-compatible fixes.
Theme #3.1 Scaler AI Labs Bonus openenv-core 0.2.3 9 tasks · 3 phases · 14 reward signals
| Method | Path | Purpose |
|---|---|---|
| GET | /health | Liveness check |
| GET | /docs | Interactive Swagger UI — click "Try it out" on any endpoint |
| POST | /reset |
Start a new episode (optional task_name, seed) |
| POST | /step |
Submit one ValidatorAction |
| GET | /state |
Current environment state |
| WS | /ws |
WebSocket session |
HOST=https://pushpam14-api-contract-validator.hf.space
curl $HOST/health
# {"status":"healthy"}
curl -X POST $HOST/reset -H "Content-Type: application/json" \\
-d '{"task_name":"trace_downstream_blast_radius","seed":1}'
find_type_mismatchesvalidate_nested_objectsdetect_breaking_changesvalidate_response_schemavalidate_cross_field_constraintsvalidate_auth_requesttrace_downstream_blast_radiuspropose_backward_compat_fixmulti_service_cascade_fix