龙卷风招摇授权不起作用
Tornado swagger Authorization not working
我在 tornado 框架上编写的项目使用 tornado-rest-swagger==1.1.3。
除授权外一切正常,添加了主要授权并且可以锁定但是每个端点上的授权都是 emphy 并且没有 header 从 swagger 发送。
将不胜感激任何帮助
# swagger setup
from tornado_swagger.setup import setup_swagger
if __name__ == '__main__':
setup_swagger(
routes,
swagger_url="/api/affiliate",
description="",
api_version="1.0.0",
title="Affiliate API",
)
@components.security_schemes.register
class Authorization(object):
"""
---
type: apiKey
in: header
name: Authorization
"""
handler
class Countries(AffiliateBaseHandler, ABC):
def initialize(self, *args, **kwargs):
super(Countries, self).initialize(*args, **kwargs)
@authenticated()
@coroutine
def get(self):
"""
---
security:
- ApiKeyAuth: []
tags:
- Helpers
summary: Countries list
operationId: countries_list
parameters:
- in: header
name: Authorization
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/CountryResponse'
UnauthorizedError:
description: Access token is missing or invalid
"""
我添加了一些屏幕截图以准确查看问题
从主授权授权时,可以在屏幕截图上看到主授权已锁定,但端点上没有任何变化
在第二个屏幕截图上,如果我转到端点并按下锁,则没有可用的授权
我已经通过直接在页面 html 中检查从 swagger 生成的 json 来解决问题
自动添加安全名称,名称为 Authorization
所以通过指定
security:
- Authorization: []
它起作用了,因为在我的问题中我添加了不同的名称,所以它不允许指定自定义名称并且是使用授权名称自行生成的
我只需要检查 swagger 页面上的元素并检查生成的 json 数据
我在 tornado 框架上编写的项目使用 tornado-rest-swagger==1.1.3。
除授权外一切正常,添加了主要授权并且可以锁定但是每个端点上的授权都是 emphy 并且没有 header 从 swagger 发送。
将不胜感激任何帮助
# swagger setup
from tornado_swagger.setup import setup_swagger
if __name__ == '__main__':
setup_swagger(
routes,
swagger_url="/api/affiliate",
description="",
api_version="1.0.0",
title="Affiliate API",
)
@components.security_schemes.register
class Authorization(object):
"""
---
type: apiKey
in: header
name: Authorization
"""
handler
class Countries(AffiliateBaseHandler, ABC):
def initialize(self, *args, **kwargs):
super(Countries, self).initialize(*args, **kwargs)
@authenticated()
@coroutine
def get(self):
"""
---
security:
- ApiKeyAuth: []
tags:
- Helpers
summary: Countries list
operationId: countries_list
parameters:
- in: header
name: Authorization
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/CountryResponse'
UnauthorizedError:
description: Access token is missing or invalid
"""
我添加了一些屏幕截图以准确查看问题
从主授权授权时,可以在屏幕截图上看到主授权已锁定,但端点上没有任何变化
在第二个屏幕截图上,如果我转到端点并按下锁,则没有可用的授权
我已经通过直接在页面 html 中检查从 swagger 生成的 json 来解决问题
自动添加安全名称,名称为 Authorization
所以通过指定
security:
- Authorization: []
它起作用了,因为在我的问题中我添加了不同的名称,所以它不允许指定自定义名称并且是使用授权名称自行生成的
我只需要检查 swagger 页面上的元素并检查生成的 json 数据