docusaurus-plugin-openapi-docs 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,9 @@ function isInfoItem(item) {
21
21
  return item.type === "info";
22
22
  }
23
23
  function groupByTags(items, sidebarOptions, options, tags, docPath) {
24
- const { outputDir, label } = options;
24
+ let { outputDir, label } = options;
25
+ // Remove trailing slash before proceeding
26
+ outputDir = outputDir.replace(/\/$/, "");
25
27
  const { sidebarCollapsed, sidebarCollapsible, customProps, categoryLinkSource, } = sidebarOptions;
26
28
  const apiItems = items.filter(isApiItem);
27
29
  const infoItems = items.filter(isInfoItem);
package/lib/types.d.ts CHANGED
@@ -13,6 +13,7 @@ export interface APIOptions {
13
13
  outputDir: string;
14
14
  template?: string;
15
15
  downloadUrl?: string;
16
+ hideSendButton?: boolean;
16
17
  sidebarOptions?: SidebarOptions;
17
18
  version?: string;
18
19
  label?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "1.5.1",
4
+ "version": "1.6.0",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -28,8 +28,8 @@
28
28
  "watch": "tsc --watch"
29
29
  },
30
30
  "devDependencies": {
31
- "@docusaurus/module-type-aliases": "^2.0.1",
32
- "@docusaurus/types": "^2.0.1",
31
+ "@docusaurus/module-type-aliases": ">=2.0.1 <2.3.0",
32
+ "@docusaurus/types": ">=2.0.1 <2.3.0",
33
33
  "@types/fs-extra": "^9.0.13",
34
34
  "@types/js-yaml": "^4.0.5",
35
35
  "@types/json-pointer": "^1.0.31",
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@apidevtools/json-schema-ref-parser": "^9.0.9",
43
- "@docusaurus/mdx-loader": "^2.0.1",
44
- "@docusaurus/plugin-content-docs": "^2.0.1",
45
- "@docusaurus/utils": "^2.0.1",
46
- "@docusaurus/utils-validation": "^2.0.1",
43
+ "@docusaurus/mdx-loader": ">=2.0.1 <2.3.0",
44
+ "@docusaurus/plugin-content-docs": ">=2.0.1 <2.3.0",
45
+ "@docusaurus/utils": ">=2.0.1 <2.3.0",
46
+ "@docusaurus/utils-validation": ">=2.0.1 <2.3.0",
47
47
  "@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
48
48
  "@paloaltonetworks/postman-collection": "^4.1.0",
49
49
  "@redocly/openapi-core": "^1.0.0-beta.103",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=14"
70
70
  },
71
- "gitHead": "11d2c2fdb2bc81048097b05bc65698777d54e456"
71
+ "gitHead": "937e6543af8c1575877a0ebe7c5732e5cffaa37d"
72
72
  }
