SwaggerHub Extension for Visual Studio CodeThe SwaggerHub extension lets you view and edit your OpenAPI definitions stored in SwaggerHub directly from Visual Studio Code. You can access your organization's APIs and domains and sync the changes back to SwaggerHub. Both SwaggerHub SaaS and On-Premise are supported. Features
RequirementsVS Code version 1.50.0 or later. Get started1. Configure the extensionBefore using the SwaggerHub extension, you need to configure its settings:
2. Load & work with your API definitionsClick on the left-hand side to open the SwaggerHub extension. You will see a list of APIs and domains from the connected organizations. Select an API or domain to view or edit it: The selected definition is downloaded to a temporary folder on your computer. When you save the changes in the editor, the updated definition is uploaded back to SwaggerHub. Use the extensionCreate an API or domainYou can create new API definitions and domains from scratch or using a template. To do this, click at the top of the SwaggerHub APIs or SwaggerHub Domains panels and follow the prompts. Create a new version of an API or domainOpen a definition in the editor, change its Set the default versionIf an API or domain has several versions, the default version has the icon in the list. To make another version the default one, open that version in the editor and select SwaggerHub > Make default from the context menu. Preview an API in Swagger UITo see how your API documentation looks in Swagger UI, click in the top right corner of the editor or select SwaggerHub > Preview in Swagger UI from the context menu. The preview is updated automatically as you make changes in the editor. In Swagger UI, you can also test the requests using Try it out. For this to work, your API definition needs to specify the Auto MockingWith SwaggerHub, you can quickly create a mock of your API. Mocks are handy for quick prototyping and integration testing. For more information, see API Auto Mocking in the SwaggerHub documentation. To create a mock, select SwaggerHub > Add Auto Mocking integration from the editor context menu. The mock server is added to the Note: SwaggerHub On-Premise users need v. 1.26 to add mocks from within the VS Code extension. Change the visibility or statusThe visibility (public or private) and status (published or unpublished) of the current definition is displayed in the VS Code status bar. Use the editor context menu to change the visibility and status. Check the syntaxThe extension checks YAML formatting and validates your definitions against the OpenAPI 3.0 and 2.0 schemas to detect errors such as missing required keywords or misspelled keywords. The number of errors is displayed in the status bar. Click that number to open the Problems view containing the full list of errors, from where you can jump to the corresponding lines in the editor. Delete APIs, domains, or versionsClick next to a specific version to delete it. If this is the only version, you will be prompted to delete the entire API or domain. Reload from SwaggerHubTo reload the list of APIs, domains, and their versions from SwaggerHub, click at the top of the list. You can also reload the version list for a specific definition by clicking next to it. TipsFind and filter APIs and domainsThe SwaggerHub APIs and SwaggerHub Domains panels support VS Code's "filter on type" feature to find and filter definitions. Select the top item, then start typing a name to find the matching definitions. Optionally, you can click Enable Filter on Type in the filter box to see only matching definitions. Peek definitionTo preview the referenced definition inline, right-click the Jump to a referenceTo navigate to the referenced definition, Ctrl-click the Questions and feedbackIf you have any questions, suggestions or want to report a bug, please open an issue here: |