{
  "openapi": "3.1.0",
  "info": {
    "title": "MythosLink API",
    "version": "0.1.0",
    "description": "面向 Agent 的中文神话知识图谱静态 JSON API。"
  },
  "servers": [
    {
      "url": "https://mythos.sensendaodao.com/"
    }
  ],
  "components": {
    "schemas": {
      "MythosLinkMythEntry": {
        "$ref": "#/definitions/MythosLinkMythEntry",
        "definitions": {
          "MythosLinkMythEntry": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z]+-[a-z0-9-]+$"
              },
              "title": {
                "type": "string"
              },
              "title_en": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "Monster",
                  "God",
                  "Human",
                  "Location",
                  "Artifact",
                  "Event"
                ]
              },
              "image": {
                "type": "object",
                "properties": {
                  "src": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  },
                  "license": {
                    "type": "string"
                  },
                  "trust_tier": {
                    "type": "string",
                    "enum": [
                      "tier-1",
                      "tier-2",
                      "tier-3"
                    ],
                    "default": "tier-1"
                  },
                  "generator": {
                    "type": "string",
                    "enum": [
                      "human",
                      "ai",
                      "scan"
                    ]
                  }
                },
                "required": [
                  "src",
                  "source",
                  "license"
                ],
                "additionalProperties": false
              },
              "claims": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "statement": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 300
                    },
                    "assertion_scope": {
                      "type": "string",
                      "enum": [
                        "TEXT_SAYS",
                        "IN_TRADITION",
                        "HISTORICAL_REALITY",
                        "SCHOLARLY_INTERPRETATION",
                        "MODERN_RECEPTION",
                        "SPECULATION"
                      ]
                    },
                    "knowledge_layer": {
                      "type": "string",
                      "enum": [
                        "ARCHAEOLOGICAL",
                        "TEXTUAL_WITNESS",
                        "MYTHIC_NARRATIVE",
                        "RITUAL_PRACTICE",
                        "SCHOLARLY_INTERPRETATION",
                        "LATER_RECEPTION",
                        "POPULAR_CULTURE",
                        "SPECULATION"
                      ]
                    },
                    "evidence": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "source_id": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9-]*$"
                          },
                          "locus": {
                            "type": "string",
                            "minLength": 1
                          },
                          "quote": {
                            "type": "string",
                            "minLength": 3
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "supports",
                              "refutes",
                              "context"
                            ],
                            "default": "supports"
                          },
                          "page": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "source_id",
                          "locus",
                          "quote"
                        ],
                        "additionalProperties": false
                      },
                      "minItems": 1
                    }
                  },
                  "required": [
                    "statement",
                    "assertion_scope",
                    "knowledge_layer",
                    "evidence"
                  ],
                  "additionalProperties": false
                },
                "minItems": 1
              },
              "region": {
                "type": "string"
              },
              "region_en": {
                "type": "string"
              },
              "country_code": {
                "type": "string",
                "minLength": 2,
                "maxLength": 2
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "default": []
              },
              "scary_index": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "cultural_origin": {
                "type": "string"
              },
              "cultural_origin_en": {
                "type": "string"
              },
              "summary": {
                "type": "string",
                "maxLength": 200
              },
              "summary_en": {
                "type": "string",
                "maxLength": 280
              },
              "last_updated": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time"
                  },
                  {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  {
                    "type": "string",
                    "format": "date-time"
                  },
                  {
                    "type": "string",
                    "format": "date-time"
                  }
                ]
              },
              "confidence": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ],
                "default": "medium"
              },
              "review_status": {
                "type": "string",
                "enum": [
                  "reviewed",
                  "pending",
                  "flagged"
                ],
                "default": "pending"
              },
              "review_type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent"
                ],
                "default": "human"
              },
              "reviewed_by": {
                "type": "string"
              },
              "reviewed_at": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "review_note": {
                "type": "string",
                "maxLength": 200
              },
              "relations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "target_id": {
                      "type": "string"
                    },
                    "target_name": {
                      "type": "string"
                    },
                    "target_name_en": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "parent_of",
                        "child_of",
                        "spouse_of",
                        "sibling_of",
                        "friend_of",
                        "enemy_of",
                        "vassal_of",
                        "ruler_of",
                        "creator_of",
                        "created_by",
                        "slayer_of",
                        "slain_by",
                        "dwells_in",
                        "guards",
                        "wields",
                        "transformed_into",
                        "knows_about",
                        "allied_with",
                        "related_to"
                      ]
                    },
                    "description": {
                      "type": "string"
                    },
                    "description_en": {
                      "type": "string"
                    },
                    "source_quote": {
                      "type": "string"
                    },
                    "confidence": {
                      "type": "string",
                      "enum": [
                        "high",
                        "medium",
                        "low"
                      ],
                      "default": "medium"
                    }
                  },
                  "required": [
                    "target_id",
                    "target_name",
                    "type",
                    "description"
                  ],
                  "additionalProperties": false
                },
                "default": []
              }
            },
            "required": [
              "id",
              "title",
              "type",
              "claims",
              "region",
              "country_code",
              "scary_index",
              "cultural_origin",
              "summary",
              "last_updated"
            ],
            "additionalProperties": false
          }
        },
        "$schema": "http://json-schema.org/draft-07/schema#"
      },
      "MythosLinkDocument": {
        "type": "object",
        "required": [
          "id",
          "title",
          "type",
          "summary",
          "markdown",
          "claims",
          "node_endpoint"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/MythosLinkMythEntry/definitions/MythosLinkMythEntry/properties/type"
          },
          "summary": {
            "type": "string"
          },
          "markdown": {
            "type": "string"
          },
          "review_type": {
            "type": "string",
            "enum": [
              "human",
              "agent"
            ]
          },
          "reviewed_by": {
            "type": "string"
          },
          "reviewed_at": {
            "type": "string",
            "format": "date"
          },
          "claims": {
            "$ref": "#/components/schemas/MythosLinkMythEntry/definitions/MythosLinkMythEntry/properties/claims"
          },
          "node_endpoint": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  },
  "paths": {
    "/api/node/{id}.json": {
      "get": {
        "summary": "获取单个节点完整数据",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "节点详情",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MythosLinkMythEntry"
                }
              }
            }
          }
        }
      }
    },
    "/api/doc/{id}.json": {
      "get": {
        "summary": "获取单个节点的 Markdown 文档与说法/证据",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "文档内容",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MythosLinkDocument"
                }
              }
            }
          }
        }
      }
    }
  }
}