APIFlask 2.3.2__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {apiflask-2.3.2 → apiflask-2.4.0}/CHANGES.md +11 -0
  2. {apiflask-2.3.2 → apiflask-2.4.0}/PKG-INFO +3 -2
  3. {apiflask-2.3.2 → apiflask-2.4.0}/examples/openapi/static_docs/index.html +3 -3
  4. {apiflask-2.3.2 → apiflask-2.4.0}/pyproject.toml +1 -1
  5. {apiflask-2.3.2 → apiflask-2.4.0}/src/APIFlask.egg-info/PKG-INFO +3 -2
  6. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/app.py +19 -1
  7. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/settings.py +7 -7
  8. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_blueprint.py +13 -0
  9. {apiflask-2.3.2 → apiflask-2.4.0}/LICENSE +0 -0
  10. {apiflask-2.3.2 → apiflask-2.4.0}/MANIFEST.in +0 -0
  11. {apiflask-2.3.2 → apiflask-2.4.0}/NOTICE +0 -0
  12. {apiflask-2.3.2 → apiflask-2.4.0}/README.md +0 -0
  13. {apiflask-2.3.2 → apiflask-2.4.0}/examples/README.md +0 -0
  14. {apiflask-2.3.2 → apiflask-2.4.0}/examples/auth/basic_auth/app.py +0 -0
  15. {apiflask-2.3.2 → apiflask-2.4.0}/examples/auth/token_auth/app.py +0 -0
  16. {apiflask-2.3.2 → apiflask-2.4.0}/examples/base_response/app.py +0 -0
  17. {apiflask-2.3.2 → apiflask-2.4.0}/examples/basic/app.py +0 -0
  18. {apiflask-2.3.2 → apiflask-2.4.0}/examples/blueprint_tags/app.py +0 -0
  19. {apiflask-2.3.2 → apiflask-2.4.0}/examples/cbv/app.py +0 -0
  20. {apiflask-2.3.2 → apiflask-2.4.0}/examples/dataclass/app.py +0 -0
  21. {apiflask-2.3.2 → apiflask-2.4.0}/examples/file_upload/app.py +0 -0
  22. {apiflask-2.3.2 → apiflask-2.4.0}/examples/file_upload/upload/.gitkeep +0 -0
  23. {apiflask-2.3.2 → apiflask-2.4.0}/examples/openapi/basic/app.py +0 -0
  24. {apiflask-2.3.2 → apiflask-2.4.0}/examples/openapi/custom_decorators/app.py +0 -0
  25. {apiflask-2.3.2 → apiflask-2.4.0}/examples/openapi/static_docs/app.py +0 -0
  26. {apiflask-2.3.2 → apiflask-2.4.0}/examples/openapi/static_docs/generate_docs.sh +0 -0
  27. {apiflask-2.3.2 → apiflask-2.4.0}/examples/openapi/static_docs/openapi.json +0 -0
  28. {apiflask-2.3.2 → apiflask-2.4.0}/examples/orm/app.py +0 -0
  29. {apiflask-2.3.2 → apiflask-2.4.0}/examples/pagination/app.py +0 -0
  30. {apiflask-2.3.2 → apiflask-2.4.0}/examples/requirements.txt +0 -0
  31. {apiflask-2.3.2 → apiflask-2.4.0}/examples/test_examples.py +0 -0
  32. {apiflask-2.3.2 → apiflask-2.4.0}/requirements/dev.txt +0 -0
  33. {apiflask-2.3.2 → apiflask-2.4.0}/requirements/docs.txt +0 -0
  34. {apiflask-2.3.2 → apiflask-2.4.0}/requirements/examples.txt +0 -0
  35. {apiflask-2.3.2 → apiflask-2.4.0}/requirements/min-versions.txt +0 -0
  36. {apiflask-2.3.2 → apiflask-2.4.0}/requirements/tests.txt +0 -0
  37. {apiflask-2.3.2 → apiflask-2.4.0}/requirements/typing.txt +0 -0
  38. {apiflask-2.3.2 → apiflask-2.4.0}/setup.cfg +0 -0
  39. {apiflask-2.3.2 → apiflask-2.4.0}/src/APIFlask.egg-info/SOURCES.txt +0 -0
  40. {apiflask-2.3.2 → apiflask-2.4.0}/src/APIFlask.egg-info/dependency_links.txt +0 -0
  41. {apiflask-2.3.2 → apiflask-2.4.0}/src/APIFlask.egg-info/entry_points.txt +0 -0
  42. {apiflask-2.3.2 → apiflask-2.4.0}/src/APIFlask.egg-info/requires.txt +0 -0
  43. {apiflask-2.3.2 → apiflask-2.4.0}/src/APIFlask.egg-info/top_level.txt +0 -0
  44. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/__init__.py +0 -0
  45. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/blueprint.py +0 -0
  46. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/commands.py +0 -0
  47. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/exceptions.py +0 -0
  48. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/fields.py +0 -0
  49. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/helpers.py +0 -0
  50. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/openapi.py +0 -0
  51. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/py.typed +0 -0
  52. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/route.py +0 -0
  53. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/scaffold.py +0 -0
  54. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/schemas.py +0 -0
  55. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/security.py +0 -0
  56. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/types.py +0 -0
  57. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/ui_templates.py +0 -0
  58. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/validators.py +0 -0
  59. {apiflask-2.3.2 → apiflask-2.4.0}/src/apiflask/views.py +0 -0
  60. {apiflask-2.3.2 → apiflask-2.4.0}/tests/__init__.py +0 -0
  61. {apiflask-2.3.2 → apiflask-2.4.0}/tests/conftest.py +0 -0
  62. {apiflask-2.3.2 → apiflask-2.4.0}/tests/schemas.py +0 -0
  63. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_app.py +0 -0
  64. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_apps/__init__.py +0 -0
  65. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_async.py +0 -0
  66. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_base_response.py +0 -0
  67. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_blueprint.py +0 -0
  68. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_commands.py +0 -0
  69. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_decorator_auth_required.py +0 -0
  70. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_decorator_doc.py +0 -0
  71. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_decorator_input.py +0 -0
  72. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_decorator_output.py +0 -0
  73. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_decorators.py +0 -0
  74. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_exceptions.py +0 -0
  75. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_fields.py +0 -0
  76. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_helpers.py +0 -0
  77. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_basic.py +0 -0
  78. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_extensions.py +0 -0
  79. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_headers.py +0 -0
  80. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_info.py +0 -0
  81. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_paths.py +0 -0
  82. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_security.py +0 -0
  83. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_openapi_tags.py +0 -0
  84. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_route.py +0 -0
  85. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_schemas.py +0 -0
  86. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_security.py +0 -0
  87. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_settings_api_docs.py +0 -0
  88. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_settings_auto_behaviour.py +0 -0
  89. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_settings_openapi_fields.py +0 -0
  90. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_settings_openapi_spec.py +0 -0
  91. {apiflask-2.3.2 → apiflask-2.4.0}/tests/test_settings_response_customization.py +0 -0
  92. {apiflask-2.3.2 → apiflask-2.4.0}/tox.ini +0 -0
