ERPTurbo_Poster/swagger.json
shenyifei dc940d2598 feat(api): 添加海报和PDF生成功能
- 新增海报生成接口,支持从网页URL或HTML内容生成海报图像
- 新增PDF生成接口,支持从网页URL或HTML内容生成PDF文档
- 添加Swagger API文档注释,完善接口描述和参数说明
- 实现HTML内容参数支持,允许直接传入HTML结构生成海报/PDF
- 添加输入验证和标准化响应格式
- 引入DOMPurify库对HTML内容进行安全过滤
- 更新环境变量配置,支持API密钥认证和CORS设置
- 优化上传逻辑,统一返回标准响应结构
- 添加构建脚本支持Docker镜像打包和推送
2025-11-20 17:51:35 +08:00

2 lines
5.2 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"openapi": "3.0.0", "info": {"title": "ERPTurbo_Poster API", "version": "1.0.0", "description": "海报和PDF生成服务API文档"}, "servers": [{"url": "http://localhost:3000", "description": "开发服务器"}], "paths": {"/status": {"get": {"summary": "健康检查", "description": "检查服务是否正常运行", "tags": ["Health"], "responses": {"200": {"description": "服务正常运行", "content": {"application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "example": true, "description": "请求是否成功"}, "data": {"type": "object", "example": {}, "description": "响应数据"}, "message": {"type": "string", "example": "Service is running", "description": "响应消息"}, "code": {"type": "number", "example": 200, "description": "响应代码"}}}}}}, "500": {"description": "服务异常"}}}}, "/api/v1/poster": {"post": {"summary": "生成海报", "description": "从网页URL或HTML内容生成海报图像", "tags": ["Poster"], "security": [{"ApiKeyAuth": []}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "properties": {"webpage": {"type": "string", "description": "要生成海报的网页URL", "example": "https://example.com"}, "html": {"type": "string", "description": "要生成海报的HTML内容可选优先级高于webpage", "example": "<html><body><h1>Hello World</h1></body></html>"}, "device": {"type": "number", "description": "设备缩放因子", "default": 1, "example": 1}, "width": {"type": "number", "description": "海报宽度", "default": 1920, "example": 1920}, "height": {"type": "number", "description": "海报高度", "default": 1080, "example": 1080}, "type": {"type": "string", "description": "输出图像类型", "default": "png", "example": "png"}, "encoding": {"type": "string", "description": "编码类型", "default": "binary", "example": "binary"}}}}}}, "responses": {"200": {"description": "成功生成海报", "content": {"application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "example": true, "description": "请求是否成功"}, "data": {"type": "object", "properties": {"name": {"type": "string", "example": "poster_abc123def456.png", "description": "生成的海报文件名"}, "path": {"type": "string", "example": "http://example.com/uploads/posters/2024/11/14/poster_abc123def456.png", "description": "生成的海报文件访问路径"}}}, "message": {"type": "string", "example": "Poster generated successfully", "description": "响应消息"}, "code": {"type": "number", "example": 200, "description": "响应代码"}}}}}}, "400": {"description": "请求参数错误", "content": {"application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "example": false, "description": "请求是否成功"}, "data": {"type": "object", "example": null, "description": "响应数据"}, "message": {"type": "string", "example": "Missing required parameter: webpage or html", "description": "错误消息"}, "code": {"type": "number", "example": 3001, "description": "错误代码"}}}}}}, "401": {"description": "未授权访问"}, "500": {"description": "服务器内部错误"}}}}, "/api/v1/pdf": {"post": {"summary": "生成PDF", "description": "从网页URL或HTML内容生成PDF文档", "tags": ["PDF"], "security": [{"ApiKeyAuth": []}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "properties": {"webpage": {"type": "string", "description": "要生成PDF的网页URL", "example": "https://example.com"}, "html": {"type": "string", "description": "要生成PDF的HTML内容可选优先级高于webpage", "example": "<html><body><h1>Hello World</h1></body></html>"}, "device": {"type": "number", "description": "设备缩放因子", "default": 1, "example": 1}, "width": {"type": "number", "description": "PDF宽度", "default": 1920, "example": 1920}, "height": {"type": "number", "description": "PDF高度", "default": 1080, "example": 1080}}}}}}, "responses": {"200": {"description": "成功生成PDF", "content": {"application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "example": true, "description": "请求是否成功"}, "data": {"type": "object", "properties": {"name": {"type": "string", "example": "pdf_abc123def456.pdf", "description": "生成的PDF文件名"}, "path": {"type": "string", "example": "http://example.com/uploads/pdfs/2024/11/14/pdf_abc123def456.pdf", "description": "生成的PDF文件访问路径"}}}, "message": {"type": "string", "example": "PDF generated successfully", "description": "响应消息"}, "code": {"type": "number", "example": 200, "description": "响应代码"}}}}}}, "400": {"description": "请求参数错误", "content": {"application/json": {"schema": {"type": "object", "properties": {"success": {"type": "boolean", "example": false, "description": "请求是否成功"}, "data": {"type": "object", "example": null, "description": "响应数据"}, "message": {"type": "string", "example": "Missing required parameter: webpage or html", "description": "错误消息"}, "code": {"type": "number", "example": 3001, "description": "错误代码"}}}}}}, "401": {"description": "未授权访问"}, "500": {"description": "服务器内部错误"}}}}}, "components": {}, "tags": []}