{
  "openapi": "3.1.0",
  "info": {
    "title": "A11y Lens 웹 API",
    "version": "2026-11-30.2",
    "summary": "주소 검사, 로그인, 계정별 기록을 다루는 Cloudflare Worker API",
    "description": "화면과 같은 출처에서만 부르는 API입니다. 로그인은 쿠키로 확인하고, 상태를 바꾸는 요청(POST)은 Origin 헤더가 이 사이트와 같아야 합니다. 접근성 판정은 서버가 하지 않습니다. 서버는 검사할 문서를 바이트로 전달하고 브라우저가 판정합니다."
  },
  "servers": [
    {
      "url": "/",
      "description": "이 사이트와 같은 출처"
    }
  ],
  "tags": [
    {
      "name": "로그인",
      "description": "OAuth(PKCE) 로그인과 계정 연결"
    },
    {
      "name": "계정",
      "description": "로그인 상태, 사용량, 동의, 계정 삭제"
    },
    {
      "name": "주소 검사",
      "description": "공개 주소의 문서와 스타일시트 가져오기"
    },
    {
      "name": "검사 기록",
      "description": "주소 검사 기록 조회와 삭제"
    },
    {
      "name": "파일 저장",
      "description": "동의한 계정의 HTML·ZIP 원본 저장"
    },
    {
      "name": "운영",
      "description": "운영자 계정만 볼 수 있는 집계 수치"
    }
  ],
  "paths": {
    "/api/auth/login": {
      "get": {
        "tags": [
          "로그인"
        ],
        "summary": "로그인 시작",
        "description": "PKCE 검증값을 10분짜리 쿠키에 두고 로그인 제공자의 화면으로 보냅니다. 주소창으로 여는 요청입니다.",
        "security": [],
        "parameters": [
          {
            "name": "provider",
            "in": "query",
            "required": true,
            "description": "배포에서 켠 제공자만 받습니다.",
            "schema": {
              "type": "string",
              "enum": [
                "github",
                "google",
                "kakao"
              ]
            }
          },
          {
            "name": "next",
            "in": "query",
            "description": "로그인 뒤 돌아갈 자리. 목록에 없는 값은 /try/ 로 바꿉니다.",
            "schema": {
              "type": "string",
              "enum": [
                "/try/",
                "/account/",
                "/account/#url-scan",
                "/pricing/"
              ]
            }
          }
        ],
        "responses": {
          "302": {
            "description": "로그인 제공자의 화면으로 이동"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "provider"
            ]
          }
        }
      }
    },
    "/api/auth/callback": {
      "get": {
        "tags": [
          "로그인"
        ],
        "summary": "로그인 완료",
        "description": "인증 코드를 세션으로 바꿔 HttpOnly 쿠키에 담습니다. 한 계정은 한 로그인만 쓰므로 앞선 로그인은 여기서 끊깁니다. 실패하면 /account/?login=failed 로 보냅니다.",
        "security": [],
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "description": "로그인 제공자가 돌려준 인증 코드",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "error_code",
            "in": "query",
            "description": "제공자가 실패를 알릴 때 싣는 값",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "로그인 전 화면 또는 실패 안내로 이동"
          }
        }
      }
    },
    "/api/auth/link": {
      "get": {
        "tags": [
          "로그인"
        ],
        "summary": "다른 로그인 제공자 연결",
        "description": "로그인한 계정에 다른 제공자를 잇습니다. 이미 다른 계정에 이어진 제공자는 /account/?link=failed 또는 ?link=taken 으로 돌아옵니다.",
        "parameters": [
          {
            "name": "provider",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "github",
                "google",
                "kakao"
              ]
            }
          }
        ],
        "responses": {
          "302": {
            "description": "제공자의 화면 또는 /account/ 로 이동"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "provider"
            ]
          }
        }
      }
    },
    "/api/auth/logout": {
      "post": {
        "tags": [
          "로그인"
        ],
        "summary": "로그아웃",
        "description": "세션을 끊고 쿠키를 지웁니다. 로그인하지 않은 요청에도 같은 응답을 줍니다.",
        "security": [],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          }
        }
      }
    },
    "/api/me": {
      "get": {
        "tags": [
          "계정"
        ],
        "summary": "로그인 상태와 사용량",
        "description": "로그인하지 않았으면 user 가 null 입니다. 다른 곳에서 새로 로그인해 이 로그인이 밀려났으면 displaced 가 true 입니다.",
        "security": [],
        "responses": {
          "200": {
            "description": "현재 상태",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/consent": {
      "post": {
        "tags": [
          "계정"
        ],
        "summary": "동의 기록",
        "description": "주소 검사 또는 원본 저장의 현재 동의문 판에 동의합니다. 지난 판의 동의는 받지 않습니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "version"
                ],
                "properties": {
                  "version": {
                    "type": "string",
                    "description": "GET /api/me 의 consentVersion 또는 files.consentVersion"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "409": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "version"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/account/delete": {
      "post": {
        "tags": [
          "계정"
        ],
        "summary": "계정 삭제",
        "description": "계정과 서버에 남은 기록·원본을 지웁니다. 되돌릴 수 없어 확인 문구를 함께 보내야 합니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm"
                ],
                "properties": {
                  "confirm": {
                    "type": "string",
                    "const": "delete"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid",
              "confirm"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/scan-url": {
      "post": {
        "tags": [
          "주소 검사"
        ],
        "summary": "검사할 문서 가져오기",
        "description": "공개 주소의 HTML을 받아 바이트로 전달합니다. 스크립트로 본문을 만드는 화면은 격리된 브라우저에서 렌더링한 결과를 전달합니다. 내부 주소·IP·비표준 포트는 로그인 확인 전에 거절합니다. 사용량은 문서를 받은 뒤에만 차감합니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "http 또는 https 공개 주소"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "받아 온 문서. 이 출처에서 문서로 해석되지 않도록 바이트로 내려보냅니다.",
            "headers": {
              "x-scan-id": {
                "description": "이번 검사의 ID. 스타일시트 요청과 결과 기록에 씁니다.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "x-final-url": {
                "description": "리다이렉트를 따라간 최종 주소",
                "schema": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "x-charset": {
                "description": "문서의 문자 인코딩",
                "schema": {
                  "type": "string"
                }
              },
              "x-scan-mode": {
                "description": "받은 방식",
                "schema": {
                  "type": "string",
                  "enum": [
                    "static",
                    "rendered"
                  ]
                }
              },
              "x-usage": {
                "description": "차감 뒤 사용량(Usage 를 JSON 문자열로)",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "받지 않는 주소",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Blocked"
                }
              }
            },
            "x-errors": [
              "blocked"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin",
              "consent"
            ]
          },
          "422": {
            "$ref": "#/components/responses/FetchFailure"
          },
          "429": {
            "description": "하루 한도를 다 썼거나(quota) 렌더링이 혼잡합니다(fetch, reason render-busy, Retry-After 10초).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-errors": [
              "quota",
              "fetch"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          },
          "503": {
            "$ref": "#/components/responses/FetchFailure"
          },
          "504": {
            "$ref": "#/components/responses/FetchFailure"
          }
        }
      }
    },
    "/api/scan-asset": {
      "post": {
        "tags": [
          "주소 검사"
        ],
        "summary": "검사에 딸린 스타일시트 가져오기",
        "description": "방금 시작한 검사에 속한 스타일시트만, 검사당 12장까지 받습니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scan",
                  "url"
                ],
                "properties": {
                  "scan": {
                    "type": "string",
                    "format": "uuid",
                    "description": "x-scan-id 로 받은 값"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "스타일시트 바이트",
            "headers": {
              "x-charset": {
                "description": "문자 인코딩",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "형식이 틀렸거나 받지 않는 주소",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Blocked"
                }
              }
            },
            "x-errors": [
              "invalid",
              "blocked"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "422": {
            "$ref": "#/components/responses/FetchFailure"
          },
          "429": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "limit"
            ]
          }
        }
      }
    },
    "/api/scan-finish": {
      "post": {
        "tags": [
          "주소 검사"
        ],
        "summary": "검사 결과 수치 기록",
        "description": "브라우저가 판정한 집계 수치만 기록합니다. 선택자, 글귀, 화면은 받지 않습니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scan"
                ],
                "properties": {
                  "scan": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "summary": {
                    "$ref": "#/components/schemas/Summary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/history": {
      "get": {
        "tags": [
          "검사 기록"
        ],
        "summary": "주소 검사 기록",
        "description": "최근 100건까지 새 것부터 돌려줍니다. 기록에는 호스트, 경로, 시각, 집계 수치만 있습니다.",
        "responses": {
          "200": {
            "description": "기록 목록",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "scans"
                  ],
                  "properties": {
                    "scans": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/UrlScan"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/history/delete": {
      "post": {
        "tags": [
          "검사 기록"
        ],
        "summary": "주소 검사 기록 삭제",
        "description": "id 를 주면 한 건, 생략하면 내 기록 전부를 지웁니다. 당일 사용량은 그대로입니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OptionalId"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/files": {
      "get": {
        "tags": [
          "파일 저장"
        ],
        "summary": "저장한 파일 검사 목록",
        "description": "저장 용량과 최근 100건의 목록입니다. 원본은 싣지 않습니다.",
        "responses": {
          "200": {
            "description": "목록과 용량",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "files"
                  ],
                  "properties": {
                    "status": {
                      "$ref": "#/components/schemas/FileStatus"
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FileScan"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/files/begin": {
      "post": {
        "tags": [
          "파일 저장"
        ],
        "summary": "파일 검사 저장 시작",
        "description": "요약을 기록하고 원본을 받을지 정합니다. 용량 한도를 넘으면 요약만 남깁니다. 파일 이름에서 경로는 떼어 냅니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "kind",
                  "name",
                  "bytes"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "zip",
                      "html"
                    ]
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "bytes": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "pages": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000
                  },
                  "summary": {
                    "$ref": "#/components/schemas/Summary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "DB가 정한 결과. result.ok 가 false 이면 reason 에 consent, invalid, rate 같은 이유가 옵니다.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Relayed"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/files/chunk": {
      "get": {
        "tags": [
          "파일 저장"
        ],
        "summary": "원본 한 조각 내려받기",
        "description": "없는 기록, 남의 기록, 원본을 두지 않은 기록은 구별하지 않고 404 로 답합니다.",
        "parameters": [
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "$ref": "#/components/parameters/Seq"
          }
        ],
        "responses": {
          "200": {
            "description": "base64 로 담은 조각",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "string",
                      "contentEncoding": "base64"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "404": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "not_found"
            ]
          }
        }
      },
      "post": {
        "tags": [
          "파일 저장"
        ],
        "summary": "원본 한 조각 올리기",
        "description": "본문은 base64 글자뿐이어야 하고 40만 자를 넘을 수 없습니다. 서버는 원본을 풀거나 해석하지 않습니다. 순서와 선언한 크기는 DB 함수가 확인합니다.",
        "parameters": [
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "$ref": "#/components/parameters/Seq"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "text/plain": {
              "schema": {
                "type": "string",
                "contentEncoding": "base64",
                "maxLength": 400000
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "413": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "size"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/files/seal": {
      "post": {
        "tags": [
          "파일 저장"
        ],
        "summary": "원본 올리기 완료",
        "description": "조각을 모두 올린 뒤 부릅니다. 선언한 크기와 맞아야 보관됩니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/files/delete": {
      "post": {
        "tags": [
          "파일 저장"
        ],
        "summary": "저장한 파일 검사 삭제",
        "description": "id 를 주면 한 건, 생략하면 내 파일 검사 전부를 원본과 함께 지웁니다.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OptionalId"
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "invalid"
            ]
          },
          "401": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "login"
            ]
          },
          "403": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "origin"
            ]
          },
          "502": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "upstream"
            ]
          }
        }
      }
    },
    "/api/admin/stats": {
      "get": {
        "tags": [
          "운영"
        ],
        "summary": "운영 수치",
        "description": "최근 91일(13주)의 화면 조회, 유입 경로, 가입과 검사 건수를 집계로 돌려줍니다. 이메일, 검사한 주소, 원본은 싣지 않습니다. 운영자가 아니거나 로그인하지 않은 요청에는 없는 길과 같은 404 로 답합니다.",
        "responses": {
          "200": {
            "description": "집계 수치",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "stats"
                  ],
                  "properties": {
                    "stats": {
                      "$ref": "#/components/schemas/AdminStats"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error",
            "x-errors": [
              "not_found"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "session": []
    }
  ],
  "components": {
    "securitySchemes": {
      "session": {
        "type": "apiKey",
        "in": "cookie",
        "name": "__Host-al-at",
        "description": "로그인하면 서버가 심는 HttpOnly·Secure·SameSite=Lax 쿠키. 만료되면 갱신 쿠키(__Host-al-rt)로 한 번 갱신합니다."
      }
    },
    "parameters": {
      "FileId": {
        "name": "id",
        "in": "query",
        "required": true,
        "description": "파일 검사의 ID",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "Seq": {
        "name": "seq",
        "in": "query",
        "required": true,
        "description": "0부터 세는 조각 번호",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9999
        }
      }
    },
    "responses": {
      "Ok": {
        "description": "처리 결과",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Relayed"
            }
          }
        }
      },
      "Error": {
        "description": "오류. error 값으로 이유를 구분합니다.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "FetchFailure": {
        "description": "대상 문서를 받지 못했습니다. 사용량은 차감하지 않습니다.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FetchFailure"
            }
          }
        },
        "x-errors": [
          "fetch"
        ]
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "blocked",
              "confirm",
              "consent",
              "fetch",
              "invalid",
              "limit",
              "login",
              "method",
              "not_found",
              "origin",
              "provider",
              "quota",
              "server",
              "size",
              "unconfigured",
              "upstream",
              "version"
            ],
            "description": "모든 길이 공통으로 method(405), not_found(404), server(500), unconfigured(503)를 낼 수 있습니다."
          },
          "reason": {
            "type": "string"
          },
          "status": {
            "description": "quota 일 때는 Usage, fetch 일 때는 대상 서버의 상태 코드"
          }
        }
      },
      "Blocked": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "blocked",
              "invalid"
            ]
          },
          "reason": {
            "type": "string",
            "enum": [
              "invalid",
              "scheme",
              "credentials",
              "port",
              "self",
              "ip",
              "internal"
            ],
            "description": "주소를 받지 않은 이유"
          }
        }
      },
      "FetchFailure": {
        "type": "object",
        "required": [
          "error",
          "reason"
        ],
        "properties": {
          "error": {
            "type": "string",
            "const": "fetch"
          },
          "reason": {
            "type": "string",
            "description": "dns, unresolved, private, size, timeout, network, render-busy, render-unavailable, render-timeout, render-incomplete 등"
          },
          "status": {
            "type": "integer",
            "description": "대상 서버가 준 상태 코드(있을 때)"
          }
        }
      },
      "Relayed": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "result": {
            "description": "DB 함수가 돌려준 값"
          }
        }
      },
      "OptionalId": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "생략하면 전부"
          }
        }
      },
      "Summary": {
        "type": "object",
        "description": "검사 결과의 집계 수치. 각 값은 0 이상 1,000,000 이하의 정수이고 벗어나면 0으로 기록합니다.",
        "properties": {
          "scanned": {
            "type": "integer",
            "description": "측정한 글자 요소 수"
          },
          "fail": {
            "type": "integer",
            "description": "명암비 기준 미달 수"
          },
          "undeterminable": {
            "type": "integer",
            "description": "배경을 단색으로 정할 수 없어 판정하지 못한 수"
          },
          "issues": {
            "type": "integer",
            "description": "접근성 규칙 위반 수"
          },
          "stylesFound": {
            "type": "integer",
            "description": "문서가 가리킨 스타일시트 수"
          },
          "stylesApplied": {
            "type": "integer",
            "description": "실제로 적용한 스타일시트 수"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "string"
          },
          "daily": {
            "type": "integer",
            "description": "하루 주소 검사 한도"
          },
          "used": {
            "type": "integer",
            "description": "오늘(한국 시간) 쓴 횟수"
          },
          "bonus": {
            "type": "integer",
            "description": "남은 추가 검사 횟수"
          },
          "stored": {
            "type": "integer",
            "description": "보관 중인 기록 수"
          },
          "storedLimit": {
            "type": "integer"
          },
          "retentionDays": {
            "type": "integer"
          },
          "consent": {
            "type": "boolean",
            "description": "현재 동의문 판에 동의했는지"
          }
        }
      },
      "FileStatus": {
        "type": "object",
        "properties": {
          "consent": {
            "type": "boolean"
          },
          "usedBytes": {
            "type": "integer"
          },
          "storageBytes": {
            "type": "integer"
          },
          "fileBytes": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "countLimit": {
            "type": "integer"
          },
          "retentionDays": {
            "type": "integer"
          }
        }
      },
      "UrlScan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "host": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "summary": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Summary"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "FileScan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "zip",
              "html"
            ]
          },
          "name": {
            "type": "string"
          },
          "bytes": {
            "type": "integer"
          },
          "pages": {
            "type": "integer"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "summary": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Summary"
              },
              {
                "type": "null"
              }
            ]
          },
          "keep": {
            "type": "boolean",
            "description": "원본을 보관하기로 했는지"
          },
          "sealed": {
            "type": "boolean",
            "description": "원본 올리기가 끝났는지"
          }
        }
      },
      "Me": {
        "type": "object",
        "required": [
          "configured"
        ],
        "properties": {
          "configured": {
            "type": "boolean",
            "description": "로그인 기능이 켜진 배포인지"
          },
          "providers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "plan": {
                "type": "string"
              },
              "dailyScans": {
                "type": "integer"
              },
              "storedScans": {
                "type": "integer"
              },
              "retentionDays": {
                "type": "integer"
              }
            }
          },
          "consentVersion": {
            "type": "string"
          },
          "files": {
            "type": "object",
            "properties": {
              "fileBytes": {
                "type": "integer"
              },
              "storageBytes": {
                "type": "integer"
              },
              "chunkBytes": {
                "type": "integer"
              },
              "consentVersion": {
                "type": "string"
              }
            }
          },
          "user": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "providers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "$ref": "#/components/schemas/Usage"
          },
          "features": {
            "type": "object",
            "properties": {
              "zip": {
                "type": "boolean"
              }
            }
          },
          "displaced": {
            "type": "boolean"
          }
        }
      },
      "AdminStats": {
        "type": "object",
        "description": "날짜는 한국 시간 기준입니다. 유입은 사이트 안에서 이동한 경우를 뺀 화면 조회입니다.",
        "properties": {
          "today": {
            "type": "string",
            "format": "date"
          },
          "days": {
            "type": "integer",
            "description": "집계 기간(일)"
          },
          "views": {
            "type": "integer",
            "description": "기간 안의 화면 조회 수"
          },
          "entries": {
            "type": "integer",
            "description": "기간 안의 유입 수"
          },
          "accounts": {
            "type": "integer",
            "description": "가입 계정 수"
          },
          "accountsNew": {
            "type": "integer",
            "description": "기간 안에 가입한 계정 수"
          },
          "urlScans": {
            "type": "integer",
            "description": "보관 중인 주소 검사 기록 수"
          },
          "fileScans": {
            "type": "integer",
            "description": "보관 중인 파일 검사 기록 수"
          },
          "storedBytes": {
            "type": "integer",
            "description": "저장한 원본의 합계 크기"
          },
          "byDay": {
            "type": "array",
            "description": "날짜별 조회와 유입",
            "items": {
              "type": "object",
              "properties": {
                "day": {
                  "type": "string",
                  "format": "date"
                },
                "views": {
                  "type": "integer"
                },
                "entries": {
                  "type": "integer"
                }
              }
            }
          },
          "bySource": {
            "type": "array",
            "description": "유입 표시별 횟수. direct, ref:호스트, 주소의 from 값",
            "items": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string"
                },
                "hits": {
                  "type": "integer"
                }
              }
            }
          },
          "byPath": {
            "type": "array",
            "description": "화면 경로별 조회 수",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "hits": {
                  "type": "integer"
                }
              }
            }
          },
          "jobs": {
            "type": "array",
            "description": "보관 작업의 마지막 실행",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "active": {
                  "type": "boolean"
                },
                "last": {
                  "type": "string",
                  "format": "date-time"
                },
                "status": {
                  "type": "string"
                }
              }
            }
          },
          "scans": {
            "type": "integer",
            "description": "기간 안의 주소 검사 건수"
          },
          "files": {
            "type": "integer",
            "description": "기간 안의 파일 검사 저장 건수"
          },
          "byWeek": {
            "type": "array",
            "description": "주별 추이. 한 주는 월요일에 시작",
            "items": {
              "type": "object",
              "properties": {
                "week": {
                  "type": "string",
                  "format": "date"
                },
                "views": {
                  "type": "integer"
                },
                "entries": {
                  "type": "integer"
                },
                "signups": {
                  "type": "integer"
                },
                "scans": {
                  "type": "integer"
                },
                "files": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}
