docusaurus-theme-openapi-docs 0.0.0-693 → 0.0.0-694

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.
@@ -0,0 +1,37 @@
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 { CodeSample, Language } from "./code-snippets-types";
9
+
10
+ export function mergeCodeSampleLanguage(
11
+ languages: Language[],
12
+ codeSamples: CodeSample[]
13
+ ): Language[] {
14
+ return languages.map((language) => {
15
+ const languageCodeSamples = codeSamples.filter(
16
+ ({ lang }) => lang === language.codeSampleLanguage
17
+ );
18
+
19
+ if (languageCodeSamples.length) {
20
+ const samples = languageCodeSamples.map(({ lang }) => lang);
21
+ const samplesLabels = languageCodeSamples.map(
22
+ ({ label, lang }) => label || lang
23
+ );
24
+ const samplesSources = languageCodeSamples.map(({ source }) => source);
25
+
26
+ return {
27
+ ...language,
28
+ sample: samples[0],
29
+ samples,
30
+ samplesSources,
31
+ samplesLabels,
32
+ };
33
+ }
34
+
35
+ return language;
36
+ });
37
+ }
@@ -94,6 +94,20 @@ body[class="ReactModal__Body--open"] {
94
94
  padding-right: 0.5rem !important;
95
95
  }
96
96
 
97
+ .openapi-tabs__code-item--sample {
98
+ color: var(--ifm-color-secondary);
99
+
100
+ &.active {
101
+ border-color: var(--ifm-toc-border-color);
102
+ }
103
+ }
104
+
105
+ .openapi-tabs__code-item--sample > span {
106
+ padding-top: unset !important;
107
+ padding-left: 0.5rem !important;
108
+ padding-right: 0.5rem !important;
109
+ }
110
+
97
111
  .openapi-tabs__code-item--python {
98
112
  color: var(--ifm-color-success);
99
113
 
@@ -19,6 +19,7 @@ function TabList({
19
19
  action,
20
20
  currentLanguage,
21
21
  includeVariant,
22
+ includeSample,
22
23
  className,
23
24
  block,
24
25
  selectedValue,
@@ -53,6 +54,12 @@ function TabList({
53
54
  )[0];
54
55
  action.setSelectedVariant(newLanguage.variant.toLowerCase());
55
56
  }
57
+
58
+ if (currentLanguage && includeSample) {
59
+ newLanguage.sample = newTabValue;
60
+ action.setSelectedSample(newTabValue.toLowerCase());
61
+ }
62
+
56
63
  action.setLanguage(newLanguage);
57
64
  }
58
65
  };
@@ -30,7 +30,7 @@ function ApiExplorer({
30
30
  {item.method !== "event" && (
31
31
  <CodeSnippets
32
32
  postman={postman}
33
- codeSamples={(item as any)["x-code-samples"] ?? []}
33
+ codeSamples={(item as any)["x-codeSamples"] ?? []}
34
34
  />
35
35
  )}
36
36
  <Request item={item} />