/api/v1/),保持向后兼容openapi: 3.0.0
info:
title: D8D Starter API
version: 1.0.0
description: D8D Starter项目RESTful API文档
servers:
- url: http://localhost:3000/api/v1
description: 本地开发环境
- url: https://api.example.com/api/v1
description: 生产环境
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
User:
type: object
properties:
id:
type: integer
format: int64
username:
type: string
email:
type: string
nullable: true
roles:
type: array
items:
$ref: '#/components/schemas/Role'
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
Role:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
permissions:
type: array
items:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
PaginatedUsers:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/User'
pagination:
$ref: '#/components/schemas/Pagination'
Pagination:
type: object
properties:
total:
type: integer
current:
type: integer
pageSize:
type: integer
totalPages:
type: integer
security:
- BearerAuth: []
用户管理端点:
/api/v1/users请求示例:
{
"page": 1,
"pageSize": 10,
"keyword": "搜索词",
"sortBy": "createdAt",
"sortOrder": "DESC"
}
响应示例:
{
"data": [
{
"id": 1,
"email": "user@example.com",
"roles": [{"id": 1, "name": "admin"}]
}
],
"pagination": {
"total": 100,
"current": 1,
"pageSize": 10
}
}