Files
mtusi2026lab4/contracts/extensions.openapi.json
T
Чиняева f39ae06ef3 Реализовать лабораторную 4 на оценку 5
Добавить приватное S3-хранилище, вложения, presigned upload, reconciler и доказательства.
2026-11-07 01:37:21 +03:00

159 lines
5.9 KiB
JSON

{
"openapi": "3.1.0",
"info": {
"title": "Messenger lab4 extensions: presigned direct upload",
"version": "1.4.0-extension.1",
"description": "Backward-compatible extension. The mandatory proxy upload in openapi.json remains supported and is the fallback."
},
"paths": {
"/api/v1/chats/{chat_id}/attachments/presign": {
"post": {
"operationId": "presignAttachmentUpload",
"summary": "Create a short-lived presigned PUT URL for a private-bucket object",
"parameters": [
{
"name": "chat_id",
"in": "path",
"required": true,
"schema": {"type": "string", "format": "uuid"}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/PresignRequest"}
}
}
},
"responses": {
"201": {
"description": "URL created; the attachment is pending until complete",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/PresignResponse"}
}
}
},
"400": {"$ref": "#/components/responses/Error"},
"401": {"$ref": "#/components/responses/Error"},
"404": {"$ref": "#/components/responses/Error"},
"413": {"$ref": "#/components/responses/Error"},
"415": {"$ref": "#/components/responses/Error"},
"503": {"$ref": "#/components/responses/Error"}
}
}
},
"/api/v1/attachments/{attachment_id}/complete": {
"post": {
"operationId": "completeAttachmentUpload",
"summary": "Verify size and SHA-256 of a direct upload and make it ready",
"parameters": [
{
"name": "attachment_id",
"in": "path",
"required": true,
"schema": {"type": "string", "format": "uuid"}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/CompleteRequest"}
}
}
},
"responses": {
"200": {
"description": "Ready attachment, or the same ready attachment on an idempotent retry",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/AttachmentExtension"}
}
}
},
"400": {"$ref": "#/components/responses/Error"},
"401": {"$ref": "#/components/responses/Error"},
"404": {"$ref": "#/components/responses/Error"},
"409": {"$ref": "#/components/responses/Error"},
"503": {"$ref": "#/components/responses/Error"}
}
}
}
},
"components": {
"responses": {
"Error": {
"description": "Typed error",
"content": {
"application/json": {
"schema": {"$ref": "../openapi.json#/components/schemas/Error"}
}
}
}
},
"schemas": {
"PresignRequest": {
"type": "object",
"properties": {
"filename": {"type": "string", "minLength": 1, "maxLength": 255},
"content_type": {"type": "string", "enum": ["image/png", "image/jpeg"]},
"size_bytes": {"type": "integer", "minimum": 1, "maximum": 10485760},
"sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
},
"required": ["filename", "content_type", "size_bytes", "sha256"],
"additionalProperties": false
},
"PresignResponse": {
"type": "object",
"properties": {
"attachment_id": {"type": "string", "format": "uuid"},
"upload_url": {"type": "string", "format": "uri"},
"method": {"type": "string", "const": "PUT"},
"headers": {
"type": "object",
"properties": {
"Content-Type": {"type": "string", "enum": ["image/png", "image/jpeg"]},
"x-amz-meta-sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
},
"required": ["Content-Type", "x-amz-meta-sha256"],
"additionalProperties": false
},
"expires_at": {"type": "string", "format": "date-time"}
},
"required": ["attachment_id", "upload_url", "method", "headers", "expires_at"],
"additionalProperties": false
},
"CompleteRequest": {
"type": "object",
"properties": {
"sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
"size_bytes": {"type": "integer", "minimum": 1, "maximum": 10485760}
},
"required": ["sha256", "size_bytes"],
"additionalProperties": false
},
"AttachmentExtension": {
"type": "object",
"properties": {
"id": {"type": "string", "format": "uuid"},
"chat_id": {"type": "string", "format": "uuid"},
"owner_id": {"type": "string", "format": "uuid"},
"filename": {"type": "string", "minLength": 1, "maxLength": 255},
"content_type": {"type": "string", "enum": ["image/png", "image/jpeg"]},
"size_bytes": {"type": "integer", "minimum": 1, "maximum": 10485760},
"sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
"status": {"type": "string", "enum": ["pending", "ready", "failed"]},
"variants": {"type": "array", "items": {"type": "object"}},
"error_code": {"type": ["string", "null"]},
"created_at": {"type": "string", "format": "date-time"},
"updated_at": {"type": "string", "format": "date-time"}
},
"required": ["id", "chat_id", "owner_id", "filename", "content_type", "size_bytes", "sha256", "status", "variants", "error_code", "created_at", "updated_at"],
"additionalProperties": false
}
}
}
}