@@ -1,3 +1,14 @@
1
+ ## Version 2.4.0
2
+
3
+ Released: 2025/3/25
4
+
5
+ - Add `docs_oauth2_redirect_path_external` parameter to support absolute OAuth2 redirect url ([issue #602][issue_602]).
6
+ - Change the default docs CDN to jsDelivr by default instead of unpkg ([pr #650](pr_650)).
7
+
8
+ [issue_602]: https://github.com/apiflask/apiflask/issues/602
9
+ [pr_650]: https://github.com/apiflask/apiflask/pull/650
10
+
11
+
1
12
  ## Version 2.3.2
2
13
 
3
14
  Released: 2024/12/15
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: APIFlask
3
- Version: 2.3.2
3
+ Version: 2.4.0
4
4
  Summary: A lightweight web API framework based on Flask and marshmallow-code projects.
5
5
  Author-email: Grey Li <withlihui@gmail.com>
6
6
  License: MIT
@@ -41,6 +41,7 @@ Provides-Extra: async
41
41
  Requires-Dist: asgiref>=3.2; extra == "async"
42
42
  Provides-Extra: yaml
43
43
  Requires-Dist: pyyaml; extra == "yaml"
44
+ Dynamic: license-file
44
45
 
45
46
 
46
47
  ![](https://apiflask.com/_assets/apiflask-logo.png)
@@ -4,7 +4,7 @@
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <title>APIFlask 0.1.0 - Swagger UI</title>
7
- <link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css">
7
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui.css">
8
8
  <link rel="icon" type="image/png"
9
9
  href="https://apiflask.com/_assets/favicon.png">
10
10
  <style>
@@ -30,8 +30,8 @@
30
30
  <body>
31
31
  <div id="swagger-ui"></div>
32
32
 
33
- <script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
34
- <script src="https://unpkg.com/swagger-ui-dist/swagger-ui-standalone-preset.js"></script>
33
+ <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui-bundle.js"></script>
34
+ <script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui-standalone-preset.js"></script>
35
35
  <script>
36
36
  // we can get several config items of Function type
37
37
  // referring to https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/
@@ -4,7 +4,7 @@ description = "A lightweight web API framework based on Flask and marshmallow-co
4
4
  readme = "README.md"
5
5
  license = { text = "MIT" }
6
6
  authors = [{ name = "Grey Li", email = "withlihui@gmail.com" }]
7
- version = "2.3.2"
7
+ version = "2.4.0"
8
8
  classifiers = [
9
9
  "Development Status :: 3 - Alpha",
10
10
  "Environment :: Web Environment",
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: APIFlask
3
- Version: 2.3.2
3
+ Version: 2.4.0
4
4
  Summary: A lightweight web API framework based on Flask and marshmallow-code projects.
5
5
  Author-email: Grey Li <withlihui@gmail.com>
6
6
  License: MIT
@@ -41,6 +41,7 @@ Provides-Extra: async
41
41
  Requires-Dist: asgiref>=3.2; extra == "async"
42
42
  Provides-Extra: yaml
43
43
  Requires-Dist: pyyaml; extra == "yaml"
44
+ Dynamic: license-file
44
45
 
45
46
 
46
47
  ![](https://apiflask.com/_assets/apiflask-logo.png)
@@ -16,6 +16,7 @@ from flask import json
16
16
  from flask import jsonify
17
17
  from flask import render_template_string
18
18
  from flask import request
19
+ from flask import url_for
19
20
  from flask.config import ConfigAttribute
20
21
  from flask.wrappers import Response
21
22
 
@@ -268,6 +269,7 @@ class APIFlask(APIScaffold, Flask):
268
269
  spec_path: str | None = '/openapi.json',
269
270
  docs_path: str | None = '/docs',
270
271
  docs_oauth2_redirect_path: str | None = '/docs/oauth2-redirect',
272
+ docs_oauth2_redirect_path_external: bool = False,
271
273
  docs_ui: str = 'swagger-ui',
272
274
  openapi_blueprint_url_prefix: str | None = None,
273
275
  json_errors: bool = True,
@@ -299,6 +301,8 @@ class APIFlask(APIScaffold, Flask):
299
301
  docs_ui: The UI of API documentation, one of `swagger-ui` (default), `redoc`,
300
302
  `elements`, `rapidoc`, and `rapipdf`.
301
303
  docs_oauth2_redirect_path: The path to Swagger UI OAuth redirect.
304
+ docs_oauth2_redirect_path_external: If `True`, the `docs_oauth2_redirect_path`
305
+ will be an external URL.
302
306
  openapi_blueprint_url_prefix: The url prefix of the OpenAPI blueprint. This
303
307
  prefix will append before all the OpenAPI-related paths (`sepc_path`,
304
308
  `docs_path`, etc.), defaults to `None`.
@@ -348,6 +352,7 @@ class APIFlask(APIScaffold, Flask):
348
352
  self.docs_ui = docs_ui
349
353
  self.docs_path = docs_path
350
354
  self.docs_oauth2_redirect_path = docs_oauth2_redirect_path
355
+ self.docs_oauth2_redirect_path_external = docs_oauth2_redirect_path_external
351
356
  self.openapi_blueprint_url_prefix = openapi_blueprint_url_prefix
352
357
  self.enable_openapi = enable_openapi
353
358
  self.json_errors = json_errors
@@ -509,6 +514,10 @@ class APIFlask(APIScaffold, Flask):
509
514
  The name of the blueprint is "openapi". This blueprint will hold the view
510
515
  functions for spec file and API docs.
511
516
 
517
+ *Version changed: 2.3.3*
518
+
519
+ - Add 'docs_oauth2_redirect_path_external' parameter to support absolute redirect url.
520
+
512
521
  *Version changed: 2.1.0*
513
522
 
514
523
  - Inject the OpenAPI endpoints decorators.
@@ -549,11 +558,20 @@ class APIFlask(APIScaffold, Flask):
549
558
  @bp.route(self.docs_path)
550
559
  @self._apply_decorators(config_name='DOCS_DECORATORS')
551
560
  def docs():
561
+ docs_oauth2_redirect_path = None
562
+ if self.docs_ui == 'swagger-ui':
563
+ if self.docs_oauth2_redirect_path_external:
564
+ docs_oauth2_redirect_path = url_for(
565
+ 'openapi.swagger_ui_oauth_redirect', _external=True
566
+ )
567
+ else:
568
+ docs_oauth2_redirect_path = self.docs_oauth2_redirect_path
569
+
552
570
  return render_template_string(
553
571
  ui_templates[self.docs_ui],
554
572
  title=self.title,
555
573
  version=self.version,
556
- oauth2_redirect_path=self.docs_oauth2_redirect_path,
574
+ oauth2_redirect_path=docs_oauth2_redirect_path,
557
575
  )
558
576
 
559
577
  if self.docs_ui == 'swagger-ui':
@@ -57,22 +57,22 @@ REDOC_USE_GOOGLE_FONT: bool = True
57
57
  REDOC_STANDALONE_JS: str = 'https://cdn.redoc.ly/redoc/latest/bundles/\
58
58
  redoc.standalone.js' # TODO: rename to REDOC_JS
59
59
  REDOC_CONFIG: dict | None = None
60
- SWAGGER_UI_CSS: str = 'https://unpkg.com/swagger-ui-dist/swagger-ui.css'
61
- SWAGGER_UI_BUNDLE_JS: str = 'https://unpkg.com/swagger-ui-dist/\
60
+ SWAGGER_UI_CSS: str = 'https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui.css'
61
+ SWAGGER_UI_BUNDLE_JS: str = 'https://cdn.jsdelivr.net/npm/swagger-ui-dist/\
62
62
  swagger-ui-bundle.js' # TODO: rename to SWAGGER_UI_JS
63
- SWAGGER_UI_STANDALONE_PRESET_JS: str = 'https://unpkg.com/swagger-ui-dist/\
63
+ SWAGGER_UI_STANDALONE_PRESET_JS: str = 'https://cdn.jsdelivr.net/npm/swagger-ui-dist/\
64
64
  swagger-ui-standalone-preset.js' # TODO: rename to SWAGGER_UI_STANDALONE_JS
65
65
  SWAGGER_UI_LAYOUT: str = 'BaseLayout'
66
66
  SWAGGER_UI_CONFIG: dict | None = None
67
67
  SWAGGER_UI_OAUTH_CONFIG: dict | None = None
68
- ELEMENTS_JS: str = 'https://unpkg.com/@stoplight/elements/web-components.min.js'
69
- ELEMENTS_CSS: str = 'https://unpkg.com/@stoplight/elements/styles.min.css'
68
+ ELEMENTS_JS: str = 'https://cdn.jsdelivr.net/npm/@stoplight/elements/web-components.min.js'
69
+ ELEMENTS_CSS: str = 'https://cdn.jsdelivr.net/npm/@stoplight/elements/styles.min.css'
70
70
  ELEMENTS_LAYOUT: str = 'sidebar'
71
71
  ELEMENTS_CONFIG: dict | None = None
72
- RAPIDOC_JS: str = 'https://unpkg.com/rapidoc/dist/rapidoc-min.js'
72
+ RAPIDOC_JS: str = 'https://cdn.jsdelivr.net/npm/rapidoc/dist/rapidoc-min.js'
73
73
  RAPIDOC_THEME: str = 'light'
74
74
  RAPIDOC_CONFIG: dict | None = None
75
- RAPIPDF_JS: str = 'https://unpkg.com/rapipdf/dist/rapipdf-min.js'
75
+ RAPIPDF_JS: str = 'https://cdn.jsdelivr.net/npm/rapipdf/dist/rapipdf-min.js'
76
76
  RAPIPDF_CONFIG: dict | None = None
77
77
 
78
78
  # Version changed: 1.2.0
@@ -69,6 +69,19 @@ def test_docs_oauth2_redirect_path(client):
69
69
  assert rv.status_code == 200
70
70
  assert b'oauth2RedirectUrl: "/docs/oauth2/redirect"' in rv.data
71
71
 
72
+ # Test the feature of external oauth2 redirect path
73
+ app = APIFlask(
74
+ __name__,
75
+ docs_oauth2_redirect_path='/docs/oauth2/redirect/external',
76
+ docs_oauth2_redirect_path_external=True,
77
+ )
78
+ rv = app.test_client().get('/docs/oauth2/redirect/external')
79
+ assert rv.status_code == 200
80
+ assert b'<title>Swagger UI: OAuth2 Redirect</title>' in rv.data
81
+ rv = app.test_client().get('/docs')
82
+ assert rv.status_code == 200
83
+ assert b'oauth2RedirectUrl: "http://localhost/docs/oauth2/redirect/external"' in rv.data
84
+
72
85
  app = APIFlask(__name__, docs_oauth2_redirect_path=None)
73
86
  assert app.docs_oauth2_redirect_path is None
74
87
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes