Serverless Workflow VSCode Editor support to Open API and Async API

In the previous blog post we saw how one can register OpenAPI endpoints and AsyncAPI channels in Service registry and pass them as functions. Also we saw steps to use those functions in Serverless Logic Web Tools via Service Catalog Explorer’s autocomplete feature. This article explains how this same feature works in Kogito Serverless Workflow VS Code extension.

In this extension, the API specifications can be uploaded via external registries, or you can create a folder named specs within the project and place the specification files there. You can look at the kogito-examples repository for examples of workflows and specification files.

Service Catalog in Serverless Workflow VSCode extension

To proceed further, you will need VS Code and the Kogito Serverless Workflow VS Code extension.

There are several ways to download and install Kogito Serverless Workflow VS Code extension

  1. You can download from the Visual studio marketplace
  2. Click on the Extensions icon in the Activity Bar on the side of VS Code, search and install.
    • extensions view icon
  3. Launch VS Code Quick Open (Ctrl+P), paste the following commands, and press enter:
    • ext install redhat.vscode-extension-serverless-workflow-editor

Before proceeding with the project, let us set up the service registries.

Some of the features in the Serverless Workflow Editor require integration with Red Hat OpenShift Application and Data Services. Here, uploading API specifications to a service registry requires this integration.

Now, in the Red Hat OpenShift application and Data Services, let us create a service registry.

Creating a service registry

You can create or use a Service Registry instance from your Red Hat OpenShift Application and Data Services console and add the Service Registry to Serverless Logic Web Tools.

Prerequisites

  • You have access to the Red Hat OpenShift Application and Data Services console.

Procedure

  1. To create a Service Registry instance in the Red Hat Openshift Application and Data Services console, perform the following steps:
    1. Go to the Service Registry | Red Hat OpenShift Application and Data Services.
    2. Click the “Create Service Registry Instance” button.
  2. Enter a Service Registry instance name in the Create a Service Registry Instance window and click Create. Click on the menu in the top-right corner of the screen.
  3. Click Connection.
    1. A drawer opens, containing the required connection and authentication information.
    2. Copy the value of the Core Registry API.
  4. If you already have a Service Registry, find the value of the Core Registry API of your Service Registry.

Upload the API Specification:

Once you have the Service registry created, you are set to upload the API specification file, which could be an Open API or an Async API.

Procedure:

  1. On the OpenShift Application Console, go to the Service Registry instance that you created.
  2. Click the Upload Artifact button, and a modal window opens.
  3. On the modal, enter the group and artifacts ID, which are mandatory fields.
  4. You can choose type from the dropdown menu, or you can leave the default option Auto-Detect alone.
  5. In the artifact section, you can browse or drag and drop the API specification file, or you can also copy-paste the content directly into the text area.
  6. Finally, click “upload.”

Configure your Visual Studio Code

Open the Command Palette:

  • Hit F1 or select from the menu View > Command Palette…​

Type Pref and select Preferences: Open User Settings (JSON)

Add the following configuration key and close it:

 "kogito.swf.serviceRegistries": {
        "registries": [
            {
                "authProvider": "red-hat-account", 
                "name": <Provide your registry name>, 
                "url": <Paste Core Registry API copied from console>
            }
        ]
    }

Against the property authProvider you can provide either none or ‘red-hat-account’.

If you choose ‘red-hat-account’, then you will need to install Red Hat Authentication VS Code extension and provide authentication, steps are as follows.

Accessing the Service Catalog in VSCode extension

When you have all the prerequisites ready, it is possible to create a workflow and try the Service Catalog feature. You can create an empty file with a filename and extension ‘.sw.json’ or ‘.sw.yaml’. Open the created document.

You can click on the Create a Serverless Workflow option to generate a basic template workflow. Just above the functions property, there will be a Setup Service Registries option. When you click, it will take you through the Red Hat account login screen where you can enter your credentials. Post login you can click on the Refresh Service Registries option to refresh the editor.

You will find the Add Function option clicking on it, a side widget containing a list of function suggestions will appear. These functions are extracted from the API specification files that you uploaded on the Red Hat OpenShift Application Console. When you select a particular function, it will automatically generate auto-filled name, operation, and type properties.

With this we have seen how you can register OpenAPI endpoints and AsyncAPI channels through Service registries and pass them as functions to the editor. Thats all for now, Stay tuned for more exciting new features on Kogito Serverless Workflow editors.

Author

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments