AWS Lambda请求URL为:我的网站是一个很好的网站,我的网站是一个很好的网站。
Screenshot
URL应该是https://.. amazonaws.com/apispec.json
当我手动删除$default时,这是很好的。
这是困扰我们,所以如果有人能帮助我们,这将是非常感谢。
Swagger配置:
swagger_config['swagger_ui_bundle_js'] = '//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js'
swagger_config['swagger_ui_standalone_preset_js'] = '//unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js'
swagger_config['jquery_js'] = '//unpkg.com/jquery@2.2.4/dist/jquery.min.js'
swagger_config['swagger_ui_css'] = '//unpkg.com/swagger-ui-dist@3/swagger-ui.css'
# swagger_config['specs'][0] = {'endpoint':'/cms-api/apispec','route':'/cms-api/apispec.json'}
Swagger(app, config=swagger_config, template=template)
摆动配置
swagger_config = {
"headers": [
],
"specs": [
{
"endpoint": 'apispec',
"route": '/apispec.json',
"rule_filter": lambda rule: True, # all in
"model_filter": lambda tag: True, # all in
}
],
"static_url_path": "/flasgger_static",
"swagger_ui": True,
"specs_route": "/cms-api"
}
serverless.yml
service: cms-backend
frameworkVersion: '3'
custom:
wsgi:
app: src.__init__.app
provider:
name: aws
stage: ${opt:stage, 'dev'}
runtime: python3.8
logs:
httpApi: true
httpApi:
metrics: true
cors: true
region: ap-southeast-1
functions:
app:
handler: wsgi_handler.handler
events:
- httpApi: '*'
plugins:
- serverless-wsgi
- serverless-python-requirements
1条答案
按热度按时间1dkrff031#
遇到了一个类似的问题,我花了很长时间才弄清楚,但结果发现它与API gateway stages有关。Serverless没有使用这个功能,只是为不同的阶段部署了一个新功能。
如果你没有使用API网关的stage,试着通过添加
STRIP_STAGE_PATH
环境变量来忽略它们,就像serverless-wsgi documentation中提到的那样。它应该会从你的路径中忽略$default
stage变量:(This是source code of the serverless_wsgi module的代码片段):