Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

feat: throw on error #138

Merged
merged 7 commits into from
Jun 21, 2024
Merged

feat: throw on error #138

merged 7 commits into from
Jun 21, 2024

Conversation

hanspagel
Copy link
Member

@hanspagel hanspagel commented Jun 20, 2024

With this PR, we’re introducing the new option throwOnError which can be passed to openapi(), validate() and dereference() to make them throw an exception on the first error that they find.

The default is still to just deal with whatever is passed, but for some use cases we might want a stricter version.

Inspiration: #136

Note: This also adds the opportunity to add more options in the future. 👀

import { validate } from '@scalar/openapi-parser'

const specification = 

validate(specification, {
  throwOnError: true,
})
.then(result => {
  // Success
})
.catch(error => {
  // Failure
})

Copy link

changeset-bot bot commented Jun 20, 2024

🦋 Changeset detected

Latest commit: 10595a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@scalar/openapi-parser Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

cloudflare-workers-and-pages bot commented Jun 20, 2024

Deploying openapi-parser with  Cloudflare Pages  Cloudflare Pages

Latest commit: 10595a3
Status: ✅  Deploy successful!
Preview URL: https://3cb6130b.openapi-parser.pages.dev
Branch Preview URL: https://feat-throw-on-error.openapi-parser.pages.dev

View logs

Copy link

relativeci bot commented Jun 20, 2024

#109 Bundle Size — 116.41KiB (+1.7%).

10595a3(current) vs 21b6fc0 main#98(baseline)

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#109
     Baseline
#98
Regression  Initial JS 116.41KiB(+1.7%) 114.45KiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 9.83% 0%
No change  Chunks 45 45
No change  Assets 45 45
No change  Modules 45 45
No change  Duplicate Modules 0 0
No change  Duplicate Code 0% 0%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#109
     Baseline
#98
Regression  JS 116.41KiB (+1.7%) 114.45KiB

Bundle analysis reportBranch feat/throw-on-errorProject dashboard

@hanspagel hanspagel marked this pull request as ready for review June 20, 2024 15:15
@hanspagel hanspagel requested a review from marclave June 20, 2024 15:15
Copy link
Member

@marclave marclave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!

@hanspagel hanspagel merged commit 89dd0ef into main Jun 21, 2024
9 checks passed
@hanspagel hanspagel deleted the feat/throw-on-error branch June 21, 2024 08:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants