You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启动Swagger Editor时移除默认Petstore规格的方法

How to Launch Swagger Editor Locally with a Blank Workspace

Absolutely, you can totally configure your local Swagger Editor to start with a blank workspace instead of the default Petstore API specification. Below are tailored methods based on how you're running the editor:

1. For npm-installed Swagger Editor (Local Development Setup)

If you installed Swagger Editor via npm and run it locally, follow these steps:

  • Locate the configuration file at swagger-editor/config/defaults.json in your installation directory.
  • Find the defaultDefinition key in this JSON file. Replace its existing Petstore-linked value with a minimal empty OpenAPI structure:
    {
      "openapi": "3.0.0",
      "info": {
        "title": "",
        "version": ""
      },
      "paths": {}
    }
    
  • Save the file and restart your Swagger Editor instance. It will now launch with this empty, valid OpenAPI skeleton ready for your edits.

2. For Docker-run Swagger Editor

If you're using Docker to run Swagger Editor, pass an environment variable to override the default spec:

  • Use this modified docker run command to start the editor with an empty workspace:
    docker run -p 8080:8080 -e SWAGGER_EDITOR_DEFAULT_DEFINITION='{"openapi":"3.0.0","info":{"title":"","version":""},"paths":{}}' swaggerapi/swagger-editor
    
  • The SWAGGER_EDITOR_DEFAULT_DEFINITION variable injects the empty OpenAPI structure directly, so the editor loads it on startup instead of Petstore.

3. For Static Swagger Editor (Local HTML File)

If you downloaded the static Swagger Editor files and open index.html directly in your browser:

  • Quick one-time fix: Append ?url= to the end of the file path in your browser's address bar (e.g., file:///path/to/swagger-editor/index.html?url=). This tells the editor to load no default spec.
  • Permanent fix: Open the index.html file in a text editor. Look for the initialization script where Swagger Editor is configured, and modify the defaultDefinition option to use the empty OpenAPI structure mentioned earlier. Save the file, and it will open blank every time.

Note

If you want an entirely empty editor (no base OpenAPI skeleton at all), you can set defaultDefinition to an empty string "" instead of the minimal structure. Just keep in mind that some older Swagger Editor versions might require a valid JSON structure to avoid loading errors, so the minimal empty OpenAPI skeleton is the safer bet.

内容的提问来源于stack exchange,提问作者Good Samartian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:25:27