@@ -4,3 +4,64 @@ title: "Tutorials: Overview"
44
55Here's where we park our various tutorials!
66
7+ Get the OpenAPI spec.
8+
9+ ``` {ojs}
10+ //| echo: true
11+
12+ // Get the OpenAPI specification and display detailed endpoint information
13+ viewof apiEndpointDetails = {
14+ // Show loading indicator
15+ const loadingElement = html`<div>Loading API endpoints...</div>`;
16+ document.body.appendChild(loadingElement);
17+
18+ try {
19+ const OPENAPI_URL = 'https://central.isample.xyz/isamples_central/openapi.json';
20+
21+ // Fetch the OpenAPI spec
22+ const response = await fetch(OPENAPI_URL);
23+ if (!response.ok) throw new Error(`Failed to fetch API spec: ${response.status}`);
24+
25+ const apiSpec = await response.json();
26+
27+ // Extract detailed information about each endpoint
28+ const endpointDetails = [];
29+
30+ for (const [path, pathMethods] of Object.entries(apiSpec.paths)) {
31+ for (const [method, details] of Object.entries(pathMethods)) {
32+ endpointDetails.push({
33+ endpoint: path,
34+ method: method.toUpperCase(),
35+ summary: details.summary || '',
36+ operationId: details.operationId || '',
37+ tags: (details.tags || []).join(', '),
38+ parameters: (details.parameters || [])
39+ .map(p => `${p.name} (${p.required ? 'required' : 'optional'})`)
40+ .join(', ')
41+ });
42+ }
43+ }
44+
45+ // Create a table with the detailed endpoint information
46+ return Inputs.table(
47+ endpointDetails,
48+ {
49+ label: "iSamples API Endpoints Details",
50+ width: {
51+ endpoint: 150,
52+ method: 80,
53+ summary: 200,
54+ operationId: 200,
55+ tags: 100,
56+ parameters: 300
57+ }
58+ }
59+ );
60+ } catch (error) {
61+ return html`<div style="color: red">Error fetching API endpoints: ${error.message}</div>`;
62+ } finally {
63+ // Remove loading indicator
64+ loadingElement.remove();
65+ }
66+ }
67+ ```
0 commit comments