Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Latest commit

 

History

History

chain-wrap-components

@dsaidgovsg/chain-wrap-components

This provides a helper function for Swagger UI, it allows:

  • Use of chainWrapComponents(plugin1, plugin2...) to enable chaining for multiple plugins with the same components in wrapComponents.
  • Add support to e.g. swagger-ui v4.18.3, pluginsOptions: {pluginLoadType: "chain"} does not support chaining in wrapComponents.

Prerequisites

Install

Add github npm registry to .npmrc,

# .npmrc
always-auth = true
@dsaidgovsg:registry=https://npm.pkg.github.com

Install the package,

$ npm install @dsaidgovsg/chain-wrap-components

Usage

import otpAuthPlugin from '@dsaidgovsg/swagger-ui-plugin-otp-auth'
import samlAuthPlugin from '@dsaidgovsg/swagger-ui-plugin-saml-auth'
import chainWrapComponents from '@dsaidgovsg/chain-wrap-components'

// swagger-ui initialization
  SwaggerUI({
    plugins: [
      // otpAuthPlugin and samlAuthPlugin both overriding wrapComponenrs
      // e.g. wrapComponents: {AuthItem: ...}
      chainWrapComponents(otpAuthPlugin, samlAuthPlugin),
      ...
    ]
  })