Code Editor for OpenAPI

This page describes SwaggerHub’s code editor for OpenAPI YAML definitions. SwaggerHub also has a visual editor for OpenAPI definitions and a code editor for AsyncAPI YAML definitions.

SwaggerHub lets you write API definitions directly in your browser and preview the generated API documentation in real time.

You can alternately use the SwaggerHub extension for Visual Studio Code where you to create, edit, and validate API definitions and domains. The extension is synchronized with SwaggerHub, and all your changes are automatically pushed to it. Learn more about the SwaggerHub extension in Visual Studio Marketplace.

SwaggerHub supports OpenAPI 2.0, OpenAPI 3.0 (with some limitations) and AsyncAPI 2.2 (also with limitations). API definitions are stored in the YAML format. You can import or paste JSON, and it will be converted to YAML. Note that you can download API definitions in both formats, YAML and JSON.

API page on SwaggerHub


SwaggerHub OpenAPI editor has a split view with the editor on the left and interactive API documentation on the right. The editor has two modes:

  • Code Editor lets you edit the YAML code of your API definition. The editor supports autocompletion for OpenAPI keywords, syntax highlighting, search and replace operations, code folding and keyboard shortcuts.

  • show-visual-editor.png Visual Editor lets you edit API metadata and operation metadata without having to understand the OpenAPI syntax.

You can switch between the Code Editor and Visual Editor by using the buttons in the sidebar on the left. The editor autosaves drafts every 2 minutes, and you can also save your progress manually at any time.

Interactive API docs are generated from your API definition and are based on Swagger UI. The API docs are updated automatically as you type, helping you visualize the API you are creating. Here you can also make API calls directly in your browser.

The Navigation panel on the left shows a list of operations and models defined in your API. You can search and filter by paths, HTTP verbs, and model names, and quickly navigate to the corresponding place in the YAML code.

You can hide or show individual panels by using the buttons on the left.

Hide/Show buttons

To undo any unsaved changes in the editor, use the Revert to Last Saved command.

The 'Revert to Last Saved' command


When working on the same API along with other collaborators, keep in mind that SwaggerHub does not support simultaneous editing. Changes are not merged, they are overwritten by the person who saves the changes last. Make sure to coordinate your editing sessions with other collaborators, or use comments to suggest changes.

Syntax validation

As you type, SwaggerHub automatically validates your API definition and shows any errors or warnings that might occur, such as syntax errors, unresolved references, or unused definitions. To see the error list, expand the validation bar at the bottom of the editor. Click an error message to jump to the line that triggered this error.


SwaggerHub SaaS, SwaggerHub On-Premise 1.20.0 and later use lazy loading for domain references, which affects the way domain errors are surfaced in APIs. See Lazy Loading to learn how to validate both the API and the referenced domains.

If your organization uses API Standardization, this is where API editors can see the style violations found in the current API.

Validation errors

Info panel: manage API and integrations

Click the API name in the header area to open the API info panel, where you can rename, compare, or transfer the API. Note: The available commands depend on whether you are the API owner or collaborator.

API info panel

On the Integrations tab of the Info panel, you can configure integrations for your API.

API integrations in the Info panel

At the bottom of the panel, you can see who created this API version and when, who owns the API, and the date and time it was last saved.

API info: Owner, Created By, Created On, Last Saved


The Created By information is only available for the API and domain versions that were created in: a) SwaggerHub SaaS after November 26, 2019; b) SwaggerHub On-Premise 1.23 and later. Information about earlier versions can be found in historical audit logs.

Version selector

If your API has several versions, you can quickly switch between the versions by using the drop-down menu next to the version number.

Selecting an API version

Editor options

You can change the editor font size and switch between the dark and light syntax highlighting themes. Editor options persist across sessions in your current browser.

SwaggerHub editor options


API definitions can include $ref references to domains or components in the current definition. To navigate to a referenced resource, hover over the $ref value and click Jump To. External links are opened in a new browser tab.

Jump to link


The editor’s toolbar also contains the following items:

pactflow-button.pngPactFlow Contract Testing

If PactFlow contract testing is configured for the current API, click this button to check compatibility.

sync.pngSync Management

If source control integrations are configured for the current API, click this button to generate the code and push it to the connected repository branches.

view-documentation.png View Documentation

Click to view interactive documentation for this API or domain in a new browser tab.

settings.png API/Domain Options

  • Edit GitHub Push – Legacy GitHub integration. Use GitHub Sync instead.

  • Reset Changes – Undoes all unsaved changes in the editor.

notifications.png Enable/Disable Notifications

Click to subscribe to or unsubscribe from email notifications about changes in this API or domain.

share.png Share & Collaborate

Click to invite other users to collaborate on this API.


  • Codegen Options – Here, you can change the code generation options for server stubs and client SDKs.

  • Client SDK – Generates a client SDK for this API in the chosen language.

  • Server Stub – Generates a server stub for this API in the chosen language.

  • Documentation – Generates documentation for this API in the chosen format.

  • Download API or Download Domain – Lets you download the API or domain definition in the YAML or JSON format.

Keyboard shortcuts

The SwaggerHub editor supports keyboard shortcuts for faster editing.





Find dialog

Ctrl + F

Command + F

Replace dialog

Ctrl + H

Command + Option + F

Find next

Ctrl + K

Command + G

Find previous

Ctrl + Shift + K

Command + Shift + G

Find all instances of the word under the cursor (case-insensitive)

Ctrl + Alt + K

Ctrl + Option + G





Show the auto-completion list

Ctrl + Space

Option + Space

Comment out or uncomment the current line

Ctrl + /

Command + /

Delete the current line

Ctrl + D

Command + D


Ctrl + Z

Command + Z


Ctrl + Y, Ctrl + Shift + Z

Command + Y, Command + Shift + Z

Indent selection



Outdent selection

Shift + Tab

Shift + Tab

Select all

Ctrl + A

Command + A





Go to line number

Ctrl + L

Command + L

Go to the next error

Alt + E

Go to the previous error

Alt + Shift + E

Code folding




Fold all

Alt + 0

Command + Option + 0

Unfold all

Alt + Shift + 0

Command + Option + Shift + 0

Fold selection

Alt + L, Ctrl + F1

Command + Option + L, Command + F1

Unfold selection

Alt + Shift + L, Ctrl + Shift + F1

Command + Option + Shift + L, Command + Shift + F1

Toggle folding



See Also

Publication date: