Creating an EGL Service Skeleton from an External File
This topic explains how to generate a service from an OpenAPI document (json, yaml or yml file) that is not currently in your workbench. For more information about the service concept, refer to Introduction to Service parts guide.
Execute the following steps for the creation of the service:
- In the workbench, click FileNewOther.
- In the Other window, select the EGLService Skeleton option.
- Select the OpenAPI file that you want to use as a base for the code generation, then select the folder that you want to use as landing for your OpenAPI document. The use of the folder EGLSource is recommended.
- 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 Nextbutton.
- In the new window, you will be presented with all the functionalities that were discovered in the paths previously selected, together with more options. Select the options and functions that you want to be generated in your code and then 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 import the OpenAPI document into the workspace and generate an output code containing all the functions selected in the wizard and the additional information present in the OpenAPI Document for every specific function. Following is an example of the generated output:
package services;
service myOpenAPIDocument_Service {
Title = "Title of the OpenAPI Document",
description = "Description of the OpenAPIDocument",
version = "X.X.X" }
function randomFunction_POST(var VarClass in){
tags = [ "tags"],
description = "Description of the POST function for this path",
@PostRest {
uriTemplate = "/pathOfTheFunction",
requestFormat = JSON,
responses = [
@RestResponse{
statusCode = 200,
description = "Successful operation",
responseFormat = JSON,
responseType = ResponseVarClass
}]
}
}
// Your future logic goes here...
end
end