Creating an EGL Client Interface
This topic explains how to generate multiple Interfaces from an OpenAPI document (json, yaml or yml file). For more information about the interface concept, refer to the Introduction to Interface parts guide.
Execute the following steps to create the interfaces:
- In the workbench, right-click a .json/.yaml/.yml file and then select the EGL Services Create EGL Client Interface option.
- In the New EGL part window, you will see all the paths available in the OpenAPI document. Select the paths you want to implement in your code and click the Next button.
- The new window has multiple tabs, one for each selected path and one for more options. Each tab has access to multiple functions. Select the options and functions you want to generate in your code and click Finish.
- The file will open, and you will see all the generated code for the functions you selected in the previous steps. Edit and implement the output code with your logic.
This process will generate an output code containing all the functions selected in the wizard
and the additional information presented in the OpenAPI Document for every specific function.
Following is an example of the generated output:
package interfaces;
interface firstInterf{
description = "Description of the first path"
}
function findByTagsFunction(tags string? in){
tags = [ "tag"],
description = "Get an object using a tag",
@GetRest {
uriTemplate = "/random/findByTags?tags={tags}",
requestFormat = JSON,
responses = [
@RestResponse{
statusCode = 200,
description = "successful operation"
responseFormat = XML
}]
}
};
end
interface secondInterf{
description = "Description of the second path"
}
function getObjectById_GET(id int in){
tags = [ "id"],
description = "Returns a single object using an ID",
@GetRest {
uriTemplate = "/object/{id}",
requestFormat = JSON,
responses = [
@RestResponse{
statusCode = 200,
description = "successful operation",
responseFormat = XML,
responseType = Object
}]
}
};
function updateObjectWithForm_POST(id int in, name string? in, status string? in){
tags = [ "id"],
description = "Update an object in the database",
@PostRest {
uriTemplate = "/object/{id}?name={name}&status={status}",
requestFormat = JSON,
responses = [
@RestResponse{
statusCode = 400,
description = "Invalid input",
responseFormat = JSON
}]
}
};
end