Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue where OpenAPI blocks can break due to an invalid positiveInteger check. #2836

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Log more errors
  • Loading branch information
emmerich committed Feb 14, 2025
commit 808eac23441d2d9a0141ca8b0f827a3bb843a1cd
38 changes: 22 additions & 16 deletions packages/openapi-parser/src/v3.ts
Original file line number Diff line number Diff line change
@@ -19,24 +19,30 @@ export async function parseOpenAPIV3(input: {
rootURL: string | null;
}): Promise<Filesystem<OpenAPIV3xDocument>> {
const { value, rootURL } = input;
const result = await validate(value);

// Spec is invalid, we stop here.
if (!result.specification) {
throw new OpenAPIParseError('Invalid OpenAPI document', {
code: 'invalid',
rootURL,
});
}
try {
const result = await validate(value);
// Spec is invalid, we stop here.
if (!result.specification) {
throw new OpenAPIParseError('Invalid OpenAPI document', {
code: 'invalid',
rootURL,
});
}

if (result.version === '2.0') {
throw new OpenAPIParseError('Only OpenAPI v3 is supported', {
code: 'parse-v2-in-v3',
rootURL,
});
}
if (result.version === '2.0') {
throw new OpenAPIParseError('Only OpenAPI v3 is supported', {
code: 'parse-v2-in-v3',
rootURL,
});
}

const filesystem = await createFileSystem({ value: result.specification, rootURL });
const filesystem = await createFileSystem({ value: result.specification, rootURL });

return filesystem;
return filesystem;
} catch (err) {
console.error(err);
console.trace();
throw err;
}
}
Loading
Oops, something went wrong.