whook-swagger-ui

0.0.0 • Public • Published

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

Param Type Description
initHTTPRouter function The httpRouter initializer

Authors

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i whook-swagger-ui

Weekly Downloads

2

Version

0.0.0

License

MIT

Unpacked Size

15.4 kB

Total Files

5

Last publish

Collaborators

  • nfroidure