Creating and deploying the API requester tutorial
Use this tutorial to understand how to call an OpenAPI 3.0 API endpoint from your z/OS applications.
zosConnect-3.0 Applies to zosConnect-3.0.
Started task Applies to z/OS Connect Servers run by using a z/OS started task procedure.
This tutorial demonstrates the IBM z/OS Connect API requester tutorial project structure and how to download the files that contain the Gradle project, ready for deployment to a z/OS Connect Server with the zosConnect-3.0 feature.
The API requester tutorial includes an OpenAPI 3.0 document. From 3.0.99, z/OS Connect supports generating an API requester from either an OpenAPI 2.0 document or OpenAPI 3.0 document when deploying to a z/OS Connect Server with the zosConnect-3.0 feature. This tutorial project is based on an OpenAPI 3.0 document
Downloading the tutorial
How to download the z/OS Connect
API requester
sample-oas3-requester project for this tutorial.
Before you begin
- IBM z/OS Connect Server is installed. For more information, see Installing IBM z/OS Connect with SMP/E.
- Gradle 7.6.1 or later installed. For more information, see IBM z/OS Connect system requirements and Building IBM z/OS Connect APIs with Gradle.
- An understanding of application development.
Procedure
Building the tutorial by using Gradle
How to build the z/OS Connect
API requester
sample-oas3-requester tutorial by using Gradle.
About this task
This topic provides an overview of the project and the Redbook OpenAPI 3.0 document and options.yaml, the build inputs, outputs, and details on how to run the build to generate the API requester.
The z/OS Connect API requester sample contains the necessary Gradle automation build files to create the API endpoint application WAR file by compiling the Java™ source code and packaging the WAR file for deployment into Liberty. The Gradle build also starts a sub Gradle build in the RedbookApi and RedbookApiPLI directories that create the z/OS Connect API requester WAR files by processing the redbookapi.yaml OpenAPI 3.0 document and associated options.yaml file.
The z/OS Connect
API requester sample also contains COBOL and PL/I
program source files that call the z/OS Connect
API requester Host API. These are provided in
different degrees of completeness depending on whether you want to start the project from scratch,
or access the completed working programs. The completed programs are in the finish
subfolder of the COBOL and PL/I sub directories. Alternatively, if you want to learn, the
start subfolder. For more information about the project structure, see the
README file that summarizes the project directory content and
structure. For more information on this Gradle build
function, see Building an API requester WAR file.
- Build inputs
-
For the endpoint application WAR file, the Java code that is located in src/main/java is compiled and packaged with src/main/webapp/WEB-INF/web.xml to create the API endpoint application WAR file redbook-1.0.0.war. For more information on how to deploy the WAR file to a running server, see Deploying an API requester WAR file.
To create the z/OS Connect API requester WAR file, the files at RedbookApi/src/main/api/redbookapi.yaml and RedbookApi/src/main/config/options.yaml are used by the z/OS Connect API requester Gradle plug-in to build the mapping and transformation information. This information is used within z/OS Connect to process a request and to call the API endpoint application, transforming binary data to and from JSON with the correct parameter settings and bodies for the API to function.
The sample mapping and transformation information are packaged in the RedbookApi.war file. For more information on how to deploy the WAR file to a running z/OS Connect Server, see Deploying an API requester WAR file.
- Redbooks OpenAPI 3.0 document
-
The redbookapi.yaml file describes an OpenAPI 3.0 API with two paths and five operations. An operation is defined as a unique callable endpoint of the application API and the five operations in the sample API are
getAllRedbooks,getRedbook,createRedbook,patchRedbook, andmergeRedbook. For more information about the RedbookAPI operations, see theREADME file.
- options.yaml file
- The z/OS Connect
API requester
Gradle plug-in processes the
redbookapi.yaml file to produce the mapping and transformation information. To
determine how this transformation takes place, the options.yaml file has
several parameters that control the generated artifacts such as
names,versions, and how the COBOL data structures are transformed to and from JSON. Only thelanguageoption is required. The other parameters are optional. For a complete description of the parameters, see The API requester Gradle plug-in properties and options.
Procedure
What to do next
Understand the build output. The Gradle build
produces two WAR files. One for the API endpoint application and one for the
z/OS Connect
API requester. The following list details the build
outputs for the sample-oas3-requester
start
tutorial.
- redbook-1.0.0.war
- The API endpoint application contains the compiled Java classes and a web.xml file in a format that conforms to WAR file standards and can be deployed to Liberty. This WAR file is created in the project's build/libs directory.
- RedbookApi.war
- The z/OS Connect API requester contains a web.xml file and conforms to WAR file standards and can be deployed to a z/OS Connect Server instance. The WAR file contains mapping and transform files for each operation. This WAR file is created in the project's RedbookApi/build/libs directory.
- RedbookApiPLI.war
- The z/OS Connect API requester for PL/I applications contains a web.xml file and conforms to WAR file standards and can be deployed to a z/OS Connect Server instance. The WAR file contains mapping and transform files for each operation. This WAR file is created in the project's RedbookApiPLI/build/libs directory.
- COBOL copybooks for each operation that is defined in the redbookapi.yaml file
- Under RedbookApi/build/generated/zosConnectRequester/structures/COBOL are the COBOL copybooks for each operation that is defined in the redbookapi.yaml file. These must be copied to a suitable PDS on z/OS that is referenced in your COBOL compile JCL.
- PL/I include files for each operation that is defined in the redbookapi.yaml file
- Under RedbookApiPLI/build/generated/zosConnectRequester/structures/PLI are the PL/I include files for each operation that is defined in the redbookapi.yaml file. These PL/I include files must be copied to a suitable PDS on z/OS that is referenced in your PL/I compile JCL.
- Parser processing log files
- The parser processing log files are located in RedbookApi/build/logs and RedbookApiPLI/build/logs.
Creating a z/OS Connect Server to deploy the
sample-oas3-requester sample
sample-oas3-requesterHow to create a z/OS Connect Server with the
zosConnect-3.0 feature to deploy the API requester
sample-oas3-requester
start
tutorial.
Before you begin
The following tasks must be completed.
About this task
This task takes you through the steps to create and deploy a sample z/OS Connect Server to run the tutorial. After creation, the sample server contains both the API requester WAR file and the API endpoint WAR file. However, you can optionally update both these WAR files if you change the tutorial source files.
For more information, see Deploying API requesters to IBM z/OS Connect.
