Package Exports
- exegesis
- exegesis/lib/types/index
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (exegesis) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Exegesis OpenAPI Engine
exegesis
n. An explanation or critical interpretation of a text, especially an API definition document.
-- No dictionary ever
This library implements a framework-agnostic server side implementation of OpenAPI 3.x.
You probably don't want to be using this library directly. Have a look at:
- exegesis-express - Middleware for serving OpenAPI 3.x APIs from express.
- exegesis-connect - Middleware for serving OpenAPI 3.x APIs from connect.
WARNING
🚨🚨 This is super beta. 🚨🚨
This is very much a work in progress. Wait for the v1.0.0 release, coming soon! :)
Usage
import * as path from 'path';
import * as http from 'http';
import * as exegesis from 'exegesis';
// See https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md
const options = {
controllers: path.resolve(__dirname, './src/controllers')
};
// `compileApi()` can either be used with a callback, or if none is provided,
// will return a Promise.
exegesis.compileApi(
path.resolve(__dirname, './openapi/openapi.yaml'),
options,
(err, middleware) => {
if(err) {
console.error("Error creating middleware", err.stack);
process.exit(1);
}
const server = http.createServer(
(req, res) =>
middleware(req, res, (err) => {
if(err) {
res.writeHead(err.status || 500);
res.end(`Internal error: ${err.message}`);
} else {
res.writeHead(404);
res.end();
}
})
);
server.listen(3000);
}
);
See options documentation for details about options.