Skip to content

Commit 2ce0b85

Browse files
author
Alban Bailly
committed
loop responses
1 parent deb2cdd commit 2ce0b85

File tree

1 file changed

+72
-7
lines changed
  • src/components/5_templates

1 file changed

+72
-7
lines changed

src/components/5_templates/api.js

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,61 @@ import SEO from "../../components/0_utlilities/seo";
66
import Sidebar from "../../components/2_molecules/sidemenu";
77

88
const apiPage = ({ data }) => {
9-
// const node = pageContext.name;
109
const n = data.allPaths.edges[0].node;
11-
// console.log(n);
10+
const modes = {
11+
get: "get",
12+
post: "post",
13+
put: "put"
14+
};
15+
const responses = {
16+
_200: "_200",
17+
_204: "_204",
18+
default: "default"
19+
};
1220
return (
1321
<Layout title="API Documentation" subtitle="Linode API Documentation">
1422
<SEO title="API Documentation" description="" />
1523
<div className="flex flex-wrap">
16-
<div className="w-full md:w-1/4 mt-8">
24+
<div className="w-full md:w-1/4">
1725
<Sidebar />
1826
</div>
1927
<div className="w-full md:w-3/4 pl-8">
2028
<h1>
21-
{n.name}
22-
{/* {(n.get && n.get.tags) ||
23-
(n.post && n.post.tags) ||
24-
(n.put && n.put.tags)} */}
29+
{(n.get && n.get.tags) ||
30+
(n.post && n.get.post) ||
31+
(n.put && n.put.tags)}
2532
</h1>
33+
{Object.keys(n).map(e => {
34+
const mode = modes[e];
35+
const m = n[mode];
36+
// console.log(m);
37+
return (
38+
m && (
39+
<div key={e} className="mb-8">
40+
<h2 id={mode}>{m.summary}</h2>
41+
<p>
42+
<b>{mode}</b>&nbsp;&nbsp; https://api.linode.com/v4{m.name}
43+
</p>
44+
<p>{m.description}</p>
45+
{Object.keys(m.responses).map((e, i) => {
46+
const response = responses[e];
47+
const r = m.responses[response];
48+
console.log(r);
49+
return (
50+
r && (
51+
<div key={i}>
52+
<p>
53+
<b>{response.replace(/[_]/g, " ")}</b>:&nbsp;
54+
{r.description}
55+
</p>
56+
</div>
57+
)
58+
);
59+
})}
60+
</div>
61+
)
62+
);
63+
})}
2664
</div>
2765
</div>
2866
</Layout>
@@ -50,6 +88,17 @@ export const query = graphql`
5088
x_linode_redoc_load_ids
5189
x_linode_cli_command
5290
tags
91+
responses {
92+
_200 {
93+
description
94+
}
95+
_204 {
96+
description
97+
}
98+
default {
99+
description
100+
}
101+
}
53102
}
54103
post {
55104
x_linode_grant
@@ -60,6 +109,14 @@ export const query = graphql`
60109
x_linode_cli_command
61110
x_linode_charge
62111
x_linode_cli_skip
112+
responses {
113+
_200 {
114+
description
115+
}
116+
default {
117+
description
118+
}
119+
}
63120
}
64121
put {
65122
x_linode_grant
@@ -68,6 +125,14 @@ export const query = graphql`
68125
operationId
69126
x_linode_cli_action
70127
x_linode_cli_skip
128+
responses {
129+
_200 {
130+
description
131+
}
132+
default {
133+
description
134+
}
135+
}
71136
}
72137
}
73138
}

0 commit comments

Comments
 (0)