Files
swagger-ui/docs/customization/plug-points.md
PoojaChandak 959b48ad3d docs: various minor grammatical changes (#6284)
* Update README.md
* Update setting-up.md
* Update plug-points.md
* Update plugin-api.md
* Update configuration.md
* Update deep-linking.md
* Update installation.md


Co-authored-by: Tim Lai <timothy.lai@gmail.com>
2020-08-24 16:54:48 -07:00

1.3 KiB
Raw Blame History

Plug points

Swagger UI exposes most of its internal logic through the plugin system.

Often, it is beneficial to override the core internals to achieve custom behavior.

Note: Semantic Versioning

Swagger UIs internal APIs are not part of our public contract, which means that they can change without the major version change.

If your custom plugins wrap, extend, override, or consume any internal core APIs, we recommend specifying a specific minor version of Swagger UI to use in your application, because they will not change between patch versions.

If youre installing Swagger UI via NPM, for example, you can do this by using a tilde:

{
  "dependencies": {
    "swagger-ui": "~3.11.0"
  }
}

fn.opsFilter

When using the filter option, tag names will be filtered by the user-provided value. If youd like to customize this behavior, you can override the default opsFilter function.

For example, you can implement a multiple-phrase filter:

const MultiplePhraseFilterPlugin = function() {
  return {
    fn: {
      opsFilter: (taggedOps, phrase) => {
        const phrases = phrase.split(", ")

        return taggedOps.filter((val, key) => {
          return phrases.some(item => key.indexOf(item) > -1)
        })
      }
    }
  }
}