@mintlify/prebuild 1.0.1361 → 1.0.1363

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.
@@ -1,11 +1,23 @@
1
- import { getOpenApiDocumentFromUrl, optionallyAddLeadingSlash, isAllowedLocalSchemaUrl, potentiallyParseOpenApiString, findNavGroup, findOpenApiPath, resolveOverlaysForSpec, } from '@mintlify/common';
1
+ import { createOpenApiBadgeResolver, createOpenApiTagResolver, getOpenApiDocumentFromUrl, optionallyAddLeadingSlash, isAllowedLocalSchemaUrl, potentiallyParseOpenApiString, findNavGroup, findOpenApiPath, resolveOverlaysForSpec, } from '@mintlify/common';
2
2
  import { readObjectArrayProperty } from '@mintlify/common/divisions/iterateObjectArrayProperty';
3
3
  import { generateOpenApiPagesForDocsConfig } from '@mintlify/scraping';
4
4
  import { processOpenApiPath, processOpenApiWebhook, } from '@mintlify/scraping/bin/openapi/common.js';
5
- import { divisions, } from '@mintlify/validation';
5
+ import { divisions, getPathItemOperation, isFixedHttpMethod, } from '@mintlify/validation';
6
6
  import * as path from 'path';
7
7
  import { findInvalidSpecFile } from '../../invalidSpecFiles.js';
8
8
  const DEFAULT_OUTPUT_DIR = 'api-reference';
9
+ const specTagResolvers = new WeakMap();
10
+ const tagResolversFor = (schema) => {
11
+ const cached = specTagResolvers.get(schema);
12
+ if (cached)
13
+ return cached;
14
+ const resolvers = {
15
+ resolveTags: createOpenApiTagResolver(schema),
16
+ resolveBadge: createOpenApiBadgeResolver(schema),
17
+ };
18
+ specTagResolvers.set(schema, resolvers);
19
+ return resolvers;
20
+ };
9
21
  const normalizeMountPath = (mountPath) => mountPath.replace(/^\/+|\/+$/g, '');
10
22
  const getMountPathForPath = (candidatePath, mountPaths) => {
11
23
  if (!candidatePath)
@@ -205,6 +217,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
205
217
  overwrite,
206
218
  localSchema,
207
219
  writeFile,
220
+ ...tagResolversFor(schema),
208
221
  }, findNavGroup);
209
222
  }
210
223
  else {
@@ -213,11 +226,14 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
213
226
  const available = Object.keys(schema.paths ?? {}).join(', ');
214
227
  throw new Error(`Endpoint ${endpoint} not found in ${openapiPath}.${available ? ` Available paths: ${available}` : ''}`);
215
228
  }
216
- const opObject = match.pathItem[method.toLowerCase()];
229
+ const opObject = method === 'webhook' ? undefined : getPathItemOperation(match.pathItem, method);
217
230
  if (!opObject) {
218
231
  throw new Error(`Method ${method.toUpperCase()} for endpoint ${match.pathKey} not found in ${openapiPath}`);
219
232
  }
220
- generatedSlugs = processOpenApiPath(match.pathKey, { [method.toLowerCase()]: opObject }, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
233
+ const singleOperationPathItem = isFixedHttpMethod(method)
234
+ ? { [method]: opObject }
235
+ : { additionalOperations: { [method]: opObject } };
236
+ generatedSlugs = processOpenApiPath(match.pathKey, singleOperationPathItem, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
221
237
  openApiFilePath: openApiFile.originalFileLocation,
222
238
  writeFiles,
223
239
  outDir: currentDirectory ?? DEFAULT_OUTPUT_DIR,
@@ -226,6 +242,7 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
226
242
  overwrite,
227
243
  localSchema,
228
244
  writeFile,
245
+ ...tagResolversFor(schema),
229
246
  }, findNavGroup);
230
247
  }
231
248
  await Promise.all(writePromises);