docs:更新swagger 文档

This commit is contained in:
root 2025-12-27 10:44:50 +08:00
parent 00a0e583a8
commit 20e9e36d29
3 changed files with 474 additions and 131 deletions

View File

@ -71,7 +71,7 @@ const docTemplate = `{
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/requests.CreateBucketRequest" "$ref": "#/definitions/file-system_internal_api_requests.CreateBucketRequest"
} }
} }
], ],
@ -104,6 +104,114 @@ const docTemplate = `{
} }
} }
} }
},
"delete": {
"description": "删除指定的 S3 存储桶(桶必须为空)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"存储桶管理"
],
"summary": "删除存储桶",
"parameters": [
{
"description": "删除存储桶请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/file-system_internal_api_requests.DeleteBucketRequest"
}
}
],
"responses": {
"200": {
"description": "删除成功消息",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/delete": {
"delete": {
"description": "从指定的存储桶删除文件",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"文件操作"
],
"summary": "删除文件",
"parameters": [
{
"description": "请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/file-system_internal_api_requests.DeleteFileRequest"
}
}
],
"responses": {
"200": {
"description": "删除成功消息",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
} }
}, },
"/files/download": { "/files/download": {
@ -207,7 +315,7 @@ const docTemplate = `{
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/repository.ListFilesResult" "$ref": "#/definitions/file-system_internal_domain_repository.ListFilesResult"
} }
}, },
"400": { "400": {
@ -251,7 +359,7 @@ const docTemplate = `{
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/requests.CompleteMultipartRequest" "$ref": "#/definitions/file-system_internal_api_requests.CompleteMultipartRequest"
} }
} }
], ],
@ -306,7 +414,7 @@ const docTemplate = `{
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/requests.InitMultipartRequest" "$ref": "#/definitions/file-system_internal_api_requests.InitMultipartRequest"
} }
} }
], ],
@ -544,18 +652,77 @@ const docTemplate = `{
} }
}, },
"definitions": { "definitions": {
"common.Part": { "file-system_internal_api_requests.CompleteMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/file-system_internal_common.Part"
}
},
"upload_id": {
"type": "string"
}
}
},
"file-system_internal_api_requests.CreateBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"file-system_internal_api_requests.DeleteBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"file-system_internal_api_requests.DeleteFileRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
},
"file-system_internal_api_requests.InitMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
},
"file-system_internal_common.Part": {
"type": "object", "type": "object",
"properties": { "properties": {
"etag": { "etag": {
"type": "string" "type": "string"
}, },
"partNumber": { "partNumber": {
"type": "integer" "type": "integer",
"format": "int32"
} }
} }
}, },
"repository.FileInfo": { "file-system_internal_domain_repository.FileInfo": {
"type": "object", "type": "object",
"properties": { "properties": {
"etag": { "etag": {
@ -568,62 +735,24 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"size": { "size": {
"type": "integer" "type": "integer",
"format": "int64"
} }
} }
}, },
"repository.ListFilesResult": { "file-system_internal_domain_repository.ListFilesResult": {
"type": "object", "type": "object",
"properties": { "properties": {
"files": { "files": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/repository.FileInfo" "$ref": "#/definitions/file-system_internal_domain_repository.FileInfo"
} }
}, },
"nextContinuationToken": { "nextContinuationToken": {
"type": "string" "type": "string"
} }
} }
},
"requests.CompleteMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/common.Part"
}
},
"upload_id": {
"type": "string"
}
}
},
"requests.CreateBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"requests.InitMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
} }
} }
}` }`

View File

@ -65,7 +65,7 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/requests.CreateBucketRequest" "$ref": "#/definitions/file-system_internal_api_requests.CreateBucketRequest"
} }
} }
], ],
@ -98,6 +98,114 @@
} }
} }
} }
},
"delete": {
"description": "删除指定的 S3 存储桶(桶必须为空)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"存储桶管理"
],
"summary": "删除存储桶",
"parameters": [
{
"description": "删除存储桶请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/file-system_internal_api_requests.DeleteBucketRequest"
}
}
],
"responses": {
"200": {
"description": "删除成功消息",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/delete": {
"delete": {
"description": "从指定的存储桶删除文件",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"文件操作"
],
"summary": "删除文件",
"parameters": [
{
"description": "请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/file-system_internal_api_requests.DeleteFileRequest"
}
}
],
"responses": {
"200": {
"description": "删除成功消息",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
} }
}, },
"/files/download": { "/files/download": {
@ -201,7 +309,7 @@
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/repository.ListFilesResult" "$ref": "#/definitions/file-system_internal_domain_repository.ListFilesResult"
} }
}, },
"400": { "400": {
@ -245,7 +353,7 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/requests.CompleteMultipartRequest" "$ref": "#/definitions/file-system_internal_api_requests.CompleteMultipartRequest"
} }
} }
], ],
@ -300,7 +408,7 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/requests.InitMultipartRequest" "$ref": "#/definitions/file-system_internal_api_requests.InitMultipartRequest"
} }
} }
], ],
@ -538,18 +646,77 @@
} }
}, },
"definitions": { "definitions": {
"common.Part": { "file-system_internal_api_requests.CompleteMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/file-system_internal_common.Part"
}
},
"upload_id": {
"type": "string"
}
}
},
"file-system_internal_api_requests.CreateBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"file-system_internal_api_requests.DeleteBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"file-system_internal_api_requests.DeleteFileRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
},
"file-system_internal_api_requests.InitMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
},
"file-system_internal_common.Part": {
"type": "object", "type": "object",
"properties": { "properties": {
"etag": { "etag": {
"type": "string" "type": "string"
}, },
"partNumber": { "partNumber": {
"type": "integer" "type": "integer",
"format": "int32"
} }
} }
}, },
"repository.FileInfo": { "file-system_internal_domain_repository.FileInfo": {
"type": "object", "type": "object",
"properties": { "properties": {
"etag": { "etag": {
@ -562,62 +729,24 @@
"type": "string" "type": "string"
}, },
"size": { "size": {
"type": "integer" "type": "integer",
"format": "int64"
} }
} }
}, },
"repository.ListFilesResult": { "file-system_internal_domain_repository.ListFilesResult": {
"type": "object", "type": "object",
"properties": { "properties": {
"files": { "files": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/repository.FileInfo" "$ref": "#/definitions/file-system_internal_domain_repository.FileInfo"
} }
}, },
"nextContinuationToken": { "nextContinuationToken": {
"type": "string" "type": "string"
} }
} }
},
"requests.CompleteMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/common.Part"
}
},
"upload_id": {
"type": "string"
}
}
},
"requests.CreateBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"requests.InitMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
} }
} }
} }

