Scalar OpenAPI Parser
Modern OpenAPI parser written in TypeScript, with support for Swagger 2.0, OpenAPI 3.0 and OpenAPI 3.1
Installation
npm add @scalar/openapi-parser
Usage
Parse
import { dereference } from '@scalar/openapi-parser'
const file = `{
"openapi": "3.1.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {}
}`
const result = await dereference(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)
}
Version
import { dereference } from '@scalar/openapi-parser'
const file = `{
"openapi": "3.1.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {}
}`
const result = await dereference(file)
console.log(result.version)