×
全部 > AI技术 > AI编程 > AI代码生成 > 生成微服务接口文档

生成微服务接口文档

claude3.5 sonnet 20240620(Anthropic)

Based on your request, I will generate an OpenAPI 3.0 formatted documentation for the provided Java + Spring Boot source code. Here’s the output: ```yaml openapi: 3.0.0 info: title: User Service API description: API for managing users in the system. version: 1.0.0 servers: - url: http://localhost:8080 paths: /users/{id}: get: summary: Retrieve a user by ID operationId: getUser parameters: - name: id in: path required: true description: The ID of the user to retrieve. schema: type: integer responses: '200': description: User retrieved successfully content: application/json: schema: $ref: '#/components/schemas/UserDTO' '404': description: User not found content: application/json: schema: type: object properties: message: type: string example: User not found /users/: post: summary: Create a new user operationId: createUser requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UserCreateRequest' responses: '201': description: User created successfully content: application/json: schema: $ref: '#/components/schemas/UserDTO' '400': description: Invalid input content: application/json: schema: type: object properties: message: type: string example: Invalid input data components: schemas: UserDTO: type: object properties: id: type: integer name: type: string email: type: string UserCreateRequest: type: object properties: name: type: string email: type: string ``` ### Summary of the Generated Documentation: - **Service Metadata**: Basic information about the User Service API. - **API Endpoints**: - `GET /users/{id}`: Retrieve a user by ID. - `POST /users/`: Create a new user. - **Detailed Interface Descriptions**: - For each endpoint, the method, path, request parameters, response formats, and error codes are specified. - **Versioning**: The API version is set to 1.0.0. This documentation is structured to comply with OpenAPI 3.0 standards and is formatted in Markdown. If you need any modifications or additional features, please let me know!

通义千问2.5-Coder-14B(阿里云百炼)

```yaml openapi: 3.0.0 info: title: User Service API version: 1.0.0 paths: /users/{id}: get: summary: Get user by ID operationId: getUser parameters: - name: id in: path description: User ID required: true schema: type: integer format: int64 responses: '200': description: A user object content: application/json: schema: $ref: '#/components/schemas/UserDTO' '404': description: User not found /users: post: summary: Create a new user operationId: createUser requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UserCreateRequest' responses: '201': description: User created successfully content: application/json: schema: $ref: '#/components/schemas/UserDTO' components: schemas: UserDTO: type: object properties: id: type: integer format: int64 name: type: string email: type: string UserCreateRequest: type: object properties: name: type: string email: type: string ```

gpt-4.1(OpenAI)

# OpenAPI 3.0 规范文档 --- ## 服务基本信息(Service Metadata) ```yaml openapi: 3.0.3 info: title: User Service API version: v1 description: 用户微服务接口文档,提供用户的查询与创建功能。 servers: - url: http://localhost:8080 description: 本地开发环境 tags: - name: User description: 用户相关操作 ``` --- ## 接口列表(API Endpoints) ```yaml paths: /users/{id}: get: tags: - User summary: 获取用户详情 operationId: getUser parameters: - name: id in: path required: true schema: type: integer format: int64 description: 用户唯一标识ID responses: '200': description: 查询成功,返回用户信息 content: application/json: schema: $ref: '#/components/schemas/UserDTO' '404': description: 用户未找到 content: application/json: schema: $ref: '#/components/schemas/Error' /users/: post: tags: - User summary: 创建新用户 operationId: createUser requestBody: required: true description: 用户创建请求对象 content: application/json: schema: $ref: '#/components/schemas/UserCreateRequest' responses: '201': description: 创建成功,返回新用户信息 content: application/json: schema: $ref: '#/components/schemas/UserDTO' '400': description: 请求参数错误 content: application/json: schema: $ref: '#/components/schemas/Error' ``` --- ## 数据结构(Schemas) ```yaml components: schemas: UserDTO: type: object properties: id: type: integer format: int64 description: 用户唯一标识ID username: type: string description: 用户名 email: type: string format: email description: 邮箱地址 createdAt: type: string format: date-time description: 创建时间 required: - id - username - email - createdAt description: 用户数据对象 UserCreateRequest: type: object properties: username: type: string description: 用户名 email: type: string format: email description: 邮箱地址 password: type: string format: password description: 用户密码 required: - username - email - password description: 创建用户请求对象 Error: type: object properties: code: type: integer format: int32 description: 错误码 message: type: string description: 错误信息 required: - code - message description: 错误响应对象 ``` --- ## 版本控制(Versioning) - 当前文档版本:v1 - 每当接口或数据结构发生变化,请更新`info.version`和必要的接口描述,并维持历史版本记录。 --- **注意:本接口文档基于输入的源代码自动生成,确保接口文档与代码实现保持一致。如有数据结构自定义或注释更详细要求,请在源代码层面补充。**

DeepSeek V3(Deepseek)

```markdown # OpenAPI 3.0 Documentation ## Service Metadata - **Title**: User Service - **Description**: API for user management operations - **Version**: 1.0.0 - **Base URL**: /users ## API Endpoints ### 1. GET /users/{id} - **Description**: Retrieve a user by ID - **Method**: GET - **Path**: /users/{id} - **Parameters**: - `id` (path, required, integer, format: int64): User ID - **Responses**: - 200: Success ```json { "id": 0, "name": "string", "email": "string" } ``` - 404: User not found - 500: Internal server error ### 2. POST /users/ - **Description**: Create a new user - **Method**: POST - **Path**: /users/ - **Request Body**: ```json { "name": "string", "email": "string", "password": "string" } ``` - **Responses**: - 201: User created ```json { "id": 0, "name": "string", "email": "string" } ``` - 400: Invalid input - 500: Internal server error ## Data Schemas ### UserDTO ```json { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "email": { "type": "string" } } } ``` ### UserCreateRequest ```json { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string" }, "password": { "type": "string" } }, "required": ["name", "email", "password"] } ``` ## Version Control - Current API version: v1 - Versioning strategy: URI path versioning (planned for future versions) ```

模型名称 模型提供商 响应总时长(s) 生成 token 数 首 token 延迟(s) 生成速率(tokens/s)
18.03
0
2.56
0
7.87
响应最快
317
0.38
延迟最小
40.29
10.15
848
内容最多
1.87
83.51
速度最快
25.85
496
3.39
19.19
AI文本生成
38家服务商提供服务
AI深度推理
11家服务商提供服务
AI代码生成
11家服务商提供服务
AI数学模型
10家服务商提供服务