Skip to main content

Setting Up an API Workspace

To work with one or more API definitions in the APIMatic's VS Code extension, you are first required to select a workspace folder in VS Code as your dedicated API workspace with all relevant files. There are several ways available to set up your API workspace and we will walk you through each of the available options below.

note

Ensure that your API workspace contains only relevant files for the API definition. See tips for working with large workspaces in the extension without affecting performance.

The documentation covers the following topics:

Opening an API Workspace

If you just opened a workspace folder with an API definition (e.g. OpenAPI) or opened an API definition file directly, you may receive a notification to open the folder or the API definition's parent folder as an API workspace in the extension. Click Yes to select it as your API workspace:

Notification

Alternatively, you can simply navigate to the APIMatic API Explorer view from the Activity Bar. Based on your usage, you may see one or more of the following options:

API Workspace Options

Here is what you can expect from each of these:

Option 1: Open a New API Workspace

The Open New Workspace Folder option will let you browse your system for a folder that you can use as your API workspace:

Open New API Workspace Folder

Choose a folder and click on Select Folder to open it in the APIMatic API Explorer view as an API workspace. Note, that this will close your existing workspace session, if any.

Option 2: Open Last API Workspace

The Open Last API Workspace Session option will only be available if you've previously worked on an API workspace. Selecting this option will help restore your last API workspace session so you can resume working from where you left.

Option 3: Use Current Workspace as API Workspace

The Use Current Workspace Folder option will be available if you have a workspace folder open that is not already marked as an API workspace. Selecting this option will keep your current folder open but will make it accessible in the APIMatic API Explorer view as an API workspace.

Adding an API Definition to Your Workspace

Once you have your API workspace ready, you can begin the next steps of adding an API definition along with any relevant files. We offer some options to help you get started, in the Open/Create API Definition side view which are discussed in more detail in the next few sections.

Worskpace API Definition Options

Adding/Importing an Existing API Definition

If you already have a raw API definition file in your local system or at a public URL, you can import that into your workspace using the relevant import options. Alternatively, if you are just looking to explore the extension and get an idea of things, you can even add a sample file. All of these options should be visible to you under the Add/Import title:

Add Import Api Definition

Option 1: Adding a Sample File

Click on Add Sample File. You will be asked to select the desired output format (json or yaml) after which a sample-petstore.<ext> will be added in your API workspace instantly.

Sample API Import

Option 2: Importing an Existing File from Local System

You can browse your local system and import any existing API definition file into your current API workspace using the Import Existing File option. The API definition file must be in one of the supported formats. Note, that multi-file selection or ZIP files are not supported for this option.

Import Existing File

Option 3: Importing an Existing File from Public URL

If your raw API definition file is available publicly at a URL, you can import it into your current API workspace using the Import File from Public URL option. The API definition file must be in one of the supported formats. Note, that multi-file selection or ZIP files are not supported for this option.

Ensure that you have a stable network connection and then provide a valid public URL path in the input dialog that opens:

Import Existing File

If the URL is valid, the file should download successfully into your workspace in a few seconds (depending upon the size):

Import Existing File

Creating an API Definition from Scratch

If you do not have an API definition, you can create one from scratch using options listed under the Create title:

Add Import Api Definition

Option 1: From an Empty File

Click on Create Empty File. You will be asked to select the desired output format (json or yaml) after which a openapi.<ext> will be added in your API workspace instantly.

Create Empty File

Option 2: From a Template

We can help you create a basic OpenAPI definition by collecting relevant metadata and generating an API definition accordingly. Click on the Create File from Template option to begin.

  • First, you will be required to enter a short meaningful name for your API service:

    Create File From Template API Name

  • Next, you will be asked to briefly describe what service your API provides:

    Create File From Template API Description

  • Next, enter the URL of the server at which your API is served:

    Create File From Template API Server

  • Lastly, pick an output format for your API definition file (JSON/YAML):

    Create File From Template API Format

After the above data is collected, an API definition file will be instantly generated in your API workspace based on the collected information:

Created File From Template

Working with an API Definition

We recommend defining your API using the latest available OpenAPI specification version. If you feel the need to refer to the specification documentation at any time while working on your API definition, you can click on the API format name in the status bar at the bottom right side which will open the standard documentation within the extension in a separate tab:

Reference Documentation

Closing an API Workspace

To close a currently open API workspace in the extension (not the VS Code), you can use the Close API Workspace option from the Manage Session view:

Close API Workspace

You will be asked to confirm this action before proceeding:

Close API Workspace Confirmation

Once closed, validation and other features will not work until the workspace is re-opened/re-selected as an API workspace.

note

Closing the API workspace will only remove the extension's access to the workspace folder. The workspace folder will still remain open in VS Code.

Managing Large Workspaces

For optimal performance, it is recommended to keep the API workspace small and focused with only relevant files present. Ideally, the workspace should not exceed 20MB in size. However, if you have a large workspace that you would like to open in your VS code, there are certain ways available to improve extension performance. Without those measures, you may encounter performance related warnings as shown below:

Large Workspace

Here are some tips for better performance when working with large workspaces:

  • Manually delete any extra files or folders that are not relevant and can be safely removed.

  • Exclude the files or folders that are not directly related to the API definition itself using the Workspace File Navigator view's Exclude option:

    Exclude

    Excluded files/folders will remain in the workspace but will be safely ignored by the extension for all of its operations.

Configuring Workspace Notifications

If the extension doesn't have any API workspace open, it will still run in the background, auto-detect API definition files and show relevant notifications:

  • On loading a new workspace folder with one or more API definitions:

    Notification

  • On opening an API definition file directly:

    Notification

If you no longer wish to receive such notifications, you can click on the Don't Ask Again option:

Dont Ask Again

Disabling file specific notifications will disable notifications for all workspaces by default.

Disabling notifications shown for currently open workspace folder will, by default, disable notifications for that particular workspace only. You will be asked to confirm whether you wish to continue receiving notifications for other workspaces or not:

Dont Ask Again

Once your notification preferences have been updated, you can change them at any time from the extension settings. To do this, navigate to the VS Code Settings (click on the gear icon at the bottom left side of the Activity Bar):

Settings

Next, navigate to the APIMatic settings from the Extensions side-menu:

Settings

Here you can toggle notifications for the When API File is Detected setting either for a specific workspace or globally for all workspaces in the User tab, as per your preferences.