0.0.0 • Published 5 years ago

whook-swagger-ui v0.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

whook-swagger-ui

An httpRouter wrapper to provider SwaggerUI for local dev

GitHub license NPM version Dependency Status devDependency Status Package Quality

To use it, just wrap the HTTP router with this module and register it again with the Knifecycle instance inside the runServer function:

import Knifecycle from 'knifecycle';
import {
  runServer as runBaseServer,
  prepareServer as prepareBaseServer,
} from 'whook';
import { initHTTPRouter } from 'swagger-http-router';
import wrapHTTPRouterWithSwaggerUI from 'whook-swagger-ui';

// It is important to do this in the runServer function since it really
//  make sense only when actually running the server
export async function runServer(injectedNames = [], $ = new Knifecycle()) {
  $.register(
    wrapHTTPRouterWithSwaggerUI(initHTTPRouter),
  );

  return await runBaseServer(injectedNames, $);
}

export const prepareServer = prepareBaseServer;

API

wrapHTTPRouterWithSwaggerUI(initHTTPRouter) ⇒ function

Wraps the httpRouter initializer to also serve the Swagger/OpenAPI UI for development purpose.

Kind: global function
Returns: function - The httpRouter initializer wrapped

ParamTypeDescription
initHTTPRouterfunctionThe httpRouter initializer

Authors

License

MIT