docusaurus-theme-openapi-docs 1.1.8 → 1.1.11
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.
- package/lib/theme/ApiDemoPanel/Body/index.js +11 -1
- package/lib/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
- package/lib/theme/ApiDemoPanel/Curl/index.js +80 -22
- package/lib/theme/ApiDemoPanel/Curl/languages.json +1386 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +4 -1
- package/lib/theme/ApiItem/Layout/styles.module.css +120 -20
- package/lib/theme/ResponseSamples/index.js +2 -2
- package/lib/theme/SchemaTabs/index.js +2 -2
- package/lib/theme/SchemaTabs/styles.module.css +3 -0
- package/lib-next/theme/ApiDemoPanel/Body/index.js +10 -1
- package/lib-next/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +85 -17
- package/lib-next/theme/ApiDemoPanel/Curl/languages.json +1386 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +2 -0
- package/lib-next/theme/ApiItem/Layout/styles.module.css +120 -20
- package/lib-next/theme/ResponseSamples/index.js +2 -2
- package/lib-next/theme/SchemaTabs/index.js +2 -2
- package/lib-next/theme/SchemaTabs/styles.module.css +3 -0
- package/package.json +6 -5
- package/src/theme/ApiDemoPanel/Body/index.tsx +10 -1
- package/src/theme/ApiDemoPanel/CodeTabs/styles.module.css +7 -1
- package/src/theme/ApiDemoPanel/Curl/index.tsx +89 -22
- package/src/theme/ApiDemoPanel/Curl/languages.json +1386 -0
- package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +2 -0
- package/src/theme/ApiItem/Layout/styles.module.css +120 -20
- package/src/theme/ResponseSamples/index.js +2 -2
- package/src/theme/SchemaTabs/index.js +2 -2
- package/src/theme/SchemaTabs/styles.module.css +3 -0
- package/lib/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
- package/lib/theme/ApiItem/Layout/icons/python-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
- package/lib-next/theme/ApiItem/Layout/icons/python-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/bash-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/go-original-wordmark.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/javascript-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/linux-original.svg +0 -1
- package/src/theme/ApiItem/Layout/icons/python-original.svg +0 -1
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _xmlFormatter = _interopRequireDefault(require("xml-formatter"));
|
|
11
|
+
|
|
10
12
|
var _ContentType = _interopRequireDefault(require("../ContentType"));
|
|
11
13
|
|
|
12
14
|
var _FormSelect = _interopRequireDefault(require("../FormSelect"));
|
|
@@ -170,7 +172,15 @@ function Body({
|
|
|
170
172
|
|
|
171
173
|
if (contentType === "application/xml") {
|
|
172
174
|
if (jsonRequestBodyExample) {
|
|
173
|
-
|
|
175
|
+
try {
|
|
176
|
+
exampleBodyString = (0, _xmlFormatter.default)((0, _json2xml.default)(jsonRequestBodyExample, ""), {
|
|
177
|
+
indentation: " ",
|
|
178
|
+
lineSeparator: "\n",
|
|
179
|
+
collapseContent: true
|
|
180
|
+
});
|
|
181
|
+
} catch {
|
|
182
|
+
exampleBodyString = (0, _json2xml.default)(jsonRequestBodyExample);
|
|
183
|
+
}
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
language = "xml";
|
|
@@ -36,47 +36,70 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
36
36
|
* LICENSE file in the root directory of this source tree.
|
|
37
37
|
* ========================================================================== */
|
|
38
38
|
const languageSet = [{
|
|
39
|
-
tabName: "cURL",
|
|
40
39
|
highlight: "bash",
|
|
41
40
|
language: "curl",
|
|
42
|
-
|
|
43
|
-
variant: "curl",
|
|
41
|
+
logoClass: "bash",
|
|
44
42
|
options: {
|
|
45
43
|
longFormat: false,
|
|
46
44
|
followRedirect: true,
|
|
47
45
|
trimRequestBody: true
|
|
48
|
-
}
|
|
46
|
+
},
|
|
47
|
+
variant: "cURL"
|
|
49
48
|
}, {
|
|
50
|
-
tabName: "Python",
|
|
51
49
|
highlight: "python",
|
|
52
50
|
language: "python",
|
|
53
|
-
|
|
54
|
-
variant: "requests",
|
|
51
|
+
logoClass: "python",
|
|
55
52
|
options: {
|
|
56
53
|
followRedirect: true,
|
|
57
54
|
trimRequestBody: true
|
|
58
|
-
}
|
|
55
|
+
},
|
|
56
|
+
variant: "requests"
|
|
59
57
|
}, {
|
|
60
|
-
tabName: "Go",
|
|
61
58
|
highlight: "go",
|
|
62
59
|
language: "go",
|
|
63
|
-
|
|
64
|
-
variant: "native",
|
|
60
|
+
logoClass: "go",
|
|
65
61
|
options: {
|
|
66
62
|
followRedirect: true,
|
|
67
63
|
trimRequestBody: true
|
|
68
|
-
}
|
|
64
|
+
},
|
|
65
|
+
variant: "native"
|
|
69
66
|
}, {
|
|
70
|
-
tabName: "Node",
|
|
71
67
|
highlight: "javascript",
|
|
72
68
|
language: "nodejs",
|
|
73
|
-
|
|
74
|
-
variant: "axios",
|
|
69
|
+
logoClass: "nodejs",
|
|
75
70
|
options: {
|
|
76
71
|
ES6_enabled: true,
|
|
77
72
|
followRedirect: true,
|
|
78
73
|
trimRequestBody: true
|
|
79
|
-
}
|
|
74
|
+
},
|
|
75
|
+
variant: "axios"
|
|
76
|
+
}, {
|
|
77
|
+
highlight: "ruby",
|
|
78
|
+
language: "ruby",
|
|
79
|
+
logoClass: "ruby",
|
|
80
|
+
options: {
|
|
81
|
+
followRedirect: true,
|
|
82
|
+
trimRequestBody: true
|
|
83
|
+
},
|
|
84
|
+
variant: "Net::HTTP"
|
|
85
|
+
}, {
|
|
86
|
+
highlight: "csharp",
|
|
87
|
+
language: "csharp",
|
|
88
|
+
logoClass: "csharp",
|
|
89
|
+
options: {
|
|
90
|
+
followRedirect: true,
|
|
91
|
+
trimRequestBody: true
|
|
92
|
+
},
|
|
93
|
+
variant: "RestSharp"
|
|
94
|
+
}, {
|
|
95
|
+
highlight: "php",
|
|
96
|
+
language: "php",
|
|
97
|
+
logoClass: "php",
|
|
98
|
+
options: {
|
|
99
|
+
followRedirect: true,
|
|
100
|
+
trimRequestBody: true
|
|
101
|
+
},
|
|
102
|
+
variant: "cURL"
|
|
80
103
|
}];
|
|
81
104
|
exports.languageSet = languageSet;
|
|
82
105
|
|
|
@@ -97,7 +120,7 @@ function Curl({
|
|
|
97
120
|
postman,
|
|
98
121
|
codeSamples
|
|
99
122
|
}) {
|
|
100
|
-
var _ref, _siteConfig$themeConf
|
|
123
|
+
var _ref, _siteConfig$themeConf;
|
|
101
124
|
|
|
102
125
|
// TODO: match theme for vscode.
|
|
103
126
|
const {
|
|
@@ -114,8 +137,16 @@ function Curl({
|
|
|
114
137
|
const auth = (0, _hooks.useTypedSelector)(state => state.auth); // TODO
|
|
115
138
|
|
|
116
139
|
const langs = [...((_ref = siteConfig === null || siteConfig === void 0 ? void 0 : (_siteConfig$themeConf = siteConfig.themeConfig) === null || _siteConfig$themeConf === void 0 ? void 0 : _siteConfig$themeConf.languageTabs) !== null && _ref !== void 0 ? _ref : languageSet), ...codeSamples];
|
|
117
|
-
const defaultLang = languageSet.filter(lang => lang.
|
|
118
|
-
const [language, setLanguage] = (0, _react.useState)((
|
|
140
|
+
const defaultLang = languageSet.filter(lang => lang.language === localStorage.getItem("docusaurus.tab.code-samples"));
|
|
141
|
+
const [language, setLanguage] = (0, _react.useState)(() => {
|
|
142
|
+
var _defaultLang$;
|
|
143
|
+
|
|
144
|
+
if (langs.length === 1) {
|
|
145
|
+
return langs[0];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return (_defaultLang$ = defaultLang[0]) !== null && _defaultLang$ !== void 0 ? _defaultLang$ : langs[0];
|
|
149
|
+
});
|
|
119
150
|
const [codeText, setCodeText] = (0, _react.useState)("");
|
|
120
151
|
(0, _react.useEffect)(() => {
|
|
121
152
|
if (language && !!language.options) {
|
|
@@ -140,6 +171,33 @@ function Curl({
|
|
|
140
171
|
});
|
|
141
172
|
} else if (language && !!language.source) {
|
|
142
173
|
setCodeText(language.source);
|
|
174
|
+
} else if (language && !language.options) {
|
|
175
|
+
const langSource = languageSet.filter(lang => lang.language === language.language); // Merges user-defined language with default languageSet
|
|
176
|
+
// This allows users to define only the minimal properties necessary in languageTabs
|
|
177
|
+
// User-defined properties should override languageSet properties
|
|
178
|
+
|
|
179
|
+
const mergedLanguage = { ...langSource[0],
|
|
180
|
+
...language
|
|
181
|
+
};
|
|
182
|
+
const postmanRequest = (0, _buildPostmanRequest.default)(postman, {
|
|
183
|
+
queryParams,
|
|
184
|
+
pathParams,
|
|
185
|
+
cookieParams,
|
|
186
|
+
contentType,
|
|
187
|
+
accept,
|
|
188
|
+
headerParams,
|
|
189
|
+
body,
|
|
190
|
+
server,
|
|
191
|
+
auth
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
_postmanCodeGenerators.default.convert(mergedLanguage.language, mergedLanguage.variant, postmanRequest, mergedLanguage.options, (error, snippet) => {
|
|
195
|
+
if (error) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
setCodeText(snippet);
|
|
200
|
+
});
|
|
143
201
|
} else {
|
|
144
202
|
setCodeText("");
|
|
145
203
|
}
|
|
@@ -152,10 +210,10 @@ function Curl({
|
|
|
152
210
|
return <>
|
|
153
211
|
<_CodeTabs.default groupId="code-samples" action={setLanguage}>
|
|
154
212
|
{langs.map(lang => {
|
|
155
|
-
return <CodeTab value={lang.language} label={""} key={lang.
|
|
156
|
-
className: `code__tab--${lang.
|
|
213
|
+
return <CodeTab value={lang.language} label={""} key={lang.variant ? `${lang.language}-${lang.variant}` : lang.language} attributes={{
|
|
214
|
+
className: `code__tab--${lang.logoClass}`
|
|
157
215
|
}}>
|
|
158
|
-
<_CodeBlock.default language={lang.
|
|
216
|
+
<_CodeBlock.default language={lang.highlight}>{codeText}</_CodeBlock.default>
|
|
159
217
|
</CodeTab>;
|
|
160
218
|
})}
|
|
161
219
|
</_CodeTabs.default>
|