geoqiao
(Geoqiao)
5
greyli
(Grey Li)
6
任务 3 已经被 RoyHuang 认领了哎,可以考虑换一个
greyli
(Grey Li)
9
@uncle-lv 这个 PR 最近有时间更新吗?刚刚才提交 review……
1 个赞
uncle-lv
(Uncle Lv)
10
已处理
.pre-commit-config.yaml
里的flake8版本是4.0.1不支持Python3.12,导致流水线跑不过
我不确定是否要像主仓库一样用Ruff替换它,所以暂时升级到5.0.0了
1 个赞
greyli
(Grey Li)
11
和主仓库同步改动以后就已经会被 Ruff 替换了吧
1 个赞
uncle-lv
(Uncle Lv)
12
看了一下,主仓库换Ruff是4个月前,我这个pr是10个月前提交的
1 个赞
任务2解决了吗? 我看issue里面评论,暂时使用其他的代替了是吗?我可以尝试一下这个任务吗?
RoyHuang
(HuangChenglong)
15
任务3已提交PR,pycon回去刚好遇上疯狂加班 ,翻的有点慢
任务 2 还没解决吧?我没看到相关 PR,我这边也有兴趣尝试~
任务 2 我提交了一个 PR
有空的时候麻烦 reivew 下
@greyli @uncle-lv
1 个赞
greyli
(Grey Li)
20
不是所有人都需要绝对 URL,我建议添加一个选项来决定是否使用哪个 URL。下面是我上次在本地大概尝试的实现,可以参考下:
纯文本:
+ docs_oauth2_redirect_path_external: bool = False,
docs_ui: str = 'swagger-ui',
openapi_blueprint_url_prefix: str | None = None,
json_errors: bool = True,
@@ -299,6 +301,8 @@ class APIFlask(APIScaffold, Flask):
docs_ui: The UI of API documentation, one of `swagger-ui` (default), `redoc`,
`elements`, `rapidoc`, and `rapipdf`.
docs_oauth2_redirect_path: The path to Swagger UI OAuth redirect.
+ docs_oauth2_redirect_path_external: If `True`, the OAuth2 redirect path
+ will be an external URL.
openapi_blueprint_url_prefix: The url prefix of the OpenAPI blueprint. This
prefix will append before all the OpenAPI-related paths (`sepc_path`,
`docs_path`, etc.), defaults to `None`.
@@ -310,6 +314,10 @@ class APIFlask(APIScaffold, Flask):
Other keyword arguments are directly passed to `flask.Flask`.
+ *Version changed: 2.2.1*
+
+ - Add `docs_oauth2_redirect_path_external` parameter.
+
*Version changed: 2.0.0*
- Remove the deprecated `redoc_path` parameter.
@@ -348,6 +356,7 @@ class APIFlask(APIScaffold, Flask):
self.docs_ui = docs_ui
self.docs_path = docs_path
self.docs_oauth2_redirect_path = docs_oauth2_redirect_path
+ self.docs_oauth2_redirect_path_external = docs_oauth2_redirect_path_external
self.openapi_blueprint_url_prefix = openapi_blueprint_url_prefix
self.enable_openapi = enable_openapi
self.json_errors = json_errors
@@ -549,11 +558,20 @@ class APIFlask(APIScaffold, Flask):
@bp.route(self.docs_path)
@self._apply_decorators(config_name='DOCS_DECORATORS')
def docs():
+ if self.docs_ui == 'swagger-ui':
+ if self.docs_oauth2_redirect_path_external:
+ oauth2_redirect_path = url_for(
+ 'openapi.swagger_ui_oauth_redirect', _external=True
+ )
+ else:
+ oauth2_redirect_path = self.docs_oauth2_redirect_path
+ else:
+ oauth2_redirect_path = None
return render_template_string(
ui_templates[self.docs_ui],
title=self.title,
version=self.version,
- oauth2_redirect_path=self.docs_oauth2_redirect_path,
+ oauth2_redirect_path=oauth2_redirect_path,
)
1 个赞