Search code examples
swagger-editor

Remove petstore spec when starting swagger editor


I am using Swagger Editor locally in my machine.

When I start the Swagger Editor, it shows the spec for petstore by default at startup.

I want to remove that and show a blank editor. Is there a way to do that at startup.


Solution

  • A simple workaround is to run the editor with the ?url= parameter where the URL points to an empty page (no HTTP response body), such as http://httpbin.org/status/200.

    http://editor.swagger.io/?url=http://httpbin.org/status/200

    This will open a blank editor.


    Alternatively, you can modify the editor's source code and build your own version. You will need Node.js 6.x and npm 3.x (as of time of this writing).

    The default editor contents seems to be set here: https://github.com/swagger-api/swagger-editor/blob/master/src/plugins/local-storage/index.js#L29

    1. In src\plugins\local-storage\index.js, replace

      import PetstoreYaml from "./petstore"
      

      with

      const PetstoreYaml = ""
      
    2. Rebuild the editor:

      npm run build