AWS请求url是: https://..amazonaws.com/$default/apispec.json
网址应该是https://..amazonaws.com/apispec.json
不过,当我手动删除$default时会很好。
这是困扰我们,所以如果有人可以帮助我们,这将是非常感谢。
昂首阔步的康菲:
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
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
发布于 2022-06-16 07:59:57
遇到了一个类似的问题,我花了很长的时间才弄明白,但事实证明它与API网关阶段有关。Serverless不使用这个特性,只是在不同的阶段部署了一个新函数。
如果您没有使用API的各个阶段,请尝试通过添加STRIP_STAGE_PATH
环境变量(如无服务器-wsgi文档中提到的那样)将它们排除在外。它应该从路径中省略$default
阶段变量:
provider:
environment:
STRIP_STAGE_PATH: yes
(这是wsgi模块的代码片段):
def get_script_name(headers, request_context):
strip_stage_path = os.environ.get("STRIP_STAGE_PATH", "").lower().strip() in
[
"yes",
"y",
"true",
"t",
"1",
]
if "amazonaws.com" in headers.get("Host", "") and not strip_stage_path:
script_name = "/{}".format(request_context.get("stage", ""))
else:
script_name = ""
return script_name
https://stackoverflow.com/questions/72539862
复制相似问题