Files
swagger-ui/docs/customization/plug-points.md
Helen Kosova 8822a7229a Change Swagger-UI -> Swagger UI in docs (#5479)
* Change Swagger-UI -> Swagger UI in docs

* Changed back to SwaggerUI in places that refer to JS construct
2019-07-19 09:22:45 -06: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 changing.

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)
        })
      }
    }
  }
}