我正在使用swagger来记录我的Java REST API。 X-Auth-Token
应该在每个API(除了一个)的头部中发送。 我想在授权的宠物商店V2中有这样的按钮。 可以在这里找到:http://petstore.swagger.io/Swagger批注以获得授权按钮
我明白它是在jason \ yaml文件中定义的,由swagger生成。 确切的说是在YAML做过这样的:
securityDefinitions:
petstore_auth:
type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
flow: "implicit"
scopes:
write:pets: "modify pets in your account"
read:pets: "read your pets"
api_key:
type: "apiKey"
name: "api_key"
in: "header"
我所有的招摇的文档我的注释做了。但是我找不到这个按钮的注释。 你能帮我找到这个注解吗?
谢谢!
曾经找到一个解决方案:
所以最后我通过调用Ajax调用取回一个令牌,并调用此方法做了一种自动授权? –
通过在@SwaggerDefinition中添加字段。我会在星期天更新答案 – sosolo