This quickstart project demonstrate how to use the Kogito Public API (Incubation). It disables the predefined generated REST endpoint and instead uses the Public API to define a custom HTTP resource.
The custom REST endpoint evaluates a DMN that computes Traffic Violation:
Incubation means that this API is experimental, but it is part of a regular release for early access and to gather community feedback.
You will need:
mvn clean compile quarkus:dev
NOTE: With dev mode of Quarkus you can take advantage of hot reload for business assets like processes, rules, decision tables and java code. No need to redeploy or restart your running application.
mvn clean package java -jar target/quarkus-app/quarkus-run.jar
You can take a look at the OpenAPI definition - automatically generated and included in this service - to determine all available operations exposed by this service. For easy readability you can visualize the OpenAPI definition file using a UI tool like for example available Swagger UI.
In addition, various clients to interact with this service can be easily generated using this OpenAPI definition.
When running in either Quarkus Development or Native mode, we also leverage the Quarkus OpenAPI extension that exposes Swagger UI that you can use to look at available REST endpoints and send test requests.
To make use of this application it is as simple as sending a request to http://localhost:8080/custom-rest-decision
with the following content
{ "Driver": { "Points" : 2 }, "Violation": { "Type" : "speed", "Actual Speed" : 120, "Speed Limit" : 100 } }
Complete curl command can be found below:
curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"Driver":{"Points":2},"Violation":{"Type":"speed","Actual Speed":120,"Speed Limit":100}}' http://localhost:8080/custom-rest-decision
Response should be similar to:
{ "Driver" : { "Age" : null, "City" : null, "Name" : null, "Points" : 2, "State" : null }, "Fine" : { "Amount" : 500, "Points" : 3 }, "Should the driver be suspended?" : "No", "Violation" : { "Actual Speed" : 120, "Code" : null, "Date" : null, "Speed Limit" : 100, "Type" : "speed" } }