Giter Club home page Giter Club logo

openapi-parse's Introduction

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

Option Default Value Description
basePath null Used 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.enabled false If 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.canParse fileInfo => false Receives { path, extension, data } about referenced content. You can override and return true if you can parse the provided file information. More info.
parser.parse async fileInfo => {} Receives { path, extension, data } about referenced content. You can override to implement a parser for the specified content. More info.
resolver.canResolve fileInfo => false Receives { path, extension } about referenced content. You can override and return true if you are able to resolve the path. More info.
resolver.resolve async fileInfo => {} Receives { path, extension } about referenced content. You can override to implement a resolver for the specified content. More info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.