Skip to main content
Version: v1.27.x LTS

Create an Extension for API ML

Create an Extension for API ML

Zowe allows extenders to define their own extension for API ML.

API ML Services with Class Path Extension Support#

For API ML services with extension support, extension executables can be loaded by setting the shared library path variable that corresponds to the particular service.

ServiceExtension directory environment variable

API ML Services with Library Path Extension Support#

The API Gateway can load native Java libraries by setting ZWE_GATEWAY_LIBRARY_PATH to a path pointing to the native library.

Example API Gateway Extension#

Follow the steps in this article to create your extension. The example in this article is for an extension of the API Gateway.

Note: The api-sample-extension-package contains a sample manifest.yml, and the apiml-sample-extension JAR that contains the extension.

Follow these steps:

  1. Create a JAR file from your extension. See the API ML sample extension to model the format of the JAR.
  2. Create a manifest.yml with the following structure. See the sample manifest.yml to model the format of the yaml file.

For more information, see Packaging z/OS extensions.


```yaml---name: apiml-extension# Component identifier. This identifier matches artifact path in Zowe Artifactory org.zowe.apiml.sdk.apiml-extension-package# Component version is defined in for Gradle project# Human readable component nametitle: Your extension for API ML# Human readable component descriptiondescription: JAR that contains the API ML extension.license: EPL-2.0repository:type: giturl: "{{build.branch}}"number: "{{build.number}}"commitHash: "{{build.commitHash}}"timestamp: "{{build.timestamp}}"# The following block contains all the extensions directory path# (or file path) that will be included in the API MLgatewaySharedLibs:  - path/to/my/lib1/  - path/to/my/lib2/```

The ZWE_GATEWAY_SHARED_LIBS environment variable points to the extension directory <instance>/workspace/gateway/sharedLibs/. The extension directory is then added to the API Gateway class path as part of the Zowe instance preparation.

Note: The paths defined under gatewaySharedLibs can either be a path to the directory where the extensions JARs are located, or a path to the files.


 gatewaySharedLibs:   - path/to/my/lib1/extension1.jar   - path/to/my/lib2/extension2.jar

After the JAR file and manifest.yml are customized according to your application, the extension is extracted, scanned, and added to the extension directory during the Zowe instance preparation. When the API Gateway starts, the API Gateway consumes the sample extension.

The extension should now be correctly added to the API Gateway classpath.

Call the REST endpoint for validation#

Follow these steps to validate that you can call the REST endpoint defined in the controller via the API Gateway:

  1. Call the https://<hostname>:<gatewayPort>/api/v1/greeting endpoint though Gateway.
  2. Verify that you receive the message, Hello, I'm a sample extension! as the response.