@camunda8/docusaurus-plugin-openapi-docs 4.6.0 → 4.6.2
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.
|
@@ -8,6 +8,9 @@ export interface SdkExampleSource {
|
|
|
8
8
|
highlight?: string;
|
|
9
9
|
/** Path to the operation-map.json file (relative to site root or absolute). */
|
|
10
10
|
operationMapPath: string;
|
|
11
|
+
/** Default import/using statement prepended to every code sample for this language.
|
|
12
|
+
* Individual entries in operation-map.json can override this with their own `imports` field. */
|
|
13
|
+
defaultImports?: string;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* A single entry in operation-map.json for one operationId.
|
|
@@ -116,6 +116,7 @@ function camelToSnake(str) {
|
|
|
116
116
|
* @returns Array of x-codeSamples entries, or empty array if none found.
|
|
117
117
|
*/
|
|
118
118
|
function buildCodeSamples(operationId, sdkExamples, siteDir, fileCache, mapCache) {
|
|
119
|
+
var _a;
|
|
119
120
|
const samples = [];
|
|
120
121
|
for (const sdk of sdkExamples) {
|
|
121
122
|
const mapPath = path_1.default.resolve(siteDir, sdk.operationMapPath);
|
|
@@ -160,10 +161,11 @@ function buildCodeSamples(operationId, sdkExamples, siteDir, fileCache, mapCache
|
|
|
160
161
|
// Use "SDK - <label>" only when there are multiple entries for the same
|
|
161
162
|
// operationId, so readers can distinguish between variants.
|
|
162
163
|
const label = hasMultipleEntries && entry.label ? `SDK - ${entry.label}` : "SDK";
|
|
164
|
+
const imports = (_a = entry.imports) !== null && _a !== void 0 ? _a : sdk.defaultImports;
|
|
163
165
|
samples.push({
|
|
164
166
|
lang: sdk.lang,
|
|
165
167
|
label,
|
|
166
|
-
source:
|
|
168
|
+
source: imports ? `${imports}\n\n${code}` : code,
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
171
|
}
|
package/lib/options.js
CHANGED
|
@@ -50,6 +50,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
|
50
50
|
lang: utils_validation_1.Joi.string().required(),
|
|
51
51
|
highlight: utils_validation_1.Joi.string(),
|
|
52
52
|
operationMapPath: utils_validation_1.Joi.string().required(),
|
|
53
|
+
defaultImports: utils_validation_1.Joi.string(),
|
|
53
54
|
})),
|
|
54
55
|
version: utils_validation_1.Joi.string().when("versions", {
|
|
55
56
|
is: utils_validation_1.Joi.exist(),
|
package/package.json
CHANGED
|
@@ -19,6 +19,9 @@ export interface SdkExampleSource {
|
|
|
19
19
|
highlight?: string;
|
|
20
20
|
/** Path to the operation-map.json file (relative to site root or absolute). */
|
|
21
21
|
operationMapPath: string;
|
|
22
|
+
/** Default import/using statement prepended to every code sample for this language.
|
|
23
|
+
* Individual entries in operation-map.json can override this with their own `imports` field. */
|
|
24
|
+
defaultImports?: string;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -218,10 +221,11 @@ export function buildCodeSamples(
|
|
|
218
221
|
const label =
|
|
219
222
|
hasMultipleEntries && entry.label ? `SDK - ${entry.label}` : "SDK";
|
|
220
223
|
|
|
224
|
+
const imports = entry.imports ?? sdk.defaultImports;
|
|
221
225
|
samples.push({
|
|
222
226
|
lang: sdk.lang,
|
|
223
227
|
label,
|
|
224
|
-
source:
|
|
228
|
+
source: imports ? `${imports}\n\n${code}` : code,
|
|
225
229
|
});
|
|
226
230
|
}
|
|
227
231
|
}
|
package/src/options.ts
CHANGED