【问题标题】:Swagger UI watch security specificationsSwagger UI 手表安全规范
【发布时间】:2016-03-08 21:45:02
【问题描述】:

我正在用 Swagger 记录一个 API,这是我第一次使用 Swagger。当我使用 swagger 编辑器时,我可以记录并查看我想看到的内容。但是,当我将相同的 yaml 文件放入 swagger ui 中时,我看不到我的安全定义。可能是我做错了什么?还是不可能?

securityDefinitions:
  clientId:
    type: apiKey
    name: x_client_id
    in: header
  accessToken:
    type: apiKey
    name: access_token
    in: header
security:
  - clientId: []
  - accessToken: []

还有一个我使用的例子

/auth/signup:
  post:
    description: register a user
    security:
     - accessToken: []
    parameters:
      - name: User
        in: body
        required: true
        schema:
          $ref: '#/definitions/UserRequest'
    responses:
      200:
        description: SuccessfulResponse
        schema:
          $ref: '#/definitions/AuthSuccessfulResponse'
      400:
        description: Error
        schema:
          $ref: '#/definitions/BadRequest'

谢谢

【问题讨论】:

    标签: swagger swagger-ui


    【解决方案1】:

    目前是的,安全定义不是动态强制执行的。这将在 https://github.com/swagger-api/swagger-ui/pull/2014 合并后的一天左右得到解决。

    【讨论】:

      猜你喜欢
      • 2021-02-09
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      • 2010-10-04
      • 1970-01-01
      • 2017-12-11
      • 2020-12-19
      • 1970-01-01
      相关资源
      最近更新 更多