star-openapi-rapidoc 9.3.8__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.
File without changes
@@ -0,0 +1,3 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ __version__ = "9.3.8"
@@ -0,0 +1,41 @@
1
+ import os.path
2
+
3
+ from jinja2 import Template
4
+ from star_openapi.plugins import BasePlugin
5
+ from starlette.responses import HTMLResponse
6
+ from starlette.routing import Route, Mount
7
+ from starlette.staticfiles import StaticFiles
8
+
9
+ from .templates import rapidoc_html_string
10
+
11
+
12
+ class RegisterPlugin(BasePlugin):
13
+ def __init__(self):
14
+ self.name = "rapidoc"
15
+ self.display_name = "RapiDoc"
16
+ self.doc_url = "/openapi.json"
17
+
18
+ def rapidoc_endpoint(self, request):
19
+ template = Template(request.app.config.get("RAPIDOC_HTML_STRING") or rapidoc_html_string)
20
+ return HTMLResponse(
21
+ content=template.render(
22
+ {
23
+ "doc_url": self.doc_url,
24
+ "rapidoc_config": request.app.config.get("RAPIDOC_CONFIG")
25
+ }
26
+ )
27
+ )
28
+
29
+ def register(self, doc_url: str) -> list[Route]:
30
+ self.doc_url = doc_url
31
+ static_folder = os.path.join(os.path.dirname(__file__), "templates", "rapidoc")
32
+
33
+ routes = [
34
+ Route(
35
+ f"/{self.name}",
36
+ endpoint=self.rapidoc_endpoint
37
+ ),
38
+ Mount("/rapidoc", app=StaticFiles(directory=static_folder), name="static"),
39
+ ]
40
+
41
+ return routes
@@ -0,0 +1,24 @@
1
+ rapidoc_html_string = """
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=yes">
7
+ <title>RapiDoc</title>
8
+ <link rel="shortcut icon" href="rapidoc/images/rapidoc.svg">
9
+ </head>
10
+ <body>
11
+ <rapi-doc spec-url='{{ doc_url }}'></rapi-doc>
12
+ <script>
13
+ const rapidoc_config = JSON.parse(`{{ rapidoc_config|default('{}')|tojson }}`);
14
+ var rapiDoc = document.querySelector("rapi-doc");
15
+ var specUrl = new URL("{{ doc_url }}", window.location.href).href;
16
+ rapiDoc.setAttribute("spec-url", specUrl);
17
+ for(var k in rapidoc_config) {
18
+ rapiDoc.setAttribute(k, rapidoc_config[k]);
19
+ }
20
+ </script>
21
+ <script src="rapidoc/js/rapidoc-min.js"></script>
22
+ </body>
23
+ </html>
24
+ """
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="64px" height="64px" viewBox="0 0 64 64" version="1.1">
3
+ <g id="surface1">
4
+ <path style=" stroke:none;fill-rule:nonzero;fill:rgb(67.843137%,75.686275%,39.607843%);fill-opacity:1;" d="M 43.875 51.375 C 39.367188 59.195312 31.027344 64.011719 22 64.011719 C 12.972656 64.011719 4.632812 59.195312 0.125 51.375 C 4.359375 44.203125 11.84375 39.566406 20.152344 38.96875 C 28.457031 38.367188 36.53125 41.882812 41.75 48.375 C 42.53125 49.324219 43.238281 50.324219 43.875 51.375 Z M 43.875 51.375 "/>
5
+ <path style=" stroke:none;fill-rule:nonzero;fill:rgb(60%,66.666667%,32.156863%);fill-opacity:1;" d="M 41.75 48.375 C 31.832031 51.300781 21.136719 47.882812 14.75 39.75 C 24.667969 36.824219 35.363281 40.242188 41.75 48.375 Z M 51.5 52.375 L 10.625 52.375 C 10.074219 52.375 9.625 51.925781 9.625 51.375 C 9.625 50.824219 10.074219 50.375 10.625 50.375 L 51.5 50.375 C 52.003906 50.4375 52.378906 50.867188 52.375 51.375 C 52.378906 51.882812 52.003906 52.3125 51.5 52.375 Z M 51.5 52.375 "/>
6
+ <path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,78.039216%,23.137255%);fill-opacity:1;" d="M 46.75 42.25 L 46.125 46 C 37.382812 48.382812 28.039062 45.898438 21.632812 39.492188 C 15.226562 33.085938 12.742188 23.742188 15.125 15 C 23.1875 12.902344 31.769531 14.894531 38.082031 20.332031 C 44.394531 25.773438 47.632812 33.964844 46.75 42.25 Z M 46.75 42.25 "/>
7
+ <path style=" stroke:none;fill-rule:nonzero;fill:rgb(93.72549%,69.019608%,14.509804%);fill-opacity:1;" d="M 46.75 42.25 C 38.066406 37.25 33.160156 27.585938 34.25 17.625 C 42.910156 22.648438 47.804688 32.292969 46.75 42.25 Z M 51.5 52.375 L 50.75 52.125 L 21.875 23.25 C 21.632812 22.855469 21.695312 22.347656 22.019531 22.019531 C 22.347656 21.695312 22.855469 21.632812 23.25 21.875 L 52.125 50.625 C 52.433594 50.894531 52.542969 51.328125 52.40625 51.710938 C 52.269531 52.097656 51.910156 52.359375 51.5 52.375 Z M 51.5 52.375 "/>
8
+ <path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,56.470588%,24.313725%);fill-opacity:1;" d="M 38.875 21.875 C 38.875 31.25 43.875 39.375 51.5 43.75 C 59.320312 39.242188 64.136719 30.902344 64.136719 21.875 C 64.136719 12.847656 59.320312 4.507812 51.5 0 C 43.683594 4.511719 38.871094 12.851562 38.875 21.875 Z M 38.875 21.875 "/>
9
+ <path style=" stroke:none;fill-rule:nonzero;fill:rgb(90.980392%,45.490196%,14.509804%);fill-opacity:1;" d="M 51.5 52.375 C 50.949219 52.375 50.5 51.925781 50.5 51.375 L 50.5 10.625 C 50.644531 10.234375 51.019531 9.972656 51.4375 9.972656 C 51.855469 9.972656 52.230469 10.234375 52.375 10.625 L 52.375 51.375 C 52.378906 51.882812 52.003906 52.3125 51.5 52.375 Z M 51.5 52.375 "/>
10
+ </g>
11
+ </svg>