Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bourdakos1 committed Mar 26, 2021
1 parent 4cb6edb commit 95662d9
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
18 changes: 12 additions & 6 deletions docusaurus-plugin-openapi/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ function getPaths(spec: OpenApiObject): ApiItem[] {
let method = key;
let operationObject = val as OperationObject;

const summary = operationObject.summary || operationObject.operationId || "Missing summary";
if (!operationObject.description) {
operationObject.description = operationObject.summary || operationObject.operationId;
const summary =
operationObject.summary ??
operationObject.operationId ??
"Missing summary";
if (operationObject.description === undefined) {
operationObject.description =
operationObject.summary ?? operationObject.operationId ?? "";
}

const baseId = kebabCase(summary);
let count = seen[baseId];

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

const servers = operationObject.servers || pathObject.servers || spec.servers;
const servers =
operationObject.servers || pathObject.servers || spec.servers;

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

if (prev) {
item.previous = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ function Curl() {
const security = useSelector((state) => state.security);
const bearerToken = useSelector((state) => state.bearerToken);

const langs = !!codeSamples ? [languageSet[0], ...codeSamples] : (siteConfig?.themeConfig?.languageTabs || languageSet);
const langs = [
...(siteConfig?.themeConfig?.languageTabs ?? languageSet),
...codeSamples,
];

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

Expand Down
14 changes: 8 additions & 6 deletions docusaurus-plugin-openapi/src/theme/ApiDemoPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ function ApiDemoPanel({ item }) {
<div style={{ marginTop: "3.5em" }}>
<Authorization />

<div
style={{ marginBottom: "var(--ifm-table-cell-padding)" }}
>
<code><b>{item.operationId}</b></code>
</div>

{item.operationId !== undefined && (
<div style={{ marginBottom: "var(--ifm-table-cell-padding)" }}>
<code>
<b>{item.operationId}</b>
</code>
</div>
)}

<MethodEndpoint />

<div className={styles.optionsPanel}>
Expand Down
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = {
[
path.resolve(__dirname, "./docusaurus-plugin-openapi"),
{
openapiPath: require.resolve("./openapi-cos.json"),
openapiPath: require.resolve("./openapi-issue-21.json"),
corsProxy: "https://cors-anywhere.herokuapp.com",
},
],
Expand Down
54 changes: 54 additions & 0 deletions openapi-issue-21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"openapi": "",
"info": {
"title": "",
"version": ""
},
"paths": {
"/health": {
"get": {
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/account/links/{partnerId}": {
"post": {
"description": "This method receives an authorization token. That token will be used to get the user's tokens."
}
},
"/account/pairs/{pairId}/linking-caps": {
"get": {}
},
"/api/aoi/subscriptions": {
"post": {
"description": "This method will create a new AOI subscription"
}
},
"/api/aoi/subscriptions/pair/{pairId}": {
"get": {
"description": "This method will return the AOI subscription based on the user session and the linked account"
},
"delete": {
"description": "This method will delete the current aoi subscription for a given pair"
}
},
"/api/exchange/orders/{transactionId}": {
"get": {}
},
"/api/feedback/contact-us": {
"post": {}
},
"/maintenance/partners/{partnerId}/accounts/{accountId}/history": {
"delete": {}
},
"/partners/accounts/{accountId}/links/{partnerId}/exists": {
"get": {
"description": "Proxy to PAUL's check if link exists"
}
}
},
"components": {}
}

0 comments on commit 95662d9

Please sign in to comment.