scalar / openapi-parser

Modern OpenAPI parser written in TypeScript
MIT License
26 stars 7 forks source link

feat: throw on error #138

Closed hanspagel closed 3 weeks ago

hanspagel commented 3 weeks ago

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
})
changeset-bot[bot] commented 3 weeks ago

πŸ¦‹ Changeset detected

Latest commit: 10595a3de46c2a27596b7550d2de78df72421d65

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

cloudflare-pages[bot] commented 3 weeks ago

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

relativeci[bot] commented 3 weeks ago

#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](https://app.relative-ci.com/projects/hXQ54UQKluDUZAKvpt9b/jobs/109-theHqbBwoh3bU3BlWLDP?utm_source=github&utm_medium=pr-report "View bundle analysis report") |      Baseline
[#98](https://app.relative-ci.com/projects/hXQ54UQKluDUZAKvpt9b/jobs/98-AK38bFH6L3Gd2tbS4tVd?utm_source=github&utm_medium=pr-report "View baseline bundle analysis report") | |:--|--:|--:| | Regression  [JS](https://app.relative-ci.com/projects/hXQ54UQKluDUZAKvpt9b/jobs/109-theHqbBwoh3bU3BlWLDP/assets?ba=%7B%22filters%22%3A%22ft.CSS-0_ft.JS-1_ft.IMG-0_ft.MEDIA-0_ft.FONT-0_ft.HTML-0_ft.OTHER-0%22%7D "View JS assets") | `116.41KiB` (`+1.7%`) | `114.45KiB` |

Bundle analysis report Branch feat/throw-on-error Project dashboard