The IBM® z/OS Connect
API provider
Gradle plug-in generates artifacts to host APIs that
expose your CICS® COBOL channel and container
applications.
Before you begin
- For more information about the API provider
Gradle plug-in, see Building z/OS Connect APIs with Gradle.
- Ensure you have access to Maven Central or the Gradle Plug-in Portal to be able to use the Gradle plug-in and its dependencies. Alternatively,
ensure that the plug-in and dependencies are in a Maven repository that is hosted internally within
your network.
- Locate or prepare the OpenAPI definition of the API
that you want to create. IBM z/OS Connect uses the OpenAPI definition as an input to generate the artifacts to
create the API. For more information about the OpenAPI definition and the generated artifacts, see Generating the artifacts for an API provider.
About this task
Follow these steps to create a Gradle project and
use the IBM z/OS Connect
Gradle plug-in to generate the API provider project,
data structures, and Web application ARchive (WAR) file for an API.
The following steps create a Gradle project and
use the IBM z/OS Connect
Gradle plug-in to generate the artifacts from your
OpenAPI definition.
Procedure
-
Create a project directory with a name of your choice, for example api-provider-project.
Note: The project directory name and the full path leading up to that directory must not contain
invalid URI characters such as spaces.
In that directory, create a
build.gradle file and add the following
content:
/**************************
* Copyright IBM Corp. 2021
**************************/
plugins {
id 'com.ibm.zosconnect.gradle' version '1.3.0'
}
repositories {
maven {
url '/templates/gradleLibs/'
}
mavenCentral()
}
- Create a settings.gradle file in the project directory and add the
following content:
/**************************
* Copyright IBM Corp. 2021
**************************/
pluginManagement {
repositories {
maven {
url '/templates/gradleLibs/'
}
gradlePluginPortal()
}
}
-
Use the following Gradle command to generate
the API provider project directory structure.
-
Copy your OpenAPI definition into the
src/main/api subdirectory.
The
API provider supports an
OpenAPI definition that consists of a single file named
openapi.yaml or
openapi.json. The directory structure
should look like this:
+-- api-provider-project
+-- src
+-- main
+-- api
+-- openapi.yaml
+-- config
+-- liberty
+-- operations
+-- zosAssets
+-- web.xml
+-- build.gradle
+-- settings.gradle
-
Create the options.yaml file in the src/main/config
directory and specify the required properties.
Tip: You can run the gradle generateApiProvider task to create
the options.yaml file for you and populate it with the required properties and
their default values. This task will create the file but will fail with message
BAQG0008E because you must supply a value for the required parameter
program.
The
options.yaml file must specify the
mandatory
provider,
programInterface,
language,
connectionRef,
program, and
ccsid properties. You can add other optional properties that are needed. For
more information about these supported properties, see
The API provider Gradle plug-in generator options.
-
Use the following Gradle command to generate
the API provider project files and the request and
response language structures for each
operation.
gradle generateApiProvider --info
Alternatively
use the following
Gradle command to generate the request and response language structures for each
operation.
gradle generateCopybooks --info
Use
the
--info
option to get more diagnostic information in the
Gradle output and the
OpenAPI
Parser log files that are generated in the
build/logs/zosConnectProvider directory.
The liberty, operations and
zosAssets directories now contain the files that were generated by the Gradle plug-in. The z/OS Assets, one for each operation in the OpenAPI definition, will all share
program. If you are planning to implement each operation as a different CICS®COBOL application, then you must edit the
zosAsset.yaml for the operations and change the program
value before the next step. You can also change the value of connectionRef in
zosAsset.yaml if you want the operations and z/OS assets to go to different CICS regions.
-
Use the following Gradle command to build the
API provider project and generate the API provider archive file.
Results
Several artifacts for the API provider
project are created in the src/main subdirectory and the language structures
and API provider
WAR file are created in the build subdirectory of the project directory. For
each API operation, an API operation, z/OS Asset,
request data structures, and response data structures are generated. The names of the generated
request and response data structures are based on the value of the
providerPrefix parameter that is specified in the
options.yaml properties file.