...
Abstract Class
org.joget.api.model.ApiPluginAbstract
...
Panel |
---|
|
To generate JSON APIs from your implementation, see the available Java annotations with samples below: @Operation Variable | Data Type | Mandatory | Description |
---|
path | String | | API path name to call the current method. Always starts start with a forward slash ( / ). To include path parameters, after annotating @Param with the method parameter (see doc below), you can add the variable enclosed within curly braces into the path. Example: Panel |
---|
/getUserDetails /getUserDetails/{username} |
| type | enum |
| Defines the request method type. Available types: - Operation.MethodType.GET
- Operation.MethodType.POST
- Operation.MethodType.PUT
- Operation.MethodType.DELETE
Default value when undefined is Operation.MethodType.POST. | summary | String |
| Provides a brief description of this operation. This is the value to display as the method name in the API Builder. Recommended to be 120 characters or less for proper visibility when previewing API. Default value when undefined is a blank string. | description | String |
| A verbose description of the operation. Default value when undefined is a blank string. | deprecated | boolean |
| Allows an operation to be marked as deprecated. Default value when undefined is false. | @Responsespublic String getIcon()Return the icon to show for this API Element in the API Builder palette. @Parampublic String getIcon() Return the icon to show for this API Element in the API Builder palette.Consists of @Response annotation(s). Information in table here: Variable | Data Type | Mandatory | Description |
---|
responseCode | int |
| The HTTP response code. Example value: | description | String |
| A short description of the response. Default value when undefined is a blank string. | definition | String |
| A definition to the data schema in response. Default value when undefined is a blank string. | dataClass | String |
| A class to the data in response. Default value when undefined is a blank string. | contentType | String |
| A content type of the data in response. Default value when undefined is "application/json". | array | boolean |
| Defines if this response value is an array. Default value when undefined is false. | @Param Variable | Data Type | Mandatory | Description |
---|
value | String |
| A short name of the parameter. Example value: | required | boolean |
| Defines if this parameter value is mandatory. Default value when undefined is true. | description | String |
| A verbose description of the parameter. Default value when undefined is a blank string. | definition | String |
| The key of definition provided by ApiPlugin. Example value: Default value when undefined is a blank string. | header | boolean |
| Defines if this parameter value is in the request header. Default value when undefined is false. |
For detailed examples, do check out the Sample Plugins attached in this page. Here is a sample code snippet from the sample Basic Current User API plugin: Code Block |
---|
| @Operation(
path = "/getUserDetails",
type = Operation.MethodType.GET,
summary = "Get user details",
description = "Get user details via username, else get current user."
)
@Responses({
@Response(responseCode = 200, description = "Success", definition = "User"),
@Response(responseCode = 404, description = "User data not found", definition = "ApiResponse")
})
public ApiResponse getUserDetails(
@Param(value = "username", required = false, description = "Username of user.") String username) {
ExtDirectoryManager dm = (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
User user = dm.getUserByUsername(username);
WorkflowUserManager wum = (WorkflowUserManager) AppUtil.getApplicationContext().getBean("workflowUserManager");
User currentUser = wum.getCurrentUser();
if (user != null) {
return new ApiResponse(200, user, getFields());
} else if (user == null && currentUser != null) {
return new ApiResponse(200, currentUser, getFields());
} else {
return new ApiResponse(404, AppPluginUtil.getMessage("BasicCurrentUserAPI.resp.404", getClassName(), getResourceBundlePath()));
}
} |
|
Abstract Methods
getIcon
public String getIcon()
...
Please refer to Plugin Properties Options for more information.
Anchor |
---|
| samplePlugins |
---|
| samplePlugins |
---|
|
Sample Plugins
Basic Current User API
- basic-current-user.zip
Sample API with property options
- apibuilder_sample_plugin.zip
...