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
@@ -36,8 +36,8 @@ _Status description:_
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
38
| ✔️| Update `ForEach` state iteration parameter example. This parameter is an expression variable, not a JSON property |
39
+
| ✔️| 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
@@ -36,23 +36,23 @@
36
36
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
37
37
},
38
38
"operation": {
39
-
"type": "string",
40
-
"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.",
41
-
"minLength": 1
39
+
"type": "object",
40
+
"$ref": "#/definitions/operation"
42
41
},
43
42
"type": {
44
43
"type": "string",
45
-
"description": "Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`",
44
+
"description": "Defines the function type. Is either `rest`, `openapi`,`asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `openapi`.",
46
45
"enum": [
47
46
"rest",
47
+
"openapi",
48
48
"asyncapi",
49
49
"rpc",
50
50
"graphql",
51
51
"odata",
52
52
"expression",
53
53
"custom"
54
54
],
55
-
"default": "rest"
55
+
"default": "openapi"
56
56
},
57
57
"authRef": {
58
58
"oneOf": [
@@ -65,14 +65,14 @@
65
65
{
66
66
"type": "object",
67
67
"description": "Configures both the auth definition used to retrieve the operation's resource and the auth definition used to invoke said operation",
68
-
"properties":{
69
-
"resource":{
68
+
"properties":{
69
+
"resource":{
70
70
"type": "string",
71
71
"description": "References an auth definition to be used to access the resource defined in the operation parameter",
72
72
"minLength": 1,
73
73
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
74
74
},
75
-
"invocation":{
75
+
"invocation":{
76
76
"type": "string",
77
77
"description": "References an auth definition to be used to invoke the operation"
78
78
}
@@ -93,6 +93,25 @@
93
93
"name",
94
94
"operation"
95
95
]
96
+
},
97
+
"operation": {
98
+
"oneOf": [
99
+
{
100
+
"type": "string",
101
+
"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
+187-6Lines changed: 187 additions & 6 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)
@@ -994,8 +995,9 @@ They can be referenced by their domain-specific names inside workflow [states](#
994
995
995
996
Reference the following sections to learn more about workflow functions:
996
997
997
-
* [Using functions for RESTful service invocations](#Using-Functions-for-RESTful-Service-Invocations)
998
-
* [Using Functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
998
+
* [Using functions for OpenAPI Service invocations](#using-functions-for-openapi-service-invocations)
999
+
+ [Using functions for RESTful Service Invocations](#using-functions-for-rest-service-invocations)
1000
+
* [Using functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
999
1001
* [Using functions for gRPC service invocation](#Using-Functions-For-RPC-Service-Invocations)
1000
1002
* [Using functions for GraphQL service invocation](#Using-Functions-For-GraphQL-Service-Invocations)
1001
1003
* [Using Functions for OData Service Invocations](#Using-Functions-for-OData-Service-Invocations)
@@ -1005,7 +1007,7 @@ Reference the following sections to learn more about workflow functions:
1005
1007
We can define if functions are invoked sync or async. Reference
1006
1008
the [functionRef](#FunctionRef-Definition) to learn more on how to do this.
1007
1009
1008
-
#### Using Functions for RESTful Service Invocations
1010
+
#### Using Functions for OpenAPI Service Invocations
1009
1011
1010
1012
[Functions](#Function-Definition) can be used to describe services and their operations that need to be invoked during
1011
1013
workflow execution. They can be referenced by states [action definitions](#Action-Definition) to clearly
@@ -1058,10 +1060,168 @@ For example:
1058
1060
}
1059
1061
```
1060
1062
1061
-
Note that the referenced function definition type in this case must be `rest` (default type).
1063
+
Note that the referenced function definition type in this case must be `openapi` (default type).
1062
1064
1063
1065
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
1064
1066
1067
+
#### Using functions for RESTful Service Invocations
1068
+
1069
+
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).
1070
+
1071
+
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}`:
1072
+
1073
+
```json
1074
+
{
1075
+
"functions":[
1076
+
{
1077
+
"name":"queryUserById",
1078
+
"operation": {
1079
+
"/users": {
1080
+
"get": {
1081
+
"parameters": [{
1082
+
"name": "id",
1083
+
"in": "path",
1084
+
"required": true
1085
+
}]
1086
+
}
1087
+
}
1088
+
},
1089
+
"type":"rest"
1090
+
}
1091
+
]
1092
+
}
1093
+
```
1094
+
1095
+
Note that the [Function Definition](#Function-Definition)'s `operation` property must follow the [OpenAPI Paths Object](https://spec.openapis.org/oas/v3.1.0#paths-object) specification definition.
1096
+
1097
+
The function can be referenced during workflow execution when the invocation of the REST service is desired. For example:
1098
+
1099
+
```json
1100
+
{
1101
+
"states":[
1102
+
{
1103
+
"name":"QueryUserInfo",
1104
+
"type":"operation",
1105
+
"actions":[
1106
+
{
1107
+
"functionRef":"queryUserById",
1108
+
"arguments":{
1109
+
"id":"${ .user.id }"
1110
+
}
1111
+
}
1112
+
],
1113
+
"end":true
1114
+
}
1115
+
]
1116
+
}
1117
+
```
1118
+
1119
+
Example of the `POST` request sending the state data as part of the body:
1120
+
1121
+
```json
1122
+
{
1123
+
"functions":[
1124
+
{
1125
+
"name": "createUser",
1126
+
"type": "rest",
1127
+
"operation": {
1128
+
"/users": {
1129
+
"post": {
1130
+
"requestBody": {
1131
+
"content": {
1132
+
"application/json": {
1133
+
"schema": {
1134
+
"type": "object",
1135
+
"properties": {
1136
+
"id": {
1137
+
"type": "string"
1138
+
},
1139
+
"name": {
1140
+
"type": "string"
1141
+
},
1142
+
"email": {
1143
+
"type": "string"
1144
+
}
1145
+
},
1146
+
"required": ["name", "email"]
1147
+
}
1148
+
}
1149
+
}
1150
+
}
1151
+
}
1152
+
}
1153
+
}
1154
+
}
1155
+
]
1156
+
}
1157
+
```
1158
+
1159
+
Note that the `requestBody` [`content` attribute](https://spec.openapis.org/oas/v3.1.0#fixed-fields-10) is described inline rather than a reference to an external document.
1160
+
1161
+
You can reference the `createUser` function and filter the input data to invoke it. Given the workflow input data:
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) since its redundat to function [Auth Definition](#Auth-Definition). If provided, this field is ignored.
1224
+
1065
1225
#### Using Functions for Async API Service Invocations
1066
1226
1067
1227
[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).
@@ -3197,12 +3357,31 @@ Note that `transition` and `end` properties are mutually exclusive, meaning that
3197
3357
3198
3358
| Parameter | Description | Type | Required |
3199
3359
| --- | --- | --- | --- |
3360
+
<<<<<<< HEAD
3200
3361
| name | Unique function name. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
3201
3362
| 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 |
3202
3363
| 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 |
3364
+
=======
3365
+
| name | Unique function name. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
3366
+
| operation | See the table "Function Operation description by type" below. | string or object | yes |
3367
+
| 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 |
3368
+
>>>>>>> 2351b12 (Fixes #420 - Add REST invocation function definition based on OpenAPI Path Item)
3203
3369
| authRef | References an [auth definition](#Auth-Definition) name to be used to access to resource defined in the operation parameter | string | no |
3204
3370
| [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.
3239
3418
3240
-
The `type` property defines the function type. Its value can be either `rest`or `expression`. Default value is `rest`.
3419
+
The `type` enum property defines the function type. Its value can be either `rest`, `openapi` or `expression`. Default value is `openapi`.
3241
3420
3242
3421
Depending on the function `type`, the `operation` property can be:
3243
3422
3244
-
* 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 '#'.
3423
+
* 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 '#'.
3245
3424
For example `https://petstore.swagger.io/v2/swagger.json#getPetById`.
3425
+
* If `type` is `rest`, an object definition of the [OpenAPI Paths Object](https://spec.openapis.org/oas/v3.1.0#paths-object).
3426
+
For example, see [Using Functions for RESTful Service Invocations](#using-functions-for-rest-service-invocations).
3246
3427
* 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 '#'.
3247
3428
For example `file://streetlightsapi.yaml#onLightMeasured`.
3248
3429
* 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