MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / validate_document

Function validate_document

server/config_schema_router.py:46–68  ·  view source on GitHub ↗
(request: SchemaValidateRequest)

Source from the content-addressed store, hash-verified

44
45@router.post("/schema/validate")
46def validate_document(request: SchemaValidateRequest) -> Dict[str, Any]:
47 try:
48 parsed = yaml.safe_load(request.document)
49 except yaml.YAMLError as exc:
50 raise HTTPException(status_code=400, detail={"message": "invalid_yaml", "error": str(exc)}) from exc
51
52 if not isinstance(parsed, Mapping):
53 raise HTTPException(status_code=422, detail={"message": "document_root_not_mapping"})
54
55 try:
56 load_design_from_mapping(parsed)
57 except ConfigError as exc:
58 return {
59 "valid": False,
60 "error": str(exc),
61 "path": exc.path,
62 "schema": _resolve_schema(request.breadcrumbs),
63 }
64
65 return {
66 "valid": True,
67 "schema": _resolve_schema(request.breadcrumbs),
68 }
69
70
71__all__ = ["router"]

Callers

nothing calls this directly

Calls 2

load_design_from_mappingFunction · 0.90
_resolve_schemaFunction · 0.85

Tested by

no test coverage detected