View File

@ -1,13 +1,51 @@
basePath: / basePath: /
definitions: definitions:
common.Part: file-system_internal_api_requests.CompleteMultipartRequest:
properties:
bucket_name:
type: string
object_key:
type: string
parts:
items:
$ref: '#/definitions/file-system_internal_common.Part'
type: array
upload_id:
type: string
type: object
file-system_internal_api_requests.CreateBucketRequest:
properties:
bucket_name:
type: string
type: object
file-system_internal_api_requests.DeleteBucketRequest:
properties:
bucket_name:
type: string
type: object
file-system_internal_api_requests.DeleteFileRequest:
properties:
bucket_name:
type: string
object_key:
type: string
type: object
file-system_internal_api_requests.InitMultipartRequest:
properties:
bucket_name:
type: string
object_key:
type: string
type: object
file-system_internal_common.Part:
properties: properties:
etag: etag:
type: string type: string
partNumber: partNumber:
format: int32
type: integer type: integer
type: object type: object
repository.FileInfo: file-system_internal_domain_repository.FileInfo:
properties: properties:
etag: etag:
type: string type: string
@ -16,42 +54,18 @@ definitions:
lastModified: lastModified:
type: string type: string
size: size:
format: int64
type: integer type: integer
type: object type: object
repository.ListFilesResult: file-system_internal_domain_repository.ListFilesResult:
properties: properties:
files: files:
items: items:
$ref: '#/definitions/repository.FileInfo' $ref: '#/definitions/file-system_internal_domain_repository.FileInfo'
type: array type: array
nextContinuationToken: nextContinuationToken:
type: string type: string
type: object type: object
requests.CompleteMultipartRequest:
properties:
bucket_name:
type: string
object_key:
type: string
parts:
items:
$ref: '#/definitions/common.Part'
type: array
upload_id:
type: string
type: object
requests.CreateBucketRequest:
properties:
bucket_name:
type: string
type: object
requests.InitMultipartRequest:
properties:
bucket_name:
type: string
object_key:
type: string
type: object
host: localhost:8080 host: localhost:8080
info: info:
contact: {} contact: {}
@ -60,6 +74,41 @@ info:
version: "1.1" version: "1.1"
paths: paths:
/buckets: /buckets:
delete:
consumes:
- application/json
description: 删除指定的 S3 存储桶(桶必须为空)
parameters:
- description: 删除存储桶请求参数
in: body
name: request
required: true
schema:
$ref: '#/definitions/file-system_internal_api_requests.DeleteBucketRequest'
produces:
- application/json
responses:
"200":
description: 删除成功消息
schema:
additionalProperties:
type: string
type: object
"400":
description: 参数错误
schema:
additionalProperties:
type: string
type: object
"500":
description: 服务器内部错误
schema:
additionalProperties:
type: string
type: object
summary: 删除存储桶
tags:
- 存储桶管理
get: get:
consumes: consumes:
- application/json - application/json
@ -94,7 +143,7 @@ paths:
name: request name: request
required: true required: true
schema: schema:
$ref: '#/definitions/requests.CreateBucketRequest' $ref: '#/definitions/file-system_internal_api_requests.CreateBucketRequest'
produces: produces:
- application/json - application/json
responses: responses:
@ -119,6 +168,42 @@ paths:
summary: 创建存储桶 summary: 创建存储桶
tags: tags:
- 存储桶管理 - 存储桶管理
/files/delete:
delete:
consumes:
- application/json
description: 从指定的存储桶删除文件
parameters:
- description: 请求参数
in: body
name: request
required: true
schema:
$ref: '#/definitions/file-system_internal_api_requests.DeleteFileRequest'
produces:
- application/json
responses:
"200":
description: 删除成功消息
schema:
additionalProperties:
type: string
type: object
"400":
description: 参数错误
schema:
additionalProperties:
type: string
type: object
"500":
description: 服务器内部错误
schema:
additionalProperties:
type: string
type: object
summary: 删除文件
tags:
- 文件操作
/files/download: /files/download:
get: get:
consumes: consumes:
@ -186,7 +271,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/repository.ListFilesResult' $ref: '#/definitions/file-system_internal_domain_repository.ListFilesResult'
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
@ -213,7 +298,7 @@ paths:
name: request name: request
required: true required: true
schema: schema:
$ref: '#/definitions/requests.CompleteMultipartRequest' $ref: '#/definitions/file-system_internal_api_requests.CompleteMultipartRequest'
produces: produces:
- application/json - application/json
responses: responses:
@ -249,7 +334,7 @@ paths:
name: request name: request
required: true required: true
schema: schema:
$ref: '#/definitions/requests.InitMultipartRequest' $ref: '#/definitions/file-system_internal_api_requests.InitMultipartRequest'
produces: produces:
- application/json - application/json
responses: responses: