◷ Reading Time: 4 minutes
This process will show you how to use the swagger endpoint as part of accessing services deployed as Azure, AWS, Google Cloud, or in FlexRule Server.
Deployed as Azure, AWS, or Google Cloud
We have learned that we can retrieve all the available services by using the Services URL: /Services/?code=randomcode.

And from the result, we can then get the service details and use it for executing the service.

To invoke the swagger endpoint, you will just simply add /swagger.json at the end of your service path. E.g., Services/age-service/1/person_growing_state/1/swagger.json?code=randomcode.
The Swagger specification result will include important details such as:
- Execution URL
- Request and Response example formats
- Schemas

If you are not familiar with swagger, you may copy-paste the result to https://editor.swagger.io/ to see it on UI.

The request body contains the example input format for the specified service. As explained in Retrieving Information on Input, the original input should be re-formatted which is already done in the swagger specification.
Deployed in FlexRule Server
Once you have successfully deployed a service on FlexRule Server, you can access the Swagger endpoint.
Navigate to Services in FlexRule Workbench and select Test Run for the service you want to access the Swagger endpoint

You will see the service URL at the top of the page.

You can use Postman or a similar tool to invoke the swagger endpoint using the following request.
- Method: GET
- Service URL: Service Url/swagger.json
Note: Add /swagger.json at the end of your service URL
e.g. http://localhost:9000/api/services/execute/dc1/1/Calculator/swagger.json
- Authorization:
- Type: ‘Bearer Token’
- Token: Get the bearer token for the service
- Body: none


You will get a similar response with the details of your service.
{
"openapi": "3.0.1",
"info": {
"title": "DC1 API",
"description": "An API to execute FlexRule package",
"version": "1"
},
"servers": [
{
"url": "http://localhost:9000/api/services/execute/dc1/1/Calculaton"
}
],
"path": {
"http://localhost:9000/api/services/execute/dc1/1/Calculaton": {
"post": {
"Tag": [
"dc1"
],
"parameters": [
{
"Name": "parcel weight",
"Type": "decimal",
"Assembly": null,
"Direction": "In"
},
{
"Name": "delivery cost",
"Type": "decimal",
"Assembly": null,
"Direction": "Out"
}
],
"RequestBody": [
{
"application/json": {
"schema": {
"ref": "#/components/schemas/Inputs"
},
"example": {
"input": [
[
{
"name": "parcel weight",
"direction": 0,
"type": "decimal",
"assembly": null
}
]
],
"output": null
}
}
}
],
"Response": [
{
"200": {
"description": "Success",
"content": {
"application/json": [
{
"ref": "#/components/schemas/Outputs"
},
{
"input": null,
"output": [
[
{
"name": "delivery cost",
"direction": 1,
"type": "decimal",
"assembly": null
}
]
]
}
]
}
}
}
]
}
}
}
}