Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 827
Good Samartian Avatar asked Mar 27 '18 14:03

Good Samartian


People also ask

How do I disable OpenAPI?

You can disable OpenAPI docs by setting openapi_url to an empty string.

What is swagger petstore?

title: Swagger Petstore - OpenAPI 3.0. description: |- This is a sample Pet Store Server based on. the OpenAPI 3.0 specification.

How do I turn off swagger in production?

To set up Swagger with Spring, we define it in a configuration bean. By default, this configuration bean is always injected into our Spring context. Thus, Swagger becomes available for all environments. To disable Swagger in production, let's toggle whether this configuration bean is injected.

What is the default swagger URL?

The generated document describing the endpoints appears as shown in OpenAPI specification (openapi. json). The Swagger UI can be found at https://localhost:<port>/swagger .


1 Answers

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
    
like image 99
Helen Avatar answered Sep 21 '22 21:09

Helen