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: schema/functions.json
+37-13Lines changed: 37 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,7 @@
22
22
}
23
23
]
24
24
},
25
-
"required": [
26
-
"functions"
27
-
],
25
+
"required": ["functions"],
28
26
"definitions": {
29
27
"function": {
30
28
"type": "object",
@@ -40,9 +38,9 @@
40
38
},
41
39
"type": {
42
40
"type": "string",
43
-
"description": "Defines the function type. Is either `rest`, `openapi`,`asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `openapi`.",
41
+
"description": "Defines the function type. Is either `http`, `openapi`,`asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `openapi`.",
44
42
"enum": [
45
-
"rest",
43
+
"http",
46
44
"openapi",
47
45
"asyncapi",
48
46
"rpc",
@@ -77,9 +75,7 @@
77
75
}
78
76
},
79
77
"additionalProperties": false,
80
-
"required": [
81
-
"resource"
82
-
]
78
+
"required": ["resource"]
83
79
}
84
80
]
85
81
},
@@ -88,10 +84,7 @@
88
84
}
89
85
},
90
86
"additionalProperties": false,
91
-
"required": [
92
-
"name",
93
-
"operation"
94
-
]
87
+
"required": ["name", "operation"]
95
88
},
96
89
"operation": {
97
90
"oneOf": [
@@ -109,8 +102,39 @@
109
102
"type": "object"
110
103
}
111
104
}
105
+
},
106
+
{
107
+
"type": "object",
108
+
"description": "HTTP Function operation definition",
+[Using Functions for OpenAPI Service Invocations](#using-functions-for-openapi-service-invocations)
27
-
+[Using Functions for RESTful Service Invocations](#using-functions-for-restful-service-invocations)
27
+
+[Using Functions for HTTP Service Invocations](#using-functions-for-http-service-invocations)
28
28
+[Using Functions for Async API Service Invocations](#using-functions-for-async-api-service-invocations)
29
29
+[Using Functions for RPC Service Invocations](#using-functions-for-rpc-service-invocations)
30
30
+[Using Functions for GraphQL Service Invocations](#using-functions-for-graphql-service-invocations)
@@ -996,7 +996,7 @@ They can be referenced by their domain-specific names inside workflow [states](#
996
996
Reference the following sections to learn more about workflow functions:
997
997
998
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)
999
+
+ [Using functions for HTTP Service Invocations](#using-functions-for-http-service-invocations)
1000
1000
* [Using functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
1001
1001
* [Using functions for gRPC service invocation](#Using-Functions-For-RPC-Service-Invocations)
1002
1002
* [Using functions for GraphQL service invocation](#Using-Functions-For-GraphQL-Service-Invocations)
@@ -1062,11 +1062,7 @@ For example:
1062
1062
1063
1063
Note that the referenced function definition type in this case must be `openapi` (default type).
1064
1064
1065
-
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
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).
1065
+
The specification also supports describing OpenAPI for REST invocations inline in the [functions definition](#Function-Definition) using [OpenAPI Paths Object](https://spec.openapis.org/oas/v3.1.0#paths-object).
1070
1066
1071
1067
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
1068
@@ -1086,7 +1082,7 @@ Here is an example function definition for REST requests with method `GET` and r
1086
1082
}
1087
1083
}
1088
1084
},
1089
-
"type":"rest"
1085
+
"type":"openapi"
1090
1086
}
1091
1087
]
1092
1088
}
@@ -1123,7 +1119,7 @@ Example of the `POST` request sending the state data as part of the body:
1123
1119
"functions":[
1124
1120
{
1125
1121
"name": "createUser",
1126
-
"type": "rest",
1122
+
"type": "openapi",
1127
1123
"operation": {
1128
1124
"/users": {
1129
1125
"post": {
@@ -1220,7 +1216,119 @@ In this case, only the contents of the `user` attribute will be passed to the fu
1220
1216
}
1221
1217
```
1222
1218
1223
-
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.
1219
+
When inlining the OpenAPI operation, 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.
1220
+
1221
+
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
1222
+
1223
+
#### Using functions for HTTP Service Invocations
1224
+
1225
+
The HTTP function can make HTTP requests to a given endpoint. It can be used in cases a service doesn't have an OpenAPI definition or users require a simple HTTP, curl-style invocation.
1226
+
1227
+
The table below lists the `operation` properties for the `http` function type.
1228
+
1229
+
| Property | Description | Type | Required |
1230
+
| --- | --- | --- | --- |
1231
+
1232
+
| uri | The URI where to send the request | String | yes |
1233
+
| method | The HTTP method according to the [RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616#page-36) | String | yes |
1234
+
| headers | Headers to send in the HTTP call. The `Content-Type` header mandates the body convertion. | Map | no |
1235
+
| cookies | Cookies to send in the HTTP call. | Map | no |
1236
+
1237
+
Note that in the function definition, these values are static. When invoking the function in the `actions` definition, `jq` can be used to set the attribute values.
1238
+
1239
+
Here is a function definition example for a HTTP service operation.
This function can be used later in the workflow definition:
1257
+
1258
+
```json
1259
+
{
1260
+
"states":[
1261
+
{
1262
+
"name": "getpet",
1263
+
"type": "operation",
1264
+
"actions":[
1265
+
{
1266
+
"functionRef": "getPetById",
1267
+
"arguments":{
1268
+
"petId": "${ .pet.id }"
1269
+
}
1270
+
}
1271
+
],
1272
+
"end":true
1273
+
}
1274
+
]
1275
+
}
1276
+
```
1277
+
1278
+
Not that the `arguments` attribute must map the template in the `uri` definition so the underlying engine can map the arguments correctly.
1279
+
1280
+
The `arguments` attribute accepts the following reserved properties when calling a HTTP function type:
1281
+
1282
+
| Property | Description | Type | Required |
1283
+
| --- | --- | --- | --- |
1284
+
1285
+
| body | The HTTP body. If an object, it will be sent as a JSON payload by default if the `Content-Type` header is missing. Otherwise, it will try to convert it based on the `Content-Type` header definition | Object or String | no |
1286
+
| headers | Headers to send in the HTTP call. The `Content-Type` header mandates the body convertion. | Map | no |
1287
+
| cookies | Cookies to send in the HTTP call. | Map | no |
1288
+
1289
+
These attributes are merged with the ones in the function definition.
1290
+
1291
+
The listing below exemplifies how to define and call a HTTP POST endpoint.
1292
+
1293
+
```json
1294
+
{
1295
+
"functions": [
1296
+
{
1297
+
"name": "createPet",
1298
+
"type": "http",
1299
+
"operation": {
1300
+
"method": "POST",
1301
+
"uri": "https://petstore.swagger.io/v2/pet/",
1302
+
"headers": {
1303
+
"Content-Type": "application/json"
1304
+
}
1305
+
}
1306
+
}
1307
+
]
1308
+
},
1309
+
{
1310
+
"states":[
1311
+
{
1312
+
"name":"create-pet",
1313
+
"type":"operation",
1314
+
"actions":[
1315
+
{
1316
+
"functionRef":"createPet",
1317
+
"arguments":{
1318
+
"body": {
1319
+
"name": "Lulu"
1320
+
},
1321
+
"headers": {
1322
+
"my-header": "my-value"
1323
+
}
1324
+
}
1325
+
}
1326
+
],
1327
+
"end":true
1328
+
}
1329
+
]
1330
+
}
1331
+
```
1224
1332
1225
1333
#### Using Functions for Async API Service Invocations
1226
1334
@@ -3359,7 +3467,7 @@ Note that `transition` and `end` properties are mutually exclusive, meaning that
3359
3467
| --- | --- | --- | --- |
3360
3468
| name | Unique function name. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
3361
3469
| operation | See the table "Function Operation description by type" below. | string or object | yes |
3362
-
| 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 |
3470
+
| type | Defines the function type. Can be either `http`, `openapi`, `asyncapi`, `rpc`, `graphql`, `odata`, `expression`, or [`custom`](#defining-custom-function-types). Default is `openapi` | enum | no |
3363
3471
| authRef | References an [auth definition](#Auth-Definition) name to be used to access to resource defined in the operation parameter | string | no |
3364
3472
| [metadata](#Workflow-Metadata) | Metadata information. Can be used to define custom function information | object | no |
0 commit comments