docusaurus-theme-openapi-docs 1.1.9 → 1.1.12

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.
Files changed (37) hide show
  1. package/lib/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
  2. package/lib/theme/ApiDemoPanel/Curl/index.js +80 -22
  3. package/lib/theme/ApiDemoPanel/Curl/languages.json +1386 -0
  4. package/lib/theme/ApiDemoPanel/FormTextInput/index.js +4 -1
  5. package/lib/theme/ApiItem/Layout/styles.module.css +118 -20
  6. package/lib/theme/SchemaTabs/index.js +2 -2
  7. package/lib/theme/SchemaTabs/styles.module.css +3 -0
  8. package/lib-next/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
  9. package/lib-next/theme/ApiDemoPanel/Curl/index.js +85 -17
  10. package/lib-next/theme/ApiDemoPanel/Curl/languages.json +1386 -0
  11. package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +2 -0
  12. package/lib-next/theme/ApiItem/Layout/styles.module.css +118 -20
  13. package/lib-next/theme/SchemaTabs/index.js +2 -2
  14. package/lib-next/theme/SchemaTabs/styles.module.css +3 -0
  15. package/package.json +5 -5
  16. package/src/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
  17. package/src/theme/ApiDemoPanel/Curl/index.tsx +89 -22
  18. package/src/theme/ApiDemoPanel/Curl/languages.json +1386 -0
  19. package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +2 -0
  20. package/src/theme/ApiItem/Layout/styles.module.css +118 -20
  21. package/src/theme/SchemaTabs/index.js +2 -2
  22. package/src/theme/SchemaTabs/styles.module.css +3 -0
  23. package/lib/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
  24. package/lib/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
  25. package/lib/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
  26. package/lib/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
  27. package/lib/theme/ApiItem/Layout/icons/python-original.svg +0 -1
  28. package/lib-next/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
  29. package/lib-next/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
  30. package/lib-next/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
  31. package/lib-next/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
  32. package/lib-next/theme/ApiItem/Layout/icons/python-original.svg +0 -1
  33. package/src/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
  34. package/src/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
  35. package/src/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
  36. package/src/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
  37. package/src/theme/ApiItem/Layout/icons/python-original.svg +0 -1
@@ -8,11 +8,13 @@ import React from "react";
8
8
  import styles from "./styles.module.css";
9
9
 
