在Swagger编辑器中禁用“生成服务器/客户端”

时间:2019-08-27 14:55:28

标签: swagger swagger-2.0 swagger-editor

每次启动Swagger编辑器后,javascript api都会向

发送两个HTTP请求
  1. https://generator.swagger.io/api/gen/servers

  2. https://generator.swagger.io/api/gen/clients

呈现导航部分Generate serverGenerate clients

由于仅内部使用,因此不需要用于生成服务器和客户端的功能。

如何禁用两个导航部分的请求和呈现?

index.html

  <script src="./dist/swagger-editor-bundle.js"> </script>
  <script src="./dist/swagger-editor-standalone-preset.js"> </script>
  <script src="./dist/spec.js"> </script>
  <script>
  window.onload = function() {
    const editor = SwaggerEditorBundle({
      spec: spec,
      dom_id: '#swagger-editor',
      layout: 'StandaloneLayout',
      presets: [
        SwaggerEditorStandalonePreset
      ]
    })

    window.editor = editor
  }
  </script>

1 个答案:

答案 0 :(得分:0)

swagger2GeneratorUrl: nulloas3GeneratorUrl: null添加到SwaggerEditorBundle初始化代码中:

    const editor = SwaggerEditorBundle({
      spec: spec,
      dom_id: '#swagger-editor',
      layout: 'StandaloneLayout',
      presets: [
        SwaggerEditorStandalonePreset
      ],
      swagger2GeneratorUrl: null,  // <-----
      oas3GeneratorUrl: null       // <-----
    })