Package Exports
- openapi-factory
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 (openapi-factory) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
OpenAPI Factory (Javascript)
API as first class node library to generate clients, servers, and documentation. To simplify the creation and management of serverless cloud API, manage the server and api using the OpenAPI Factory.
Create an API
var ApiFactory = require('openapi-factory');
var api = new ApiFactory();
api.get('/example', request => {
// which auto wraps => body: { value: 'test' }, statusCode => 200, headers => application/json
return { value: 'test' };
// or non-wrap coerce
return {
body: { value: 'testWithStatus' },
statusCode: 200,
headers: { 'Content-Type': 'application/json'}
};
// a static type
return new ApiFactory.response({ value: 'testWithStatus' }, 200, { 'Content-Type': 'application/json'});
});
// converts dynamic variables paths
api.get('/example/{id}/subpath', request => {
let idFromPath = request.pathParameters.id;
});
api.setAuthorizer(request => {
return 'valid-policy-doument';
});
api.onEvent(event => {
console.log('triggered by event trigger');
});
api.onSchedule(data => {
console.log('triggered by a schedule');
});
api.get('/items/{itemid}', (request) => {
console.log(request.pathParameters.itemId);
new ApiFactory.Response({ value: 'testWithStatus' }, 200, { 'Content-Type': 'application/json'});
});