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 inwrapComponents
. - Add support to e.g.
swagger-ui v4.18.3
,pluginsOptions: {pluginLoadType: "chain"}
does not support chaining inwrapComponents
.
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
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),
...
]
})