Skip to content

Commit 86f886e

Browse files
committed
feat: Implement website
1 parent 9d61e67 commit 86f886e

File tree

2 files changed

+212
-5
lines changed

2 files changed

+212
-5
lines changed

website/src/main.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
2-
<div>
3-
hello world
4-
</div>
5-
`;
1+
import { createApiReference } from "@scalar/api-reference";
2+
import "@scalar/api-reference/style.css";
3+
import openapi from "./openapi.json";
4+
5+
createApiReference("#app", {
6+
content: openapi,
7+
agent: {
8+
disabled: true,
9+
},
10+
showDeveloperTools: "never",
11+
hideClientButton: true,
12+
hideTestRequestButton: true,
13+
});

website/src/openapi.json

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
{
2+
"openapi": "3.1.0",
3+
"info": {
4+
"title": "Codize Sandbox API",
5+
"description": "Execute code in a sandboxed environment.",
6+
"version": "1.0.0"
7+
},
8+
"servers": [{ "url": "https://codize.dev" }],
9+
"components": {
10+
"securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } }
11+
},
12+
"paths": {
13+
"/api/v1/sandbox": {
14+
"post": {
15+
"operationId": "postApiV1Sandbox",
16+
"summary": "Execute code in sandbox",
17+
"description": "Execute code files in a secure sandboxed environment.",
18+
"tags": ["Sandbox"],
19+
"security": [{ "bearerAuth": [] }],
20+
"requestBody": {
21+
"required": true,
22+
"content": { "application/json": { "schema": { "vendor": "zod" } } }
23+
},
24+
"responses": {
25+
"200": {
26+
"description": "Successful execution result",
27+
"content": {
28+
"application/json": {
29+
"schema": {
30+
"type": "object",
31+
"properties": {
32+
"compile": {
33+
"anyOf": [
34+
{
35+
"type": "object",
36+
"properties": {
37+
"stdout": { "type": "string" },
38+
"stderr": { "type": "string" },
39+
"output": { "type": "string" },
40+
"exit_code": {
41+
"anyOf": [
42+
{ "type": "number" },
43+
{ "type": "null" }
44+
]
45+
}
46+
},
47+
"required": [
48+
"stdout",
49+
"stderr",
50+
"output",
51+
"exit_code"
52+
]
53+
},
54+
{ "type": "null" }
55+
]
56+
},
57+
"run": {
58+
"type": "object",
59+
"properties": {
60+
"stdout": { "type": "string" },
61+
"stderr": { "type": "string" },
62+
"output": { "type": "string" },
63+
"exit_code": {
64+
"anyOf": [{ "type": "number" }, { "type": "null" }]
65+
}
66+
},
67+
"required": ["stdout", "stderr", "output", "exit_code"]
68+
}
69+
},
70+
"required": ["compile", "run"]
71+
}
72+
}
73+
}
74+
},
75+
"401": {
76+
"description": "Missing or invalid API key",
77+
"content": {
78+
"application/json": {
79+
"schema": {
80+
"type": "object",
81+
"properties": {
82+
"error": {
83+
"type": "object",
84+
"properties": {
85+
"code": {
86+
"type": "string",
87+
"enum": [
88+
"UNAUTHORIZED",
89+
"INTERNAL_ERROR",
90+
"RATE_LIMITED",
91+
"NOT_FOUND",
92+
"VALIDATION_ERROR"
93+
]
94+
},
95+
"message": { "type": "string" }
96+
},
97+
"required": ["code", "message"]
98+
}
99+
},
100+
"required": ["error"]
101+
}
102+
}
103+
}
104+
},
105+
"422": {
106+
"description": "Request body validation failed",
107+
"content": {
108+
"application/json": {
109+
"schema": {
110+
"type": "object",
111+
"properties": {
112+
"error": {
113+
"type": "object",
114+
"properties": {
115+
"code": {
116+
"type": "string",
117+
"enum": [
118+
"UNAUTHORIZED",
119+
"INTERNAL_ERROR",
120+
"RATE_LIMITED",
121+
"NOT_FOUND",
122+
"VALIDATION_ERROR"
123+
]
124+
},
125+
"message": { "type": "string" }
126+
},
127+
"required": ["code", "message"]
128+
}
129+
},
130+
"required": ["error"]
131+
}
132+
}
133+
}
134+
},
135+
"429": {
136+
"description": "Rate limit exceeded",
137+
"content": {
138+
"application/json": {
139+
"schema": {
140+
"type": "object",
141+
"properties": {
142+
"error": {
143+
"type": "object",
144+
"properties": {
145+
"code": {
146+
"type": "string",
147+
"enum": [
148+
"UNAUTHORIZED",
149+
"INTERNAL_ERROR",
150+
"RATE_LIMITED",
151+
"NOT_FOUND",
152+
"VALIDATION_ERROR"
153+
]
154+
},
155+
"message": { "type": "string" }
156+
},
157+
"required": ["code", "message"]
158+
}
159+
},
160+
"required": ["error"]
161+
}
162+
}
163+
}
164+
},
165+
"500": {
166+
"description": "Internal server error",
167+
"content": {
168+
"application/json": {
169+
"schema": {
170+
"type": "object",
171+
"properties": {
172+
"error": {
173+
"type": "object",
174+
"properties": {
175+
"code": {
176+
"type": "string",
177+
"enum": [
178+
"UNAUTHORIZED",
179+
"INTERNAL_ERROR",
180+
"RATE_LIMITED",
181+
"NOT_FOUND",
182+
"VALIDATION_ERROR"
183+
]
184+
},
185+
"message": { "type": "string" }
186+
},
187+
"required": ["code", "message"]
188+
}
189+
},
190+
"required": ["error"]
191+
}
192+
}
193+
}
194+
}
195+
}
196+
}
197+
}
198+
}
199+
}

0 commit comments

Comments
 (0)