openapi: 3.1.0
info:
  title: 媒体解析 API
  version: 1.0.0
  description: 使用公开分享链接解析图片或视频资源。API Key 必须通过 Authorization 请求头传递。
externalDocs:
  description: 中文快速开始与调用示例
  url: /developers/
servers:
  - url: /v1
paths:
  /parse:
    post:
      summary: 解析公开分享链接
      operationId: parsePublicUrl
      security: [{ bearerAuth: [] }]
      requestBody:
        required: true
        content:
          application/json:
            example:
              url: https://平台公开分享链接
              platform: auto
            schema:
              type: object
              required: [url]
              properties:
                url: { type: string, format: uri, description: 已登记平台的公开分享链接 }
                platform: { type: string, default: auto, description: auto 或与链接匹配的平台标识 }
      responses:
        '200':
          description: 解析成功
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Success' }
        '401': { description: API Key 缺失、无效或已过期 }
        '403': { description: API Key 无权调用该平台 }
        '422': { description: 链接或平台参数不受支持 }
        '429': { description: 超过频率或配额 }
        '502': { description: 上游解析失败 }
        '503': { description: 鉴权、限流或内部解析服务不可用 }
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API-Key
      description: 管理后台创建的 wm_live_ 或 wm_test_ API Key；只放在 Authorization 请求头中。
  schemas:
    Asset:
      type: object
      required: [type, url]
      properties:
        type: { type: string, enum: [image, video] }
        url: { type: string, format: uri }
    Success:
      type: object
      required: [request_id, code, message, data]
      properties:
        request_id: { type: string }
        code: { type: string, const: OK }
        message: { type: string }
        data:
          type: object
          properties:
            platform: { type: string }
            content_type: { type: string, enum: [image, video] }
            title: { type: string }
            author: {}
            assets: { type: array, items: { $ref: '#/components/schemas/Asset' } }
        usage:
          type: object
          properties:
            cost: { type: integer }
            remaining: { type: integer }
