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

chore: continue openapi imports on error with a partial import #4535

Merged
Merged
Changes from 1 commit
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
Next Next commit
fix: continue parsing openapi doc instead of failing
  • Loading branch information
amk-dev authored and jamesgeorge007 committed Nov 25, 2024
commit 34e8e218d76bd1514aa82bd011a5138d1edcbcb1
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,26 @@ export const hoppOpenAPIImporter = (fileContents: string[]) =>
const resultDoc = []

for (const docObj of docArr) {
const validatedDoc = await SwaggerParser.validate(docObj)
resultDoc.push(validatedDoc)
try {
const validatedDoc = await SwaggerParser.validate(docObj, {
// @ts-expect-error - this is a valid option, but seems like the types are not updated
continueOnError: true,
})

resultDoc.push(validatedDoc)
} catch (err) {
if (
// @ts-expect-error the type for err is not exported from the library
err.files &&
// @ts-expect-error the type for err is not exported from the library
err.files instanceof SwaggerParser &&
// @ts-expect-error the type for err is not exported from the library
err.files.schema
) {
// @ts-expect-error the type for err is not exported from the library
resultDoc.push(err.files.schema)
}
}
}

return resultDoc
Expand Down