offapi 0.1.0__tar.gz → 0.1.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.
- {offapi-0.1.0 → offapi-0.1.1}/PKG-INFO +7 -1
- {offapi-0.1.0 → offapi-0.1.1}/README.md +6 -0
- offapi-0.1.1/offapi/__init__.py +42 -0
- offapi-0.1.1/offapi/__version__.py +1 -0
- offapi-0.1.1/offapi/scalar.js +44 -0
- {offapi-0.1.0 → offapi-0.1.1}/pdm_build.py +1 -0
- {offapi-0.1.0 → offapi-0.1.1}/pyproject.toml +1 -1
- offapi-0.1.0/offapi/__init__.py +0 -30
- offapi-0.1.0/offapi/__version__.py +0 -1
- offapi-0.1.0/offapi/scalar.js +0 -45
- {offapi-0.1.0 → offapi-0.1.1}/LICENSE +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/py.typed +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/redoc.js +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/swagger_bundle.js +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/swagger_preset.js +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/swagger_style.css +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/templates.py +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/offapi/url.json +0 -0
- {offapi-0.1.0 → offapi-0.1.1}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: offapi
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: OpenAPI frontend render offline template.
|
|
5
5
|
Author-Email: Keming <kemingy94@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -35,3 +35,9 @@ from offapi import OpenAPITemplate
|
|
|
35
35
|
swagger_template = OpenAPITemplate.SWAGGER.value
|
|
36
36
|
swagger_template.format(spec_url="your_path_to_the_spec.json")
|
|
37
37
|
```
|
|
38
|
+
|
|
39
|
+
## Used by
|
|
40
|
+
|
|
41
|
+
- [spectree](https://github.com/0b01001001/spectree): API spec validator and OpenAPI document generator for Python web frameworks.
|
|
42
|
+
- [defspec](https://github.com/kemingy/defspec/): Create the OpenAPI spec and document from dataclass, attrs, etc.
|
|
43
|
+
|
|
@@ -24,3 +24,9 @@ from offapi import OpenAPITemplate
|
|
|
24
24
|
swagger_template = OpenAPITemplate.SWAGGER.value
|
|
25
25
|
swagger_template.format(spec_url="your_path_to_the_spec.json")
|
|
26
26
|
```
|
|
27
|
+
|
|
28
|
+
## Used by
|
|
29
|
+
|
|
30
|
+
- [spectree](https://github.com/0b01001001/spectree): API spec validator and OpenAPI document generator for Python web frameworks.
|
|
31
|
+
- [defspec](https://github.com/kemingy/defspec/): Create the OpenAPI spec and document from dataclass, attrs, etc.
|
|
32
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from importlib import resources
|
|
4
|
+
from pathlib import PurePath
|
|
5
|
+
|
|
6
|
+
from offapi.templates import ReDocTemplate, ScalarTemplate, SwaggerTemplate
|
|
7
|
+
|
|
8
|
+
__all__ = ["OpenAPITemplate"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
with (resources.files("offapi") / "url.json").open(encoding="utf-8") as f:
|
|
12
|
+
urls = json.load(f)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def load_resource_file(filename: str) -> str:
|
|
16
|
+
content = (resources.files("offapi") / filename).read_text(encoding="utf-8")
|
|
17
|
+
# escape curly braces
|
|
18
|
+
return content.replace("{", "{{").replace("}", "}}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class OpenAPITemplate(Enum):
|
|
22
|
+
SWAGGER = SwaggerTemplate.safe_substitute(
|
|
23
|
+
{
|
|
24
|
+
PurePath(key).stem: load_resource_file(key)
|
|
25
|
+
for key in urls
|
|
26
|
+
if key.startswith("swagger")
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
REDOC = ReDocTemplate.safe_substitute(
|
|
30
|
+
{
|
|
31
|
+
PurePath(key).stem: load_resource_file(key)
|
|
32
|
+
for key in urls
|
|
33
|
+
if key.startswith("redoc")
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
SCALAR = ScalarTemplate.safe_substitute(
|
|
37
|
+
{
|
|
38
|
+
PurePath(key).stem: load_resource_file(key)
|
|
39
|
+
for key in urls
|
|
40
|
+
if key.startswith("scalar")
|
|
41
|
+
}
|
|
42
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.1'
|