Skip to content

Commit

Permalink
fix(openapi): add spinner catch statement (#961)
Browse files Browse the repository at this point in the history
fix: add spinner catch statement
  • Loading branch information
kanadgupta authored Jan 9, 2024
1 parent 09734da commit 4669b29
Showing 1 changed file with 14 additions and 7 deletions.
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

0 comments on commit 4669b29

Please sign in to comment.