{
  "openapi": "3.1.0",
  "info": {
    "title": "HTTP Echo & Inspect API",
    "version": "1.0",
    "description": "Request inspection with httpbin-compatible paths: echo any method, read your headers and IP, delay a response, chain redirects, test Basic and Bearer auth, ETags and cache headers."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/echo/v1"
    }
  ],
  "tags": [
    {
      "name": "request",
      "description": "request"
    },
    {
      "name": "timing",
      "description": "timing"
    },
    {
      "name": "status",
      "description": "status"
    },
    {
      "name": "redirects",
      "description": "redirects"
    },
    {
      "name": "auth",
      "description": "auth"
    },
    {
      "name": "data",
      "description": "data"
    },
    {
      "name": "formats",
      "description": "formats"
    },
    {
      "name": "caching",
      "description": "caching"
    }
  ],
  "paths": {
    "/anything": {
      "get": {
        "tags": [
          "request"
        ],
        "summary": "Echo a GET: method, query, headers, body and origin",
        "operationId": "ec-anything-get",
        "responses": {
          "200": {
            "description": "The request as the server saw it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {
                        "q": {
                          "type": "string"
                        }
                      }
                    },
                    "json": {
                      "type": "null"
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "test"
          }
        ]
      },
      "post": {
        "tags": [
          "request"
        ],
        "summary": "Echo a POST: method, query, headers, body and origin",
        "operationId": "ec-anything-post",
        "responses": {
          "200": {
            "description": "The request as the server saw it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {
                        "q": {
                          "type": "string"
                        }
                      }
                    },
                    "json": {
                      "type": "object",
                      "properties": {
                        "hello": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "test"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hello": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "example": {
                "hello": "world",
                "items": [
                  1,
                  2,
                  3
                ]
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "request"
        ],
        "summary": "Echo a PUT: method, query, headers, body and origin",
        "operationId": "ec-anything-put",
        "responses": {
          "200": {
            "description": "The request as the server saw it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {
                        "q": {
                          "type": "string"
                        }
                      }
                    },
                    "json": {
                      "type": "object",
                      "properties": {
                        "hello": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "test"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hello": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "example": {
                "hello": "world",
                "items": [
                  1,
                  2,
                  3
                ]
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "request"
        ],
        "summary": "Echo a PATCH: method, query, headers, body and origin",
        "operationId": "ec-anything-patch",
        "responses": {
          "200": {
            "description": "The request as the server saw it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {
                        "q": {
                          "type": "string"
                        }
                      }
                    },
                    "json": {
                      "type": "object",
                      "properties": {
                        "hello": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "test"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hello": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "example": {
                "hello": "world",
                "items": [
                  1,
                  2,
                  3
                ]
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "request"
        ],
        "summary": "Echo a DELETE: method, query, headers, body and origin",
        "operationId": "ec-anything-delete",
        "responses": {
          "200": {
            "description": "The request as the server saw it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {
                        "q": {
                          "type": "string"
                        }
                      }
                    },
                    "json": {
                      "type": "null"
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "test"
          }
        ]
      }
    },
    "/get": {
      "get": {
        "tags": [
          "request"
        ],
        "summary": "httpbin-style /get — same echo, GET only",
        "operationId": "ec-get",
        "responses": {
          "200": {
            "description": "Echoed request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {}
                    },
                    "json": {
                      "type": "null"
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Wrong method, with Allow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/post": {
      "post": {
        "tags": [
          "request"
        ],
        "summary": "httpbin-style /post — same echo, POST only",
        "operationId": "ec-post",
        "responses": {
          "200": {
            "description": "Echoed request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {}
                    },
                    "json": {
                      "type": "object",
                      "properties": {
                        "hello": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Wrong method, with Allow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hello": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "example": {
                "hello": "world",
                "items": [
                  1,
                  2,
                  3
                ]
              }
            }
          }
        }
      }
    },
    "/put": {
      "put": {
        "tags": [
          "request"
        ],
        "summary": "httpbin-style /put — same echo, PUT only",
        "operationId": "ec-put",
        "responses": {
          "200": {
            "description": "Echoed request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {}
                    },
                    "json": {
                      "type": "object",
                      "properties": {
                        "hello": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Wrong method, with Allow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hello": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "example": {
                "hello": "world",
                "items": [
                  1,
                  2,
                  3
                ]
              }
            }
          }
        }
      }
    },
    "/patch": {
      "patch": {
        "tags": [
          "request"
        ],
        "summary": "httpbin-style /patch — same echo, PATCH only",
        "operationId": "ec-patch",
        "responses": {
          "200": {
            "description": "Echoed request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {}
                    },
                    "json": {
                      "type": "object",
                      "properties": {
                        "hello": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Wrong method, with Allow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hello": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "example": {
                "hello": "world",
                "items": [
                  1,
                  2,
                  3
                ]
              }
            }
          }
        }
      }
    },
    "/delete": {
      "delete": {
        "tags": [
          "request"
        ],
        "summary": "httpbin-style /delete — same echo, DELETE only",
        "operationId": "ec-delete",
        "responses": {
          "200": {
            "description": "Echoed request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {}
                    },
                    "json": {
                      "type": "null"
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Wrong method, with Allow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/headers": {
      "get": {
        "tags": [
          "request"
        ],
        "summary": "The request headers the server received",
        "operationId": "ec-headers",
        "responses": {
          "200": {
            "description": "Headers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ip": {
      "get": {
        "tags": [
          "request"
        ],
        "summary": "The caller IP as seen by the server",
        "operationId": "ec-ip",
        "responses": {
          "200": {
            "description": "Origin IP",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "origin": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/user-agent": {
      "get": {
        "tags": [
          "request"
        ],
        "summary": "The User-Agent header",
        "operationId": "ec-user-agent",
        "responses": {
          "200": {
            "description": "User-Agent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user-agent": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/delay/{seconds}": {
      "get": {
        "tags": [
          "timing"
        ],
        "summary": "Respond after 0–10 seconds — test client timeouts",
        "operationId": "ec-delay",
        "responses": {
          "200": {
            "description": "Delayed echo",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "method": {
                      "type": "string"
                    },
                    "args": {
                      "type": "object",
                      "properties": {
                        "seconds": {
                          "type": "string"
                        }
                      }
                    },
                    "json": {
                      "type": "null"
                    },
                    "data": {
                      "type": "string"
                    },
                    "headers": {
                      "type": "object",
                      "properties": {
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "origin": {
                      "type": "string"
                    },
                    "url": {
                      "type": "null"
                    },
                    "delayedSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "seconds outside 0–10",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "seconds",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 2
          }
        ]
      }
    },
    "/status/{code}": {
      "get": {
        "tags": [
          "status"
        ],
        "summary": "Return the status code you ask for (200–599)",
        "operationId": "ec-status",
        "responses": {
          "200": {
            "description": "Or any code 200–599",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Code outside 200–599",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 503
          }
        ]
      }
    },
    "/redirect/{n}": {
      "get": {
        "tags": [
          "redirects"
        ],
        "summary": "Redirect n times (302 chain), then echo",
        "operationId": "ec-redirect",
        "responses": {
          "302": {
            "description": "Next hop in Location",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "n outside 1–10",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 3
          }
        ]
      }
    },
    "/basic-auth/{user}/{password}": {
      "get": {
        "tags": [
          "auth"
        ],
        "summary": "HTTP Basic auth: 200 when the credentials match the path, 401 otherwise",
        "operationId": "ec-basic-auth",
        "responses": {
          "200": {
            "description": "Authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "authenticated": {
                      "type": "boolean"
                    },
                    "user": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong credentials, with WWW-Authenticate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "user",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "tester"
          },
          {
            "name": "password",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "s3cret"
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "Basic dGVzdGVyOnMzY3JldA=="
          }
        ]
      }
    },
    "/bearer": {
      "get": {
        "tags": [
          "auth"
        ],
        "summary": "Any Bearer token → 200; none → 401 with WWW-Authenticate",
        "operationId": "ec-bearer",
        "responses": {
          "200": {
            "description": "Token received",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "authenticated": {
                      "type": "boolean"
                    },
                    "token": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing Bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "Bearer any-token"
          }
        ]
      }
    },
    "/uuid": {
      "get": {
        "tags": [
          "data"
        ],
        "summary": "A random UUID v4",
        "operationId": "ec-uuid",
        "responses": {
          "200": {
            "description": "UUID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/base64/{value}": {
      "get": {
        "tags": [
          "data"
        ],
        "summary": "Decode a base64 / base64url value",
        "operationId": "ec-base64",
        "responses": {
          "200": {
            "description": "Decoded text",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "decoded": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not valid base64",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "value",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "RnVuIEFQSSBQbGF5Z3JvdW5k"
          }
        ]
      }
    },
    "/json": {
      "get": {
        "tags": [
          "formats"
        ],
        "summary": "A fixed JSON document",
        "operationId": "ec-json",
        "responses": {
          "200": {
            "description": "JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "slideshow": {
                      "type": "object",
                      "properties": {
                        "title": {
                          "type": "string"
                        },
                        "author": {
                          "type": "string"
                        },
                        "slides": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "title": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "items": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/xml": {
      "get": {
        "tags": [
          "formats"
        ],
        "summary": "A fixed XML document (application/xml)",
        "operationId": "ec-xml",
        "responses": {
          "200": {
            "description": "XML",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/stream/{n}": {
      "get": {
        "tags": [
          "formats"
        ],
        "summary": "n newline-delimited JSON objects (application/x-ndjson)",
        "operationId": "ec-stream",
        "responses": {
          "200": {
            "description": "NDJSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "n outside 1–100",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 5
          }
        ]
      }
    },
    "/etag/{etag}": {
      "get": {
        "tags": [
          "caching"
        ],
        "summary": "Responds with your ETag; If-None-Match → 304, mismatched If-Match → 412",
        "operationId": "ec-etag",
        "responses": {
          "200": {
            "description": "ETag set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "etag": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "If-None-Match matched"
          },
          "412": {
            "description": "If-Match did not match",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "etag",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "abc123"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/cache/{seconds}": {
      "get": {
        "tags": [
          "caching"
        ],
        "summary": "Sets Cache-Control: private, max-age=seconds (browser caching only)",
        "operationId": "ec-cache",
        "responses": {
          "200": {
            "description": "Cacheable response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cacheControl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "seconds outside 0–86400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "seconds",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 60
          }
        ]
      }
    },
    "/response-headers": {
      "get": {
        "tags": [
          "caching"
        ],
        "summary": "Echo query pairs back as response headers (X-* and a few safe names)",
        "operationId": "ec-response-headers",
        "responses": {
          "200": {
            "description": "Headers set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "headers": {
                      "type": "object",
                      "properties": {
                        "X-Test": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Header name not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "X-Test",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "hello"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use qa-admin-token / qa-viewer-token, or a JWT from POST /auth/v1/login."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Cargo demo key: cargo-key-123."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
