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
@@ -23,7 +23,10 @@ function FormTextInput({
23
23
  password,
24
24
  onChange
25
25
  }) {
26
- return <input className={_stylesModule.default.input} type={password ? "password" : "text"} placeholder={placeholder} value={value} onChange={onChange} autoComplete="off" />;
26
+ var _placeholder;
27
+
28
+ placeholder = (_placeholder = placeholder) === null || _placeholder === void 0 ? void 0 : _placeholder.split("\n")[0];
29
+ return <input className={_stylesModule.default.input} type={password ? "password" : "text"} placeholder={placeholder} title={placeholder} value={value} onChange={onChange} autoComplete="off" />;
27
30
  }
28
31
 
29
32
  var _default = FormTextInput;
@@ -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 */
@@ -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
  }
@@ -15,50 +15,76 @@ import buildPostmanRequest from "./../buildPostmanRequest";
15
15
  import styles from "./styles.module.css";
16
16
  export const languageSet = [
17
17
  {
18
- tabName: "cURL",
19
18
  highlight: "bash",
20
19
  language: "curl",
21
- codeLanguage: "bash",
22
- variant: "curl",
20
+ logoClass: "bash",
23
21
  options: {
24
22
  longFormat: false,
25
23
  followRedirect: true,
26
24
  trimRequestBody: true,
27
25
  },
26
+ variant: "cURL",
28
27
  },
29
28
  {
30
- tabName: "Python",
31
29
  highlight: "python",
32
30
  language: "python",
33
- codeLanguage: "python",
34
- variant: "requests",
31
+ logoClass: "python",
35
32
  options: {
36
33
  followRedirect: true,
37
34
  trimRequestBody: true,
38
35
  },
36
+ variant: "requests",
39
37
  },
40
38
  {
41
- tabName: "Go",
42
39
  highlight: "go",
43
40
  language: "go",
44
- codeLanguage: "go",
45
- variant: "native",
41
+ logoClass: "go",
46
42
  options: {
47
43
  followRedirect: true,
48
44
  trimRequestBody: true,
49
45
  },
46
+ variant: "native",
50
47
  },
51
48
  {
52
- tabName: "Node",
53
49
  highlight: "javascript",
54
50
  language: "nodejs",
55
- codeLanguage: "javascript",
56
- variant: "axios",
51
+ logoClass: "nodejs",
57
52
  options: {
58
53
  ES6_enabled: true,
59
54
  followRedirect: true,
60
55
  trimRequestBody: true,
61
56
  },
57
+ variant: "axios",
58
+ },
59
+ {
60
+ highlight: "ruby",
61
+ language: "ruby",
62
+ logoClass: "ruby",
63
+ options: {
64
+ followRedirect: true,
65
+ trimRequestBody: true,
66
+ },
67
+ variant: "Net::HTTP",
68
+ },
69
+ {
70
+ highlight: "csharp",
71
+ language: "csharp",
72
+ logoClass: "csharp",
73
+ options: {
74
+ followRedirect: true,
75
+ trimRequestBody: true,
76
+ },
77
+ variant: "RestSharp",
78
+ },
79
+ {
80
+ highlight: "php",
81
+ language: "php",
82
+ logoClass: "php",
83
+ options: {
84
+ followRedirect: true,
85
+ trimRequestBody: true,
86
+ },
87
+ variant: "cURL",
62
88
  },
63
89
  ];
64
90
 
@@ -95,9 +121,15 @@ function Curl({ postman, codeSamples }) {
95
121
  ];
96
122
  const defaultLang = languageSet.filter(
97
123
  (lang) =>
98
- lang.codeLanguage === localStorage.getItem("docusaurus.tab.code-samples")
124
+ lang.language === localStorage.getItem("docusaurus.tab.code-samples")
99
125
  );
100
- const [language, setLanguage] = useState(defaultLang[0] ?? langs[0]);
126
+ const [language, setLanguage] = useState(() => {
127
+ if (langs.length === 1) {
128
+ return langs[0];
129
+ }
130
+
131
+ return defaultLang[0] ?? langs[0];
132
+ });
101
133
  const [codeText, setCodeText] = useState("");
102
134
  useEffect(() => {
103
135
  if (language && !!language.options) {
@@ -127,6 +159,38 @@ function Curl({ postman, codeSamples }) {
127
159
  );
128
160
  } else if (language && !!language.source) {
129
161
  setCodeText(language.source);
162
+ } else if (language && !language.options) {
163
+ const langSource = languageSet.filter(
164
+ (lang) => lang.language === language.language
165
+ ); // Merges user-defined language with default languageSet
166
+ // This allows users to define only the minimal properties necessary in languageTabs
167
+ // User-defined properties should override languageSet properties
168
+
169
+ const mergedLanguage = { ...langSource[0], ...language };
170
+ const postmanRequest = buildPostmanRequest(postman, {
171
+ queryParams,
172
+ pathParams,
173
+ cookieParams,
174
+ contentType,
175
+ accept,
176
+ headerParams,
177
+ body,
178
+ server,
179
+ auth,
180
+ });
181
+ codegen.convert(
182
+ mergedLanguage.language,
183
+ mergedLanguage.variant,
184
+ postmanRequest,
185
+ mergedLanguage.options,
186
+ (error, snippet) => {
187
+ if (error) {
188
+ return;
189
+ }
190
+
191
+ setCodeText(snippet);
192
+ }
193
+ );
130
194
  } else {
131
195
  setCodeText("");
132
196
  }
@@ -156,12 +220,16 @@ function Curl({ postman, codeSamples }) {
156
220
  <CodeTab
157
221
  value={lang.language}
158
222
  label={""}
159
- key={lang.tabName || lang.label}
223
+ key={
224
+ lang.variant
225
+ ? `${lang.language}-${lang.variant}`
226
+ : lang.language
227
+ }
160
228
  attributes={{
161
- className: `code__tab--${lang.codeLanguage}`,
229
+ className: `code__tab--${lang.logoClass}`,
162
230
  }}
163
231
  >
164
- <CodeBlock language={lang.codeLanguage}>{codeText}</CodeBlock>
232
+ <CodeBlock language={lang.highlight}>{codeText}</CodeBlock>
165
233
  </CodeTab>
166
234
  );
167
235
  })}