ricardozanini commented on code in PR #541:
URL: 
https://github.com/apache/incubator-kie-kogito-docs/pull/541#discussion_r1497520163


##########
serverlessworkflow/modules/ROOT/pages/core/custom-functions-support.adoc:
##########
@@ -531,7 +531,91 @@ kogito.sw.functions.greet.timeout=5000 <1>
 ----
 <1> Time in milliseconds
 
-== Custom function types
+== Rest custom function 
+
+Serverless Workflow Specification defines the 
xref:service-orchestration/orchestration-of-openapi-based-services.adoc[OpenAPI 
function type], which is the preferred way to interact with existing REST 
servers. 
+However, sometimes a workflow should interact with several REST APIs that are 
not described using an OpenAPI specification file. Since generating such files 
for these services might be tedious, {product_name} offers REST custom type as 
a shortcut. 
+
+When using custom rest, in the function definition, you specify the HTTP URI 
to be invoked and the HTTP method (get, post, patch, or put) to be used, using 
the `operation` string. When the function is invoked, you pass the request 
arguments as you do when using an OpenAPI function. 
+
+The following example shows the declaration of a `rest` function:
+
+.Example of a `rest` function declaration
+[source,json]
+----
+{
+  "functions": [
+    {
+      "name": "multiplyAllByAndSum", <1>
+      "type": "custom", <2>
+      "operation": "rest:post:/numbers/{multiplier}/multiplyByAndSum" <3>
+    }
+  ]
+}
+----
+
+<1> `multiplyAllAndSum` is the function name
+<2> `custom` is the function type
+<3> `rest:post:/numbers/{multiplier}/multiplyByAndSum` is the custom operation 
definition. In the custom operation definition: 
+* `rest` is the reserved operation keyword that indicates this is a REST call.
+* `post` is the HTTP method. 
+* `/numbers/{multiplier}/multiplyByAndSum` is the relative endpoint. 
+
+When using the relative endpoints you must specify the host as a property. The 
format of the host property is `kogito.sw.functions.<function_name>.host`. 
Therefore, in this example, `kogito.sw.functions.multiplyAllByAndSum.host` is 
the host property key. You might override the default port (80) if needed by 
specifying `kogito.sw.functions.multiplyAllAndSum.port` property. 
+
+This particular endpoint expects as body a JSON object whose field `numbers` 
is an array of integers, multiplies each item in the array by `multiplier` and 
returns the sum of all the multiplied items. Therefore, to invoke it, assuming 
the input array is stored in the workflow model as property `inputNumbers`, you 
should write:
+
+.Example of a `rest` function call
+[source,json]
+----
+{
+ "functionRef": {
+   "refName": "multiplyAllByAndSum",
+   "arguments": {
+     "numbers": "$.inputNumbers"
+     "multiplier": 3 <1>
+   }
+ }
+}
+----
+<4> you replace path and query parameters by specifying an argument which name 
is equal to the path or query parameter. The query or path parameter to be 
replaced should be enclosed within {} in the endpoint string.  

Review Comment:
   ```suggestion
   <1> you replace path and query parameters by specifying an argument which 
name is equal to the path or query parameter. The query or path parameter to be 
replaced should be enclosed within {} in the endpoint string.  
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to