Search code examples
swaggerswagger-2.0swagger-editor

Disable "Generate Server/Client" inside Swagger Editor


After every start of Swagger Editor, the javascript api sends out two HTTP requests to

  1. https://generator.swagger.io/api/gen/servers

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

to render the navigation sections Generate server and Generate clients.

Because of only internal using, I doesn't need the functions for generating of server and client.

How to disable the requests and the rendering for both navigation sections?

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>

Solution

  • Add swagger2GeneratorUrl: null and oas3GeneratorUrl: null to the SwaggerEditorBundle initialization code:

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