{
  "openapi": "3.1.0",
  "info": {
    "title": "Object Storage API",
    "version": "1.0",
    "description": "Practice object metadata, base64 content, checksums, Range requests and resumable upload state."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/storage/v1"
    }
  ],
  "tags": [
    {
      "name": "objects",
      "description": "stored test files"
    },
    {
      "name": "uploads",
      "description": "resumable sessions"
    }
  ],
  "paths": {
    "/objects": {
      "get": {
        "tags": [
          "objects"
        ],
        "summary": "List stored objects",
        "operationId": "st-list",
        "responses": {
          "200": {
            "description": "Objects",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/objects/{key}": {
      "put": {
        "tags": [
          "objects"
        ],
        "summary": "Upload a base64 object with checksum",
        "operationId": "st-put",
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "412": {
            "description": "ETag mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid base64",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "fixtures/users.json"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contentBase64": {
                    "type": "string"
                  },
                  "contentType": {
                    "type": "string"
                  },
                  "checksum": {
                    "type": "string"
                  }
                },
                "required": [
                  "contentBase64",
                  "contentType",
                  "checksum"
                ],
                "additionalProperties": false
              },
              "example": {
                "contentBase64": "SGVsbG8sIHRlc3RlciE=",
                "contentType": "text/plain",
                "checksum": "demo-checksum"
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "objects"
        ],
        "summary": "Download object metadata/content; accepts Range",
        "operationId": "st-get",
        "responses": {
          "200": {
            "description": "Whole object",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "206": {
            "description": "Partial content",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "416": {
            "description": "Invalid range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "fixtures/users.json"
          },
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "bytes=0-9"
          }
        ]
      },
      "delete": {
        "tags": [
          "objects"
        ],
        "summary": "Delete an object",
        "operationId": "st-delete",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "fixtures/users.json"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "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
      }
    }
  }
}
