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(openapi): add spinner catch statement #961

Merged
merged 1 commit into from
Jan 9, 2024
Merged
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
21 changes: 14 additions & 7 deletions src/lib/prepareOas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,20 @@ export default async function prepareOas(
// And though `.validate()` will run `.load()` itself running `.load()` here will not have any
// performance implications as `oas-normalizes` caches the result of `.load()` the first time you
// run it.
const { specType, definitionVersion } = await oas.load().then(async schema => {
const type = getAPIDefinitionType(schema);
return {
specType: capitalizeSpecType(type),
definitionVersion: await oas.version(),
};
});
const { specType, definitionVersion } = await oas
.load()
.then(async schema => {
const type = getAPIDefinitionType(schema);
return {
specType: capitalizeSpecType(type),
definitionVersion: await oas.version(),
};
})
.catch((err: Error) => {
spinner.fail();
debug(`raw oas load error object: ${JSON.stringify(err)}`);
throw err;
});

// If we were supplied a Postman collection this will **always** convert it to OpenAPI 3.0.
let api: OpenAPI.Document = await oas.validate({ convertToLatest: opts.convertToLatest }).catch((err: Error) => {
Expand Down