288 lines
7.1 KiB
YAML

components:
# 数据模型
schemas:
# 基础请求模型
BaseRequest:
type: object
required:
- Version
- InstId
- TranCode
- TranDate
- TranSeq
properties:
Version:
type: string
description: 版本号
example: "1.0.1"
InstId:
type: string
description: 机构编码
example: "00001"
maxLength: 30
TranCode:
type: string
description: 交易码
example: "Query"
maxLength: 20
TranDate:
type: string
description: 交易日期
pattern: '^\d{8}$'
example: "20240101"
TranSeq:
type: string
description: 交易流水号(银行生成的唯一标识)
example: "123456789012"
maxLength: 40
# 基础响应模型
BaseResponse:
type: object
required:
- Version
- InstId
- TranCode
- TranDate
- TranSeq
- RespCode
- RespMessage
properties:
Version:
type: string
description: 版本号
example: "1.0.1"
InstId:
type: string
description: 机构编码
example: "00001"
TranCode:
type: string
description: 交易码
example: "QueryRes"
TranDate:
type: string
description: 交易日期
pattern: '^\d{8}$'
example: "20240101"
TranSeq:
type: string
description: 交易流水号
example: "123456789012"
RespCode:
type: string
description: 返回码
enum:
- "AAAAAAA" # 成功
- "DEF0001" # 无相应记录
- "DEF0002" # 缴费金额不匹配
- "SYS1001" # 系统异常
- "SEC2001" # 加密错误
example: "AAAAAAA"
RespMessage:
type: string
description: 返回消息
example: "成功"
maxLength: 60
# 错误详情
ErrorDetail:
type: object
properties:
ErrorCode:
type: string
description: 错误码
example: "DEF0001"
ErrorMsg:
type: string
description: 错误消息
example: "用户编号123456不存在"
ErrorTime:
type: string
format: date-time
description: 错误时间
example: "2024-01-01T12:00:00.000Z"
# 其他数据模型引用原有文件
BillQueryRequest:
$ref: './schemas.yaml#/components/schemas/BillQueryRequest'
BillQueryResponse:
$ref: './schemas.yaml#/components/schemas/BillQueryResponse'
BillPayRequest:
$ref: './schemas.yaml#/components/schemas/BillPayRequest'
BillPayResponse:
$ref: './schemas.yaml#/components/schemas/BillPayResponse'
# 响应组件
responses:
# 业务错误响应
BusinessError:
description: 业务处理错误
content:
application/xml:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
application/json:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
# 系统错误响应
SystemError:
description: 系统异常错误
content:
application/xml:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
application/json:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
# 安全错误响应
SecurityError:
description: 安全验证错误
content:
application/xml:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
application/json:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
# 网络错误响应
NetworkError:
description: 网络通信错误
content:
application/xml:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
application/json:
schema:
allOf:
- $ref: '#/components/schemas/BaseResponse'
- type: object
properties:
ErrorDetail:
$ref: '#/components/schemas/ErrorDetail'
# 参数组件
parameters:
ContentTypeHeader:
name: Content-Type
in: header
required: true
description: 请求内容类型
schema:
type: string
enum:
- application/xml
- application/json
example: "application/xml"
EncryptTypeHeader:
name: X-Encrypt-Type
in: header
required: false
description: 加密算法类型
schema:
type: string
enum:
- "3DES"
- "SM2"
- "SM4"
example: "3DES"
EncryptModeHeader:
name: X-Encrypt-Mode
in: header
required: false
description: 加密模式
schema:
type: string
enum:
- "ECB"
- "CBC"
example: "ECB"
DataTypeHeader:
name: X-Data-Type
in: header
required: false
description: 数据格式类型
schema:
type: string
enum:
- "XML"
- "JSON"
example: "XML"
# 响应头组件
headers:
ContentType:
description: 响应内容类型
schema:
type: string
example: "application/xml; charset=GBK"
ResponseTime:
description: 响应时间(毫秒)
schema:
type: integer
example: 150
RequestId:
description: 请求唯一标识
schema:
type: string
example: "req-123456789012"
# 安全认证组件
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API密钥认证
EncryptedData:
type: http
scheme: bearer
bearerFormat: encrypted
description: 加密数据传输认证