fastapi_swagger2 0.2.7__tar.gz → 0.3.1__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 (40) hide show
  1. fastapi_swagger2-0.3.1/.flake8 +2 -0
  2. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1}/PKG-INFO +5 -3
  3. fastapi_swagger2-0.3.1/README.md +93 -0
  4. fastapi_swagger2-0.3.1/fastapi_0.100.0/.git +1 -0
  5. fastapi_swagger2-0.3.1/fastapi_0.100.0/.gitignore +163 -0
  6. fastapi_swagger2-0.3.1/fastapi_0.100.0/LICENSE +21 -0
  7. fastapi_swagger2-0.3.1/pyproject.toml +95 -0
  8. fastapi_swagger2-0.3.1/requirements-dev.txt +1 -0
  9. fastapi_swagger2-0.3.1/requirements.txt +1 -0
  10. fastapi_swagger2-0.3.1/scripts/build.sh +3 -0
  11. fastapi_swagger2-0.3.1/scripts/clean.sh +8 -0
  12. fastapi_swagger2-0.3.1/scripts/format.sh +6 -0
  13. fastapi_swagger2-0.3.1/scripts/lint.sh +9 -0
  14. fastapi_swagger2-0.3.1/scripts/publish.sh +5 -0
  15. fastapi_swagger2-0.3.1/scripts/test.sh +9 -0
  16. fastapi_swagger2-0.3.1/setup.cfg +3 -0
  17. fastapi_swagger2-0.3.1/src/fastapi_swagger2/__init__.py +346 -0
  18. fastapi_swagger2-0.3.1/src/fastapi_swagger2/models.py +26 -0
  19. fastapi_swagger2-0.3.1/src/fastapi_swagger2/utils.py +544 -0
  20. fastapi_swagger2-0.3.1/src/fastapi_swagger2_old/__init__.py +145 -0
  21. fastapi_swagger2-0.3.1/src/fastapi_swagger2_old/constants.py +2 -0
  22. fastapi_swagger2-0.3.1/src/fastapi_swagger2_old/models.py +425 -0
  23. fastapi_swagger2-0.3.1/src/fastapi_swagger2_old/utils.py +673 -0
  24. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1}/.gitignore +0 -0
  25. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1}/LICENSE +0 -0
  26. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/README.md +0 -0
  27. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/pyproject.toml +0 -0
  28. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/requirements-dev.txt +0 -0
  29. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/requirements.txt +0 -0
  30. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/scripts/build.sh +0 -0
  31. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/scripts/clean.sh +0 -0
  32. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/scripts/format.sh +0 -0
  33. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/scripts/lint.sh +0 -0
  34. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/scripts/publish.sh +0 -0
  35. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/scripts/test.sh +0 -0
  36. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/setup.cfg +0 -0
  37. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/src/fastapi_swagger2/__init__.py +0 -0
  38. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/src/fastapi_swagger2/constants.py +0 -0
  39. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/src/fastapi_swagger2/models.py +0 -0
  40. {fastapi_swagger2-0.2.7 → fastapi_swagger2-0.3.1/fastapi_0.100.0}/src/fastapi_swagger2/utils.py +0 -0
@@ -0,0 +1,2 @@
1
+ [flake8]
2
+ max-line-length = 88
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi_swagger2
3
- Version: 0.2.7
3
+ Version: 0.3.1
4
4
  Summary: Swagger2 support for FastAPI framework
5
5
  Project-URL: Homepage, https://github.com/virajkanwade/fastapi_swagger2
6
6
  Project-URL: Documentation, https://github.com/virajkanwade/fastapi_swagger2
@@ -53,7 +53,7 @@ Classifier: Topic :: Software Development :: Libraries
53
53
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
54
54
  Classifier: Typing :: Typed
55
55
  Requires-Python: >=3.9
56
- Requires-Dist: fastapi<0.119.0,>=0.100.0
56
+ Requires-Dist: fastapi<=0.127.1,>=0.123.9
57
57
  Provides-Extra: all
58
58
  Requires-Dist: httpx>=0.28.1; extra == 'all'
59
59
  Provides-Extra: dev
@@ -96,7 +96,9 @@ Python 3.9+
96
96
  * 0.0.3 - FastAPI >= 0.79.0, <= 0.98.0
97
97
  * 0.1.1 - FastAPI >= 0.99.0, <= 0.99.1
98
98
  * 0.2.4 - FastAPI >= 0.100.0
