【问题标题】:Swagger Configuration to Specify Authentication Schema用于指定身份验证架构的 Swagger 配置
【发布时间】:2018-01-30 11:27:13
【问题描述】:

我已经指定了 Swagger 注解,用于生成 API 所需的 Security/Authentication;根据 Swagger 文档。

 @ApiOperation(value = "Add a new pet to the store", 
    authorizations = {
          @Authorization(
                  value="petoauth", 
                  scopes = {
                          @AuthorizationScope(
                                  scope = "add:pet", 
                                  description = "allows adding of pets")
                          }
                  )
    }
  )

添加此代码并生成文档后,作为文档的一部分,我看到安全部分的“类型”设置为“未知”。 我可以控制它并将其设置为任何自定义值吗?

【问题讨论】:

    标签: java swagger


    【解决方案1】:

    进一步研究发现,在指定 swagger-maven-plugin 并在 pom(模块的 pom.xml)下配置它时,在此处指定此配置:

    <securityDefinition>
        <name>basicAuth</name>
        <type>basic</type>
    </securityDefinition>
    

    (Stackoverflow 的其中一个答案没有太多详细信息,但错过了相同的链接。如果有人找到它,请在此处链接以给予应有的信任)

    另外,这里需要注意的是类型值。这些必须是以下之一: - 基本的 - oauth2 (有人可以在这一点上纠正我,但根据我的观察发现了这一点)

    【讨论】:

      猜你喜欢
      • 2018-06-26
      • 2021-10-18
      • 2013-06-17
      • 2012-06-13
      • 2012-08-06
      • 1970-01-01
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多