Files
AIOA/contracts/openapi/aioa-v1.yaml
T

139 lines
3.8 KiB
YAML

openapi: 3.1.0
info:
title: AIOA API
version: 0.1.0
servers:
- url: /api/v1
paths:
/me:
get:
operationId: getCurrentUser
summary: 获取当前登录用户
responses:
"200":
description: 当前用户
content:
application/json:
schema:
$ref: "#/components/schemas/CurrentUser"
"401":
$ref: "#/components/responses/Unauthorized"
/leave-requests:
post:
operationId: createLeaveRequest
summary: 创建并发起请假申请
parameters:
- $ref: "#/components/parameters/IdempotencyKey"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateLeaveRequest"
responses:
"201":
description: 已创建
content:
application/json:
schema:
$ref: "#/components/schemas/LeaveRequest"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
components:
parameters:
IdempotencyKey:
name: Idempotency-Key
in: header
required: true
schema:
type: string
minLength: 16
maxLength: 128
responses:
BadRequest:
description: 请求无效
content:
application/problem+json:
schema:
$ref: "#/components/schemas/Problem"
Unauthorized:
description: 未认证
content:
application/problem+json:
schema:
$ref: "#/components/schemas/Problem"
Forbidden:
description: 无权操作
content:
application/problem+json:
schema:
$ref: "#/components/schemas/Problem"
schemas:
CurrentUser:
type: object
required: [id, tenantId, username, displayName, roles]
properties:
id: { type: string, format: uuid }
tenantId: { type: string, format: uuid }
username: { type: string }
displayName: { type: string }
email:
type: [string, "null"]
format: email
department:
oneOf:
- $ref: "#/components/schemas/OrganizationRef"
- type: "null"
position:
oneOf:
- $ref: "#/components/schemas/OrganizationRef"
- type: "null"
roles:
type: array
uniqueItems: true
items: { type: string }
OrganizationRef:
type: object
required: [id, name]
properties:
id: { type: string, format: uuid }
name: { type: string }
CreateLeaveRequest:
type: object
required: [type, startsAt, endsAt, reason]
properties:
type:
type: string
enum: [PERSONAL, SICK, ANNUAL]
startsAt: { type: string, format: date-time }
endsAt: { type: string, format: date-time }
reason: { type: string, minLength: 1, maxLength: 2000 }
attachmentIds:
type: array
maxItems: 10
items: { type: string, format: uuid }
LeaveRequest:
type: object
required: [id, status, version, createdAt]
properties:
id: { type: string, format: uuid }
status:
type: string
enum: [PENDING, APPROVED, REJECTED, WITHDRAWN]
version: { type: integer, minimum: 0 }
createdAt: { type: string, format: date-time }
Problem:
type: object
required: [type, title, status, code, traceId]
properties:
type: { type: string, format: uri-reference }
title: { type: string }
status: { type: integer }
detail: { type: string }
code: { type: string }
traceId: { type: string }