import json

with open(r"docs\openapi_検証.json", encoding="utf-8") as f:
    api = json.load(f)
components = api.get("components", {}).get("schemas", {})

# results_apply の内容
ra = components.get("results_apply", {})
props = ra.get("properties", {})
print("=== results_apply ===")
for k, v in props.items():
    desc = v.get("description", "")[:100]
    print(f"  {k}: {v.get('type','?')} - {desc}")

# apply/lists のパラメータ
print("\n=== /apply/lists parameters ===")
get = api["paths"]["/apply/lists"].get("get", {})
for p in get.get("parameters", []):
    pname = p.get("name", "")
    pdesc = p.get("description", "")[:60]
    print(f"  {pname} ({p.get('in','')}): {pdesc}")

# results_apply_lists
ral = components.get("results_apply_lists", {})
print("results_apply_lists props:", list(ral.get("properties", {}).keys())[:10])


TARGET_PATHS = ["/apply", "/apply/lists", "/apply/{arrive_id}", "/post/lists", "/post/{post_id}", "/procedure/{proc_id}"]

for path in TARGET_PATHS:
    path_obj = api["paths"].get(path, {})
    if not path_obj:
        continue
    print(f"\n=== {path} ===")
    for method in ["get", "post", "put", "delete"]:
        if method not in path_obj:
            continue
        details = path_obj[method]
        if not isinstance(details, dict):
            continue
        summary = details.get("summary", "")
        print(f"  {method.upper()}: {summary}")
        rb = details.get("requestBody", {})
        if rb:
            content = rb.get("content", {})
            print(f"    request content-types: {list(content.keys())}")
            for ct, schema_wrap in content.items():
                schema = schema_wrap.get("schema", {})
                props = schema.get("properties", {})
                required = schema.get("required", [])
                print(f"    required: {required}")
                for pname, pdef in list(props.items())[:10]:
                    desc = str(pdef.get("description", ""))[:60]
                    print(f"      {pname}: {pdef.get('type','?')} - {desc}")
        resp200 = details.get("responses", {}).get("200", {})
        resp_content = resp200.get("content", {})
        if resp_content:
            for ct, schema_wrap in resp_content.items():
                schema = schema_wrap.get("schema", {})
                results_schema = schema.get("properties", {}).get("results", {})
                results_props = results_schema.get("properties", {})
                print(f"    response results props: {list(results_props.keys())[:10]}")
