@mintlify/prebuild 1.0.607 → 1.0.609

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,7 +1,7 @@
1
1
  import { getOpenApiDocumentFromUrl, optionallyAddLeadingSlash, isAllowedLocalSchemaUrl, potentiallyParseOpenApiString, } from '@mintlify/common';
2
2
  import { generateOpenApiPagesForDocsConfig } from '@mintlify/scraping';
3
3
  import { findNavGroup } from '@mintlify/scraping/bin/apiPages/common.js';
4
- import { processOpenApiPath } from '@mintlify/scraping/bin/openapi/common.js';
4
+ import { processOpenApiPath, processOpenApiWebhook, } from '@mintlify/scraping/bin/openapi/common.js';
5
5
  import { divisions, } from '@mintlify/validation';
6
6
  import * as path from 'path';
7
7
  const DEFAULT_OUTPUT_DIR = 'api-reference';
@@ -125,25 +125,42 @@ export const generateOpenApiFromDocsConfig = async (navigation, openApiFiles, pa
125
125
  throw new Error(`Openapi file ${openapiPath} referenced in docs.json does not exist`);
126
126
  }
127
127
  const schema = openApiFile.spec;
128
- const pathItemObject = (schema.paths ?? {})[endpoint];
129
- if (!pathItemObject || typeof pathItemObject !== 'object') {
130
- throw new Error(`Endpoint ${endpoint} not found in ${openapiPath}`);
131
- }
132
- const opObject = pathItemObject[method.toLowerCase()];
133
- if (!opObject) {
134
- throw new Error(`Method ${method.toUpperCase()} for endpoint ${endpoint} not found in ${openapiPath}`);
135
- }
128
+ const isWebhook = method.toLowerCase() === 'webhook';
136
129
  const tempNav = [];
137
130
  const tempDecoratedNav = [];
138
131
  const writePromises = [];
139
- processOpenApiPath(endpoint, { [method.toLowerCase()]: opObject }, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
140
- openApiFilePath: openApiFile.originalFileLocation,
141
- writeFiles,
142
- outDir: DEFAULT_OUTPUT_DIR,
143
- outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
144
- overwrite,
145
- localSchema,
146
- }, findNavGroup);
132
+ if (isWebhook) {
133
+ const webhookObject = schema.webhooks?.[endpoint];
134
+ if (!webhookObject || typeof webhookObject !== 'object') {
135
+ throw new Error(`Webhook ${endpoint} not found in ${openapiPath}`);
136
+ }
137
+ processOpenApiWebhook(endpoint, webhookObject, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
138
+ openApiFilePath: openApiFile.originalFileLocation,
139
+ writeFiles,
140
+ outDir: DEFAULT_OUTPUT_DIR,
141
+ outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
142
+ overwrite,
143
+ localSchema,
144
+ }, findNavGroup);
145
+ }
146
+ else {
147
+ const pathItemObject = (schema.paths ?? {})[endpoint];
148
+ if (!pathItemObject || typeof pathItemObject !== 'object') {
149
+ throw new Error(`Endpoint ${endpoint} not found in ${openapiPath}`);
150
+ }
151
+ const opObject = pathItemObject[method.toLowerCase()];
152
+ if (!opObject) {
153
+ throw new Error(`Method ${method.toUpperCase()} for endpoint ${endpoint} not found in ${openapiPath}`);
154
+ }
155
+ processOpenApiPath(endpoint, { [method.toLowerCase()]: opObject }, schema, tempNav, tempDecoratedNav, writePromises, pagesAcc, {
156
+ openApiFilePath: openApiFile.originalFileLocation,
157
+ writeFiles,
158
+ outDir: DEFAULT_OUTPUT_DIR,
159
+ outDirBasePath: path.join(targetDir ?? '', 'src', '_props'),
160
+ overwrite,
161
+ localSchema,
162
+ }, findNavGroup);
163
+ }
147
164
  await Promise.all(writePromises);
148
165
  let slug;
149
166
  const firstEntry = tempNav[0];