0.4.1 • Published 6 years ago

openapi-parse v0.4.1

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

openapi-parse

Basic parser for OpenAPI specs. This is a thin wrapper around existing libraries. If you need more power/flexibility, check out Swagger/OpenAPI Parser, JSON Schema $Ref Parser, or swagger2openapi.

Installation

npm i openapi-parse

or

yarn add openapi-parse

Usage

import parse from 'openapi-parse'
// or const parse = require('openapi-parse').default

const options = { ... }
const specPathOrSchemaObject = ... // specify Swagger/OpenAPI spec path or a loaded schema object

const result = await parse(options)(specPathOrSchemaObject)

Options

OptionDefault ValueDescription
basePathnullUsed as the base path for relative references within the spec.
dereference.mode['none']Set to an array of dereference modes. Possible mode values are none (no references will be dereferenced), external (only external references will be dereferenced), and all (both external and internal references will be dereferenced). The result will be an array of schemas, one for each mode specified.
dereference.resolve(original, result) => result[0]After dereferencing, the result collection is passed to the specified resolve function. The resolve function also receives the original loaded schema, the return value will be used as the final dereferenced schema.
upgrade.enabledfalseIf enabled, OpenAPI 2.0 specs will be automatically upgraded to OpenAPI 3.0 using swagger2openapi.
upgrade.options{}These options are passed down to swagger2openapi. More info.
parser.canParsefileInfo => falseReceives { path, extension, data } about referenced content. You can override and return true if you can parse the provided file information. More info.
parser.parseasync fileInfo => {}Receives { path, extension, data } about referenced content. You can override to implement a parser for the specified content. More info.
resolver.canResolvefileInfo => falseReceives { path, extension } about referenced content. You can override and return true if you are able to resolve the path. More info.
resolver.resolveasync fileInfo => {}Receives { path, extension } about referenced content. You can override to implement a resolver for the specified content. More info.
0.4.1

6 years ago

0.3.0

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.1

6 years ago