Package Exports
- @scalar/openapi-parser
- @scalar/openapi-parser/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@scalar/openapi-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Scalar OpenAPI Parser
Modern OpenAPI parser written in TypeScript, with support for Swagger 2.0, OpenAPI 3.0 and OpenAPI 3.1
Goals
- TypeScript FTW
- No Node.js polyfills required
- Well tested
- Small bundlesize
- Better errors
- Support for OpenAPI 4.0 👀
Installation
npm add @scalar/openapi-parser
Usage
Parse
import { parse } from '@scalar/openapi-parser'
const file = `{
"openapi": "3.1.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {}
}`
const result = await parse(file)
Validate
import { validate } from '@scalar/openapi-parser'
const file = `{
"openapi": "3.1.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {}
}`
const result = await validate(file)
console.log(result.valid)
if (!result.valid) {
console.log(result.errors)
}