@camunda8/docusaurus-plugin-openapi-docs 4.5.4 → 4.6.0

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.
@@ -16,6 +16,8 @@ interface OperationMapEntry {
16
16
  file: string;
17
17
  region: string;
18
18
  label?: string;
19
+ /** Import/using statement to prepend to the code sample (e.g. "import { CamundaClient } from ..."). */
20
+ imports?: string;
19
21
  }
20
22
  /**
21
23
  * Shape of operation-map.json: operationId -> entries[].
@@ -140,6 +140,7 @@ function buildCodeSamples(operationId, sdkExamples, siteDir, fileCache, mapCache
140
140
  if (!entries || entries.length === 0)
141
141
  continue;
142
142
  const mapDir = path_1.default.dirname(mapPath);
143
+ const hasMultipleEntries = entries.length > 1;
143
144
  for (const entry of entries) {
144
145
  const filePath = path_1.default.resolve(mapDir, entry.file);
145
146
  let fileContent = fileCache.get(filePath);
@@ -156,10 +157,13 @@ function buildCodeSamples(operationId, sdkExamples, siteDir, fileCache, mapCache
156
157
  console.warn(`SDK examples: region "${entry.region}" not found in ${filePath} (${sdk.lang}, ${operationId})`);
157
158
  continue;
158
159
  }
160
+ // Use "SDK - <label>" only when there are multiple entries for the same
161
+ // operationId, so readers can distinguish between variants.
162
+ const label = hasMultipleEntries && entry.label ? `SDK - ${entry.label}` : "SDK";
159
163
  samples.push({
160
164
  lang: sdk.lang,
161
- label: "SDK",
162
- source: code,
165
+ label,
166
+ source: entry.imports ? `${entry.imports}\n\n${code}` : code,
163
167
  });
164
168
  }
165
169
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@camunda8/docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "4.5.4",
4
+ "version": "4.6.0",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -28,6 +28,8 @@ interface OperationMapEntry {
28
28
  file: string;
29
29
  region: string;
30
30
  label?: string;
31
+ /** Import/using statement to prepend to the code sample (e.g. "import { CamundaClient } from ..."). */
32
+ imports?: string;
31
33
  }
32
34
 
33
35
  /**
@@ -187,6 +189,7 @@ export function buildCodeSamples(
187
189
  if (!entries || entries.length === 0) continue;
188
190
 
189
191
  const mapDir = path.dirname(mapPath);
192
+ const hasMultipleEntries = entries.length > 1;
190
193
 
191
194
  for (const entry of entries) {
192
195
  const filePath = path.resolve(mapDir, entry.file);
@@ -210,10 +213,15 @@ export function buildCodeSamples(
210
213
  continue;
211
214
  }
212
215
 
216
+ // Use "SDK - <label>" only when there are multiple entries for the same
217
+ // operationId, so readers can distinguish between variants.
218
+ const label =
219
+ hasMultipleEntries && entry.label ? `SDK - ${entry.label}` : "SDK";
220
+
213
221
  samples.push({
214
222
  lang: sdk.lang,
215
- label: "SDK",
216
- source: code,
223
+ label,
224
+ source: entry.imports ? `${entry.imports}\n\n${code}` : code,
217
225
  });
218
226
  }
219
227
  }