@bagelink/sdk 1.2.56 → 1.2.61
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/dist/index.cjs +17 -13
- package/dist/index.mjs +17 -13
- package/package.json +1 -1
- package/src/openAPITools/functionGenerator.ts +35 -23
package/dist/index.cjs
CHANGED
|
@@ -258,19 +258,7 @@ function generateAxiosFunction(method, formattedPath, allParams, responseTypeStr
|
|
|
258
258
|
axiosFunction += "}";
|
|
259
259
|
return axiosFunction;
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
if (!operation) return "";
|
|
263
|
-
const isFileUpload = operation.requestBody?.content["multipart/form-data"]?.schema?.$ref?.includes("Body_upload_files");
|
|
264
|
-
const parameters = generateFunctionParameters(
|
|
265
|
-
operation.parameters,
|
|
266
|
-
isFileUpload
|
|
267
|
-
);
|
|
268
|
-
const { requestBodyParam, requestBodyPayload } = generateRequestBody(
|
|
269
|
-
operation.requestBody
|
|
270
|
-
);
|
|
271
|
-
const allParams = isFileUpload ? "file: File, options?: UploadOptions & { dirPath?: string, tags?: string[] }" : combineAllParams(parameters, requestBodyParam);
|
|
272
|
-
const responseType = generateResponseType(operation.responses);
|
|
273
|
-
const responseTypeStr = responseType ? `: Promise<AxiosResponse<${responseType}>>` : "";
|
|
261
|
+
function buildJSDocComment(operation, method, path) {
|
|
274
262
|
let functionComment = "/**\n";
|
|
275
263
|
if (operation.summary) {
|
|
276
264
|
functionComment += ` * ${operation.summary}
|
|
@@ -289,6 +277,22 @@ function generateFunctionForOperation(method, path, operation) {
|
|
|
289
277
|
* @endpoint ${method.toUpperCase()} ${path}
|
|
290
278
|
`;
|
|
291
279
|
functionComment += " */\n";
|
|
280
|
+
return functionComment;
|
|
281
|
+
}
|
|
282
|
+
function generateFunctionForOperation(method, path, operation) {
|
|
283
|
+
if (!operation) return "";
|
|
284
|
+
const isFileUpload = operation.requestBody?.content["multipart/form-data"]?.schema?.$ref?.includes("Body_upload_files");
|
|
285
|
+
const parameters = generateFunctionParameters(
|
|
286
|
+
operation.parameters,
|
|
287
|
+
isFileUpload
|
|
288
|
+
);
|
|
289
|
+
const { requestBodyParam, requestBodyPayload } = generateRequestBody(
|
|
290
|
+
operation.requestBody
|
|
291
|
+
);
|
|
292
|
+
const allParams = isFileUpload ? "file: File, options?: UploadOptions & { dirPath?: string, tags?: string[] }" : combineAllParams(parameters, requestBodyParam);
|
|
293
|
+
const responseType = generateResponseType(operation.responses);
|
|
294
|
+
const responseTypeStr = responseType ? `: Promise<AxiosResponse<${responseType}>>` : "";
|
|
295
|
+
const functionComment = buildJSDocComment(operation, method, path);
|
|
292
296
|
return functionComment + generateAxiosFunction(
|
|
293
297
|
method,
|
|
294
298
|
formatPathWithParams(path),
|
package/dist/index.mjs
CHANGED
|
@@ -252,19 +252,7 @@ function generateAxiosFunction(method, formattedPath, allParams, responseTypeStr
|
|
|
252
252
|
axiosFunction += "}";
|
|
253
253
|
return axiosFunction;
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
if (!operation) return "";
|
|
257
|
-
const isFileUpload = operation.requestBody?.content["multipart/form-data"]?.schema?.$ref?.includes("Body_upload_files");
|
|
258
|
-
const parameters = generateFunctionParameters(
|
|
259
|
-
operation.parameters,
|
|
260
|
-
isFileUpload
|
|
261
|
-
);
|
|
262
|
-
const { requestBodyParam, requestBodyPayload } = generateRequestBody(
|
|
263
|
-
operation.requestBody
|
|
264
|
-
);
|
|
265
|
-
const allParams = isFileUpload ? "file: File, options?: UploadOptions & { dirPath?: string, tags?: string[] }" : combineAllParams(parameters, requestBodyParam);
|
|
266
|
-
const responseType = generateResponseType(operation.responses);
|
|
267
|
-
const responseTypeStr = responseType ? `: Promise<AxiosResponse<${responseType}>>` : "";
|
|
255
|
+
function buildJSDocComment(operation, method, path) {
|
|
268
256
|
let functionComment = "/**\n";
|
|
269
257
|
if (operation.summary) {
|
|
270
258
|
functionComment += ` * ${operation.summary}
|
|
@@ -283,6 +271,22 @@ function generateFunctionForOperation(method, path, operation) {
|
|
|
283
271
|
* @endpoint ${method.toUpperCase()} ${path}
|
|
284
272
|
`;
|
|
285
273
|
functionComment += " */\n";
|
|
274
|
+
return functionComment;
|
|
275
|
+
}
|
|
276
|
+
function generateFunctionForOperation(method, path, operation) {
|
|
277
|
+
if (!operation) return "";
|
|
278
|
+
const isFileUpload = operation.requestBody?.content["multipart/form-data"]?.schema?.$ref?.includes("Body_upload_files");
|
|
279
|
+
const parameters = generateFunctionParameters(
|
|
280
|
+
operation.parameters,
|
|
281
|
+
isFileUpload
|
|
282
|
+
);
|
|
283
|
+
const { requestBodyParam, requestBodyPayload } = generateRequestBody(
|
|
284
|
+
operation.requestBody
|
|
285
|
+
);
|
|
286
|
+
const allParams = isFileUpload ? "file: File, options?: UploadOptions & { dirPath?: string, tags?: string[] }" : combineAllParams(parameters, requestBodyParam);
|
|
287
|
+
const responseType = generateResponseType(operation.responses);
|
|
288
|
+
const responseTypeStr = responseType ? `: Promise<AxiosResponse<${responseType}>>` : "";
|
|
289
|
+
const functionComment = buildJSDocComment(operation, method, path);
|
|
286
290
|
return functionComment + generateAxiosFunction(
|
|
287
291
|
method,
|
|
288
292
|
formatPathWithParams(path),
|
package/package.json
CHANGED
|
@@ -339,6 +339,40 @@ function generateAxiosFunction(
|
|
|
339
339
|
return axiosFunction
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Builds a JSDoc comment for an OpenAPI operation
|
|
344
|
+
* @param operation - The OpenAPI operation object
|
|
345
|
+
* @param method - The HTTP method
|
|
346
|
+
* @param path - The API path
|
|
347
|
+
* @returns The JSDoc comment as a string
|
|
348
|
+
*/
|
|
349
|
+
function buildJSDocComment(operation: OperationObject, method: string, path: string) {
|
|
350
|
+
let functionComment = '/**\n'
|
|
351
|
+
|
|
352
|
+
// Add summary
|
|
353
|
+
if (operation.summary) {
|
|
354
|
+
functionComment += ` * ${operation.summary}\n`
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Add description if available
|
|
358
|
+
if (operation.description) {
|
|
359
|
+
// If there's already a summary, add a line break
|
|
360
|
+
if (operation.summary) functionComment += ` *\n`
|
|
361
|
+
|
|
362
|
+
// Split description into lines and add each line with proper JSDoc formatting
|
|
363
|
+
const descriptionLines = operation.description.split('\n')
|
|
364
|
+
descriptionLines.forEach((line: string) => {
|
|
365
|
+
functionComment += ` * ${line}\n`
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Add endpoint path and method information
|
|
370
|
+
functionComment += ` *\n * @endpoint ${method.toUpperCase()} ${path}\n`
|
|
371
|
+
|
|
372
|
+
functionComment += ' */\n'
|
|
373
|
+
return functionComment
|
|
374
|
+
}
|
|
375
|
+
|
|
342
376
|
/**
|
|
343
377
|
* Generates a function for an OpenAPI operation
|
|
344
378
|
* @param method - The HTTP method
|
|
@@ -377,29 +411,7 @@ function generateFunctionForOperation(
|
|
|
377
411
|
: ''
|
|
378
412
|
|
|
379
413
|
// Create JSDoc comment with OpenAPI documentation
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
// Add summary
|
|
383
|
-
if (operation.summary) {
|
|
384
|
-
functionComment += ` * ${operation.summary}\n`
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Add description if available
|
|
388
|
-
if (operation.description) {
|
|
389
|
-
// If there's already a summary, add a line break
|
|
390
|
-
if (operation.summary) functionComment += ` *\n`
|
|
391
|
-
|
|
392
|
-
// Split description into lines and add each line with proper JSDoc formatting
|
|
393
|
-
const descriptionLines = operation.description.split('\n')
|
|
394
|
-
descriptionLines.forEach((line: string) => {
|
|
395
|
-
functionComment += ` * ${line}\n`
|
|
396
|
-
})
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// Add endpoint path and method information
|
|
400
|
-
functionComment += ` *\n * @endpoint ${method.toUpperCase()} ${path}\n`
|
|
401
|
-
|
|
402
|
-
functionComment += ' */\n'
|
|
414
|
+
const functionComment = buildJSDocComment(operation, method, path)
|
|
403
415
|
|
|
404
416
|
return functionComment + generateAxiosFunction(
|
|
405
417
|
method,
|