{
  "openapi": "3.1.0",
  "info": {
    "title": "主体核验开发原型API",
    "version": "0.4",
    "description": "当前实现的公开参考快照。没有已开放的公共服务地址；生产契约、鉴权和部署未冻结。文档站本身不执行查询。"
  },
  "servers": [],
  "paths": {
    "/health": {
      "get": {
        "summary": "进程健康，不表示来源健康",
        "responses": {
          "200": {
            "description": "进程可响应",
            "content": {
              "application/json": {
                "example": {
                  "status": "ok",
                  "schema_version": "0.4"
                }
              }
            }
          }
        }
      }
    },
    "/verifications": {
      "post": {
        "summary": "创建查询任务，每次创建新任务，rid不提供幂等",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerificationRequest"
              },
              "example": {
                "rid": "example-001",
                "name": "瑞金医院",
                "query_mask": 7
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "任务已接受",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "JSON或字段校验失败",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "413": {
            "description": "请求体为空或超出8192字节",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "415": {
            "description": "非application/json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "429": {
            "description": "队列已满",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/verifications/{job_id}": {
      "get": {
        "summary": "查询任务及业务结果",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务存在；COMPLETED不代表唯一匹配或字段齐全",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "路径或任务不存在",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "VerificationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rid"
        ],
        "properties": {
          "rid": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "\\S"
              },
              {
                "type": "integer"
              }
            ],
            "description": "关联标识，不提供幂等性；整数的字符串表示也不超过200字符。"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "social_credit_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200,
            "description": "格式问题在业务结果中反馈，非本字段的HTTP格式拒绝条件。"
          },
          "query_mask": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7,
            "default": 7
          }
        },
        "anyOf": [
          {
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              }
            }
          },
          {
            "required": [
              "social_credit_code"
            ],
            "properties": {
              "social_credit_code": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              }
            }
          }
        ]
      },
      "Job": {
        "type": "object",
        "required": [
          "job_id",
          "state",
          "request",
          "result"
        ],
        "properties": {
          "job_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{32}$"
          },
          "state": {
            "type": "string",
            "enum": [
              "QUEUED",
              "RUNNING",
              "COMPLETED",
              "FAILED"
            ]
          },
          "request": {
            "$ref": "#/components/schemas/VerificationRequest"
          },
          "result": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "开发原型结果；包含schema_version、原输入、status、details、sources、issues等，未冻结生产契约。"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "status_url": {
            "type": "string"
          }
        }
      }
    }
  },
  "x-not-production-contract": true
}
