You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: roadmap/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,8 @@ _Status description:_
35
35
| ✔️| Apply fixes to auth spec schema [workflow schema](https://github.com/serverlessworkflow/specification/tree/main/schema)|
36
36
| ✔️| Update the `dataInputSchema` top-level property by supporting the assignment of a JSON schema object [workflow schema](https://github.com/serverlessworkflow/specification/tree/main/specification.md#workflow-definition-structure)|
37
37
| ✔️| Add the new `WORKFLOW` reserved keyword to workflow expressions |
38
+
| ✔️| Add the new `rest` function type [spec doc](https://github.com/serverlessworkflow/specification/tree/main/specification.md#using-functions-for-restful-service-invocations)|
Copy file name to clipboardExpand all lines: schema/functions.json
+27-8Lines changed: 27 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -35,23 +35,23 @@
35
35
"minLength": 1
36
36
},
37
37
"operation": {
38
-
"type": "string",
39
-
"description": "If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `asyncapi`, <path_to_asyncapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \\\"mutation\\\" or \\\"query\\\">#<query_or_mutation_name>. If type is `odata`, <URI_to_odata_service>#<Entity_Set_Name>. If type is `expression`, defines the workflow expression.",
40
-
"minLength": 1
38
+
"type": "object",
39
+
"$ref": "#/definitions/operation"
41
40
},
42
41
"type": {
43
42
"type": "string",
44
-
"description": "Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`",
43
+
"description": "Defines the function type. Is either `rest`, `openapi`,`asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `openapi`.",
45
44
"enum": [
46
45
"rest",
46
+
"openapi",
47
47
"asyncapi",
48
48
"rpc",
49
49
"graphql",
50
50
"odata",
51
51
"expression",
52
52
"custom"
53
53
],
54
-
"default": "rest"
54
+
"default": "openapi"
55
55
},
56
56
"authRef": {
57
57
"oneOf": [
@@ -63,13 +63,13 @@
63
63
{
64
64
"type": "object",
65
65
"description": "Configures both the auth definition used to retrieve the operation's resource and the auth definition used to invoke said operation",
66
-
"properties":{
67
-
"resource":{
66
+
"properties":{
67
+
"resource":{
68
68
"type": "string",
69
69
"description": "References an auth definition to be used to access the resource defined in the operation parameter",
70
70
"minLength": 1
71
71
},
72
-
"invocation":{
72
+
"invocation":{
73
73
"type": "string",
74
74
"description": "References an auth definition to be used to invoke the operation"
75
75
}
@@ -90,6 +90,25 @@
90
90
"name",
91
91
"operation"
92
92
]
93
+
},
94
+
"operation": {
95
+
"oneOf": [
96
+
{
97
+
"type": "string",
98
+
"description": "If type is `openapi`, <path_to_openapi_definition>#<operation_id>. If type is `asyncapi`, <path_to_asyncapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \\\"mutation\\\" or \\\"query\\\">#<query_or_mutation_name>. If type is `odata`, <URI_to_odata_service>#<Entity_Set_Name>. If type is `expression`, defines the workflow expression.",
Copy file name to clipboardExpand all lines: specification.md
+183-8Lines changed: 183 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@
23
23
+[Using multiple data filters](#using-multiple-data-filters)
24
24
+[Data Merging](#data-merging)
25
25
*[Workflow Functions](#workflow-functions)
26
+
+[Using Functions for OpenAPI Service Invocations](#using-functions-for-openapi-service-invocations)
26
27
+[Using Functions for RESTful Service Invocations](#using-functions-for-restful-service-invocations)
27
28
+[Using Functions for Async API Service Invocations](#using-functions-for-async-api-service-invocations)
28
29
+[Using Functions for RPC Service Invocations](#using-functions-for-rpc-service-invocations)
@@ -991,8 +992,9 @@ They can be referenced by their domain-specific names inside workflow [states](#
991
992
992
993
Reference the following sections to learn more about workflow functions:
993
994
994
-
* [Using functions for RESTful service invocations](#Using-Functions-for-RESTful-Service-Invocations)
995
-
* [Using Functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
995
+
* [Using functions for OpenAPI Service invocations](#using-functions-for-openapi-service-invocations)
996
+
+ [Using functions for RESTful Service Invocations](#using-functions-for-rest-service-invocations)
997
+
* [Using functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
996
998
* [Using functions for gRPC service invocation](#Using-Functions-For-RPC-Service-Invocations)
997
999
* [Using functions for GraphQL service invocation](#Using-Functions-For-GraphQL-Service-Invocations)
998
1000
* [Using Functions for OData Service Invocations](#Using-Functions-for-OData-Service-Invocations)
@@ -1002,7 +1004,7 @@ Reference the following sections to learn more about workflow functions:
1002
1004
We can define if functions are invoked sync or async. Reference
1003
1005
the [functionRef](#FunctionRef-Definition) to learn more on how to do this.
1004
1006
1005
-
#### Using Functions for RESTful Service Invocations
1007
+
#### Using Functions for OpenAPI Service Invocations
1006
1008
1007
1009
[Functions](#Function-Definition) can be used to describe services and their operations that need to be invoked during
1008
1010
workflow execution. They can be referenced by states [action definitions](#Action-Definition) to clearly
@@ -1055,10 +1057,168 @@ For example:
1055
1057
}
1056
1058
```
1057
1059
1058
-
Note that the referenced function definition type in this case must be `rest` (default type).
1060
+
Note that the referenced function definition type in this case must be `openapi` (default type).
1059
1061
1060
1062
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
1061
1063
1064
+
#### Using functions for RESTful Service Invocations
1065
+
1066
+
The specification also supports describing REST invocations in the [functions definition](#Function-Definition) using [OpenAPI Paths Object](https://spec.openapis.org/oas/v3.1.0#paths-object).
1067
+
1068
+
Here is an example function definition for REST requests with method `GET` and request target corresponding with [URI Template](https://www.rfc-editor.org/rfc/rfc6570.html) `/users/{id}`:
1069
+
1070
+
```json
1071
+
{
1072
+
"functions":[
1073
+
{
1074
+
"name":"queryUserById",
1075
+
"operation": {
1076
+
"/users": {
1077
+
"get": {
1078
+
"parameters": [{
1079
+
"name": "id",
1080
+
"in": "path",
1081
+
"required": true
1082
+
}]
1083
+
}
1084
+
}
1085
+
},
1086
+
"type":"rest"
1087
+
}
1088
+
]
1089
+
}
1090
+
```
1091
+
1092
+
Note that the [Function Definition](#Function-Definition)'s `operation` property must follow the OpenAPI Paths Object specification definition.
1093
+
1094
+
The function can be referenced during workflow execution when the invocation of the REST service is desired. For example:
1095
+
1096
+
```json
1097
+
{
1098
+
"states":[
1099
+
{
1100
+
"name":"QueryUserInfo",
1101
+
"type":"operation",
1102
+
"actions":[
1103
+
{
1104
+
"functionRef":"queryUserById",
1105
+
"arguments":{
1106
+
"id":"${ .user.id }"
1107
+
}
1108
+
}
1109
+
],
1110
+
"end":true
1111
+
}
1112
+
]
1113
+
}
1114
+
```
1115
+
1116
+
Example of the `POST` request sending the state data as part of the body:
1117
+
1118
+
```json
1119
+
{
1120
+
"functions":[
1121
+
{
1122
+
"name": "createUser",
1123
+
"operation": {
1124
+
"/users": {
1125
+
"post": {
1126
+
"requestBody": {
1127
+
"content": {
1128
+
"application/json": {
1129
+
"schema": {
1130
+
"type": "object",
1131
+
"properties": {
1132
+
"id": {
1133
+
"type": "string"
1134
+
},
1135
+
"name": {
1136
+
"type": "string"
1137
+
},
1138
+
"email": {
1139
+
"type": "string"
1140
+
}
1141
+
},
1142
+
"required": ["name", "email"]
1143
+
}
1144
+
}
1145
+
}
1146
+
}
1147
+
}
1148
+
}
1149
+
},
1150
+
"type": "rest"
1151
+
}
1152
+
]
1153
+
}
1154
+
```
1155
+
1156
+
Note that the `requestBody` content schema is described inline rather than a reference to an external document.
1157
+
1158
+
You can reference the `createUser` function and filter the input data to invoke it, as shown in the example below:
In this case, only the contents of the `user` attribute will be passed to the function. The user ID returned by the REST request body will then be added to the state data:
The specification does not support the [Security Requirement Object](https://spec.openapis.org/oas/v3.1.0#security-requirement-object). To define authentication for the REST operation, use the [Auth Definition](#Auth-Definition). If provided, this field is ignored.
1221
+
1062
1222
#### Using Functions for Async API Service Invocations
1063
1223
1064
1224
[Functions](#Function-Definition) can be used to invoke PUBLISH and SUBSCRIBE operations on a message broker documented by the [Async API Specification](https://www.asyncapi.com/docs/specifications/v2.1.0).
@@ -3189,11 +3349,24 @@ Note that `transition` and `end` properties are mutually exclusive, meaning that
3189
3349
| Parameter | Description | Type | Required |
3190
3350
| --- | --- | --- | --- |
3191
3351
| name | Unique function name | string | yes |
3192
-
| operation | If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `asyncapi`, <path_to_asyncapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \"mutation\" or \"query\">#<query_or_mutation_name>. If type is `odata`, <URI_to_odata_service>#<Entity_Set_Name>. If type is `expression`, defines the workflow expression. | string | yes |
3193
-
| type | Defines the function type. Can be either `rest`, `asyncapi`, `rpc`, `graphql`, `odata`, `expression`, or [`custom`](#defining-custom-function-types). Default is `rest` | enum | no |
3352
+
| operation | See the table "Function Operation description by type" below. | string or object | yes |
3353
+
| type | Defines the function type. Can be either `rest`, `openapi`, `asyncapi`, `rpc`, `graphql`, `odata`, `expression`, or [`custom`](#defining-custom-function-types). Default is `openapi` | enum | no |
3194
3354
| authRef | References an [auth definition](#Auth-Definition) name to be used to access to resource defined in the operation parameter | string | no |
3195
3355
| [metadata](#Workflow-Metadata) | Metadata information. Can be used to define custom function information | object | no |
The `name` property defines an unique name of the function definition.
3230
3403
3231
-
The `type` property defines the function type. Its value can be either `rest`or `expression`. Default value is `rest`.
3404
+
The `type` property defines the function type. Its value can be either `rest`, `openapi` or `expression`. Default value is `openapi`.
3232
3405
3233
3406
Depending on the function `type`, the `operation` property can be:
3234
3407
3235
-
* If `type` is `rest`, a combination of the function/service OpenAPI definition document URI and the particular service operation that needs to be invoked, separated by a '#'.
3408
+
* If `type` is `openapi`, a combination of the function/service OpenAPI definition document URI and the particular service operation that needs to be invoked, separated by a '#'.
3236
3409
For example `https://petstore.swagger.io/v2/swagger.json#getPetById`.
3410
+
* If `type` is `rest`, an object definition of the [OpenAPI Paths Object](https://spec.openapis.org/oas/v3.1.0#paths-object).
3411
+
For example, see [Using Functions for RESTful Service Invocations](#using-functions-for-rest-service-invocations).
3237
3412
* If `type` is `asyncapi`, a combination of the AsyncApi definition document URI and the particular service operation that needs to be invoked, separated by a '#'.
3238
3413
For example `file://streetlightsapi.yaml#onLightMeasured`.
3239
3414
* If `type` is `rpc`, a combination of the gRPC proto document URI and the particular service name and service method name that needs to be invoked, separated by a '#'.
0 commit comments