mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-22 05:05:23 +00:00
Fix OpenAPI v2 parsing (#3498)
This commit is contained in:
@@ -35,6 +35,13 @@ async function untrustedValidate(input: ValidateOpenAPIV3Input) {
|
||||
const { value, rootURL } = input;
|
||||
const result = await validate(value);
|
||||
|
||||
if (result.version === '2.0') {
|
||||
throw new OpenAPIParseError('Only OpenAPI v3 is supported', {
|
||||
code: 'parse-v2-in-v3',
|
||||
rootURL,
|
||||
});
|
||||
}
|
||||
|
||||
// Spec is invalid, we stop here.
|
||||
if (!result.valid) {
|
||||
throw new OpenAPIParseError('Invalid OpenAPI document', {
|
||||
@@ -44,13 +51,6 @@ async function untrustedValidate(input: ValidateOpenAPIV3Input) {
|
||||
});
|
||||
}
|
||||
|
||||
if (result.version === '2.0') {
|
||||
throw new OpenAPIParseError('Only OpenAPI v3 is supported', {
|
||||
code: 'parse-v2-in-v3',
|
||||
rootURL,
|
||||
});
|
||||
}
|
||||
|
||||
return result.specification;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user