@mintlify/prebuild 1.0.1285 → 1.0.1287

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.
@@ -58,7 +58,7 @@ const filterToImportClosure = (snippetV2Filenames, rootFilenames, fileImportsMap
58
58
  }
59
59
  return snippetV2Filenames.filter((filename) => needed.has(filename.toLowerCase()));
60
60
  };
61
- export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, disablePrefetch, strict, invalidSpecFiles, allowSourceRefs, lazyPages, pageScans, fileImportsMap, }) => {
61
+ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, disablePrefetch, strict, invalidSpecFiles, allowSourceRefs, lazyPages, pageScans, fileImportsMap, overlayRegistry, }) => {
62
62
  const mintConfigResult = await updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema, strict, invalidSpecFiles);
63
63
  // we used the original mint config without openapi pages injected
64
64
  // because we will do it in `updateDocsConfigFile`, this will avoid duplicated openapi pages
@@ -73,6 +73,7 @@ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFil
73
73
  strict,
74
74
  invalidSpecFiles,
75
75
  allowSourceRefs,
76
+ overlayRegistry,
76
77
  });
77
78
  let contentFilenamesToParse = contentFilenames;
78
79
  if (lazyPages) {
@@ -1,5 +1,6 @@
1
+ import { type OverlayRegistry } from '@mintlify/common';
1
2
  import type { ConfigType, MintConfig, OpenApiFile } from '@mintlify/models';
2
3
  import { DocsConfig } from '@mintlify/validation';
3
4
  type ConfigInput<T extends ConfigType> = T extends 'docs' ? DocsConfig : MintConfig;
4
- export declare const getOpenApiFilesFromConfig: <T extends ConfigType>(type: T, config: ConfigInput<T>, localSchema?: boolean) => Promise<OpenApiFile[]>;
5
+ export declare const getOpenApiFilesFromConfig: <T extends ConfigType>(type: T, config: ConfigInput<T>, localSchema?: boolean, overlayRegistry?: OverlayRegistry, fetchRemoteDocument?: (url: string) => Promise<unknown>) => Promise<OpenApiFile[]>;
5
6
  export {};
@@ -1,5 +1,6 @@
1
- import { getOpenApiDocumentFromUrl, isAllowedLocalSchemaUrl } from '@mintlify/common';
2
- export const getOpenApiFilesFromConfig = async (type, config, localSchema) => {
1
+ import { getOpenApiDocumentFromUrl, isAllowedLocalSchemaUrl, resolveOverlaysForSpec, } from '@mintlify/common';
2
+ import { extractOpenApiEntries } from '@mintlify/validation';
3
+ export const getOpenApiFilesFromConfig = async (type, config, localSchema, overlayRegistry, fetchRemoteDocument) => {
3
4
  let openapi;
4
5
  if (type === 'docs') {
5
6
  openapi = config.api?.openapi;
@@ -10,28 +11,19 @@ export const getOpenApiFilesFromConfig = async (type, config, localSchema) => {
10
11
  const openApiFiles = [];
11
12
  // Download OpenApi file if url is provided
12
13
  async function addOpenApiFileFromUrl(openapi) {
13
- const specFromUrl = await getOpenApiDocumentFromUrl(openapi);
14
+ const overlays = overlayRegistry
15
+ ? await resolveOverlaysForSpec(overlayRegistry, openapi)
16
+ : undefined;
17
+ const specFromUrl = await getOpenApiDocumentFromUrl(openapi, { overlays, fetchRemoteDocument });
14
18
  openApiFiles.push({
15
19
  filename: openapi,
16
20
  spec: specFromUrl,
17
21
  originalFileLocation: openapi,
18
22
  });
19
23
  }
20
- if (openapi) {
21
- if (typeof openapi === 'string' && isAllowedLocalSchemaUrl(openapi, localSchema)) {
22
- await addOpenApiFileFromUrl(openapi);
23
- }
24
- else if (Array.isArray(openapi)) {
25
- for (const openapiUrl of openapi) {
26
- if (typeof openapiUrl === 'string' && isAllowedLocalSchemaUrl(openapiUrl, localSchema)) {
27
- await addOpenApiFileFromUrl(openapiUrl);
28
- }
29
- }
30
- }
31
- else if (typeof openapi === 'object' &&
32
- 'source' in openapi &&
33
- isAllowedLocalSchemaUrl(openapi.source, localSchema)) {
34
- await addOpenApiFileFromUrl(openapi.source);
24
+ for (const entry of extractOpenApiEntries(openapi)) {
25
+ if (isAllowedLocalSchemaUrl(entry.source, localSchema)) {
26
+ await addOpenApiFileFromUrl(entry.source);
35
27
  }
36
28
  }
37
29
  return openApiFiles;