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
npm install --save listener-from-oas3
yarn add listener-from-oas3
The signature for handlers is
async myHandler(ctx)
The ctx object is the same as the koa ctx object but also includes:
Object where each property is the name of a path parameter applicable to the operation and it's provided value.
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
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
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)
}
releases are versioned according to and tagged; see CHANGELOG.md for release notes
see CONTRIBUTING.md