mirror of
https://github.com/langchain-ai/langchain-extract.git
synced 2026-07-01 20:24:03 -04:00
16 lines
465 B
Python
16 lines
465 B
Python
from typing import Any, Dict
|
|
|
|
from fastapi import HTTPException
|
|
from jsonschema import exceptions
|
|
from jsonschema.validators import Draft202012Validator
|
|
|
|
|
|
def validate_json_schema(schema: Dict[str, Any]) -> None:
|
|
"""Validate a JSON schema."""
|
|
try:
|
|
Draft202012Validator.check_schema(schema)
|
|
except exceptions.ValidationError as e:
|
|
raise HTTPException(
|
|
status_code=422, detail=f"Not a valid JSON schema: {e.message}"
|
|
)
|