Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

chrisdostert/listener-from-oas3-js

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Build Status Coverage

Be advised: this project is currently at Major version zero. Per the semantic versioning spec: "Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable."

Javascript library which generates a native http server listener from a v3 open api spec

Installation

NPM

npm install --save listener-from-oas3

Yarn

yarn add listener-from-oas3

Handlers

The signature for handlers is async myHandler(ctx)

The ctx object is the same as the koa ctx object but also includes:

ctx.parameters.path

Object where each property is the name of a path parameter applicable to the operation and it's provided value.

ctx.parameters.query

Object where each property is the name of a query parameter applicable to the operation and it's provided value.

parameters declared w/ application/json content will be deserialized

ctx.security

Object where each property is the name of a security definition applicable to the operation and it's provided value.

for oauth2, value will be the bearer token string

for http bearer, value will be the bearer token string

for http basic, value will be a {userId, password} object

Examples

Basic usage

const getRequestListener = require('listener-from-oas3')
const http = require('http')

async function listen(port) {
  const requestListener = await getRequestListener(
    `${__dirname}/openapi.yaml`,
    // resolve handlers from `${__dirname}/${operation-path}/${operation-method}`
    __dirname
  )

  http
    .createServer(requestListener)
    .listen(port)
}

Support

open an issue

Releases

releases are versioned according to semver 2.0.0 and tagged; see CHANGELOG.md for release notes

Contributing

see CONTRIBUTING.md

About

Javascript library which generates a native http server listener from a v3 open api spec

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published