swastik-codes 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.
- swastik_codes/__init__.py +28 -0
- swastik_codes/__main__.py +33 -0
- swastik_codes/adapters.py +169 -0
- swastik_codes/assets/logo.svg +1 -0
- swastik_codes/assets/manifest.json +6 -0
- swastik_codes/assets/swc-docs.6b428a9eb2.css +1 -0
- swastik_codes/assets/swc-docs.6b428a9eb2.css.br +0 -0
- swastik_codes/assets/swc-docs.6b428a9eb2.css.gz +0 -0
- swastik_codes/assets/swc-docs.a102eaf1ec.js +59 -0
- swastik_codes/assets/swc-docs.a102eaf1ec.js.br +0 -0
- swastik_codes/assets/swc-docs.a102eaf1ec.js.gz +0 -0
- swastik_codes/core.py +443 -0
- swastik_codes/schema.json +111 -0
- swastik_codes-0.1.0.dist-info/METADATA +195 -0
- swastik_codes-0.1.0.dist-info/RECORD +17 -0
- swastik_codes-0.1.0.dist-info/WHEEL +4 -0
- swastik_codes-0.1.0.dist-info/licenses/LICENSE.md +27 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Swastik Codes docs: API documentation and a request collection for Python web apps.
|
|
2
|
+
|
|
3
|
+
FastAPI::
|
|
4
|
+
|
|
5
|
+
from fastapi import FastAPI
|
|
6
|
+
from swastik_codes import mount
|
|
7
|
+
|
|
8
|
+
app = FastAPI()
|
|
9
|
+
mount(app, config="swastik-codes.json") # /swc/docs and /swc/collection
|
|
10
|
+
|
|
11
|
+
Flask, Django and any ASGI/WSGI app: see README.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from .adapters import SwastikCodesMiddleware, SwastikCodesWSGI, django_urls, init_flask, mount
|
|
15
|
+
from .core import Docs, Response, SwastikCodesWarning, merge_spec
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"Docs",
|
|
19
|
+
"Response",
|
|
20
|
+
"SwastikCodesMiddleware",
|
|
21
|
+
"SwastikCodesWSGI",
|
|
22
|
+
"SwastikCodesWarning",
|
|
23
|
+
"django_urls",
|
|
24
|
+
"init_flask",
|
|
25
|
+
"merge_spec",
|
|
26
|
+
"mount",
|
|
27
|
+
]
|
|
28
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""python -m swastik_codes init [swastik-codes.json] — writes a starter configuration."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
STARTER = {
|
|
8
|
+
"theme": {"accent": "#0d9488", "mode": "system"},
|
|
9
|
+
"tags": {},
|
|
10
|
+
"groups": [],
|
|
11
|
+
"operations": {},
|
|
12
|
+
"hide": [],
|
|
13
|
+
"pages": [],
|
|
14
|
+
"links": [],
|
|
15
|
+
"languages": ["curl", "javascript", "python", "go"],
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main(argv: list) -> int:
|
|
20
|
+
if not argv or argv[0] != "init":
|
|
21
|
+
print("Usage: python -m swastik_codes init [swastik-codes.json]\n\nWrites a starter configuration for the docs and collection pages.")
|
|
22
|
+
return 1 if argv else 0
|
|
23
|
+
target = Path(argv[1] if len(argv) > 1 else "swastik-codes.json")
|
|
24
|
+
if target.exists():
|
|
25
|
+
print(f"{target} already exists: nothing written.", file=sys.stderr)
|
|
26
|
+
return 1
|
|
27
|
+
target.write_text(json.dumps(STARTER, indent=2) + "\n", "utf-8")
|
|
28
|
+
print(f'Wrote {target}. Pass it as config="{target}" and edit it: the pages pick up changes on the next reload.')
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
sys.exit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""Adapters: FastAPI / Starlette, any ASGI app, any WSGI app, Flask and Django."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Callable, Iterable, List, Optional
|
|
6
|
+
|
|
7
|
+
from .core import DEFAULT_PREFIX, Config, Docs, Response, SpecSource
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _route_path(scope: dict) -> str:
|
|
11
|
+
path = scope.get("path") or "/"
|
|
12
|
+
root = scope.get("root_path") or ""
|
|
13
|
+
# Newer servers keep root_path inside path; older ones strip it.
|
|
14
|
+
if root and path.startswith(root):
|
|
15
|
+
path = path[len(root):] or "/"
|
|
16
|
+
return path
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _asgi_headers(scope: dict) -> dict:
|
|
20
|
+
return {k.decode("latin-1").lower(): v.decode("latin-1") for k, v in scope.get("headers") or []}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async def _asgi_send(send: Callable, r: Response) -> None:
|
|
24
|
+
await send({"type": "http.response.start", "status": r.status, "headers": [(k.encode("latin-1"), v.encode("latin-1")) for k, v in r.headers]})
|
|
25
|
+
await send({"type": "http.response.body", "body": r.body})
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# ---- ASGI ----------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class SwastikCodesMiddleware:
|
|
32
|
+
"""ASGI middleware for any ASGI app (FastAPI, Starlette, Litestar, Quart, Django ASGI…).
|
|
33
|
+
|
|
34
|
+
app = SwastikCodesMiddleware(app, spec=..., config="swastik-codes.json")
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, app: Any, spec: SpecSource, config: Config = None, prefix: str = DEFAULT_PREFIX, csp: bool = True):
|
|
38
|
+
self.app = app
|
|
39
|
+
self.docs = Docs(spec, config=config, prefix=prefix, csp=csp)
|
|
40
|
+
|
|
41
|
+
async def __call__(self, scope: dict, receive: Callable, send: Callable) -> None:
|
|
42
|
+
if scope.get("type") == "http":
|
|
43
|
+
path = _route_path(scope)
|
|
44
|
+
if path == self.docs.prefix or path.startswith(self.docs.prefix + "/") or self.docs.prefix == "":
|
|
45
|
+
r = self.docs.handle(scope.get("method", "GET"), path, _asgi_headers(scope), scope.get("path"))
|
|
46
|
+
if r is not None:
|
|
47
|
+
await _asgi_send(send, r)
|
|
48
|
+
return
|
|
49
|
+
await self.app(scope, receive, send)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def mount(app: Any, prefix: str = DEFAULT_PREFIX, config: Config = None, spec: Optional[SpecSource] = None, csp: bool = True) -> Docs:
|
|
53
|
+
"""Add the pages to a FastAPI (or Starlette) app.
|
|
54
|
+
|
|
55
|
+
from swastik_codes import mount
|
|
56
|
+
mount(app, config="swastik-codes.json") # → /swc/docs and /swc/collection
|
|
57
|
+
|
|
58
|
+
``spec`` defaults to ``app.openapi`` (FastAPI's own cached document).
|
|
59
|
+
"""
|
|
60
|
+
if spec is None:
|
|
61
|
+
if not callable(getattr(app, "openapi", None)):
|
|
62
|
+
raise TypeError("swastik_codes.mount: this app has no .openapi(); pass spec=<your OpenAPI dict or a function>")
|
|
63
|
+
spec = app.openapi
|
|
64
|
+
docs = Docs(spec, config=config, prefix=prefix, csp=csp)
|
|
65
|
+
|
|
66
|
+
class Endpoint: # Starlette calls an object (not a function) as a raw ASGI app
|
|
67
|
+
async def __call__(self, scope: dict, receive: Callable, send: Callable) -> None:
|
|
68
|
+
r = docs.handle(scope.get("method", "GET"), _route_path(scope), _asgi_headers(scope), scope.get("path"))
|
|
69
|
+
if r is None:
|
|
70
|
+
r = Response(404, [("content-type", "text/plain")], b"Not found")
|
|
71
|
+
await _asgi_send(send, r)
|
|
72
|
+
|
|
73
|
+
endpoint = Endpoint()
|
|
74
|
+
|
|
75
|
+
from starlette.routing import Route # FastAPI and Starlette ship it
|
|
76
|
+
|
|
77
|
+
# Raw ASGI endpoints (no Request object), placed ahead of any catch-all routes the app has.
|
|
78
|
+
paths = [docs.prefix, docs.prefix + "/{rest:path}"] if docs.prefix else ["/docs", "/docs/", "/collection", "/collection/", "/openapi.json", "/_swc/{rest:path}"]
|
|
79
|
+
for i, p in enumerate(paths):
|
|
80
|
+
app.router.routes.insert(i, Route(p, endpoint, methods=["GET", "HEAD", "OPTIONS"], include_in_schema=False))
|
|
81
|
+
return docs
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# ---- WSGI ----------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class SwastikCodesWSGI:
|
|
88
|
+
"""WSGI middleware: app.wsgi_app = SwastikCodesWSGI(app.wsgi_app, spec=...)."""
|
|
89
|
+
|
|
90
|
+
def __init__(self, app: Callable, spec: SpecSource, config: Config = None, prefix: str = DEFAULT_PREFIX, csp: bool = True):
|
|
91
|
+
self.app = app
|
|
92
|
+
self.docs = Docs(spec, config=config, prefix=prefix, csp=csp)
|
|
93
|
+
|
|
94
|
+
def __call__(self, environ: dict, start_response: Callable) -> Iterable[bytes]:
|
|
95
|
+
path = environ.get("PATH_INFO") or "/"
|
|
96
|
+
r = self.docs.handle(environ.get("REQUEST_METHOD", "GET"), path, _wsgi_headers(environ), (environ.get("SCRIPT_NAME") or "") + path)
|
|
97
|
+
if r is None:
|
|
98
|
+
return self.app(environ, start_response)
|
|
99
|
+
start_response(f"{r.status} {_REASONS.get(r.status, 'OK')}", r.headers)
|
|
100
|
+
return [r.body]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
_REASONS = {200: "OK", 204: "No Content", 301: "Moved Permanently", 302: "Found", 304: "Not Modified", 404: "Not Found"}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _wsgi_headers(environ: dict) -> dict:
|
|
107
|
+
out = {k[5:].replace("_", "-").lower(): v for k, v in environ.items() if k.startswith("HTTP_")}
|
|
108
|
+
return out
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# ---- Flask ---------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def init_flask(app: Any, spec: SpecSource, config: Config = None, prefix: str = DEFAULT_PREFIX, csp: bool = True) -> Docs:
|
|
115
|
+
"""Add the pages to a Flask app.
|
|
116
|
+
|
|
117
|
+
from swastik_codes import init_flask
|
|
118
|
+
init_flask(app, spec=lambda: api.spec.to_dict(), config="swastik-codes.json")
|
|
119
|
+
"""
|
|
120
|
+
from flask import Response as FlaskResponse, request
|
|
121
|
+
|
|
122
|
+
docs = Docs(spec, config=config, prefix=prefix, csp=csp)
|
|
123
|
+
|
|
124
|
+
def view(rest: str = "") -> Any:
|
|
125
|
+
r = docs.handle(request.method, request.path, {k.lower(): v for k, v in request.headers.items()}, request.full_path if request.query_string else request.path)
|
|
126
|
+
if r is None:
|
|
127
|
+
return FlaskResponse("Not found", status=404, mimetype="text/plain")
|
|
128
|
+
resp = FlaskResponse(r.body, status=r.status)
|
|
129
|
+
resp.headers.clear()
|
|
130
|
+
for k, v in r.headers:
|
|
131
|
+
resp.headers[k] = v
|
|
132
|
+
resp.direct_passthrough = True
|
|
133
|
+
return resp
|
|
134
|
+
|
|
135
|
+
opts = {"methods": ["GET", "HEAD", "OPTIONS"], "provide_automatic_options": False, "strict_slashes": False}
|
|
136
|
+
if docs.prefix:
|
|
137
|
+
app.add_url_rule(docs.prefix, "swastik_codes_root", view, **opts)
|
|
138
|
+
app.add_url_rule(f"{docs.prefix}/<path:rest>", "swastik_codes", view, **opts)
|
|
139
|
+
return docs
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# ---- Django --------------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def django_urls(spec: SpecSource, config: Config = None, prefix: str = DEFAULT_PREFIX, csp: bool = True) -> List[Any]:
|
|
146
|
+
"""URL patterns for Django: ``urlpatterns += django_urls(spec=...)``.
|
|
147
|
+
|
|
148
|
+
Use them in the ROOT urls.py (the prefix is matched against the full path).
|
|
149
|
+
"""
|
|
150
|
+
import re
|
|
151
|
+
|
|
152
|
+
from django.http import HttpResponse
|
|
153
|
+
from django.urls import re_path
|
|
154
|
+
from django.views.decorators.csrf import csrf_exempt
|
|
155
|
+
|
|
156
|
+
docs = Docs(spec, config=config, prefix=prefix, csp=csp)
|
|
157
|
+
|
|
158
|
+
@csrf_exempt
|
|
159
|
+
def view(request: Any, rest: str = "") -> Any:
|
|
160
|
+
r = docs.handle(request.method, request.path_info, {k.lower(): v for k, v in request.headers.items()}, request.path)
|
|
161
|
+
if r is None:
|
|
162
|
+
return HttpResponse("Not found", status=404, content_type="text/plain")
|
|
163
|
+
resp = HttpResponse(r.body, status=r.status)
|
|
164
|
+
for k, v in r.headers:
|
|
165
|
+
resp[k] = v
|
|
166
|
+
return resp
|
|
167
|
+
|
|
168
|
+
p = re.escape(docs.prefix.lstrip("/"))
|
|
169
|
+
return [re_path(rf"^{p}(?:/(?P<rest>.*))?$" if p else r"^(?P<rest>docs/?|collection/?|openapi\.json|_swc/[^/]+)$", view, name="swastik_codes")]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><defs><linearGradient id="swc-g" x1="4" y1="2" x2="28" y2="30" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#34d399"/><stop offset=".55" stop-color="#0d9488"/><stop offset="1" stop-color="#0e7490"/></linearGradient></defs><rect width="32" height="32" rx="8.5" fill="url(#swc-g)"/><path d="M21.6 9H13.8a3.5 3.5 0 0 0 0 7h2.5" fill="none" stroke="#fff" stroke-width="3.2" stroke-linejoin="round"/><path d="M16 16h2.2a3.5 3.5 0 0 1 0 7h-7.8" fill="none" stroke="#a7f3d0" stroke-width="3.2" stroke-linejoin="round"/><circle cx="21.8" cy="9" r="2.35" fill="#fff"/><circle cx="10.2" cy="23" r="2.35" fill="#a7f3d0"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--accent: #0d9488;--on-accent: #fff;--bg: #fff;--bg-subtle: #f6f7f9;--bg-elevated: #fff;--bg-hover: #eef0f3;--bg-active: #e5e8ec;--bg-input: #fff;--border: #e2e5e9;--border-strong: #cfd4da;--text: #1d2125;--text-muted: #5a636e;--text-faint: #8b939d;--danger: #d0352b;--warning: #b7791f;--success: #15803d;--info: #2563eb;--t-key: #a3420f;--t-str: #0b7a3e;--t-num: #1d4ed8;--t-lit: #8b3dbf;--m-get: #0b8a4b;--m-post: #b26b00;--m-put: #1f5fd1;--m-patch: #7c3aed;--m-delete: #c62828;--m-options: #be185d;--m-other: #5a636e;--shadow: 0 10px 30px rgba(15, 23, 42, .16), 0 1px 3px rgba(15, 23, 42, .08);--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;--mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;--radius: 6px;--top-h: 52px;--side-w: 300px;--accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);--accent-text: color-mix(in srgb, var(--accent) 82%, #000);color-scheme:light}:root[data-theme=dark]{--on-accent: #04201d;--bg: #1a1c20;--bg-subtle: #202328;--bg-elevated: #272a30;--bg-hover: #2b2f35;--bg-active: #33373e;--bg-input: #1f2227;--border: #33373e;--border-strong: #454a52;--text: #e4e7eb;--text-muted: #a3abb5;--text-faint: #737b86;--danger: #f2685e;--warning: #e3a94a;--success: #4ade80;--info: #60a5fa;--t-key: #f0a868;--t-str: #8fd694;--t-num: #7cb7ff;--t-lit: #d19af5;--m-get: #4ade80;--m-post: #fbbf24;--m-put: #60a5fa;--m-patch: #c4b5fd;--m-delete: #f87171;--m-options: #f9a8d4;--m-other: #a3abb5;--shadow: 0 10px 30px rgba(0, 0, 0, .5);--accent-text: color-mix(in srgb, var(--accent) 60%, #fff);color-scheme:dark}@media(prefers-color-scheme:dark){:root:not([data-theme]){--on-accent: #04201d;--bg: #1a1c20;--bg-subtle: #202328;--bg-elevated: #272a30;--bg-hover: #2b2f35;--bg-active: #33373e;--bg-input: #1f2227;--border: #33373e;--border-strong: #454a52;--text: #e4e7eb;--text-muted: #a3abb5;--text-faint: #737b86;color-scheme:dark}}*,*:before,*:after{box-sizing:border-box}html,body{margin:0;height:100%;background:var(--bg);color:var(--text);font:14px/1.6 var(--font);-webkit-font-smoothing:antialiased;text-size-adjust:100%}a{color:var(--accent-text)}code,kbd,pre,.mono{font-family:var(--mono);font-size:12.5px}kbd{border:1px solid var(--border-strong);border-bottom-width:2px;border-radius:4px;padding:0 4px;font-size:11px}[hidden]{display:none!important}.sr,.swc-offscreen{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.ic{flex:none;width:16px;height:16px}.ic.big{width:28px;height:28px;opacity:.5}.muted{color:var(--text-muted)}.small{font-size:12.5px}.pad{padding:12px 16px}.spacer{flex:1}.err{color:var(--danger)}:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.btn{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 12px;border:1px solid var(--border-strong);border-radius:var(--radius);background:var(--bg-elevated);color:var(--text);font:500 13px var(--font);text-decoration:none;white-space:nowrap;cursor:pointer}.btn:hover{background:var(--bg-hover)}.btn.ghost{border-color:transparent;background:transparent}.btn.ghost:hover{background:var(--bg-hover)}.btn.primary{border-color:var(--accent);background:var(--accent);color:var(--on-accent)}.btn.primary:hover{filter:brightness(1.08)}.btn.small{height:26px;padding:0 8px;font-size:12px}.icon-btn{display:inline-grid;place-items:center;width:30px;height:30px;padding:0;border:0;border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer}.icon-btn:hover{background:var(--bg-hover);color:var(--text)}.icon-btn.copy .ok,.icon-btn.copy.done .ic:not(.ok){display:none}.icon-btn.copy.done .ok{display:block;color:var(--success)}.input,.select,.body-input{width:100%;min-width:0;height:32px;padding:0 10px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-input);color:var(--text);font:13px var(--font)}.input.mono{font:12.5px var(--mono)}.select{width:auto;padding-right:6px}.input:focus,.select:focus,.body-input:focus,.url-input:focus{outline:none;border-color:var(--accent)}.chip{padding:1px 7px;border:1px solid var(--border);border-radius:99px;color:var(--text-muted);font-size:11.5px}.tabs{display:flex;gap:2px;overflow-x:auto;scrollbar-width:none}.tabs button,.seg button{position:relative;display:inline-flex;align-items:center;gap:5px;height:36px;padding:0 10px;border:0;background:none;color:var(--text-muted);font:500 13px var(--font);white-space:nowrap;cursor:pointer}.tabs button:hover,.tabs button[aria-selected=true]{color:var(--text)}.tabs button[aria-selected=true]:after{content:"";position:absolute;left:8px;right:8px;bottom:0;height:2px;border-radius:2px;background:var(--accent)}.tabs.small button{height:30px;padding:0 7px;font-size:12px}.tabs .count{color:var(--accent-text);font-size:11.5px}.tabs .dot{width:6px;height:6px;border-radius:50%;background:var(--accent)}.seg{display:inline-flex;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.seg button{height:26px;font-size:12px}.seg button[aria-selected=true]{background:var(--accent-soft);color:var(--accent-text)}.m{flex:none;width:38px;font:700 10.5px var(--mono);letter-spacing:.02em;text-align:right;color:var(--m-other)}.m-get,.m-head{color:var(--m-get)}.m-post{color:var(--m-post)}.m-put{color:var(--m-put)}.m-patch{color:var(--m-patch)}.m-delete{color:var(--m-delete)}.m-options{color:var(--m-options)}.m.big{width:auto;font-size:12.5px}.status{padding:1px 8px;border-radius:4px;font:600 12px var(--mono);color:var(--text-muted);background:var(--bg-hover)}.status.s2{color:var(--success);background:color-mix(in srgb,var(--success) 13%,transparent)}.status.s3{color:var(--info);background:color-mix(in srgb,var(--info) 13%,transparent)}.status.s4{color:var(--warning);background:color-mix(in srgb,var(--warning) 14%,transparent)}.status.s5{color:var(--danger);background:color-mix(in srgb,var(--danger) 13%,transparent)}.swc{display:flex;flex-direction:column;height:100%}.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:8px;height:var(--top-h);padding:0 16px;border-bottom:1px solid var(--border);background:var(--bg)}.brand{display:flex;align-items:center;gap:10px;min-width:0}.brand-mark{display:flex}.swc-logo{flex:none;display:block}.brand-title{overflow:hidden;font-weight:650;font-size:15px;white-space:nowrap;text-overflow:ellipsis}.server .select{max-width:240px;height:30px}.only-narrow{display:none}.side{display:flex;flex-direction:column;width:var(--side-w);flex:none;min-height:0;border-right:1px solid var(--border);background:var(--bg-subtle)}.side-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px 4px;font-weight:600}.side-search{position:relative;padding:10px 12px}.side-search .ic{position:absolute;left:22px;top:18px;color:var(--text-faint)}.side-search .input{padding-left:32px;height:34px}.nav,.tree{flex:1;min-height:0;overflow-y:auto;padding:0 8px 16px;overscroll-behavior:contain}.side-foot{padding:10px 14px;border-top:1px solid var(--border)}.powered{display:inline-flex;align-items:center;gap:8px;color:var(--text-muted);font-size:12.5px;text-decoration:none}.powered .swc-logo{width:18px;height:18px}.powered:hover{color:var(--text)}.nav-top,.nav-op,.tree-op{display:flex;align-items:center;gap:8px;min-height:32px;padding:4px 8px;border-radius:var(--radius);color:var(--text);text-decoration:none;font-size:13.5px}.nav-top{font-weight:500}.nav-top:hover,.nav-op:hover,.tree-op:hover{background:var(--bg-hover)}.nav-top.on,.nav-op.on,.tree-op.on{background:var(--accent-soft);color:var(--accent-text)}.nav-name{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.nav-name.dep{text-decoration:line-through;opacity:.7}details>summary{list-style:none;cursor:pointer}details>summary::-webkit-details-marker{display:none}details>summary .chev{transition:transform .12s;color:var(--text-faint)}details[open]>summary .chev{transform:rotate(90deg)}.nav-section>summary,.nav-folder>summary,.tree-folder>summary{display:flex;align-items:center;gap:6px;min-height:32px;padding:4px 6px;border-radius:var(--radius);color:var(--text);font-size:13.5px}.nav-section>summary{margin-top:6px;font-weight:600}.nav-section>summary:hover,.nav-folder>summary:hover,.tree-folder>summary:hover{background:var(--bg-hover)}.nav-section>div,.nav-folder,.tree-folder>:not(summary){margin-left:14px}.nav-section>.nav-group>.nav-folder{margin-left:0}.tree-folder>summary .fold{color:var(--text-faint)}.tree-group>summary{font-weight:600}.docs-body,.col-body{display:flex;flex:1;min-height:0}.docs .side{position:sticky;top:var(--top-h);height:calc(100vh - var(--top-h))}.docs{height:auto}.docs-body{align-items:flex-start}.content{flex:1;min-width:0;padding:8px 40px 64px}.intro,.folder-head,.op{max-width:1320px}.intro{max-width:860px;padding:28px 0 8px}.intro h1{margin:0 0 4px;font-size:30px;line-height:1.25;letter-spacing:-.01em}.intro h2,.folder-head h2{margin:32px 0 10px;font-size:22px;line-height:1.3}.page-title{margin-top:8px!important}.base{display:flex;align-items:center;gap:6px}.base .select{min-width:260px;height:36px;font:13px var(--mono)}.scheme{margin:0 0 14px;padding:12px 14px;border:1px solid var(--border);border-radius:8px}.links{padding-left:18px}.folder-head{padding-top:24px;border-top:1px solid var(--border);margin-top:32px}.folder-head h2{margin-top:0}.op{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,.9fr);gap:32px;padding:28px 0;border-top:1px solid var(--border);scroll-margin-top:calc(var(--top-h) + 8px);content-visibility:auto;contain-intrinsic-size:auto 640px}.op.pending{min-height:420px}.folder-head+.op{border-top:0}.intro,.page{scroll-margin-top:calc(var(--top-h) + 8px)}.op-title{position:relative;margin:0 0 8px;font-size:19px;line-height:1.35}.op-title .anchor{position:absolute;left:-20px;color:var(--text-faint);text-decoration:none;opacity:0}.op-title:hover .anchor{opacity:1}.op-path{display:flex;align-items:center;gap:8px;padding:6px 6px 6px 10px;margin-bottom:12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-subtle);overflow:hidden}.op-path .m{width:auto}.op-path code{flex:1;min-width:0;overflow-wrap:anywhere}.op h4,.docs-tab h4,.req-pane h4{display:flex;align-items:center;gap:8px;margin:22px 0 6px;font-size:13px;font-weight:650;text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted)}.req-pane h4:first-child{margin-top:4px}.ct{color:var(--text-faint);font:400 11.5px var(--mono);text-transform:none;letter-spacing:0}.auth-note{display:flex;align-items:center;gap:4px;color:var(--text-muted);font-size:13px}.try{display:inline-flex;align-items:center;gap:6px;margin-top:18px;font-weight:500;font-size:13px;text-decoration:none}.try:hover{text-decoration:underline}.op-side{display:flex;flex-direction:column;gap:14px;min-width:0}.op-side .panel{position:sticky;top:calc(var(--top-h) + 12px)}.op-side .panel+.panel{position:static}.panel{border:1px solid var(--border);border-radius:8px;background:var(--bg-subtle);overflow:hidden}.panel-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 4px 0 12px;border-bottom:1px solid var(--border);font-size:12.5px;font-weight:600;min-height:34px}.panel .code-wrap{border:0;border-radius:0}.panel .code{max-height:460px}.fields{border-top:1px solid var(--border)}.field-row{padding:9px 0;border-bottom:1px solid var(--border)}.field-row.d1{padding-left:18px}.field-row.d2{padding-left:36px}.field-row.d3{padding-left:54px}.field-row.d4{padding-left:72px}.f-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px}.f-name{font-weight:600;color:var(--text)}.f-type{color:var(--text-muted);font:12px var(--mono)}.f-req{color:var(--danger);font-size:11.5px;font-weight:600;text-transform:none;letter-spacing:0}.f-dep,.f-meta-chip{padding:0 6px;border-radius:4px;font-size:11px;background:var(--bg-hover);color:var(--text-muted)}.f-desc{margin-top:2px;color:var(--text-muted);font-size:13px}.f-desc p{margin:0}.f-meta{margin-top:2px;color:var(--text-faint);font:11.5px var(--mono);overflow-wrap:anywhere}.responses .resp{border:1px solid var(--border);border-radius:8px;margin-bottom:8px;padding:0 12px}.resp>summary{display:flex;align-items:center;gap:8px;min-height:40px}.resp-desc{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--text-muted);font-size:13px}.resp[open]{padding-bottom:8px}.resp .fields{margin-top:4px}.docs-foot{margin-top:48px;padding-top:16px;border-top:1px solid var(--border)}.md{overflow-wrap:break-word}.md p,.md ul,.md ol,.md blockquote{margin:0 0 12px}.md h3,.md h4,.md h5,.md h6{margin:20px 0 8px}.md code{padding:1px 5px;border-radius:4px;background:var(--bg-hover)}.md pre code{padding:0;background:none}.md blockquote{padding:2px 14px;border-left:3px solid var(--accent);color:var(--text-muted)}.md img{max-width:100%}.md hr{border:0;border-top:1px solid var(--border)}.table-wrap{overflow-x:auto;margin:0 0 12px}.md table{border-collapse:collapse;font-size:13px}.md th,.md td{padding:6px 10px;border:1px solid var(--border);text-align:left}.code-wrap{position:relative;border:1px solid var(--border);border-radius:8px;background:var(--bg-subtle)}.md .code,.intro .code{border:1px solid var(--border);border-radius:8px;background:var(--bg-subtle)}.code-wrap>.copy+.code{padding-right:44px}.code-wrap>.copy{position:absolute;top:6px;right:6px;background:var(--bg-subtle)}.code-label{padding:6px 12px;border-bottom:1px solid var(--border);font-size:12px;color:var(--text-muted)}.code{margin:0;padding:12px 14px;overflow:auto;line-height:1.55;tab-size:2}.code code{white-space:pre}.t-key{color:var(--t-key)}.t-str{color:var(--t-str)}.t-num{color:var(--t-num)}.t-lit{color:var(--t-lit)}.collection{overflow:hidden}.work{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0}.overview{max-width:760px;padding:32px 40px;overflow-y:auto}.overview h1{margin:0 0 4px;font-size:26px}.editor{--split: .45;display:grid;grid-template-rows:auto auto auto minmax(80px,calc((100% - 150px) * var(--split))) 6px minmax(120px,1fr);flex:1;min-height:0}.crumbs{display:flex;align-items:center;gap:6px;padding:10px 16px 0;color:var(--text-muted);font-size:13.5px;white-space:nowrap;overflow:hidden}.crumbs strong{color:var(--text);overflow:hidden;text-overflow:ellipsis}.crumbs .sep{color:var(--text-faint)}.urlbar{display:flex;gap:8px;padding:10px 16px}.url-method{display:flex;align-items:center;padding:0 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-subtle)}.url-field{display:flex;align-items:center;flex:1;min-width:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-input)}.url-field:focus-within{border-color:var(--accent)}.base-pill{flex:none;margin-left:10px;padding:1px 4px;border-radius:4px;color:var(--accent-text);background:var(--accent-soft);cursor:help}.url-input{flex:1;min-width:0;height:38px;padding:0 10px 0 2px;border:0;background:transparent;color:var(--text)}.send{height:40px;padding:0 20px}.send.busy{background:var(--bg-hover);border-color:var(--border-strong);color:var(--text)}.editor>.tabs{padding:0 10px;border-bottom:1px solid var(--border)}.req-pane{min-height:0;overflow:auto;padding:12px 16px}.resizer{border-top:1px solid var(--border);cursor:row-resize;touch-action:none}.resizer:hover{background:var(--accent-soft)}.res-pane{display:flex;flex-direction:column;min-height:0}.res-head{display:flex;align-items:center;gap:10px;min-height:40px;padding:0 16px 0 10px;border-bottom:1px solid var(--border)}.res-title{padding-left:6px;font-weight:600}.res-head .meta{color:var(--success);font:12px var(--mono)}.res-body{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}.res-tools{display:flex;align-items:center;gap:10px;padding:8px 16px}.res-code{flex:1;min-height:0;padding:4px 16px 16px}.empty{display:grid;place-items:center;align-content:center;gap:4px;flex:1;padding:24px;color:var(--text-muted);text-align:center}.empty.err{color:var(--danger)}.empty p{max-width:560px;margin:0}.hdrs{overflow:auto;padding:8px 16px}.hdr{display:grid;grid-template-columns:minmax(140px,.4fr) 1fr;gap:12px;padding:6px 0;border-bottom:1px solid var(--border)}.hk{font-weight:600}.hv{overflow-wrap:anywhere}.preview{padding:16px;overflow:auto}.preview img{max-width:100%}.kv{border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.kv-row{display:grid;grid-template-columns:34px minmax(0,1fr) minmax(0,1.3fr) minmax(0,1fr) 34px;align-items:center;border-bottom:1px solid var(--border)}.kv-row:last-child{border-bottom:0}.kv-headrow{min-height:30px;background:var(--bg-subtle);color:var(--text-muted);font-size:12px;font-weight:600}.kv-headrow>span{padding:0 10px}.kv-row .input{height:34px;border:0;border-left:1px solid var(--border);border-radius:0;background:transparent}.kv-row .input:focus{box-shadow:inset 0 0 0 1px var(--accent)}.kv-row input[type=file]{padding-top:6px;font-size:12px}.kv-on{display:grid;place-items:center}.kv-on input{accent-color:var(--accent)}.kv-desc{height:34px;padding:0 10px;border-left:1px solid var(--border);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--text-muted);font-size:12.5px;line-height:34px}.kv-row.new .kv-on input,.kv-row.new .kv-del{visibility:hidden}.kv.fixed .kv-row{grid-template-columns:34px minmax(0,1fr) minmax(0,1.3fr) minmax(0,1fr)}.kv-del{justify-self:center;width:26px;height:26px}.tip{margin-top:12px}.field{display:block;margin-bottom:12px}.field.inline{display:flex;align-items:center;gap:10px}.field-label{display:inline-flex;align-items:center;gap:4px;margin-bottom:4px;color:var(--text-muted);font-size:12.5px;font-weight:600}.field.inline .field-label{margin:0}.input-row{display:flex;gap:6px;max-width:640px}.auth-row p{margin:4px 0}.body-head{display:flex;align-items:center;gap:8px;margin-bottom:8px}.body-input{height:calc(100% - 42px);min-height:140px;padding:10px 12px;resize:none;font:12.5px/1.55 var(--mono);tab-size:2}.docs-tab{max-width:820px}.docs-tab h3{margin:0 0 6px}.dlg-wrap{position:fixed;inset:0;z-index:100;display:grid;place-items:center;padding:16px;background:#0f172a66}.dlg{width:min(480px,100%);border:1px solid var(--border);border-radius:10px;background:var(--bg-elevated);box-shadow:var(--shadow)}.dlg-head{display:flex;align-items:center;justify-content:space-between;padding:12px 12px 0 18px}.dlg-body{padding:4px 18px 18px}.dlg-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}.fatal{max-width:640px;margin:64px auto;padding:0 16px}.scrim{display:none}@media(max-width:1180px){.op{grid-template-columns:minmax(0,1fr);gap:18px}.op-side .panel{position:static}}@media(max-width:900px){:root{--side-w: min(320px, 86vw)}.only-narrow{display:inline-grid}.hide-narrow{display:none}.side,.docs .side{position:fixed;top:var(--top-h);bottom:0;left:0;z-index:30;height:auto;transform:translate(-100%);transition:transform .18s ease}.side-open .side{transform:none;box-shadow:var(--shadow)}.side-open .scrim{display:block;position:fixed;inset:var(--top-h) 0 0;z-index:25;background:#0f172a59}.content{padding:4px 16px 48px}.overview{padding:24px 16px}.topbar{padding:0 8px;gap:4px}.run span{display:none}.run{padding:0 9px}.server .select{max-width:120px}.kv-row{grid-template-columns:30px minmax(0,1fr) minmax(0,1.2fr) 30px}.kv.fixed .kv-row{grid-template-columns:30px minmax(0,1fr) minmax(0,1.2fr)}.kv-desc,.kv-headrow>span:nth-child(4){display:none}}@media(max-width:560px){.brand-title{font-size:14px}.brand .chip,.send span{display:none}.send{padding:0 12px}.urlbar{padding:8px;gap:6px}.url-method{padding:0 8px}.base-pill{display:none}.url-input{padding-left:8px}.intro h1{font-size:24px}.base .select{min-width:0;width:100%}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";(()=>{function t(e,n,...s){let r=document.createElement(e);if(n)for(let a in n){let o=n[a];o==null||o===!1||(a.startsWith("on")&&typeof o=="function"?r.addEventListener(a.slice(2),o):a==="class"?r.className=String(o):a==="value"&&"value"in r?r.value=String(o):a==="checked"&&"checked"in r?r.checked=!!o:r.setAttribute(a,o===!0?"":String(o)))}return ne(r,s),r}function ne(e,n){for(let s of n)s==null||s===!1||(Array.isArray(s)?ne(e,s):e.appendChild(typeof s=="object"?s:document.createTextNode(String(s))))}function q(e,...n){for(;e.firstChild;)e.removeChild(e.firstChild);ne(e,n)}function D(e){let n=document.createElement("template");return n.innerHTML=e,n.content}function re(e){return e.replace(/[&<>"']/g,n=>n==="&"?"&":n==="<"?"<":n===">"?">":n==='"'?""":"'")}var ct={search:'<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3"/>',sun:'<circle cx="8" cy="8" r="3"/><path d="M8 1.5v1.5M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1 1M11.6 11.6l1 1M3.4 12.6l1-1M11.6 4.4l1-1"/>',moon:'<path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7z"/>',download:'<path d="M8 2v8M4.5 6.5 8 10l3.5-3.5M2.5 13.5h11"/>',play:'<path d="M5 3.5v9l7-4.5z"/>',send:'<path d="m14 2-6.5 12-1.5-5-5-1.5z"/><path d="M14 2 6 9"/>',menu:'<path d="M2.5 4h11M2.5 8h11M2.5 12h11"/>',chev:'<path d="m6 4 4 4-4 4"/>',book:'<path d="M2.5 3h4a1.5 1.5 0 0 1 1.5 1.5V13a1 1 0 0 0-1-1H2.5zM13.5 3h-4A1.5 1.5 0 0 0 8 4.5V13a1 1 0 0 1 1-1h4.5z"/>',folder:'<path d="M2 4.5A1 1 0 0 1 3 3.5h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z"/>',copy:'<rect x="5" y="5" width="8.5" height="8.5" rx="1.5"/><path d="M3 10.5V3.5A1 1 0 0 1 4 2.5h6.5"/>',check:'<path d="m3 8.5 3 3 7-7"/>',x:'<path d="m4 4 8 8M12 4l-8 8"/>',plus:'<path d="M8 3v10M3 8h10"/>',lock:'<rect x="3" y="7" width="10" height="7" rx="1.5"/><path d="M5.5 7V5a2.5 2.5 0 0 1 5 0v2"/>',grid:'<rect x="2.5" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="9" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="2.5" y="9" width="4.5" height="4.5" rx="1"/><rect x="9" y="9" width="4.5" height="4.5" rx="1"/>',code:'<path d="m5.5 4.5-3.5 3.5 3.5 3.5M10.5 4.5 14 8l-3.5 3.5"/>'};function M(e,n="ic"){return D(`<svg class="${n}" viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ct[e]||""}</svg>`).firstChild}var dt='<svg class="swc-logo" viewBox="0 0 32 32" width="24" height="24" aria-hidden="true"><defs><linearGradient id="swc-g" x1="4" y1="2" x2="28" y2="30" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#34d399"/><stop offset=".55" stop-color="#0d9488"/><stop offset="1" stop-color="#0e7490"/></linearGradient></defs><rect width="32" height="32" rx="8.5" fill="url(#swc-g)"/><path d="M21.6 9H13.8a3.5 3.5 0 0 0 0 7h2.5" fill="none" stroke="#fff" stroke-width="3.2" stroke-linejoin="round"/><path d="M16 16h2.2a3.5 3.5 0 0 1 0 7h-7.8" fill="none" stroke="#a7f3d0" stroke-width="3.2" stroke-linejoin="round"/><circle cx="21.8" cy="9" r="2.35" fill="#fff"/><circle cx="10.2" cy="23" r="2.35" fill="#a7f3d0"/></svg>';function Ne(){return D(dt).firstChild}function ce(e,n="m"){let s=e.toUpperCase();return t("span",{class:`${n} m-${s.toLowerCase()}`},s==="DELETE"?"DEL":s==="OPTIONS"?"OPT":s)}async function pt(e,n){try{await navigator.clipboard.writeText(e)}catch{let s=t("textarea",{class:"swc-offscreen"},e);document.body.appendChild(s),s.select(),document.execCommand("copy"),s.remove()}n&&(n.classList.add("done"),setTimeout(()=>n.classList.remove("done"),1200))}function ae(e,n="Copy"){let s=t("button",{class:"icon-btn copy",type:"button",title:n,"aria-label":n},M("copy"),M("check","ic ok"));return s.addEventListener("click",()=>void pt(e(),s)),s}function W(e,n){try{let s=localStorage.getItem(e);return s==null?n:JSON.parse(s)}catch{return n}}function Z(e,n){try{localStorage.setItem(e,JSON.stringify(n))}catch{}}var Qe=["get","post","put","patch","delete","head","options","trace"];function j(e,n,s=0){if(!n||typeof n!="object"||typeof n.$ref!="string"||s>20)return n;let r=n.$ref;if(!r.startsWith("#/"))return{};let a=e;for(let o of r.slice(2).split("/")){let i=decodeURIComponent(o).replace(/~1/g,"/").replace(/~0/g,"~");a=a==null?void 0:a[i]}return a==null?{}:j(e,a,s+1)}function ut(e){return e&&typeof e.$ref=="string"&&e.$ref.split("/").pop()||""}function ft(e){var i,c;let n={...e,openapi:"3.0.0"},s=(i=e.schemes)!=null&&i.length?e.schemes:["https"];n.servers=e.host?[{url:`${s[0]}://${e.host}${e.basePath||""}`}]:e.basePath?[{url:e.basePath}]:[],n.components={schemas:e.definitions||{},securitySchemes:{}};for(let[d,h]of Object.entries(e.securityDefinitions||{}))n.components.securitySchemes[d]=h.type==="basic"?{type:"http",scheme:"basic",description:h.description}:{...h};let r=e.consumes||["application/json"],a=e.produces||["application/json"],o={};for(let[d,h]of Object.entries(e.paths||{})){let b={};for(let $ of Qe){let v=h[$];if(!v)continue;let u=[],f=null,m={type:"object",properties:{},required:[]},N=v.consumes||r;for(let X of[...h.parameters||[],...v.parameters||[]]){let J=j(e,X);if(J.in==="body")f={required:J.required,description:J.description,content:{[N[0]]:{schema:J.schema}}};else if(J.in==="formData")m.properties[J.name]=J.type==="file"?{type:"string",format:"binary"}:{type:J.type,description:J.description},J.required&&m.required.push(J.name);else{let{type:p,format:S,items:V,enum:H,default:C,...Q}=J;u.push({...Q,schema:{type:p,format:S,items:V,enum:H,default:C}})}}!f&&Object.keys(m.properties).length&&(f={content:{[N.find(J=>J.includes("form"))||"application/x-www-form-urlencoded"]:{schema:m}}});let F={};for(let[X,J]of Object.entries(v.responses||{})){let p=j(e,J),S=v.produces||a;F[X]={description:p.description||"",headers:p.headers,content:p.schema?{[S[0]]:{schema:p.schema,example:(c=p.examples)==null?void 0:c[S[0]]}}:void 0}}b[$]={...v,parameters:u,requestBody:f||void 0,responses:F}}o[d]=b}return n.paths=o,n}function mt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ht(e,n){let s=e.split("/").filter(Boolean).map(r=>r.replace(/[{}]/g,""));return`${n[0].toUpperCase()}${n.slice(1)} ${s.join(" ")||"/"}`}function Xe(e,n){var r;let s=[];for(let[a,o]of Object.entries(n||{})){let i=j(e,o)||{},c=i.example;if(c===void 0&&i.examples&&typeof i.examples=="object"){let d=Object.values(i.examples)[0];d!==void 0&&(c=(r=j(e,d))==null?void 0:r.value)}s.push({type:a,schema:i.schema,example:c})}return s.sort((a,o)=>+!ue(a.type)-+!ue(o.type)),s}function ue(e){return/\bjson\b|\+json/i.test(e)}function gt(e,n,s){let r=j(e,s)||{},a=r.description||"";if(r.type==="http"){let o=String(r.scheme||"").toLowerCase();return o==="basic"?{key:n,type:"basic",description:a}:o==="bearer"?{key:n,type:"bearer",description:a,format:r.bearerFormat}:{key:n,type:"other",description:a}}return r.type==="apiKey"?{key:n,type:"apiKey",in:r.in||"header",name:r.name||"X-API-Key",description:a}:r.type==="oauth2"||r.type==="openIdConnect"?{key:n,type:"oauth2",description:a}:{key:n,type:"other",description:a}}function Ye(e){var F,X,J;let n=e&&e.swagger==="2.0"?ft(e):e||{},s=n.info||{},r=n["x-swc"]||{},a=new Map;for(let[p,S]of Object.entries(((F=n.components)==null?void 0:F.securitySchemes)||{}))a.set(p,gt(n,p,S));let o=p=>Array.isArray(p)?p.flatMap(S=>Object.keys(S||{})).filter(S=>a.has(S)):[],i=o(n.security),c=new Map;for(let p of n.tags||[])p&&p.name&&c.set(p.name,{name:p["x-displayName"]||p.name,description:p.description||""});let d=[],h=new Set;for(let[p,S]of Object.entries(n.paths||{})){let V=j(n,S)||{};for(let H of Qe){let C=V[H];if(!C||C["x-swc-hidden"])continue;let Q=[],ee=new Set;for(let U of[...C.parameters||[],...V.parameters||[]]){let A=j(n,U);if(!A||!A.name||!A.in)continue;let P=`${A.in}:${A.name}`;if(ee.has(P))continue;ee.add(P);let G=A.example;G===void 0&&A.examples&&(G=(X=j(n,Object.values(A.examples)[0]))==null?void 0:X.value),Q.push({name:A.name,in:A.in,required:A.in==="path"||!!A.required,description:A.description||"",schema:A.schema||(A.content?(J=Object.values(A.content)[0])==null?void 0:J.schema:void 0)||{},example:G,deprecated:!!A.deprecated})}let Y=C.requestBody?j(n,C.requestBody):null,se=Y?{required:!!Y.required,description:Y.description||"",media:Xe(n,Y.content)}:null,g=[];for(let[U,A]of Object.entries(C.responses||{})){let P=j(n,A)||{};g.push({status:U,description:P.description||"",media:Xe(n,P.content),headers:Object.entries(P.headers||{}).map(([G,le])=>{let me=j(n,le)||{};return{name:G,description:me.description||"",schema:me.schema||{}}})})}let E=C.summary||(C.operationId?String(C.operationId).replace(/[_-]+/g," "):"")||ht(p,H),T=mt(C.operationId||`${H}-${p}`)||H;if(h.has(T)){let U=2;for(;h.has(`${T}-${U}`);)U++;T=`${T}-${U}`}h.add(T);let B=Array.isArray(C.tags)&&C.tags[0]||"";d.push({id:T,method:H,path:p,name:E,summary:C.summary||"",description:C.description||"",tag:B,params:Q,body:se,responses:g,security:C.security!==void 0?o(C.security):i,deprecated:!!C.deprecated})}}let b=new Map;for(let p of n.tags||[])p!=null&&p.name&&b.set(p.name,{key:p.name,name:"",description:"",ops:[]});for(let p of d){let S=p.tag||"";b.has(S)||b.set(S,{key:S,name:"",description:"",ops:[]}),b.get(S).ops.push(p)}for(let p of b.values()){let S=c.get(p.key);p.name=(S==null?void 0:S.name)||p.key||"Requests",p.description=(S==null?void 0:S.description)||""}let $=p=>p.filter(S=>!!(S&&S.ops.length)),v=[],u=Array.isArray(n["x-tagGroups"])?n["x-tagGroups"]:[];if(u.length){let p=new Set;for(let V of u){let H=$((V.tags||[]).map(C=>(p.add(C),b.get(C))));H.length&&v.push({name:V.name||"",folders:H})}let S=$([...b.values()].filter(V=>!p.has(V.key)));S.length&&v.push({name:v.length?"More":"",folders:S})}else v.push({name:"",folders:$([...b.values()])});let f=v.flatMap(p=>p.folders.flatMap(S=>S.ops)),m=(Array.isArray(n.servers)?n.servers:[]).filter(p=>p&&typeof p.url=="string").map(p=>{let S=p.url;for(let[V,H]of Object.entries(p.variables||{}))S=S.split(`{${V}}`).join(String((H==null?void 0:H.default)??""));return{url:S,description:p.description||""}}),N={accent:typeof r.accent=="string"?r.accent:void 0,theme:r.theme==="light"||r.theme==="dark"?r.theme:"system",pages:(Array.isArray(r.pages)?r.pages:[]).filter(p=>p&&p.title).map(p=>({title:String(p.title),body:String(p.body||"")})),links:(Array.isArray(r.links)?r.links:[]).filter(p=>p&&p.label&&p.url).map(p=>({label:String(p.label),url:String(p.url)})),languages:Array.isArray(r.languages)&&r.languages.length?r.languages.map(String):["curl","javascript","python","go"]};return{title:s.title||"API",version:s.version||"",description:s.description||"",servers:m,groups:v,ops:f,byId:new Map(f.map(p=>[p.id,p])),schemes:a,root:n,ui:N}}function oe(e){let n=e.type;return Array.isArray(n)?n.find(s=>s!=="null")||"null":n||(e.properties||e.additionalProperties?"object":e.items?"array":"")}var yt={"date-time":"2026-01-01T09:30:00Z",date:"2026-01-01",time:"09:30:00",email:"user@example.com",uuid:"3fa85f64-5717-4562-b3fc-2c963f66afa6",uri:"https://example.com",url:"https://example.com",hostname:"example.com",ipv4:"192.0.2.1",ipv6:"2001:db8::1",binary:"",byte:"U3dhc3RpayBDb2Rlcw=="};function de(e,n,s=0,r=[]){if(!n||typeof n!="object")return null;let a=typeof n.$ref=="string"?n.$ref:"";if(a&&r.includes(a))return oe(j(e,n))==="array"?[]:{};let o=j(e,n),i=a?[...r,a]:r;if(!o||s>8)return null;if(o.example!==void 0)return o.example;if(Array.isArray(o.examples)&&o.examples.length)return o.examples[0];if(o.default!==void 0)return o.default;if(o.const!==void 0)return o.const;if(Array.isArray(o.enum)&&o.enum.length)return o.enum[0];if(Array.isArray(o.allOf)){let d={},h=!1;for(let b of o.allOf){let $=de(e,b,s+1,i);if($&&typeof $=="object"&&!Array.isArray($))Object.assign(d,$),h=!0;else if(!h&&$!==null)return $}return o.properties&&Object.assign(d,de(e,{...o,allOf:void 0},s+1,i)),d}let c=o.oneOf||o.anyOf;if(Array.isArray(c)&&c.length){let d=c.find(h=>{var b;return((b=j(e,h))==null?void 0:b.type)!=="null"})||c[0];return de(e,d,s+1,i)}switch(oe(o)){case"object":{let d={},h=0;for(let[b,$]of Object.entries(o.properties||{})){if(h++>=60)break;let v=j(e,$);v!=null&&v.readOnly&&s===0&&r.length===0||(d[b]=de(e,$,s+1,i))}return!h&&o.additionalProperties&&typeof o.additionalProperties=="object"&&(d.key=de(e,o.additionalProperties,s+1,i)),d}case"array":return o.items?[de(e,o.items,s+1,i)]:[];case"integer":return typeof o.minimum=="number"?o.minimum:0;case"number":return typeof o.minimum=="number"?o.minimum:0;case"boolean":return!0;case"null":return null;case"string":return(o.format&&yt[o.format])??"string";default:return null}}function Ce(e,n){let s=j(e,n)||{};return oe(s)==="array"&&s.items?Ce(e,s.items):oe(s)==="string"&&(s.format==="binary"||typeof s.contentMediaType=="string")}function pe(e,n){if(!n)return"any";let s=ut(n),r=j(e,n)||{};if(Ce(e,r))return oe(r)==="array"?"array<file>":"file";let a=r.oneOf||r.anyOf;if(Array.isArray(a))return a.map(d=>pe(e,d)).join(" | ");if(Array.isArray(r.allOf)&&r.allOf.length===1)return pe(e,r.allOf[0]);let o=r.nullable||Array.isArray(r.type)&&r.type.includes("null"),i=oe(r),c;return i==="array"?c=`array<${pe(e,r.items)}>`:i==="object"&&s||s&&!i?c=s:c=i?r.format?`${i}<${r.format}>`:i:s||"any",o&&!c.endsWith("null")?`${c} | null`:c}function Ze(e,n){let s=[],r=(a,o,i)=>{if(o>4||s.length>400)return;let c=typeof(a==null?void 0:a.$ref)=="string"?a.$ref:"";if(c&&i.includes(c))return;let d=c?[...i,c]:i,h=j(e,a)||{};if(Array.isArray(h.allOf)){for(let v of h.allOf)r(v,o,d);if(!h.properties)return}oe(h)==="array"&&h.items&&(h=j(e,h.items)||{});let b=h.oneOf||h.anyOf;if(!h.properties&&Array.isArray(b)){let v=b.find(u=>{var f;return(f=j(e,u))==null?void 0:f.properties});v&&r(v,o,d);return}let $=new Set(Array.isArray(h.required)?h.required:[]);for(let[v,u]of Object.entries(h.properties||{})){let f=j(e,u)||{};s.push({name:v,depth:o,type:pe(e,u),required:$.has(v),description:f.description||f.title||"",enumValues:Array.isArray(f.enum)?f.enum:[],def:f.default,deprecated:!!f.deprecated,readOnly:!!f.readOnly});let m=oe(f)==="array"?j(e,f.items):f;m&&(m.properties||m.allOf||m.oneOf||m.anyOf)&&r(oe(f)==="array"?f.items:u,o+1,d)}};return r(n,0,[]),s}function Ee(e,n){if(n)return n.example!==void 0?n.example:de(e,n.schema)}function we(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??""}catch{return String(e)}}function Ve(e,n){let s=j(e,n.schema)||{},r=n.example!==void 0?n.example:s.example!==void 0?s.example:s.default!==void 0?s.default:Array.isArray(s.enum)?s.enum[0]:Array.isArray(s.examples)?s.examples[0]:void 0;return r==null?"":typeof r=="object"?JSON.stringify(r):String(r)}function et(e){let n=e.trim();return/^(https?:|mailto:)/i.test(n)||/^[#/.?]/.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)?n:null}function Te(e){let n=[],s=re(e).replace(/`([^`]+)`/g,(r,a)=>`\0${n.push(`<code>${a}</code>`)-1}\0`);return s=s.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(r,a,o)=>{let i=et(o.replace(/&/g,"&"));return i&&/^https?:|^\//.test(i)?`<img src="${re(i)}" alt="${a}" loading="lazy">`:r}),s=s.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(r,a,o)=>{let i=et(o.replace(/&/g,"&"));if(!i)return a;let c=/^https?:/i.test(i);return`<a href="${re(i)}"${c?' target="_blank" rel="noopener noreferrer"':""}>${a}</a>`}),s=s.replace(/(^|[\s(])(https?:\/\/[^\s<)]+)/g,'$1<a href="$2" target="_blank" rel="noopener noreferrer">$2</a>'),s=s.replace(/\*\*([^*]+)\*\*|__([^_]+)__/g,(r,a,o)=>`<strong>${a??o}</strong>`),s=s.replace(/(^|[^*\w])\*([^*\s][^*]*?)\*(?!\w)|(^|[^_\w])_([^_\s][^_]*?)_(?!\w)/g,(r,a,o,i,c)=>`${a??i}<em>${o??c}</em>`),s=s.replace(/~~([^~]+)~~/g,"<del>$1</del>"),s.replace(/\u0000(\d+)\u0000/g,(r,a)=>n[Number(a)])}function z(e){if(!e)return"";let n=e.replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),s=[],r=0,a=[],o=()=>{a.length&&s.push(`<p>${Te(a.join(" "))}</p>`),a.length=0};for(;r<n.length;){let i=n[r],c=/^\s*(```|~~~)\s*([\w+-]*)/.exec(i);if(c){o();let b=[];for(r++;r<n.length&&!n[r].trim().startsWith(c[1]);)b.push(n[r++]);r++,s.push(`<pre class="code"><code>${re(b.join(`
|
|
4
|
+
`))}</code></pre>`);continue}let d=/^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(i);if(d){o();let b=Math.min(6,d[1].length+2);s.push(`<h${b}>${Te(d[2])}</h${b}>`),r++;continue}if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(i)){o(),s.push("<hr>"),r++;continue}if(/^\s*>/.test(i)){o();let b=[];for(;r<n.length&&/^\s*>/.test(n[r]);)b.push(n[r++].replace(/^\s*>\s?/,""));s.push(`<blockquote>${z(b.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^\s*\|.*\|\s*$/.test(i)&&r+1<n.length&&/^\s*\|?\s*:?-{2,}/.test(n[r+1])){o();let b=u=>u.trim().replace(/^\||\|$/g,"").split("|").map(f=>Te(f.trim())),$=b(i);r+=2;let v=[];for(;r<n.length&&/^\s*\|.*\|\s*$/.test(n[r]);)v.push(`<tr>${b(n[r++]).map(u=>`<td>${u}</td>`).join("")}</tr>`);s.push(`<div class="table-wrap"><table><thead><tr>${$.map(u=>`<th>${u}</th>`).join("")}</tr></thead><tbody>${v.join("")}</tbody></table></div>`);continue}let h=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/.exec(i);if(h){o();let b=/\d/.test(h[2]),$=[],v=[];for(;r<n.length;){let f=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/.exec(n[r]);if(f&&f[1].length<=h[1].length+1)v.length&&$.push(v.join(`
|
|
6
|
+
`)),v=[f[3]],r++;else if(n[r].trim()&&/^\s+/.test(n[r]))v.push(n[r].trim()),r++;else break}v.length&&$.push(v.join(`
|
|
7
|
+
`));let u=b?"ol":"ul";s.push(`<${u}>${$.map(f=>`<li>${Te(f.replace(/\n/g," "))}</li>`).join("")}</${u}>`);continue}if(!i.trim()){o(),r++;continue}a.push(i.trim()),r++}return o(),s.join("")}function tt(e,n=160){let s=e.replace(/```[\s\S]*?```/g," ").replace(/[#>*_`|[\]()-]+/g," ").replace(/\s+/g," ").trim();return s.length>n?`${s.slice(0,n-1)}\u2026`:s}var bt=3e5;function Oe(e){return e.length>bt?re(e):e.replace(/("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([&<>])/g,(n,s,r,a,o,i)=>s?r?`<span class="t-key">${re(s)}</span>${r}`:`<span class="t-str">${re(s)}</span>`:a?`<span class="t-lit">${a}</span>`:o?`<span class="t-num">${o}</span>`:re(i||n))}var Me={curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",php:"PHP"},ie=e=>`'${e.replace(/'/g,"'\\''")}'`,K=e=>JSON.stringify(e);function _e(e){try{return JSON.parse(e)}catch{return}}function $e(e,n=""){if(e===null)return"None";if(e===!0)return"True";if(e===!1)return"False";if(typeof e=="number")return String(e);if(typeof e=="string")return JSON.stringify(e);let s=`${n} `;if(Array.isArray(e))return e.length?`[
|
|
8
|
+
${e.map(a=>s+$e(a,s)).join(`,
|
|
9
|
+
`)}
|
|
10
|
+
${n}]`:"[]";let r=Object.entries(e);return r.length?`{
|
|
11
|
+
${r.map(([a,o])=>`${s}${JSON.stringify(a)}: ${$e(o,s)}`).join(`,
|
|
12
|
+
`)}
|
|
13
|
+
${n}}`:"{}"}function qe(e,n){let s=n.method.toUpperCase(),r=n.body;switch(e){case"javascript":{let a=[` method: ${K(s)}`];n.headers.length&&a.push(` headers: {
|
|
14
|
+
${n.headers.map(([i,c])=>` ${K(i)}: ${K(c)}`).join(`,
|
|
15
|
+
`)}
|
|
16
|
+
}`);let o="";if((r==null?void 0:r.kind)==="json"&&r.text){let i=_e(r.text);a.push(i===void 0?` body: ${K(r.text)}`:` body: JSON.stringify(${JSON.stringify(i,null,2).replace(/\n/g,`
|
|
17
|
+
`)})`)}else(r==null?void 0:r.kind)==="text"&&r.text?a.push(` body: ${K(r.text)}`):r!=null&&r.fields&&(o=`const form = new ${r.kind==="multipart"?"FormData":"URLSearchParams"}();
|
|
18
|
+
${r.fields.map(([c,d])=>`form.append(${K(c)}, ${K(d)});`).join(`
|
|
19
|
+
`)}
|
|
20
|
+
|
|
21
|
+
`,a.push(" body: form"));return`${o}const res = await fetch(${K(n.url)}, {
|
|
22
|
+
${a.join(`,
|
|
23
|
+
`)}
|
|
24
|
+
});
|
|
25
|
+
const data = await res.json();
|
|
26
|
+
console.log(data);`}case"python":{let a=[K(n.url)];if(n.headers.length&&a.push(`headers=${$e(Object.fromEntries(n.headers)," ")}`),(r==null?void 0:r.kind)==="json"&&r.text){let o=_e(r.text);a.push(o===void 0?`data=${K(r.text)}`:`json=${$e(o," ")}`)}else(r==null?void 0:r.kind)==="text"&&r.text?a.push(`data=${K(r.text)}`):r!=null&&r.fields&&a.push(`${r.kind==="multipart"?"files":"data"}=${$e(Object.fromEntries(r.fields)," ")}`);return`import requests
|
|
27
|
+
|
|
28
|
+
res = requests.${s==="GET"||s==="POST"||s==="PUT"||s==="PATCH"||s==="DELETE"||s==="HEAD"||s==="OPTIONS"?s.toLowerCase():"request"}(
|
|
29
|
+
${a.join(`,
|
|
30
|
+
`)},
|
|
31
|
+
)
|
|
32
|
+
print(res.status_code, res.json())`}case"go":{let a="nil",o="";r!=null&&r.text?(o=` payload := strings.NewReader(\`${r.text.replace(/`/g,'` + "`" + `')}\`)
|
|
33
|
+
`,a="payload"):r!=null&&r.fields&&(o=` payload := strings.NewReader(${K(r.fields.map(([c,d])=>`${encodeURIComponent(c)}=${encodeURIComponent(d)}`).join("&"))})
|
|
34
|
+
`,a="payload");let i=n.headers.map(([c,d])=>` req.Header.Set(${K(c)}, ${K(d)})
|
|
35
|
+
`).join("");return`package main
|
|
36
|
+
|
|
37
|
+
import (
|
|
38
|
+
"fmt"
|
|
39
|
+
"io"
|
|
40
|
+
"net/http"${a==="nil"?"":`
|
|
41
|
+
"strings"`}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
func main() {
|
|
45
|
+
${o} req, _ := http.NewRequest(${K(s)}, ${K(n.url)}, ${a})
|
|
46
|
+
${i} res, err := http.DefaultClient.Do(req)
|
|
47
|
+
if err != nil {
|
|
48
|
+
panic(err)
|
|
49
|
+
}
|
|
50
|
+
defer res.Body.Close()
|
|
51
|
+
out, _ := io.ReadAll(res.Body)
|
|
52
|
+
fmt.Println(res.Status, string(out))
|
|
53
|
+
}`}case"php":{let a=[`$ch = curl_init(${K(n.url)});`,`curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ${K(s)});`,"curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);"];return n.headers.length&&a.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
54
|
+
${n.headers.map(([o,i])=>` ${ie(`${o}: ${i}`)}`).join(`,
|
|
55
|
+
`)}
|
|
56
|
+
]);`),r!=null&&r.text?a.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, ${ie(r.text)});`):r!=null&&r.fields&&a.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, [${r.fields.map(([o,i])=>`${ie(o)} => ${ie(i)}`).join(", ")}]);`),a.push("$response = curl_exec($ch);","curl_close($ch);","echo $response;"),`<?php
|
|
57
|
+
${a.join(`
|
|
58
|
+
`)}`}default:{let a=[`curl${s==="GET"?"":` -X ${s}`} ${ie(n.url)}`];for(let[o,i]of n.headers)a.push(`-H ${ie(`${o}: ${i}`)}`);if(r!=null&&r.text)a.push(`-d ${ie(r.kind==="json"?vt(r.text):r.text)}`);else if(r!=null&&r.fields)for(let[o,i]of r.fields)a.push(`${r.kind==="multipart"?"-F":"--data-urlencode"} ${ie(`${o}=${i}`)}`);return a.join(` \\
|
|
59
|
+
`)}}}function vt(e){let n=_e(e);if(n===void 0)return e;let s=JSON.stringify(n);return s.length<=100?s:JSON.stringify(n,null,2)}function De(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var Fe="https://swastik.codes";function wt(){return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function st(e){let n=e.spec.ui.theme==="light"||e.spec.ui.theme==="dark"?e.spec.ui.theme:wt();document.documentElement.dataset.theme=W("swc-docs-theme",null)||n;let s=e.spec.ui.accent;s&&/^#[0-9a-f]{3,8}$/i.test(s)&&document.documentElement.style.setProperty("--accent",s)}function Ae(){let e=t("button",{class:"icon-btn",type:"button",title:"Switch theme","aria-label":"Switch theme"}),n=()=>q(e,M(document.documentElement.dataset.theme==="dark"?"sun":"moon"));return e.addEventListener("click",()=>{let s=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=s,Z("swc-docs-theme",s),n()}),n(),e}function $t(e){return e==="localhost"||e.endsWith(".localhost")||e.endsWith(".local")||/^127\./.test(e)||/^10\./.test(e)||/^192\.168\./.test(e)||/^172\.(1[6-9]|2\d|3[01])\./.test(e)||e==="[::1]"||e==="0.0.0.0"}function Re(e){let n=`${Fe}/app?import=${encodeURIComponent(e.specUrl)}`,s=t("a",{class:"btn primary run",href:n,target:"_blank",rel:"noopener",title:"Open this API as a collection in Swastik Codes"},M("play"),t("span",null,"Run in Swastik Codes"));return s.addEventListener("click",r=>{$t(location.hostname)&&(r.preventDefault(),kt("Open in Swastik Codes",t("div",{class:"dlg-body"},t("p",null,"This API runs on your computer, so swastik.codes may not be able to fetch it. Download the collection file and import it in Swastik Codes (Import \u2192 File), or try opening it directly."),t("div",{class:"dlg-actions"},t("a",{class:"btn",href:e.boot.spec,download:"openapi.json"},M("download"),"Download openapi.json"),t("a",{class:"btn primary",href:n,target:"_blank",rel:"noopener"},M("play"),"Open anyway")))))}),s}function kt(e,n){var a;let s=()=>r.remove(),r=t("div",{class:"dlg-wrap",onclick:o=>o.target===r&&s()},t("div",{class:"dlg",role:"dialog","aria-modal":"true","aria-label":e},t("div",{class:"dlg-head"},t("strong",null,e),t("button",{class:"icon-btn",type:"button","aria-label":"Close",onclick:s},M("x"))),n));r.addEventListener("keydown",o=>o.key==="Escape"&&s()),document.body.appendChild(r),(a=r.querySelector("a,button:not([aria-label=Close])"))==null||a.focus()}function Je(e,n){return t("div",{class:"brand"},n&&t("button",{class:"icon-btn only-narrow",type:"button","aria-label":"Menu",onclick:n},M("menu")),t("a",{class:"brand-mark",href:Fe,target:"_blank",rel:"noopener",title:"Swastik Codes"},Ne()),t("span",{class:"brand-title"},e.spec.title),e.spec.version&&t("span",{class:"chip"},e.spec.version))}function fe(){return t("a",{class:"powered",href:`${Fe}/?ref=docs`,target:"_blank",rel:"noopener"},Ne(),t("span",null,"Built with ",t("strong",null,"Swastik Codes")))}function ze(e){let n=e.spec.servers.map(s=>({url:xt(s.url),label:s.description||s.url}));return n.length||n.push({url:location.origin,label:location.origin}),n}function xt(e){try{return new URL(e,location.href).href.replace(/\/$/,"")}catch{return e.replace(/\/$/,"")}}function Ke(e){let n=W(`${e.key}:server`,0);return n>=0&&n<ze(e).length?n:0}function ge(e){let n=W(`${e.key}:server-custom`,"");return n?n.replace(/\/$/,""):ze(e)[Ke(e)].url}function je(e,n){let s=ze(e),r=W(`${e.key}:server-custom`,""),a=t("select",{class:"select","aria-label":"Server"},s.map((o,i)=>t("option",{value:String(i),selected:!r&&i===Ke(e)},o.label)),t("option",{value:"custom",selected:!!r},r?`Custom: ${r}`:"Custom URL\u2026"));return a.addEventListener("change",()=>{if(a.value==="custom"){let o=prompt("Base URL for requests",W(`${e.key}:server-custom`,"")||ge(e));if(o&&/^https?:\/\//i.test(o.trim()))Z(`${e.key}:server-custom`,o.trim()),a.options[a.options.length-1].textContent=`Custom: ${o.trim()}`;else{a.value=String(Ke(e));return}}else Z(`${e.key}:server-custom`,""),Z(`${e.key}:server`,Number(a.value));n()}),t("label",{class:"server"},t("span",{class:"sr"},"Server"),a)}function rt(e,n){try{return sessionStorage.getItem(`${e.key}:auth:${n}`)||""}catch{return""}}function St(e,n,s){try{s?sessionStorage.setItem(`${e.key}:auth:${n}`,s):sessionStorage.removeItem(`${e.key}:auth:${n}`)}catch{}}function ye(e,n){for(let s of n.security){let r=e.spec.schemes.get(s);if(r&&r.type!=="other")return r}return null}function Lt(e,n,s){let r=n||(s?e.type==="basic"?"username:password":e.type==="apiKey"?"<api-key>":"<token>":"");if(!r)return null;if(e.type==="bearer"||e.type==="oauth2")return["Authorization",`Bearer ${r}`];if(e.type==="basic"){if(!n)return["Authorization","Basic <base64 username:password>"];let a=r;try{a=btoa(unescape(encodeURIComponent(r)))}catch{}return["Authorization",`Basic ${a}`]}return e.type==="apiKey"&&e.in==="header"?[e.name||"X-API-Key",r]:null}function ot(e,n,s){let r=n.type==="basic"?"Username:password":n.type==="apiKey"?`${n.name} (${n.in})`:"Bearer token",a=t("input",{class:"input mono",type:"password",autocomplete:"off",spellcheck:"false",placeholder:n.type==="basic"?"user:password":n.type==="apiKey"?"API key":"Token",value:rt(e,n.key)});a.addEventListener("input",()=>{St(e,n.key,a.value.trim()),s()});let o=t("button",{class:"btn small",type:"button"},"Show");return o.addEventListener("click",()=>{a.type=a.type==="password"?"text":"password",o.textContent=a.type==="password"?"Show":"Hide"}),t("div",{class:"auth-row"},t("label",{class:"field"},t("span",{class:"field-label"},M("lock"),` ${n.key} \xB7 ${r}`),t("div",{class:"input-row"},a,o)),n.description&&t("div",{class:"md small"},D(z(n.description))),n.type==="apiKey"&&n.in==="cookie"&&t("p",{class:"muted small"},"Browsers do not let pages set cookies on other requests: sign in to the API in this browser instead."),t("p",{class:"muted small"},"Kept in this tab only (session storage). It is sent with every request that uses this scheme."))}var nt=(e,n)=>({on:n.required,key:n.name,value:Ve(e.spec.root,n),desc:n.description});function ke(e,n){var c;let s={};for(let d of n.params)d.in==="path"&&(s[d.name]=Ve(e.spec.root,d));let r=(c=n.body)==null?void 0:c.media[0],a="",o=[],i=(r==null?void 0:r.type)||"";if(r){let d=Ee(e.spec.root,r);if(/form/i.test(r.type)){let h=j(e.spec.root,r.schema)||{},b=new Set(h.required||[]);o=Object.entries(h.properties||{}).map(([$,v])=>{let u=j(e.spec.root,v)||{},f=Ce(e.spec.root,u),m=d&&typeof d=="object"?d[$]:"";return{on:b.has($)||!f,key:$,value:f||m==null?"":typeof m=="object"?JSON.stringify(m):String(m),desc:`${f?"File. ":""}${b.has($)?"Required. ":""}${u.description||""}`,file:f?null:void 0}})}else d!=null&&(a=ue(r.type)||typeof d=="object"?we(d):String(d))}return{path:n.path,pathVals:s,query:n.params.filter(d=>d.in==="query").map(d=>nt(e,d)),headers:n.params.filter(d=>d.in==="header").map(d=>nt(e,d)),bodyType:i,body:a,form:o,auth:"inherit"}}function be(e,n,s,r){let a=s.path.replace(/\{([^}]+)\}/g,(u,f)=>{let m=s.pathVals[f];return m?encodeURIComponent(m):r?`{${f}}`:u}),o=new URLSearchParams;for(let u of s.query)u.on&&u.key&&o.append(u.key,u.value);let i=[],c=s.auth==="inherit"?ye(e,n):null;if(c){let u=rt(e,c.key),f=Lt(c,u,r);f&&i.push(f),c.type==="apiKey"&&c.in==="query"&&(u||r)&&o.set(c.name||"api_key",u||"<api-key>")}for(let u of s.headers)u.on&&u.key&&i.push([u.key,u.value]);let d=null,h,b=s.bodyType;if(b&&!["GET","HEAD"].includes(n.method.toUpperCase()))if(/multipart/i.test(b)){let u=new FormData,f=[];for(let m of s.form)!m.on||!m.key||(m.file?(u.append(m.key,m.file,m.file.name),f.push([m.key,`@${m.file.name}`])):(u.append(m.key,m.value),f.push([m.key,m.file===null?"@file":m.value])));d={kind:"multipart",fields:f},h=u}else if(/x-www-form-urlencoded/i.test(b)){let u=s.form.filter(f=>f.on&&f.key).map(f=>[f.key,f.value]);d={kind:"form",fields:u},h=new URLSearchParams(u),i.push(["Content-Type",b])}else s.body&&(d={kind:ue(b)?"json":"text",text:s.body},h=s.body,i.some(([u])=>u.toLowerCase()==="content-type")||i.push(["Content-Type",b]));a.startsWith("/")||(a=`/${a}`);let $=o.toString(),v=`${ge(e)}${a}${$?`?${$}`:""}`;return{url:v,sample:{method:n.method,url:v,headers:i,body:d},init:{method:n.method.toUpperCase(),headers:i.filter(([u])=>!(h instanceof FormData&&u.toLowerCase()==="content-type")),body:h}}}function Ct(e,n){let s=j(e,n)||{},r=[];return Array.isArray(s.enum)&&s.enum.length&&r.push(`one of: ${s.enum.slice(0,12).map(a=>JSON.stringify(a)).join(", ")}${s.enum.length>12?", \u2026":""}`),s.default!==void 0&&r.push(`default: ${JSON.stringify(s.default)}`),s.minimum!==void 0&&r.push(`min ${s.minimum}`),s.maximum!==void 0&&r.push(`max ${s.maximum}`),s.minLength!==void 0&&r.push(`min length ${s.minLength}`),s.maxLength!==void 0&&r.push(`max length ${s.maxLength}`),s.pattern&&r.push(`pattern ${s.pattern}`),r}function Be(e,n){return t("div",{class:"fields"},n.map(s=>t("div",{class:"field-row"},t("div",{class:"f-head"},t("code",{class:"f-name"},s.name),t("span",{class:"f-type"},pe(e.spec.root,s.schema)),s.required&&t("span",{class:"f-req"},"required"),s.deprecated&&t("span",{class:"f-dep"},"deprecated")),s.description&&t("div",{class:"md f-desc"},D(z(s.description))),Ct(e.spec.root,s.schema).map(r=>t("div",{class:"f-meta"},r)))))}function xe(e,n){let s=Ze(e.spec.root,n);if(!s.length){let r=pe(e.spec.root,n);return!n||r==="any"?null:n?t("div",{class:"fields"},t("div",{class:"field-row"},t("div",{class:"f-head"},t("span",{class:"f-type"},r)))):null}return t("div",{class:"fields"},s.map(r=>t("div",{class:`field-row d${Math.min(r.depth,4)}`},t("div",{class:"f-head"},t("code",{class:"f-name"},r.name),t("span",{class:"f-type"},r.type),r.required&&t("span",{class:"f-req"},"required"),r.readOnly&&t("span",{class:"f-meta-chip"},"read-only"),r.deprecated&&t("span",{class:"f-dep"},"deprecated")),r.description&&t("div",{class:"md f-desc"},D(z(r.description))),r.enumValues.length>0&&t("div",{class:"f-meta"},`one of: ${r.enumValues.slice(0,12).map(a=>JSON.stringify(a)).join(", ")}${r.enumValues.length>12?", \u2026":""}`),r.def!==void 0&&t("div",{class:"f-meta"},`default: ${JSON.stringify(r.def)}`))))}function Se(e,n,s){let r=t("pre",{class:"code"}),a=t("code");return n!==void 0?a.appendChild(D(n)):a.textContent=e,r.appendChild(a),t("div",{class:"code-wrap"},s&&t("div",{class:"code-label"},s),ae(()=>e),r)}function Ue(e,n="nav-op"){return t("a",{class:n,href:`#${e.id}`,"data-op":e.id,title:`${e.method.toUpperCase()} ${e.path}`},ce(e.method),t("span",{class:`nav-name${e.deprecated?" dep":""}`},e.name))}function He(e,n,s){if(!s)return!0;let r=`${e.name} ${e.path} ${e.method} ${n}`.toLowerCase();return s.toLowerCase().split(/\s+/).every(a=>r.includes(a))}var Et=30,Ge=2e6;function at(e,n){let{spec:s}=e,r=new Map,a=new Map,o=null,i=W("swc-col-tab","params"),c="body",d=W("swc-col-view","pretty"),h=null,b=()=>document.body.classList.toggle("side-open"),$=t("aside",{class:"side tree-side"}),v=t("main",{class:"work"});ne(n,[t("header",{class:"topbar"},Je(e,b),t("span",{class:"spacer"}),je(e,()=>o&&B()),Ae(),t("a",{class:"btn ghost hide-narrow",href:e.boot.docs},M("book"),"Documentation"),Re(e)),t("div",{class:"col-body"},$,t("div",{class:"scrim",onclick:b}),v)]);let u=t("input",{class:"input",type:"search",placeholder:"Filter requests","aria-label":"Filter requests"}),f=t("nav",{class:"tree","aria-label":"Collection"}),m=new Set(W(`${e.key}:closed`,[])),N=(l,y,k,L,x)=>{let w=t("details",{class:x,open:L?!0:!m.has(l)},t("summary",null,M("chev","ic chev"),M("folder","ic fold"),t("span",null,y)),k);return w.addEventListener("toggle",()=>{L||(w.open?m.delete(l):m.add(l),Z(`${e.key}:closed`,[...m]))}),w},F=()=>{let l=u.value.trim(),y=[];for(let k of s.groups){let L=[];for(let x of k.folders){let w=x.ops.filter(O=>He(O,x.name,l));if(!w.length)continue;let R=w.map(O=>{let I=Ue(O,"tree-op");return(o==null?void 0:o.id)===O.id&&I.classList.add("on"),I});L.push(x.key||s.groups.length>1||k.folders.length>1?N(`f:${k.name}:${x.key}`,x.name,R,l,"tree-folder"):t("div",null,R))}L.length&&y.push(k.name?N(`g:${k.name}`,k.name,L,l,"tree-folder tree-group"):t("div",null,L))}q(f,y.length?y:t("p",{class:"muted pad"},`Nothing matches \u201C${l}\u201D.`))};u.addEventListener("input",F),f.addEventListener("click",l=>{let y=l.target.closest("a[data-op]");y&&(l.preventDefault(),U(y.dataset.op),document.body.classList.remove("side-open"))}),ne($,[t("div",{class:"side-head"},t("span",null,"Collection"),t("span",{class:"muted small"},`${s.ops.length}`)),t("div",{class:"side-search"},M("search"),u),f,t("div",{class:"side-foot"},fe())]);let X=t("div",{class:"crumbs"}),J=t("span",{class:"url-method"}),p=t("input",{class:"url-input mono",spellcheck:"false","aria-label":"Request URL"}),S=t("span",{class:"base-pill mono",title:""},"{{baseUrl}}"),V=t("button",{class:"btn primary send",type:"submit"},M("send"),t("span",null,"Send")),H=t("div",{class:"tabs",role:"tablist"}),C=t("div",{class:"req-pane"}),Q=t("div",{class:"res-head"}),ee=t("div",{class:"res-body"}),Y=t("div",{class:"resizer",role:"separator","aria-orientation":"horizontal",tabindex:"0","aria-label":"Resize"}),se=t("div",{class:"editor"},X,t("form",{class:"urlbar",onsubmit:l=>(l.preventDefault(),le())},J,t("div",{class:"url-field"},S,p),V),H,C,Y,t("section",{class:"res-pane","aria-label":"Response"},Q,ee)),g=W("swc-col-split",.45);se.style.setProperty("--split",String(g));let E=!1;Y.addEventListener("pointerdown",l=>{E=!0,Y.setPointerCapture(l.pointerId)}),Y.addEventListener("pointermove",l=>{if(!E)return;let y=se.getBoundingClientRect(),k=C.getBoundingClientRect().top,L=Math.min(.8,Math.max(.12,(l.clientY-k)/(y.bottom-k)));se.style.setProperty("--split",String(L))}),Y.addEventListener("pointerup",()=>{E=!1,Z("swc-col-split",Number(se.style.getPropertyValue("--split")))}),p.addEventListener("change",()=>{if(!o)return;let l=T(o),y=p.value.trim(),[k,L=""]=y.split("?");l.path=k.startsWith("/")?k:`/${k}`;let x=new URLSearchParams(L),w=l.query.filter(R=>!R.on);l.query=[...[...x].map(([R,O])=>{var I;return{on:!0,key:R,value:O,desc:((I=l.query.find(te=>te.key===R))==null?void 0:I.desc)||""}}),...w],i==="params"&&G()}),document.addEventListener("keydown",l=>{(l.metaKey||l.ctrlKey)&&l.key==="Enter"&&o&&(l.preventDefault(),le())});function T(l){let y=r.get(l.id);return y||(y=ke(e,l),r.set(l.id,y)),y}function B(){if(!o)return;let l=T(o),y=new URLSearchParams(l.query.filter(k=>k.on&&k.key).map(k=>[k.key,k.value])).toString();document.activeElement!==p&&(p.value=`${l.path}${y?`?${y}`:""}`),S.title=ge(e)}function U(l,y=!0){var x;let k=s.byId.get(l);if(!k)return;o=k,y&&history.replaceState(null,"",`#${l}`),document.title=`${k.name} \xB7 ${s.title}`;for(let w of f.querySelectorAll(".tree-op.on"))w.classList.remove("on");(x=f.querySelector(`a[data-op="${CSS.escape(l)}"]`))==null||x.classList.add("on");let L=s.groups.flatMap(w=>w.folders).find(w=>w.ops.includes(k));q(X,t("span",null,s.title),L!=null&&L.key?[t("span",{class:"sep"},"/"),t("span",null,L.name)]:null,t("span",{class:"sep"},"/"),t("strong",null,k.name),ae(()=>be(e,k,T(k),!1).url,"Copy URL")),q(J,ce(k.method,"m big")),v.firstChild!==se&&q(v,se),B(),A(),G(),Le()}function A(){if(!o)return;let l=T(o),y=L=>L?t("span",{class:"count"},String(L)):null,k=[["params","Params",y(l.query.filter(L=>L.on).length+Object.keys(l.pathVals).length)],["auth","Authorization",ye(e,o)&&l.auth==="inherit"?t("span",{class:"dot"}):null],["headers","Headers",y(l.headers.filter(L=>L.on).length)],["body","Body",l.bodyType?t("span",{class:"dot"}):null],["docs","Docs",null],["code","Code",null]];k.some(([L])=>L===i)||(i="params"),q(H,k.map(([L,x,w])=>t("button",{type:"button",role:"tab","aria-selected":String(L===i),onclick:()=>{i=L,Z("swc-col-tab",L),A(),G()}},x,w)))}let P=()=>{B(),A()};function G(){var k,L;if(!o)return;let l=o,y=T(l);switch(C.scrollTop=0,i){case"params":{let x=Object.keys(y.pathVals);q(C,x.length>0&&[t("h4",null,"Path variables"),Pe(x.map(w=>{var R;return{on:!0,key:w,value:y.pathVals[w],desc:((R=l.params.find(O=>O.in==="path"&&O.name===w))==null?void 0:R.description)||""}}),w=>{for(let R of w)y.pathVals[R.key]=R.value;P()},{fixed:!0})],t("h4",null,"Query params"),Pe(y.query,w=>{y.query=w,P()}),t("p",{class:"muted small tip"},"Tip: ",t("kbd",null,"Ctrl")," + ",t("kbd",null,"Enter")," sends the request."));break}case"auth":{let x=ye(e,l),w=t("select",{class:"select","aria-label":"Auth"},t("option",{value:"inherit",selected:y.auth==="inherit"},x?`Use ${x.key}`:"No auth needed"),t("option",{value:"none",selected:y.auth==="none"},"No auth"));w.addEventListener("change",()=>{y.auth=w.value,P(),G()}),q(C,t("label",{class:"field inline"},t("span",{class:"field-label"},"Type"),w),x&&y.auth==="inherit"?ot(e,x,P):t("p",{class:"muted"},x?"This request is sent without credentials.":"This request does not declare any authentication."));break}case"headers":q(C,Pe(y.headers,x=>{y.headers=x,P()}),t("p",{class:"muted small tip"},"Authorization and Content-Type are added for you. The browser controls some headers (Cookie, Host, User-Agent) and leaves them out."));break;case"body":{let x=((k=l.body)==null?void 0:k.media.map(_=>_.type))||[],w=t("select",{class:"select","aria-label":"Body type"},t("option",{value:"",selected:!y.bodyType},"none"),[...new Set([...x,...x.length?[]:["application/json"]])].map(_=>t("option",{value:_,selected:_===y.bodyType},_)));w.addEventListener("change",()=>{y.bodyType=w.value,P(),G()});let R=t("div",{class:"body-head"},w);if(!y.bodyType){q(C,R,t("p",{class:"muted"},"This request has no body."));break}if(/form/i.test(y.bodyType)){q(C,R,Pe(y.form,_=>{y.form=_,P()},{files:/multipart/i.test(y.bodyType)}));break}let O=t("textarea",{class:"body-input mono",spellcheck:"false","aria-label":"Request body"});O.value=y.body,O.addEventListener("input",()=>{y.body=O.value,I.textContent=""}),O.addEventListener("keydown",_=>{_.key==="Tab"&&!_.shiftKey&&(_.preventDefault(),O.setRangeText(" ",O.selectionStart,O.selectionEnd,"end"),y.body=O.value)});let I=t("span",{class:"err small"}),te=t("button",{class:"btn small",type:"button"},"Beautify");te.addEventListener("click",()=>{try{O.value=y.body=JSON.stringify(JSON.parse(O.value),null,2)}catch(_){I.textContent=`Not valid JSON: ${_.message}`}});let he=t("button",{class:"btn small ghost",type:"button"},"Reset to example");he.addEventListener("click",()=>{O.value=y.body=ke(e,l).body}),ne(R,[/json/i.test(y.bodyType)&&te,he,I]),q(C,R,O);break}case"docs":{let x=[["path","Path parameters"],["query","Query parameters"],["header","Headers"]];q(C,t("div",{class:"docs-tab"},t("h3",null,l.name),l.description?t("div",{class:"md"},D(z(l.description))):t("p",{class:"muted"},"No description."),x.map(([w,R])=>{let O=l.params.filter(I=>I.in===w);return O.length?[t("h4",null,R),Be(e,O)]:null}),((L=l.body)==null?void 0:L.media[0])&&[t("h4",null,"Request body"),xe(e,l.body.media[0].schema)],t("a",{class:"try",href:`${e.boot.docs}#${l.id}`},M("book"),"Open in documentation")));break}case"code":{let x=W("swc-docs-lang",s.ui.languages[0]);s.ui.languages.includes(x)||(x=s.ui.languages[0]);let w=t("div"),R=t("div",{class:"tabs small"}),O=()=>{q(R,s.ui.languages.map(I=>t("button",{type:"button","aria-selected":String(I===x),onclick:()=>(x=I,Z("swc-docs-lang",I),O())},Me[I]||I))),q(w,Se(qe(x,be(e,l,y,!1).sample)))};O(),q(C,R,w,t("p",{class:"muted small tip"},"Built from the request as it is now, including your credentials. Take care where you paste it."));break}}}async function le(){if(!o)return;if(h){h.abort();return}let l=o,y=be(e,l,T(l),!1),k=/\{[^}]+\}/.exec(y.url.split("?")[0]);if(k){me(l.id,{status:0,statusText:"",ms:0,size:0,headers:[],type:"",text:null,blobUrl:null,error:`Fill in the path variable ${k[0]} (Params tab).`});return}h=new AbortController,q(V,M("x"),t("span",null,"Cancel")),V.classList.add("busy"),q(Q,t("span",{class:"muted"},"Sending\u2026"));let L=performance.now();try{let x=await fetch(y.url,{...y.init,signal:h.signal,credentials:"same-origin",redirect:"follow"}),w=await x.blob(),R=Math.round(performance.now()-L),O=x.headers.get("content-type")||w.type||"",I=!O||/json|text|xml|html|javascript|csv|yaml|x-www-form-urlencoded|problem/i.test(O),te=a.get(l.id);te!=null&&te.blobUrl&&URL.revokeObjectURL(te.blobUrl),me(l.id,{status:x.status,statusText:x.statusText,ms:R,size:w.size,headers:[...x.headers],type:O,text:I?await w.text():null,blobUrl:I?null:URL.createObjectURL(w),error:null})}catch(x){let w=x.name==="AbortError";me(l.id,{status:0,statusText:"",ms:Math.round(performance.now()-L),size:0,headers:[],type:"",text:null,blobUrl:null,error:w?"Request cancelled.":`Could not get a response. The server may be down, or it does not allow requests from this page (CORS). For another server, enable CORS for ${location.origin}, or use Run in Swastik Codes.`})}finally{h=null,q(V,M("send"),t("span",null,"Send")),V.classList.remove("busy")}}function me(l,y){if(a.delete(l),a.set(l,y),a.size>Et){let k=a.keys().next().value,L=a.get(k);L!=null&&L.blobUrl&&URL.revokeObjectURL(L.blobUrl),a.delete(k)}(o==null?void 0:o.id)===l&&Le()}function Le(){let l=o?a.get(o.id):void 0;if(!l){q(Q,t("span",{class:"res-title"},"Response")),q(ee,t("div",{class:"empty"},M("send","ic big"),t("p",null,"Press ",t("strong",null,"Send")," to get a response.")));return}if(l.error){q(Q,t("span",{class:"res-title"},"Response"),l.ms>0&&t("span",{class:"muted small"},`${l.ms} ms`)),q(ee,t("div",{class:"empty err"},t("p",null,l.error)));return}let y=(_,ve,We)=>t("button",{type:"button",role:"tab","aria-selected":String(c===_),onclick:()=>(c=_,Le())},ve,We?t("span",{class:"count"},String(We)):null);if(q(Q,t("div",{class:"tabs",role:"tablist"},y("body","Body"),y("headers","Headers",l.headers.length)),t("span",{class:"spacer"}),t("span",{class:`status s${String(l.status)[0]}`},`${l.status} ${l.statusText}`.trim()),t("span",{class:"meta"},`${l.ms} ms`),t("span",{class:"meta"},De(l.size))),c==="headers"){q(ee,t("div",{class:"hdrs"},l.headers.map(([_,ve])=>t("div",{class:"hdr"},t("span",{class:"hk mono"},_),t("span",{class:"hv mono"},ve)))));return}if(l.blobUrl){q(ee,/^image\//i.test(l.type)?t("div",{class:"preview"},t("img",{src:l.blobUrl,alt:"Response image"})):t("p",{class:"muted pad"},`Binary response (${l.type||"unknown type"}).`),t("div",{class:"pad"},t("a",{class:"btn",href:l.blobUrl,download:"response"},M("download"),"Save response")));return}let k=l.text||"",L=k,x=!1;if(/json/i.test(l.type)||/^\s*[[{]/.test(k))try{L=JSON.stringify(JSON.parse(k),null,2),x=!0}catch{}let w=d==="pretty"?L:k,R=w.length>Ge,O=R?w.slice(0,Ge):w,I=(_,ve)=>t("button",{type:"button","aria-selected":String(d===_),onclick:()=>(d=_,Z("swc-col-view",_),Le())},ve),te=t("pre",{class:"code res-code"}),he=t("code");d==="pretty"&&x&&!R?he.appendChild(D(Oe(O))):he.textContent=O,te.appendChild(he),q(ee,t("div",{class:"res-tools"},t("div",{class:"seg"},I("pretty","Pretty"),I("raw","Raw")),t("span",{class:"muted small"},l.type.split(";")[0]),t("span",{class:"spacer"}),ae(()=>w,"Copy body")),k?te:t("p",{class:"muted pad"},"Empty body."),R&&t("p",{class:"muted small pad"},`Showing the first ${De(Ge)} \u2014 copy for the whole body.`))}q(v,t("div",{class:"overview"},t("h1",null,s.title),t("p",{class:"muted"},`${s.ops.length} request${s.ops.length===1?"":"s"} in ${s.groups.reduce((l,y)=>l+y.folders.length,0)} folder(s)${s.version?` \xB7 Version ${s.version}`:""}`),s.description&&t("div",{class:"md"},D(z(s.description))),t("p",null,"Pick a request on the left to send it from this page."),s.ops[0]&&t("button",{class:"btn primary",type:"button",onclick:()=>U(s.ops[0].id)},M("send"),`Open \u201C${s.ops[0].name}\u201D`))),F();let Ie=decodeURIComponent(location.hash.slice(1));Ie&&s.byId.has(Ie)&&U(Ie,!1),window.addEventListener("hashchange",()=>{let l=decodeURIComponent(location.hash.slice(1));l&&l!==(o==null?void 0:o.id)&&U(l,!1)})}function Pe(e,n,s={}){let r=e.map(c=>({...c})),a=t("div",{class:"kv-body"}),o=()=>n(r.filter(c=>c.key||c.value||c.file)),i=(c,d)=>{var m;let h=t("input",{type:"checkbox",checked:c.on,"aria-label":"Send this row",disabled:s.fixed}),b=t("input",{class:"input mono",value:c.key,placeholder:"Key",readonly:s.fixed,"aria-label":"Key",spellcheck:"false"}),$=s.files&&c.file!==void 0,v=$?t("input",{class:"input",type:"file","aria-label":"File"}):t("input",{class:"input mono",value:c.value,placeholder:"Value","aria-label":"Value",spellcheck:"false"}),u=t("div",{class:`kv-row${d?" new":""}`},t("span",{class:"kv-on"},h),b,v,t("span",{class:"kv-desc",title:c.desc},c.desc),!s.fixed&&t("button",{class:"icon-btn kv-del",type:"button","aria-label":"Remove row"},M("x"))),f=()=>{u.classList.contains("new")&&(u.classList.remove("new"),c.on=!0,h.checked=!0,r.push(c),a.appendChild(i({on:!0,key:"",value:"",desc:""},!0)))};return h.addEventListener("change",()=>{c.on=h.checked,o()}),b.addEventListener("input",()=>{c.key=b.value,f(),o()}),v.addEventListener($?"change":"input",()=>{var N;$?c.file=((N=v.files)==null?void 0:N[0])||null:c.value=v.value,f(),o()}),(m=u.querySelector(".kv-del"))==null||m.addEventListener("click",()=>{u.classList.contains("new")||(r.splice(r.indexOf(c),1),u.remove(),o())}),u};for(let c of r)a.appendChild(i(c,!1));return s.fixed||a.appendChild(i({on:!0,key:"",value:"",desc:""},!0)),t("div",{class:`kv${s.fixed?" fixed":""}`},t("div",{class:"kv-row kv-headrow"},t("span"),t("span",null,"Key"),t("span",null,"Value"),t("span",null,"Description"),!s.fixed&&t("span")),a)}var it=24;function lt(e,n){let{spec:s}=e,r=t("aside",{class:"side",id:"swc-side"}),a=t("main",{class:"content",id:"swc-main"}),o=()=>document.body.classList.toggle("side-open"),i=t("header",{class:"topbar"},Je(e,o),t("span",{class:"spacer"}),Ae(),t("a",{class:"btn ghost hide-narrow",href:e.boot.collection},M("grid"),"Collection"),t("a",{class:"btn ghost hide-narrow",href:e.boot.spec,download:"openapi.json"},M("download"),"Download"),Re(e));ne(n,[i,t("div",{class:"docs-body"},r,t("div",{class:"scrim",onclick:o}),a)]);let c=t("input",{class:"input",type:"search",placeholder:"Search","aria-label":"Search requests"}),d=t("nav",{class:"nav","aria-label":"Requests"}),h=new Map,b=()=>{let g=c.value.trim();q(d),g||(d.appendChild(t("a",{class:"nav-top",href:"#introduction","data-op":"introduction"},M("book"),"Introduction")),s.ui.pages.forEach((T,B)=>d.appendChild(t("a",{class:"nav-top",href:`#page-${B+1}`,"data-op":`page-${B+1}`},M("book"),T.title)))),h.clear();let E=0;for(let T of s.groups){let B=t("div",{class:"nav-group"});for(let U of T.folders){let A=U.ops.filter(G=>He(G,U.name,g));if(!A.length)continue;E+=A.length;let P=t("details",{class:"nav-folder",open:!0},t("summary",null,M("chev","ic chev"),t("span",null,U.name)));for(let G of A){let le=Ue(G);h.set(G.id,le),P.appendChild(le)}B.appendChild(P)}B.childNodes.length&&d.appendChild(T.name?t("details",{class:"nav-section",open:!0},t("summary",null,M("chev","ic chev"),t("span",null,T.name)),B):B)}g&&!E&&d.appendChild(t("p",{class:"muted pad"},`Nothing matches \u201C${g}\u201D.`)),v($)};c.addEventListener("input",b),c.addEventListener("keydown",g=>{if(g.key!=="Enter")return;let E=d.querySelector("a[data-op]");E&&(location.hash=E.getAttribute("href").slice(1))}),d.addEventListener("click",g=>{g.target.closest("a")&&document.body.classList.remove("side-open")}),ne(r,[t("div",{class:"side-search"},M("search"),c),d,t("div",{class:"side-foot"},fe())]);let $="";function v(g){var U;$=g,(U=d.querySelector(".on"))==null||U.classList.remove("on");let E=d.querySelector(`a[data-op="${CSS.escape(g)}"]`);if(!E)return;E.classList.add("on");let T=E.getBoundingClientRect(),B=d.getBoundingClientRect();(T.top<B.top||T.bottom>B.bottom)&&E.scrollIntoView({block:"nearest"})}let u=s.ops.length,f=t("section",{class:"intro",id:"introduction"},t("h1",null,s.title),t("p",{class:"muted"},`${u} request${u===1?"":"s"}${s.version?` \xB7 Version ${s.version}`:""}`),s.description&&t("div",{class:"md"},D(z(s.description))),t("h2",null,"Base URL"),t("div",{class:"base"},je(e,()=>F()),ae(()=>ge(e),"Copy base URL")));s.schemes.size&&ne(f,[t("h2",null,"Authentication"),[...s.schemes.values()].map(g=>t("div",{class:"scheme"},t("div",{class:"f-head"},M("lock"),t("code",{class:"f-name"},g.key),t("span",{class:"f-type"},g.type==="apiKey"?`API key in ${g.in} \u201C${g.name}\u201D`:g.type==="basic"?"HTTP Basic":g.type==="bearer"?`Bearer token${g.format?` (${g.format})`:""}`:g.type==="oauth2"?"OAuth 2 / OpenID (send the access token as a bearer token)":"Custom")),g.description&&t("div",{class:"md"},D(z(g.description)))))]),s.ui.links.length&&ne(f,[t("h2",null,"Links"),t("ul",{class:"links"},s.ui.links.map(g=>t("li",null,t("a",{href:g.url,target:"_blank",rel:"noopener noreferrer"},g.label))))]),a.appendChild(f),s.ui.pages.forEach((g,E)=>a.appendChild(t("section",{class:"intro page",id:`page-${E+1}`},t("h2",{class:"page-title"},g.title),t("div",{class:"md"},D(z(g.body))))));let m={cur:W("swc-docs-lang",s.ui.languages[0])};s.ui.languages.includes(m.cur)||(m.cur=s.ui.languages[0]);let N=[],F=()=>N.forEach(g=>X(g.op,g.el,g.tabs));function X(g,E,T){for(let U of T.querySelectorAll("button"))U.setAttribute("aria-selected",String(U.dataset.lang===m.cur));let B=qe(m.cur,be(e,g,ke(e,g),!0).sample);q(E,Se(B))}let J=[];for(let g of s.groups)for(let E of g.folders)E.ops.forEach((T,B)=>J.push({op:T,folder:E.name,first:B===0,fdesc:E.description}));let p="IntersectionObserver"in window?new IntersectionObserver(g=>{for(let E of g)E.isIntersecting&&v(E.target.id)},{rootMargin:"-72px 0px -75% 0px"}):null;p==null||p.observe(f),a.querySelectorAll("section.page").forEach(g=>p==null?void 0:p.observe(g));let S=new Map,V=g=>{let E=S.get(g);E&&(S.delete(g),H==null||H.unobserve(g),q(g,Tt(e,E,m,N,X)),g.classList.remove("pending"))},H="IntersectionObserver"in window?new IntersectionObserver(g=>g.forEach(E=>E.isIntersecting&&V(E.target)),{rootMargin:"1500px 0px"}):null,C=0,Q=g=>{let E=document.createDocumentFragment();for(;C<Math.min(g,J.length);C++){let{op:T,folder:B,first:U,fdesc:A}=J[C];U&&E.appendChild(t("div",{class:"folder-head"},t("h2",null,B),A&&t("div",{class:"md muted"},D(z(A)))));let P=t("section",{class:"op pending",id:T.id,"aria-label":`${T.method.toUpperCase()} ${T.path}`},t("div",{class:"op-main"},t("h3",{class:"op-title"},T.name),t("div",{class:"op-path"},ce(T.method),t("code",null,T.path))));S.set(P,T),E.appendChild(P),p==null||p.observe(P),H?H.observe(P):V(P)}a.appendChild(E)},ee=window.requestIdleCallback||(g=>setTimeout(g,16)),Y=()=>{if(C>=J.length){a.appendChild(t("footer",{class:"docs-foot"},fe()));return}Q(C+it),ee(Y)},se=()=>{let g=decodeURIComponent(location.hash.slice(1));if(!g)return;let E=J.findIndex(B=>B.op.id===g);E>=0&&E>=C&&Q(E+1);let T=document.getElementById(g);T&&(V(T),T.nextElementSibling&&V(T.nextElementSibling),T.scrollIntoView({block:"start"}),v(g))};window.addEventListener("hashchange",se),m.cur=m.cur||"curl",b(),Q(it),se(),ee(Y)}function Tt(e,n,s,r,a){let o=e.spec.root,i=[["path","Path parameters"],["query","Query parameters"],["header","Headers"],["cookie","Cookies"]],c=ye(e,n),d=t("div",{class:"op-main"},t("h3",{class:"op-title"},t("a",{class:"anchor",href:`#${n.id}`,"aria-label":"Link to this request"},"#"),n.name,n.deprecated&&t("span",{class:"f-dep"},"deprecated")),t("div",{class:"op-path"},ce(n.method),t("code",null,n.path),ae(()=>n.path,"Copy path")),n.description&&n.description!==n.summary&&t("div",{class:"md"},D(z(n.description))),c&&t("p",{class:"auth-note"},M("lock")," Requires ",t("code",null,c.key)),i.map(([m,N])=>{let F=n.params.filter(X=>X.in===m);return F.length?[t("h4",null,N),Be(e,F)]:null}),n.body&&n.body.media.length>0&&[t("h4",null,"Request body",t("span",{class:"ct"},n.body.media.map(m=>m.type).join(", ")),n.body.required&&t("span",{class:"f-req"},"required")),n.body.description&&t("div",{class:"md"},D(z(n.body.description))),xe(e,n.body.media[0].schema)],n.responses.length>0&&[t("h4",null,"Responses"),t("div",{class:"responses"},n.responses.map((m,N)=>Ot(e,m,N===0)))],t("a",{class:"try",href:`${e.boot.collection}#${n.id}`},M("send"),"Try it in the collection")),h=t("div",{class:"tabs small",role:"tablist"},e.spec.ui.languages.map(m=>t("button",{type:"button",role:"tab","data-lang":m,"aria-selected":String(m===s.cur)},Me[m]||m))),b=t("div");h.addEventListener("click",m=>{let N=m.target.closest("button");if(N!=null&&N.dataset.lang){s.cur=N.dataset.lang,Z("swc-docs-lang",s.cur);for(let F of r)a(F.op,F.el,F.tabs)}}),r.push({op:n,el:b,tabs:h}),a(n,b,h);let $=n.responses.find(m=>/^2/.test(m.status))||n.responses[0],v=$==null?void 0:$.media[0],u=v?Ee(o,v):void 0,f=t("div",{class:"op-side"},t("div",{class:"panel"},t("div",{class:"panel-head"},t("span",null,"Request"),h),b),u!=null&&t("div",{class:"panel"},t("div",{class:"panel-head"},t("span",null,"Response"),t("span",{class:`status s${$.status[0]}`},$.status)),Se(we(u),v&&ue(v.type)?Oe(we(u)):void 0)));return[d,f]}function Ot(e,n,s){let r=n.media[0],a=r?xe(e,r.schema):null;return t("details",{class:"resp",open:s},t("summary",null,M("chev","ic chev"),t("span",{class:`status s${n.status[0]}`},n.status),t("span",{class:"resp-desc"},tt(n.description,120)),r&&t("span",{class:"ct"},r.type)),n.description.length>120&&t("div",{class:"md"},D(z(n.description))),n.headers.length>0&&t("div",{class:"fields"},n.headers.map(o=>t("div",{class:"field-row"},t("div",{class:"f-head"},t("code",{class:"f-name"},o.name),t("span",{class:"f-type"},"header")),o.description&&t("div",{class:"md f-desc"},D(z(o.description)))))),a,!r&&!n.headers.length&&t("p",{class:"muted small"},"No body."))}async function Mt(){let e=document.getElementById("swc-root"),n=document.getElementById("swc-boot");if(!e||!n)return;let s=JSON.parse(n.textContent||"{}"),r=W("swc-docs-theme",null);r&&(document.documentElement.dataset.theme=r);let a=new URL(s.spec,location.href).href,o;try{let d=await fetch(a,{credentials:"same-origin"});if(!d.ok)throw new Error(`${d.status} ${d.statusText}`);o=await d.json()}catch(d){e.appendChild(t("div",{class:"fatal"},t("h1",null,"Could not load the API description"),t("p",null,`${a}: ${d.message}`),fe()));return}let i=Ye(o),c={spec:i,boot:s,specUrl:a,key:`swc-docs:${new URL(a).pathname}`};st(c),document.title=s.view==="collection"?`${i.title} \xB7 Collection`:`${i.title} \xB7 Documentation`,e.className=`swc ${s.view}`,s.view==="collection"?at(c,e):lt(c,e)}Mt();})();
|
|
Binary file
|
|
Binary file
|