offapi 0.1.0__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.
.gitignore ADDED
@@ -0,0 +1 @@
1
+ *
offapi/__init__.py ADDED
@@ -0,0 +1,30 @@
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.open_text("offapi", "url.json") as f:
12
+ urls = json.load(f)
13
+
14
+ def load_resource_file(filename: str) -> str:
15
+ with resources.open_text("offapi", filename) as f:
16
+ content = f.read()
17
+ # escape curly braces
18
+ return content.replace("{", "{{").replace("}", "}}")
19
+
20
+
21
+ class OpenAPITemplate(Enum):
22
+ SWAGGER = SwaggerTemplate.safe_substitute(
23
+ {PurePath(key).stem: load_resource_file(key) for key in urls if key.startswith("swagger")}
24
+ )
25
+ REDOC = ReDocTemplate.safe_substitute(
26
+ {PurePath(key).stem: load_resource_file(key) for key in urls if key.startswith("redoc")}
27
+ )
28
+ SCALAR = ScalarTemplate.safe_substitute(
29
+ {PurePath(key).stem: load_resource_file(key) for key in urls if key.startswith("scalar")}
30
+ )
offapi/__version__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = '0.1.0'
offapi/py.typed ADDED
File without changes