Spaces:
Sleeping
Sleeping
File size: 1,171 Bytes
19a3093 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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}')
|