Skip to content

Commit 95662d9

Browse files
committed
bug fixes
1 parent 4cb6edb commit 95662d9

File tree

5 files changed

+79
-14
lines changed

5 files changed

+79
-14
lines changed

docusaurus-plugin-openapi/src/openapi.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ function getPaths(spec: OpenApiObject): ApiItem[] {
4141
let method = key;
4242
let operationObject = val as OperationObject;
4343

44-
const summary = operationObject.summary || operationObject.operationId || "Missing summary";
45-
if (!operationObject.description) {
46-
operationObject.description = operationObject.summary || operationObject.operationId;
44+
const summary =
45+
operationObject.summary ??
46+
operationObject.operationId ??
47+
"Missing summary";
48+
if (operationObject.description === undefined) {
49+
operationObject.description =
50+
operationObject.summary ?? operationObject.operationId ?? "";
4751
}
48-
52+
4953
const baseId = kebabCase(summary);
5054
let count = seen[baseId];
5155

@@ -58,7 +62,8 @@ function getPaths(spec: OpenApiObject): ApiItem[] {
5862
seen[baseId] = 1;
5963
}
6064

61-
const servers = operationObject.servers || pathObject.servers || spec.servers;
65+
const servers =
66+
operationObject.servers || pathObject.servers || spec.servers;
6267

6368
// NOTE: no security on the path level, only op level.
6469
// The following line is unneeded, but is just for piece of mind.
@@ -229,7 +234,8 @@ export async function loadOpenapi(
229234
const prev =
230235
order[i].items[ii - 1] ||
231236
order[i - 1]?.items[order[i - 1].items.length - 1];
232-
const next = order[i].items[ii + 1] || (order[i+1] ? order[i + 1].items[0] : null);
237+
const next =
238+
order[i].items[ii + 1] || (order[i + 1] ? order[i + 1].items[0] : null);
233239

234240
if (prev) {
235241
item.previous = {

docusaurus-plugin-openapi/src/theme/ApiDemoPanel/Curl/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ function Curl() {
124124
const security = useSelector((state) => state.security);
125125
const bearerToken = useSelector((state) => state.bearerToken);
126126

127-
const langs = !!codeSamples ? [languageSet[0], ...codeSamples] : (siteConfig?.themeConfig?.languageTabs || languageSet);
127+
const langs = [
128+
...(siteConfig?.themeConfig?.languageTabs ?? languageSet),
129+
...codeSamples,
130+
];
128131

129132
const [language, setLanguage] = useState(langs[0]);
130133

docusaurus-plugin-openapi/src/theme/ApiDemoPanel/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ function ApiDemoPanel({ item }) {
3131
<div style={{ marginTop: "3.5em" }}>
3232
<Authorization />
3333

34-
<div
35-
style={{ marginBottom: "var(--ifm-table-cell-padding)" }}
36-
>
37-
<code><b>{item.operationId}</b></code>
38-
</div>
39-
34+
{item.operationId !== undefined && (
35+
<div style={{ marginBottom: "var(--ifm-table-cell-padding)" }}>
36+
<code>
37+
<b>{item.operationId}</b>
38+
</code>
39+
</div>
40+
)}
41+
4042
<MethodEndpoint />
4143

4244
<div className={styles.optionsPanel}>

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module.exports = {
9797
[
9898
path.resolve(__dirname, "./docusaurus-plugin-openapi"),
9999
{
100-
openapiPath: require.resolve("./openapi-cos.json"),
100+
openapiPath: require.resolve("./openapi-issue-21.json"),
101101
corsProxy: "https://cors-anywhere.herokuapp.com",
102102
},
103103
],

openapi-issue-21.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"openapi": "",
3+
"info": {
4+
"title": "",
5+
"version": ""
6+
},
7+
"paths": {
8+
"/health": {
9+
"get": {
10+
"responses": {
11+
"200": {
12+
"description": "OK"
13+
}
14+
}
15+
}
16+
},
17+
"/api/account/links/{partnerId}": {
18+
"post": {
19+
"description": "This method receives an authorization token. That token will be used to get the user's tokens."
20+
}
21+
},
22+
"/account/pairs/{pairId}/linking-caps": {
23+
"get": {}
24+
},
25+
"/api/aoi/subscriptions": {
26+
"post": {
27+
"description": "This method will create a new AOI subscription"
28+
}
29+
},
30+
"/api/aoi/subscriptions/pair/{pairId}": {
31+
"get": {
32+
"description": "This method will return the AOI subscription based on the user session and the linked account"
33+
},
34+
"delete": {
35+
"description": "This method will delete the current aoi subscription for a given pair"
36+
}
37+
},
38+
"/api/exchange/orders/{transactionId}": {
39+
"get": {}
40+
},
41+
"/api/feedback/contact-us": {
42+
"post": {}
43+
},
44+
"/maintenance/partners/{partnerId}/accounts/{accountId}/history": {
45+
"delete": {}
46+
},
47+
"/partners/accounts/{accountId}/links/{partnerId}/exists": {
48+
"get": {
49+
"description": "Proxy to PAUL's check if link exists"
50+
}
51+
}
52+
},
53+
"components": {}
54+
}

0 commit comments

Comments
 (0)