NurseLex / fetch_schema.py
NurseCitizenDeveloper's picture
feat: complete local embedding search with i-dot-ai HF model
19a3093
import httpx
import json
base_url = 'https://lex.lab.i.ai.gov.uk'
openapi_url = f'{base_url}/openapi.json'
try:
r = httpx.get(openapi_url, timeout=10)
r.raise_for_status()
spec = r.json()
print('--- Available Endpoints ---')
for path, methods in spec.get('paths', {}).items():
if 'search' in path or 'explanatory_note' in path or 'similar' in path:
print(f'{path}:')
for method, details in methods.items():
print(f' - {method.upper()}: {details.get("summary", "")}')
print('\n--- Search Request Schemas ---')
schemas = spec.get('components', {}).get('schemas', {})
for name, schema in schemas.items():
if 'Search' in name or 'Explanatory' in name:
print(f'{name}:')
props = schema.get('properties', {})
for p_name, p_details in props.items():
p_type = p_details.get('type', 'unknown')
if p_type == 'unknown' and 'anyOf' in p_details:
p_type = 'anyOf'
print(f' - {p_name} ({p_type})')
except Exception as e:
print(f'Error: {type(e).__name__} - {e}')