@mondaydotcomorg/atp-server 0.21.2 → 0.21.6

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 CHANGED
@@ -6317,8 +6317,20 @@ function matchPathPattern(path, pattern) {
6317
6317
  const regexPattern = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
6318
6318
  return new RegExp(`^${regexPattern}$`).test(path);
6319
6319
  }
6320
+ function resolveReference(ref, spec) {
6321
+ const refPath = ref.split("/").slice(1);
6322
+ let resolved = spec;
6323
+ for (const part of refPath) {
6324
+ resolved = resolved?.[part];
6325
+ }
6326
+ return resolved;
6327
+ }
6320
6328
  function convertOperation(path, method, operation, spec, baseURL, options, auth) {
6321
- const functionName = operation.operationId || `${method}_${path.replace(/[^a-zA-Z0-9]/g, "_")}`;
6329
+ const operationName = operation.operationId || [
6330
+ method,
6331
+ path
6332
+ ].join("_");
6333
+ const functionName = operationName.replace(/[^a-zA-Z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
6322
6334
  const operationKey = `${method.toUpperCase()} ${path}`;
6323
6335
  const description = options.descriptions?.[operationKey] || operation.summary || operation.description || `${method.toUpperCase()} ${path}`;
6324
6336
  const inputSchema = buildInputSchema(operation, spec);
@@ -6401,7 +6413,8 @@ function convertOperation(path, method, operation, spec, baseURL, options, auth)
6401
6413
  }
6402
6414
  }
6403
6415
  if (operation.parameters) {
6404
- for (const param of operation.parameters) {
6416
+ for (let param of operation.parameters) {
6417
+ param = resolveParamReferenceIfNeeded(param, spec);
6405
6418
  if (param.in === "path" && input[param.name]) {
6406
6419
  requestPath = requestPath.replace(`{${param.name}}`, encodeURIComponent(String(input[param.name])));
6407
6420
  } else if (param.in === "query" && input[param.name] !== void 0) {
@@ -6499,11 +6512,21 @@ function convertOperation(path, method, operation, spec, baseURL, options, auth)
6499
6512
  keywords: operation.tags || []
6500
6513
  };
6501
6514
  }
6515
+ function resolveParamReferenceIfNeeded(param, spec) {
6516
+ if ("$ref" in param) {
6517
+ const resolved = resolveReference(param.$ref, spec);
6518
+ if (resolved) {
6519
+ param = resolved;
6520
+ }
6521
+ }
6522
+ return param;
6523
+ }
6502
6524
  function buildInputSchema(operation, spec) {
6503
6525
  const properties = {};
6504
6526
  const required = [];
6505
6527
  if (operation.parameters) {
6506
- for (const param of operation.parameters) {
6528
+ for (let param of operation.parameters) {
6529
+ param = resolveParamReferenceIfNeeded(param, spec);
6507
6530
  if (param.schema) {
6508
6531
  const paramSchema = resolveSchema(param.schema, spec);
6509
6532
  properties[param.name] = typeof paramSchema === "object" && paramSchema !== null ? {
@@ -6575,11 +6598,7 @@ function resolveSchema(schema, spec, visited = /* @__PURE__ */ new Set()) {
6575
6598
  description: "Circular reference: " + schema.$ref
6576
6599
  };
6577
6600
  }
6578
- const refPath = schema.$ref.split("/").slice(1);
6579
- let resolved = spec;
6580
- for (const part of refPath) {
6581
- resolved = resolved?.[part];
6582
- }
6601
+ const resolved = resolveReference(schema.$ref, spec);
6583
6602
  if (resolved) {
6584
6603
  visited.add(schema.$ref);
6585
6604
  const result = resolveSchema(resolved, spec, visited);
@@ -6747,7 +6766,9 @@ var init_openapi_loader = __esm({
6747
6766
  __name(loadSpec, "loadSpec");
6748
6767
  __name(shouldIncludeOperation, "shouldIncludeOperation");
6749
6768
  __name(matchPathPattern, "matchPathPattern");
6769
+ __name(resolveReference, "resolveReference");
6750
6770
  __name(convertOperation, "convertOperation");
6771
+ __name(resolveParamReferenceIfNeeded, "resolveParamReferenceIfNeeded");
6751
6772
  __name(buildInputSchema, "buildInputSchema");
6752
6773
  __name(buildOutputSchema, "buildOutputSchema");
6753
6774
  __name(resolveSchema, "resolveSchema");