@mintlify/prebuild 1.0.412 → 1.0.414

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,5 +1,5 @@
1
1
  import { openApiCheck } from '@mintlify/common';
2
- import { asyncApiCheck } from '@mintlify/common/asyncapi';
2
+ import { validateAsyncApi } from '@mintlify/common/asyncapi';
3
3
  import { readFile } from 'fs/promises';
4
4
  import yaml from 'js-yaml';
5
5
  import * as path from 'path';
@@ -31,31 +31,38 @@ export const categorizeFilePaths = async (contentDirectoryPath) => {
31
31
  case 'json':
32
32
  case 'yaml':
33
33
  case 'yml':
34
- try {
35
- // we need to read from the fs so we can store the original spec
36
- const str = await readFile(path.join(contentDirectoryPath, filename), 'utf8');
37
- const obj = yaml.load(str);
38
- const isOpenApi = await openApiCheck(obj);
39
- const isAsyncApi = await asyncApiCheck(obj);
40
- if (!isOpenApi && !isAsyncApi)
41
- break;
42
- const fileName = path.parse(filename).name;
43
- if (isOpenApi) {
44
- openApiFiles.push({
45
- filename: fileName,
46
- spec: obj,
47
- originalFileLocation: filename,
48
- });
34
+ const filePath = path.join(contentDirectoryPath, filename);
35
+ const str = await readFile(filePath, 'utf8');
36
+ const obj = yaml.load(str);
37
+ const isOpenApi = Object.keys(obj).includes('openapi');
38
+ const isAsyncApi = Object.keys(obj).includes('asyncapi');
39
+ const fileName = path.parse(filename).name;
40
+ if (isOpenApi) {
41
+ try {
42
+ const openApiDocument = await openApiCheck(obj);
43
+ if (openApiDocument) {
44
+ openApiFiles.push({
45
+ filename: fileName,
46
+ spec: openApiDocument,
47
+ originalFileLocation: filename,
48
+ });
49
+ }
49
50
  }
50
- if (isAsyncApi) {
51
- asyncApiFiles.push({
52
- filename: fileName,
53
- spec: obj,
54
- originalFileLocation: filename,
55
- });
51
+ catch { }
52
+ }
53
+ if (isAsyncApi) {
54
+ try {
55
+ const { document: asyncApiDocument } = await validateAsyncApi(str);
56
+ if (asyncApiDocument) {
57
+ asyncApiFiles.push({
58
+ filename: fileName,
59
+ spec: asyncApiDocument,
60
+ originalFileLocation: filename,
61
+ });
62
+ }
56
63
  }
64
+ catch { }
57
65
  }
58
- catch { }
59
66
  break;
60
67
  default:
61
68
  staticFilenames.push(filename);