@mintlify/prebuild
Advanced tools
Comparing version 1.0.100 to 1.0.101
import { openApiCheck } from '@mintlify/common'; | ||
import { readFile } from 'fs/promises'; | ||
import yaml from 'js-yaml'; | ||
import * as path from 'path'; | ||
@@ -30,11 +32,16 @@ import { getFileList } from '../fs/index.js'; | ||
case 'yml': | ||
const doc = await openApiCheck(path.join(contentDirectoryPath, filename)); | ||
if (!doc) { | ||
break; | ||
try { | ||
// we need to read from the fs so we can store the original spec | ||
const str = await readFile(path.join(contentDirectoryPath, filename), 'utf8'); | ||
const obj = extension === 'json' ? JSON.parse(str) : yaml.load(str); | ||
// openApiCheck modifies the spec in place - copy before | ||
if (!(await openApiCheck(structuredClone(obj)))) | ||
break; | ||
const fileName = path.parse(filename).base; | ||
openApiFiles.push({ | ||
filename: fileName.substring(0, fileName.lastIndexOf('.')), | ||
spec: obj, | ||
}); | ||
} | ||
const fileName = path.parse(filename).base; | ||
openApiFiles.push({ | ||
filename: fileName.substring(0, fileName.lastIndexOf('.')), | ||
spec: doc, | ||
}); | ||
catch { } // not an openapi spec | ||
break; | ||
@@ -41,0 +48,0 @@ default: |
@@ -1,3 +0,2 @@ | ||
import SwaggerParser from '@apidevtools/swagger-parser'; | ||
import { hasImports, findAndRemoveImports } from '@mintlify/common'; | ||
import { hasImports, findAndRemoveImports, openApiCheck } from '@mintlify/common'; | ||
import { promises as _promises } from 'fs'; | ||
@@ -101,4 +100,4 @@ import { outputFile } from 'fs-extra'; | ||
mintConfig.openapi.startsWith('http')) { | ||
try { | ||
const specFromUrl = await SwaggerParser.validate(mintConfig.openapi); | ||
const specFromUrl = await openApiCheck(mintConfig.openapi, true); | ||
if (specFromUrl) { | ||
this.openApiFiles.push({ | ||
@@ -109,4 +108,4 @@ filename: 'openapi-from-url', | ||
} | ||
catch (e) { | ||
console.log("OpenApi file couldn't be downloaded from url.", e); | ||
else { | ||
console.log("OpenApi file couldn't be downloaded from url."); | ||
} | ||
@@ -113,0 +112,0 @@ } |
{ | ||
"name": "@mintlify/prebuild", | ||
"type": "module", | ||
"version": "1.0.100", | ||
"version": "1.0.101", | ||
"description": "Helpful functions for Mintlify's prebuild step", | ||
@@ -45,3 +45,3 @@ "author": "Mintlify, Inc.", | ||
"@apidevtools/swagger-parser": "10.x", | ||
"@mintlify/common": "1.0.34", | ||
"@mintlify/common": "1.0.35", | ||
"@mintlify/validation": "0.1.113", | ||
@@ -52,2 +52,3 @@ "favicons": "^7.0.2", | ||
"is-absolute-url": "^4.0.1", | ||
"js-yaml": "^4.1.0", | ||
"openapi-types": "12.x", | ||
@@ -76,3 +77,3 @@ "unist-util-visit": "^4.1.1" | ||
}, | ||
"gitHead": "313ee51ddee037b95d495b16bd3df1c8d309143a" | ||
"gitHead": "fbfceeb3e1431daa3d192dd980436fa8aa3f1716" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106652
828
10
15
+ Addedjs-yaml@^4.1.0
+ Added@mintlify/common@1.0.35(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedjs-yaml@4.1.0(transitive)
- Removed@mintlify/common@1.0.34(transitive)
Updated@mintlify/common@1.0.35