10
10
  function FormTextInput({ value, placeholder, password, onChange }) {
11
+ placeholder = placeholder?.split("\n")[0];
11
12
  return (
12
13
  <input
13
14
  className={styles.input}
14
15
  type={password ? "password" : "text"}
15
16
  placeholder={placeholder}
17
+ title={placeholder}
16
18
  value={value}
17
19
  onChange={onChange}
18
20
  autoComplete="off"
@@ -161,18 +161,20 @@
161
161
  padding-left: 2px;
162
162
  }
163
163
 
164
+ /* CodeTabs */
165
+
164
166
  :global(.code__tab--python::after) {
165
167
  content: "";
166
- width: 32px;
167
- height: 32px;
168
- background: url(./icons/python-original.svg);
168
+ width: 28px;
169
+ height: 28px;
170
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-original.svg");
169
171
  margin-block: auto;
170
172
  }
171
173
 
172
174
  :global(.code__tab--python) {
173
175
  color: var(--ifm-color-success);
174
- padding-left: 2rem;
175
- padding-right: 2rem;
176
+ padding-left: 1.4rem;
177
+ padding-right: 1.4rem;
176
178
  }
177
179
 
178
180
  :global(.code__tab--python.tabs__item--active) {
@@ -187,16 +189,16 @@
187
189
 
188
190
  :global(.code__tab--go::after) {
189
191
  content: "";
190
- width: 32px;
191
- height: 32px;
192
- background: url(./icons/go-original-wordmark.svg);
192
+ width: 28px;
193
+ height: 28px;
194
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/go/go-original-wordmark.svg");
193
195
  margin-block: auto;
194
196
  }
195
197
 
196
198
  :global(.code__tab--go) {
197
199
  color: var(--ifm-color-info);
198
- padding-left: 2rem;
199
- padding-right: 2rem;
200
+ padding-left: 1.4rem;
201
+ padding-right: 1.4rem;
200
202
  }
201
203
 
202
204
  :global(.code__tab--go.tabs__item--active) {
@@ -211,16 +213,16 @@
211
213
 
212
214
  :global(.code__tab--javascript::after) {
213
215
  content: "";
214
- width: 32px;
215
- height: 32px;
216
- background: url(./icons/javascript-original.svg);
216
+ width: 28px;
217
+ height: 28px;
218
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg");
217
219
  margin-block: auto;
218
220
  }
219
221
 
220
222
  :global(.code__tab--javascript) {
221
223
  color: var(--ifm-color-warning);
222
- padding-left: 2rem;
223
- padding-right: 2rem;
224
+ padding-left: 1.4rem;
225
+ padding-right: 1.4rem;
224
226
  }
225
227
 
226
228
  :global(.code__tab--javascript.tabs__item--active) {
@@ -235,16 +237,16 @@
235
237
 
236
238
  :global(.code__tab--bash::after) {
237
239
  content: "";
238
- width: 32px;
239
- height: 32px;
240
- background: url(./icons/linux-original.svg);
240
+ width: 28px;
241
+ height: 28px;
242
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/linux/linux-original.svg");
241
243
  margin-block: auto;
242
244
  }
243
245
 
244
246
  :global(.code__tab--bash) {
245
247
  color: var(--ifm-color-danger);
246
- padding-left: 2rem;
247
- padding-right: 2rem;
248
+ padding-left: 1.4rem;
249
+ padding-right: 1.4rem;
248
250
  }
249
251
 
250
252
  :global(.code__tab--bash.tabs__item--active) {
@@ -256,3 +258,99 @@
256
258
  max-height: 500px;
257
259
  overflow: auto;
258
260
  }
261
+
262
+ :global(.code__tab--ruby::after) {
263
+ content: "";
264
+ width: 28px;
265
+ height: 28px;
266
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/ruby/ruby-plain.svg");
267
+ margin-block: auto;
268
+ }
269
+
270
+ :global(.code__tab--ruby) {
271
+ color: var(--ifm-color-danger);
272
+ padding-left: 1.4rem;
273
+ padding-right: 1.4rem;
274
+ }
275
+
276
+ :global(.code__tab--ruby.tabs__item--active) {
277
+ border-bottom-color: var(--ifm-color-danger);
278
+ background-color: var(--ifm-color-emphasis-100);
279
+ }
280
+
281
+ :global(.language-ruby) {
282
+ max-height: 500px;
283
+ overflow: auto;
284
+ }
285
+
286
+ :global(.code__tab--csharp::after) {
287
+ content: "";
288
+ width: 28px;
289
+ height: 28px;
290
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/csharp/csharp-original.svg");
291
+ margin-block: auto;
292
+ }
293
+
294
+ :global(.code__tab--csharp) {
295
+ color: var(--ifm-color-gray-500);
296
+ padding-left: 1.4rem;
297
+ padding-right: 1.4rem;
298
+ }
299
+
300
+ :global(.code__tab--csharp.tabs__item--active) {
301
+ border-bottom-color: var(--ifm-color-gray-500);
302
+ background-color: var(--ifm-color-emphasis-100);
303
+ }
304
+
305
+ :global(.language-csharp) {
306
+ max-height: 500px;
307
+ overflow: auto;
308
+ }
309
+
310
+ :global(.code__tab--nodejs::after) {
311
+ content: "";
312
+ width: 28px;
313
+ height: 28px;
314
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg");
315
+ margin-block: auto;
316
+ }
317
+
318
+ :global(.code__tab--nodejs) {
319
+ color: var(--ifm-color-success);
320
+ padding-left: 1.4rem;
321
+ padding-right: 1.4rem;
322
+ }
323
+
324
+ :global(.code__tab--nodejs.tabs__item--active) {
325
+ border-bottom-color: var(--ifm-color-success);
326
+ background-color: var(--ifm-color-emphasis-100);
327
+ }
328
+
329
+ :global(.language-nodejs) {
330
+ max-height: 500px;
331
+ overflow: auto;
332
+ }
333
+
334
+ :global(.code__tab--php::after) {
335
+ content: "";
336
+ width: 28px;
337
+ height: 28px;
338
+ background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/php/php-original.svg");
339
+ margin-block: auto;
340
+ }
341
+
342
+ :global(.code__tab--php) {
343
+ color: var(--ifm-color-gray-500);
344
+ padding-left: 1.4rem;
345
+ padding-right: 1.4rem;
346
+ }
347
+
348
+ :global(.code__tab--php.tabs__item--active) {
349
+ border-bottom-color: var(--ifm-color-gray-500);
350
+ background-color: var(--ifm-color-emphasis-100);
351
+ }
352
+
353
+ :global(.language-php) {
354
+ max-height: 500px;
355
+ overflow: auto;
356
+ }
@@ -229,11 +229,11 @@ function SchemaTabsComponent(props) {
229
229
  (tabItem) => tabItem.props.value === selectedValue
230
230
  )[0],
231
231
  {
232
- className: clsx("margin-vert--md", styles.schemaTabsContainer),
232
+ className: "margin-vert--md",
233
233
  }
234
234
  )
235
235
  ) : (
236
- <div className={clsx("margin-vert--md", styles.schemaTabsContainer)}>
236
+ <div className="margin-vert--md">
237
237
  {children.map((tabItem, i) =>
238
238
  cloneElement(tabItem, {
239
239
  key: i,
@@ -59,7 +59,10 @@
59
59
  }
60
60
 
61
61
  .schemaTabsContainer {
62
+ display: flex;
63
+ align-items: center;
62
64
  max-width: 600px;
65
+ overflow: hidden;
63
66
  }
64
67
 
65
68
  /* Tab Arrows */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "1.1.9",
4
+ "version": "1.1.12",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -42,15 +42,15 @@
42
42
  "concurrently": "^5.2.0"
43
43
  },
44
44
  "dependencies": {
45
- "@docusaurus/theme-common": "2.0.1",
45
+ "@docusaurus/theme-common": "^2.0.1",
46
46
  "@mdx-js/react": "^1.6.21",
47
- "@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
47
+ "@paloaltonetworks/postman-code-generators": "^1.1.9",
48
48
  "@paloaltonetworks/postman-collection": "^4.1.0",
49
49
  "@reduxjs/toolkit": "^1.7.1",
50
50
  "buffer": "^6.0.3",
51
51
  "clsx": "^1.1.1",
52
52
  "crypto-js": "^4.1.1",
53
- "docusaurus-plugin-openapi-docs": "^1.1.9",
53
+ "docusaurus-plugin-openapi-docs": "^1.1.12",
54
54
  "immer": "^9.0.7",
55
55
  "lodash": "^4.17.20",
56
56
  "process": "^0.11.10",
@@ -69,5 +69,5 @@
69
69
  "engines": {
70
70
  "node": ">=14"
71
71
  },
72
- "gitHead": "c9153730f9f180dbd199fbc9cb66f8470339c877"
72
+ "gitHead": "a45dcbd12f26156147a50f5f61026c3adee4b1c8"
73
73
  }
@@ -7,5 +7,11 @@
7
7
  }
8
8
 
9
9
  .code__tabs {
10
- justify-content: space-around;
10
+ display: table-row-group;
11
+ }
12
+
13
+ @media only screen and (min-width: 768px) and (max-width: 996px) {
14
+ .code__tabs {
15
+ justify-content: space-around;
16
+ }
11
17
  }
@@ -19,61 +19,86 @@ import buildPostmanRequest from "./../buildPostmanRequest";
19
19
  import styles from "./styles.module.css";
20
20
 
21
21
  interface Language {
22
- tabName: string;
23
- highlight: string;
22
+ highlight?: string;
24
23
  language: string;
25
- codeLanguage?: string;
26
- variant: string;
27
- options: { [key: string]: boolean };
24
+ logoClass?: string;
25
+ variant?: string;
26
+ options?: { [key: string]: boolean };
28
27
  source?: string;
29
28
  }
30
29
 
31
30
  export const languageSet: Language[] = [
32
31
  {
33
- tabName: "cURL",
34
32
  highlight: "bash",
35
33
  language: "curl",
36
- codeLanguage: "bash",
37
- variant: "curl",
34
+ logoClass: "bash",
38
35
  options: {
39
36
  longFormat: false,
40
37
  followRedirect: true,
41
38
  trimRequestBody: true,
42
39
  },
40
+ variant: "cURL",
43
41
  },
44
42
  {
45
- tabName: "Python",
46
43
  highlight: "python",
47
44
  language: "python",
48
- codeLanguage: "python",
49
- variant: "requests",
45
+ logoClass: "python",
50
46
  options: {
51
47
  followRedirect: true,
52
48
  trimRequestBody: true,
53
49
  },
50
+ variant: "requests",
54
51
  },
55
52
  {
56
- tabName: "Go",
57
53
  highlight: "go",
58
54
  language: "go",
59
- codeLanguage: "go",
60
- variant: "native",
55
+ logoClass: "go",
61
56
  options: {
62
57
  followRedirect: true,
63
58
  trimRequestBody: true,
64
59
  },
60
+ variant: "native",
65
61
  },
66
62
  {
67
- tabName: "Node",
68
63
  highlight: "javascript",
69
64
  language: "nodejs",
70
- codeLanguage: "javascript",
71
- variant: "axios",
65
+ logoClass: "nodejs",
72
66
  options: {
73
67
  ES6_enabled: true,
74
68
  followRedirect: true,
75
69
  trimRequestBody: true,
76
70
  },
71
+ variant: "axios",
72
+ },
73
+ {
74
+ highlight: "ruby",
75
+ language: "ruby",
76
+ logoClass: "ruby",
77
+ options: {
78
+ followRedirect: true,
79
+ trimRequestBody: true,
80
+ },
81
+ variant: "Net::HTTP",
82
+ },
83
+ {
84
+ highlight: "csharp",
85
+ language: "csharp",
86
+ logoClass: "csharp",
87
+ options: {
88
+ followRedirect: true,
89
+ trimRequestBody: true,
90
+ },
91
+ variant: "RestSharp",
92
+ },
93
+ {
94
+ highlight: "php",
95
+ language: "php",
96
+ logoClass: "php",
97
+ options: {
98
+ followRedirect: true,
99
+ trimRequestBody: true,
100
+ },
101
+ variant: "cURL",
77
102
  },
78
103
  ];
79
104
 
@@ -120,10 +145,15 @@ function Curl({ postman, codeSamples }: Props) {
120
145
 
121
146
  const defaultLang: Language[] = languageSet.filter(
122
147
  (lang) =>
123
- lang.codeLanguage === localStorage.getItem("docusaurus.tab.code-samples")
148
+ lang.language === localStorage.getItem("docusaurus.tab.code-samples")
124
149
  );
125
150
 
126
- const [language, setLanguage] = useState(defaultLang[0] ?? langs[0]);
151
+ const [language, setLanguage] = useState(() => {
152
+ if (langs.length === 1) {
153
+ return langs[0];
154
+ }
155
+ return defaultLang[0] ?? langs[0];
156
+ });
127
157
 
128
158
  const [codeText, setCodeText] = useState("");
129
159
 
@@ -155,6 +185,39 @@ function Curl({ postman, codeSamples }: Props) {
155
185
  );
156
186
  } else if (language && !!language.source) {
157
187
  setCodeText(language.source);
188
+ } else if (language && !language.options) {
189
+ const langSource = languageSet.filter(
190
+ (lang) => lang.language === language.language
191
+ );
192
+
193
+ // Merges user-defined language with default languageSet
194
+ // This allows users to define only the minimal properties necessary in languageTabs
195
+ // User-defined properties should override languageSet properties
196
+ const mergedLanguage = { ...langSource[0], ...language };
197
+ const postmanRequest = buildPostmanRequest(postman, {
198
+ queryParams,
199
+ pathParams,
200
+ cookieParams,
201
+ contentType,
202
+ accept,
203
+ headerParams,
204
+ body,
205
+ server,
206
+ auth,
207
+ });
208
+
209
+ codegen.convert(
210
+ mergedLanguage.language,
211
+ mergedLanguage.variant,
212
+ postmanRequest,
213
+ mergedLanguage.options,
214
+ (error: any, snippet: string) => {
215
+ if (error) {
216
+ return;
217
+ }
218
+ setCodeText(snippet);
219
+ }
220
+ );
158
221
  } else {
159
222
  setCodeText("");
160
223
  }
@@ -184,10 +247,14 @@ function Curl({ postman, codeSamples }: Props) {
184
247
  <CodeTab
185
248
  value={lang.language}
186
249
  label={""}
187
- key={lang.tabName || lang.label}
188
- attributes={{ className: `code__tab--${lang.codeLanguage}` }}
250
+ key={
251
+ lang.variant
252
+ ? `${lang.language}-${lang.variant}`
253
+ : lang.language
254
+ }
255
+ attributes={{ className: `code__tab--${lang.logoClass}` }}
189
256
  >
190
- <CodeBlock language={lang.codeLanguage}>{codeText}</CodeBlock>
257
+ <CodeBlock language={lang.highlight}>{codeText}</CodeBlock>
191
258
  </CodeTab>
192
259
  );
193
260
  })}