fastapi-standalone-docs 0.0.1__py3-none-any.whl
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.
- fastapi_standalone_docs/__init__.py +2 -0
- fastapi_standalone_docs/scripts.py +59 -0
- fastapi_standalone_docs/standalone_docs.py +74 -0
- fastapi_standalone_docs/static/fastapi/LICENSE +21 -0
- fastapi_standalone_docs/static/fastapi/favicon.png +0 -0
- fastapi_standalone_docs/static/redoc/logo-mini.svg +1 -0
- fastapi_standalone_docs/static/redoc/redoc.standalone.js +1782 -0
- fastapi_standalone_docs/static/redoc/redoc.standalone.js.LICENSE.txt +97 -0
- fastapi_standalone_docs/static/swagger/LICENSE +202 -0
- fastapi_standalone_docs/static/swagger/swagger-ui-bundle.js +3 -0
- fastapi_standalone_docs/static/swagger/swagger-ui.css +3 -0
- fastapi_standalone_docs/tests/__init__.py +0 -0
- fastapi_standalone_docs/tests/conftests.py +0 -0
- fastapi_standalone_docs/tests/test_standalone_docs.py +194 -0
- fastapi_standalone_docs-0.0.1.dist-info/LICENSE +21 -0
- fastapi_standalone_docs-0.0.1.dist-info/METADATA +143 -0
- fastapi_standalone_docs-0.0.1.dist-info/RECORD +19 -0
- fastapi_standalone_docs-0.0.1.dist-info/WHEEL +4 -0
- fastapi_standalone_docs-0.0.1.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fastapi-standalone-docs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Host FastAPI Swagger UI and ReDoc without third party CDNs
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: IOXIO Ltd
|
|
7
|
+
Requires-Python: >=3.8.1,<4.0
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Provides-Extra: scripts
|
|
14
|
+
Requires-Dist: fastapi (>=0.95.2,<0.98.0)
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# FastAPI Standalone Docs
|
|
18
|
+
|
|
19
|
+
[](https://github.com/ioxiocom/fastapi-standalone-docs/actions/workflows/publish.yaml)
|
|
20
|
+
[](https://github.com/psf/black)
|
|
21
|
+
[](https://pypi.org/project/fastapi-standalone-docs/)
|
|
22
|
+
[](https://pypi.org/project/fastapi-standalone-docs/)
|
|
23
|
+
[](https://opensource.org/license/mit/)
|
|
24
|
+
|
|
25
|
+
Host FastAPI Swagger UI and ReDoc without any third party CDNs. Handy if you want to be
|
|
26
|
+
able to use the docs offline or want to avoid loading content from 3rd party CDNs due to
|
|
27
|
+
privacy reasons.
|
|
28
|
+
|
|
29
|
+
This library was heavily inspired by
|
|
30
|
+
[fastapi-offline-swagger-ui](https://github.com/ahmetoner/fastapi-offline-swagger-ui),
|
|
31
|
+
but we wanted a way to take it into use with less boilerplate code and also have it
|
|
32
|
+
hosted on PyPI.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
The package is available on PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install fastapi-standalone-docs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
Import `StandaloneDocs` and pass in the FastAPI application to it:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from fastapi import FastAPI
|
|
48
|
+
from fastapi_standalone_docs import StandaloneDocs
|
|
49
|
+
|
|
50
|
+
app = FastAPI()
|
|
51
|
+
StandaloneDocs(app=app)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The static files will by default be served from subpaths of the `docs_url` and
|
|
55
|
+
`redoc_url` as you've specified in your FastAPI app. The library doesn't make any
|
|
56
|
+
assumption on any particular path being reserved for the library. And if you disable
|
|
57
|
+
either of the two UIs, the corresponding files won't either be served unnecessarily.
|
|
58
|
+
|
|
59
|
+
This example would move the Swagger UI and the static files needed for it to the path
|
|
60
|
+
`/swagger` and disable the ReDoc interface and the static files needed by it:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from fastapi import FastAPI
|
|
64
|
+
from fastapi_standalone_docs import StandaloneDocs
|
|
65
|
+
|
|
66
|
+
app = FastAPI(docs_url="/swagger", redoc_url=None)
|
|
67
|
+
StandaloneDocs(app=app)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
By default, the library will use the FastAPI favicons, and they're served from
|
|
71
|
+
`{docs_url}/fastapi/favicon.png` and `{redoc_url}/fastapi/favicon.png`. You can use your
|
|
72
|
+
own favicons like this, which will also disable the FastAPI icons:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from fastapi import FastAPI
|
|
76
|
+
from fastapi_standalone_docs import StandaloneDocs
|
|
77
|
+
|
|
78
|
+
app = FastAPI()
|
|
79
|
+
StandaloneDocs(
|
|
80
|
+
app=app,
|
|
81
|
+
redoc_favicon_url="/favicon.png",
|
|
82
|
+
swagger_favicon_url="/favicon.png",
|
|
83
|
+
)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To make the docs truly stand alone the Google Fonts are by default disabled (they are
|
|
87
|
+
used in the ReDoc interface). If you want to enable them just set
|
|
88
|
+
`with_google_fonts=True`, like this:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from fastapi import FastAPI
|
|
92
|
+
from fastapi_standalone_docs import StandaloneDocs
|
|
93
|
+
|
|
94
|
+
app = FastAPI()
|
|
95
|
+
StandaloneDocs(
|
|
96
|
+
app=app,
|
|
97
|
+
with_google_fonts=True,
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
PRs are welcome!
|
|
104
|
+
|
|
105
|
+
This project is using [Poetry](https://python-poetry.org/) and
|
|
106
|
+
[pre-commit](https://pre-commit.com/), so please ensure you've installed both. To set up
|
|
107
|
+
the project with them run:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pre-commit install
|
|
111
|
+
poetry install
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Running tests locally:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
poetry run invoke test
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Updating the static files from the CDNs:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
poetry run update-fastapi-standalone-docs
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
If you want to test using it locally in some other project, in that project run this
|
|
127
|
+
(make sure to adjust the path to the local repo):
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
poetry add ../fastapi-standalone-docs --editable
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
The code of this library itself is released under the [MIT license](./LICENSE). Please
|
|
136
|
+
however note that this library also contains parts of
|
|
137
|
+
[ReDoc](./fastapi_standalone_docs/static/redoc/), which is licensed under the
|
|
138
|
+
[MIT license](./fastapi_standalone_docs/static/redoc/redoc.standalone.js.LICENSE.txt),
|
|
139
|
+
[Swagger UI](./fastapi_standalone_docs/static/swagger/), which is licensed under the
|
|
140
|
+
[Apache 2.0 License](./fastapi_standalone_docs/static/swagger/LICENSE), as well as parts
|
|
141
|
+
of [FastAPI](./fastapi_standalone_docs/static/fastapi) (the favicon), which is licensed
|
|
142
|
+
under the [MIT license](./fastapi_standalone_docs/static/fastapi/LICENSE).
|
|
143
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
fastapi_standalone_docs/__init__.py,sha256=Z8btRrND2S1O7eHP-7pyJ6y6jkUonp-xS3A4evJpg00,82
|
|
2
|
+
fastapi_standalone_docs/scripts.py,sha256=foJW0kJqTz5EN_oCirL-arUEdGXxVTNLHvrmEAbqTrw,1826
|
|
3
|
+
fastapi_standalone_docs/standalone_docs.py,sha256=tR_iLeqJ2BuumiQwmdd_0NmrYxkhni6pRxdYXHHSWeA,2709
|
|
4
|
+
fastapi_standalone_docs/static/fastapi/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
|
|
5
|
+
fastapi_standalone_docs/static/fastapi/favicon.png,sha256=cOPeoFIQCjIrPOstAVMGlDq6ODvn1adAuwVgqsV83vM,412
|
|
6
|
+
fastapi_standalone_docs/static/redoc/logo-mini.svg,sha256=C9tZQb-HUmZr80BoH8Aw5syJA3ctVvoVvC4EoVtsDTg,1174
|
|
7
|
+
fastapi_standalone_docs/static/redoc/redoc.standalone.js,sha256=DppGqyVg7YR8QBILUYLEqIA3OR0JECDYGtV35U7p3Hg,1042007
|
|
8
|
+
fastapi_standalone_docs/static/redoc/redoc.standalone.js.LICENSE.txt,sha256=m-O2qTO1Rl1Tuv777q8S4VUiX1ZNYrXnEjJQqFiJ3B0,2634
|
|
9
|
+
fastapi_standalone_docs/static/swagger/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
fastapi_standalone_docs/static/swagger/swagger-ui-bundle.js,sha256=rC3gtSIhxpalJh4cLClpkHR4Veukz_vw8mWLg2bXDmE,1048219
|
|
11
|
+
fastapi_standalone_docs/static/swagger/swagger-ui.css,sha256=SAA66tKLwuKJA6buaPtWkbgU4beu9n-GYPUplCMeAzE,145206
|
|
12
|
+
fastapi_standalone_docs/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
fastapi_standalone_docs/tests/conftests.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
fastapi_standalone_docs/tests/test_standalone_docs.py,sha256=BN9c5NQVC0ADtgZEan_fsLBkvJnkhsF2ASjH0mlLeUc,5787
|
|
15
|
+
fastapi_standalone_docs-0.0.1.dist-info/LICENSE,sha256=a9Hb3Z53CCDmNiiz0eliyKDg5o63LIuEdGLQ3EmHy-I,1064
|
|
16
|
+
fastapi_standalone_docs-0.0.1.dist-info/METADATA,sha256=aI6lf1EuA4j6Bm35nc9wfqRqJFBG2Tr_3HXtEq2lSt0,4774
|
|
17
|
+
fastapi_standalone_docs-0.0.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
18
|
+
fastapi_standalone_docs-0.0.1.dist-info/entry_points.txt,sha256=mh1ZwM5qQ_PsUYsbFvxFGoY1t33wwmklAh8bD08jnzI,94
|
|
19
|
+
fastapi_standalone_docs-0.0.1.dist-info/RECORD,,
|