@readyapi/openapi-parser
v0.3.3
Published
modern OpenAPI parser written in TypeScript
Downloads
17
Maintainers
Readme
KhulnaSoft OpenAPI Parser
Modern OpenAPI parser written in TypeScript, with support for Swagger 2.0, OpenAPI 3.0 and OpenAPI 3.1
Installation
npm add @readyapi/openapi-parser
Usage
Parse
import { resolve } from '@readyapi/openapi-parser'
const file = `{
"openapi": "3.1.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {}
}`
const result = await resolve(file)
Validate
import { validate } from '@readyapi/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 { resolve } from '@readyapi/openapi-parser'
const file = `{
"openapi": "3.1.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {}
}`
const result = await resolve(file)
console.log(result.version)