package/src/index.ts CHANGED
@@ -94,6 +94,9 @@ export default function pluginOpenAPIDocs(
94
94
  let { specPath, outputDir, template, downloadUrl, sidebarOptions } =
95
95
  options;
96
96
 
97
+ // Remove trailing slash before proceeding
98
+ outputDir = outputDir.replace(/\/$/, "");
99
+
97
100
  // Override docPath if pluginId provided
98
101
  if (pluginId) {
99
102
  docData = getDocsPluginConfig(presetsPlugins, pluginId);
@@ -187,6 +190,9 @@ custom_edit_url: null
187
190
  {{#frontMatter.proxy}}
188
191
  proxy: {{{frontMatter.proxy}}}
189
192
  {{/frontMatter.proxy}}
193
+ {{#frontMatter.hide_send_button}}
194
+ hide_send_button: true
195
+ {{/frontMatter.hide_send_button}}
190
196
  ---
191
197
 
192
198
  {{{markdown}}}
@@ -0,0 +1,35 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import { create } from "./utils";
9
+
10
+ export function createOpeningArrayBracket() {
11
+ return create("li", {
12
+ children: create("div", {
13
+ style: {
14
+ fontSize: "var(--ifm-code-font-size)",
15
+ opacity: "0.6",
16
+ marginLeft: "-.5rem",
17
+ paddingBottom: ".5rem",
18
+ },
19
+ children: ["Array ["],
20
+ }),
21
+ });
22
+ }
23
+
24
+ export function createClosingArrayBracket() {
25
+ return create("li", {
26
+ children: create("div", {
27
+ style: {
28
+ fontSize: "var(--ifm-code-font-size)",
29
+ opacity: "0.6",
30
+ marginLeft: "-.5rem",
31
+ },
32
+ children: ["]"],
33
+ }),
34
+ });
35
+ }
@@ -13,7 +13,8 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
13
13
  if (!securitySchemes || !Object.keys(securitySchemes).length) return "";
14
14
 
15
15
  const createAuthenticationTable = (securityScheme: any) => {
16
- const { bearerFormat, flows, name, scheme, type } = securityScheme;
16
+ const { bearerFormat, flows, name, scheme, type, openIdConnectUrl } =
17
+ securityScheme;
17
18
 
18
19
  const createSecuritySchemeTypeRow = () =>
19
20
  create("tr", {
@@ -30,7 +31,7 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
30
31
 
31
32
  return create("tr", {
32
33
  children: [
33
- create("th", { children: `${flowType} OAuth Flow:` }),
34
+ create("th", { children: `OAuth Flow (${flowType}):` }),
34
35
  create("td", {
35
36
  children: [
36
37
  guard(tokenUrl, () =>
@@ -91,12 +92,14 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
91
92
  create("td", { children: scheme }),
92
93
  ],
93
94
  }),
94
- create("tr", {
95
- children: [
96
- create("th", { children: "Bearer format:" }),
97
- create("td", { children: bearerFormat }),
98
- ],
99
- }),
95
+ guard(bearerFormat, () =>
96
+ create("tr", {
97
+ children: [
98
+ create("th", { children: "Bearer format:" }),
99
+ create("td", { children: bearerFormat }),
100
+ ],
101
+ })
102
+ ),
100
103
  ],
101
104
  }),
102
105
  }),
@@ -115,23 +118,51 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
115
118
  }),
116
119
  ],
117
120
  });
121
+ case "openIdConnect":
122
+ return create("div", {
123
+ children: [
124
+ create("table", {
125
+ children: create("tbody", {
126
+ children: [
127
+ createSecuritySchemeTypeRow(),
128
+ guard(openIdConnectUrl, () =>
129
+ create("tr", {
130
+ children: [
131
+ create("th", { children: "OpenID Connect URL:" }),
132
+ create("td", { children: openIdConnectUrl }),
133
+ ],
134
+ })
135
+ ),
136
+ ],
137
+ }),
138
+ }),
139
+ ],
140
+ });
118
141
  default:
119
142
  return "";
120
143
  }
121
144
  };
122
145
 
123
- const formatTabLabel = (str: string) => {
124
- const formattedLabel = str
146
+ const formatTabLabel = (key: string, type: string, scheme: string) => {
147
+ const formattedLabel = key
125
148
  .replace(/(_|-)/g, " ")
126
149
  .trim()
127
150
  .replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
128
151
  .replace(/([a-z])([A-Z])/g, "$1 $2")
129
152
  .replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
153
+ const isOAuth = type === "oauth2";
154
+ const isApiKey = type === "apiKey";
155
+ const isHttpBasic = type === "http" && scheme === "basic";
156
+ const isHttpBearer = type === "http" && scheme === "bearer";
157
+ const isOpenId = type === "openIdConnect";
130
158
 
131
- const isOAuth = formattedLabel.toLowerCase().includes("oauth2");
132
- const isApiKey = formattedLabel.toLowerCase().includes("api");
159
+ if (isOAuth) return `OAuth 2.0: ${key}`;
160
+ if (isApiKey) return `API Key: ${key}`;
161
+ if (isHttpBasic) return "HTTP: Basic Auth";
162
+ if (isHttpBearer) return "HTTP: Bearer Auth";
163
+ if (isOpenId) return `OpenID Connect: ${key}`;
133
164
 
134
- return isOAuth ? "OAuth 2.0" : isApiKey ? "API Key" : formattedLabel;
165
+ return formattedLabel;
135
166
  };
136
167
 
137
168
  return create("div", {
@@ -141,12 +172,17 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
141
172
  id: "authentication",
142
173
  style: { marginBottom: "1rem" },
143
174
  }),
144
- create("Tabs", {
175
+ create("SchemaTabs", {
176
+ className: "openapi-tabs__security-schemes",
145
177
  children: Object.entries(securitySchemes).map(
146
- ([schemeType, schemeObj]) =>
178
+ ([schemeKey, schemeObj]) =>
147
179
  create("TabItem", {
148
- label: formatTabLabel(schemeType),
149
- value: `${schemeType}`,
180
+ label: formatTabLabel(
181
+ schemeKey,
182
+ schemeObj.type,
183
+ schemeObj.scheme
184
+ ),
185
+ value: `${schemeKey}`,
150
186
  children: [
151
187
  createDescription(schemeObj.description),
152
188
  createAuthenticationTable(schemeObj),