您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

plug-points.md 1.3 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Plug points
  2. Swagger UI exposes most of its internal logic through the plugin system.
  3. Often, it is beneficial to override the core internals to achieve custom behavior.
  4. ### Note: Semantic Versioning
  5. Swagger UI's internal APIs are _not_ part of our public contract, which means that they can change without the major version changing.
  6. 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.
  7. If you're installing Swagger UI via NPM, for example, you can do this by using a tilde:
  8. ```js
  9. {
  10. "dependencies": {
  11. "swagger-ui": "~3.11.0"
  12. }
  13. }
  14. ```
  15. ### `fn.opsFilter`
  16. When using the `filter` option, tag names will be filtered by the user-provided value. If you'd like to customize this behavior, you can override the default `opsFilter` function.
  17. For example, you can implement a multiple-phrase filter:
  18. ```js
  19. const MultiplePhraseFilterPlugin = function() {
  20. return {
  21. fn: {
  22. opsFilter: (taggedOps, phrase) => {
  23. const phrases = phrase.split(", ")
  24. return taggedOps.filter((val, key) => {
  25. return phrases.some(item => key.indexOf(item) > -1)
  26. })
  27. }
  28. }
  29. }
  30. }
  31. ```