elsa-workflows / elsa-workflows/elsa-core

[FEAT] Add OpenApi ActivityProvider

Open
#6,360 1 comment 2 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

## Feature Request

### Problem Overview
Cloud workflow services like Make.com offer activities for many different third party cloud applications (HubSpot, Monday, AirTable, Notion, etc.). Interacting with these services offers a set of custom activities for each cloud service but Elsa has none of those integrations.

### Proposed Solution
Implement a new `OpenApiActivityProvider` that implements `IActivityProvider` to dynamically generate activities based on an Open API specification to expose all API operations as separate activities.

#### Process
1. At startup, specify the different API specifications via a URL or local file that you wish to expose as activities
2. The `services.AddActivityProvider();` is registered internally with any initial call to add a set of Open API activities.
3. A set of activities get created - one activity for each endpoint operation specified in the Open API specification with inputs specific to the query parameters specified in the specification.
4. The outputs are standardized to include `Response` and `ResponseCode`, etc. across all requests.

So for example if Microsoft offered an OpenAPI spec for OneDrive, the first declaration below might point to that document and allow the setup configuration to be manipulated to include or exclude specific APIs from getting added. Offering this configuration is useful when you may be hitting an API with many different endpoints you don't care about and only want to include (or exclude the ones containing the text you care about. So `IncludeEndpointsContaining ` and `ExcludeEndpointsContaining` options would be OR conditions.

This is a rough idea of what the extension methods could look like:

```csharp
services.AddElsa(elsa =>
{
IFile openApiDoc; // some file downloaded for microsoft api spec

elsa.AddOpenApi((openApiDoc, api, type, apiSpec) =>
{
api.Name = $"{type.Name}";
api.Namespace = "Microsoft",
api.DisplayName = $"{apiSpec.HttpMethod.ToUpper()} {apiSpec.Name}",
Category = "Cloud Services",
Description = $"{apiSpec.Description}",
api.IncludeEndpointsContaining = ["Async"];
api.ExcludeEndpointsContaining = ["Execute", "Delete"];
});

Uri openApiUri; // some url to hubspot api spec

elsa.AddOpenApi((openApiUri, api, type, apiSpec) =>
{
api.Name = $"{type.Name}";
api.Namespace = "HubSpot",
api.DisplayName = $"{apiSpec.HttpMethod.ToUpper()} {apiSpec.Name}",
Category = "Cloud Services",
Description = $"{apiSpec.Description}",
api.IncludeEndpointsNotContaining = ["Async"];
api.ExcludeEndpointsContaining = ["Execute", "Delete"];
});
};
```

### Use Cases
I am a developer wanting to expose all of the operations of a third party service that offers an Open API specification in Elsa Studio UI as separate activities. Specifying the open API spec at startup through a new Elsa module will allow me to achieve this.

### Impact of Feature
Instantly create and expose strongly-typed activities for any third party service that offers Open API specifications with a single `AddOpenApi()` declaration for the new API at startup.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the IActivityProvider contract and the existing AddActivityProvider registration, then trace how an Elsa module could expose AddOpenApi. Define the OpenApiActivityProvider behavior around loading a URL or local specification, filtering endpoints, and generating one activity per operation. Done means the proposed configuration and standardized outputs are implemented and usable in Elsa Studio.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.