1.0.2 • Published 6 years ago

@bb-cli/bb-convert-plugin-searchable v1.0.2

Weekly downloads
16
License
-
Repository
-
Last release
6 years ago

BB-Convert Searchable plugin middleware

This plugin will make any HTTP GET service method from RAML specification which has configured search query parameter (query by default) to respect it. Those methods will return filtered by the provided value.

This plugin will only be applied in mock template.

Install alongside bb-convert (prefer global)

npm i -g @bb-cli/bb-convert-plugin-searchable

Usage

bb-convert raml --transform-plugins @bb-cli/bb-convert-plugin-searchable --template mock-ng
# OR
bb-convert raml --transform-plugins searchable --template mock-ng

Configure in .bbconfig

Searchable plugin can be configured in _.bbconfig_file:

{
  "default": {
    "convert": {
      "raml": {
        "transform-plugins": "searchable"
      }
    }
  }
}

With this configuration in place, you can simply run

bb-convert raml --template mock-ng

Customization

It is possible to customize search query parameter name as well as list of properties to search upon.

// Custom plugin code example

const searchable = require('@bb-cli/bb-convert-plugin-searchable');

const queryParameterName = 'searchTerm';
const searchFields = "'name', 'IBAN'";

module.exports = searchable.pluginFnFactory(queryParameterName, searchFields);