99
- * 0.2.7 - FastAPI >= 0.100.0, < 0.119.0 > + Pydantic v1/v2
99
+ * 0.2.7 - FastAPI >= 0.100.0, < 0.119.0 + Pydantic v1/v2
100
+ * 0.3.0 - FastAPI >= 0.119.0, <= 0.123.8 + Pydantic v1/v2
101
+ * 0.3.1 - FastAPI >= 0.123.9, <= 0.127.1 + Pydantic v1/v2 (Since FastAPI 0.126.1, Pydantic v1 is deprecated)
100
102
 
101
103
  ## Installation
102
104
 
@@ -0,0 +1,93 @@
1
+ # fastapi_swagger2
2
+ <p align="center">
3
+ Swagger2 support for FastAPI
4
+ </p>
5
+ <p align="center">
6
+ <a href="https://pypi.org/project/fastapi_swagger2" target="_blank">
7
+ <img src="https://img.shields.io/pypi/v/fastapi_swagger2?color=%2334D058&label=pypi%20package" alt="Package version">
8
+ </a>
9
+ <a href="https://pypi.org/project/fastapi_swagger2" target="_blank">
10
+ <img src="https://img.shields.io/pypi/pyversions/fastapi_swagger2.svg?color=%2334D058" alt="Supported Python versions">
11
+ </a>
12
+ </p>
13
+
14
+ ---
15
+
16
+ _Reason behind this library:_
17
+
18
+ Few API GW services like Google Cloud API GW still support only Swagger 2.0 spec. Since FastAPI only supports OAS3, it is a challenge. Converting from OAS3 to Swagger 2.0 requires some manual steps which would hinder CI/CD.
19
+
20
+ ---
21
+
22
+ ## Requirements
23
+
24
+ Python 3.9+
25
+
26
+ * 0.0.3 - FastAPI >= 0.79.0, <= 0.98.0
27
+ * 0.1.1 - FastAPI >= 0.99.0, <= 0.99.1
28
+ * 0.2.4 - FastAPI >= 0.100.0
29
+ * 0.2.7 - FastAPI >= 0.100.0, < 0.119.0 + Pydantic v1/v2
30
+ * 0.3.0 - FastAPI >= 0.119.0, <= 0.123.8 + Pydantic v1/v2
31
+ * 0.3.1 - FastAPI >= 0.123.9, <= 0.127.1 + Pydantic v1/v2 (Since FastAPI 0.126.1, Pydantic v1 is deprecated)
32
+
33
+ ## Installation
34
+
35
+ <div class="termy">
36
+
37
+ ```console
38
+ $ pip install fastapi_swagger2
39
+ ```
40
+
41
+ </div>
42
+
43
+ ## Example
44
+
45
+ ```Python
46
+ from typing import Union
47
+
48
+ from fastapi import FastAPI
49
+ from fastapi_swagger2 import FastAPISwagger2
50
+
51
+ app = FastAPI()
52
+ FastAPISwagger2(app)
53
+
54
+
55
+ @app.get("/")
56
+ def read_root():
57
+ return {"Hello": "World"}
58
+
59
+
60
+ @app.get("/items/{item_id}")
61
+ def read_item(item_id: int, q: Union[str, None] = None):
62
+ return {"item_id": item_id, "q": q}
63
+ ```
64
+
65
+ This adds following endpoints:
66
+ * http://localhost:8000/swagger2.json
67
+ * http://localhost:8000/swagger2/docs
68
+ * http://localhost:8000/swagger2/redoc
69
+
70
+ ## Generate spec for CI/CD
71
+
72
+ ```Python
73
+ import os
74
+
75
+ import yaml
76
+
77
+ from app.main import app
78
+
79
+ URL = os.environ["CLOUD_RUN_URL"]
80
+
81
+ app.servers.append(URL)
82
+
83
+ spec = app.swagger2()
84
+ spec['x-google-backend'] = {'address': URL}
85
+
86
+ print(yaml.dump(spec))
87
+ ```
88
+
89
+ ## Development
90
+
91
+ ```console
92
+ $ pip install "/path/to/fastapi_swagger2/repo[test,all]"
93
+ ```
@@ -0,0 +1 @@
1
+ gitdir: /Users/vkanwade/Work/open_source/fastapi_swagger2/.git/worktrees/fastapi_0.100.0
@@ -0,0 +1,163 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
161
+
162
+
163
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Viraj Kanwade
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,95 @@
1
+ [build-system]
2
+ requires = ["hatchling", "flit_core >=3.2,<4"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "fastapi_swagger2"
7
+ description = "Swagger2 support for FastAPI framework"
8
+ readme = "README.md"
9
+ requires-python = ">=3.9"
10
+ license = { file="LICENSE" }
11
+ authors = [
12
+ { name = "Viraj Kanwade", email = "virajk.oib@gmail.com" },
13
+ ]
14
+ classifiers = [
15
+ "Intended Audience :: Information Technology",
16
+ "Intended Audience :: System Administrators",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python",
20
+ "Topic :: Internet",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ "Topic :: Software Development :: Libraries",
23
+ "Topic :: Software Development",
24
+ "Typing :: Typed",
25
+ "Environment :: Web Environment",
26
+ "Framework :: AsyncIO",
27
+ "Framework :: FastAPI",
28
+ "Framework :: Pydantic",
29
+ "Framework :: Pydantic :: 1",
30
+ "Intended Audience :: Developers",
31
+ "License :: OSI Approved :: MIT License",
32
+ "Programming Language :: Python :: 3 :: Only",
33
+ "Programming Language :: Python :: 3.9",
34
+ "Programming Language :: Python :: 3.10",
35
+ "Programming Language :: Python :: 3.11",
36
+ "Programming Language :: Python :: 3.12",
37
+ "Programming Language :: Python :: 3.13",
38
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
39
+ "Topic :: Internet :: WWW/HTTP",
40
+ ]
41
+ dependencies = [
42
+ "fastapi >=0.123.9,<=0.127.1",
43
+ ]
44
+ dynamic = ["version"]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/virajkanwade/fastapi_swagger2"
48
+ Documentation = "https://github.com/virajkanwade/fastapi_swagger2"
49
+
50
+ [project.optional-dependencies]
51
+ test = [
52
+ "pytest >=9.0.2,<10.0.0",
53
+ "coverage[toml] >= 7.13.1,< 8.0",
54
+ "mypy ==1.19.1",
55
+ "ruff ==0.14.10",
56
+ "black == 25.12.0",
57
+ "isort >=7.0.0",
58
+ "httpx >=0.28.1",
59
+ ]
60
+ dev = [
61
+ "ruff ==0.14.10",
62
+ ]
63
+ all = [
64
+ "httpx >=0.28.1",
65
+ ]
66
+
67
+ [tool.hatch.version]
68
+ path = "src/fastapi_swagger2/__init__.py"
69
+
70
+ [tool.isort]
71
+ profile = "black"
72
+ known_third_party = ["fastapi", "pydantic", "starlette"]
73
+
74
+ [tool.mypy]
75
+ strict = true
76
+
77
+ [tool.black]
78
+ line-length = 119
79
+
80
+ [tool.ruff.lint]
81
+ select = [
82
+ "E", # pycodestyle errors
83
+ "W", # pycodestyle warnings
84
+ "F", # pyflakes
85
+ # "I", # isort
86
+ "C", # flake8-comprehensions
87
+ "B", # flake8-bugbear
88
+ ]
89
+ ignore = [
90
+ "E501", # line too long, handled by black
91
+ "B008", # do not perform function calls in argument defaults
92
+ "C901", # too complex
93
+ ]
94
+ per-file-ignores = { "__init__.py" = ["F401"] }
95
+ isort = { known-third-party = ["fastapi", "pydantic", "starlette"] }
@@ -0,0 +1 @@
1
+ -e .[dev,test,all]
@@ -0,0 +1 @@
1
+ -e .[all]
@@ -0,0 +1,3 @@
1
+ #!/bin/sh -e
2
+
3
+ hatchling build
@@ -0,0 +1,8 @@
1
+ #!/bin/sh -e
2
+
3
+ if [ -d 'dist' ] ; then
4
+ rm -r dist
5
+ fi
6
+ if [ -d 'site' ] ; then
7
+ rm -r site
8
+ fi
@@ -0,0 +1,6 @@
1
+ #!/bin/sh -e
2
+ set -x
3
+
4
+ ruff check src/fastapi_swagger2 tests scripts --fix
5
+ black src/fastapi_swagger2 tests scripts
6
+ isort src/fastapi_swagger2 tests scripts
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+ set -x
5
+
6
+ mypy src/fastapi_swagger2
7
+ ruff check src/fastapi_swagger2 tests scripts
8
+ black src/fastapi_swagger2 tests --check
9
+ isort src/fastapi_swagger2 tests scripts --check-only
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ hatch publish
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+ set -x
5
+
6
+ # # Check README.md is up to date
7
+ # python ./scripts/docs.py verify-readme
8
+ # export PYTHONPATH=./docs_src
9
+ coverage run -m pytest tests ${@}
@@ -0,0 +1,3 @@
1
+ [flake8]
2
+ max-line-length=88
3
+