Modeling an API with the API toolkit

You can model your API by adding paths, creating methods, and associating the methods with related z/OS® Connect services.

Before you begin

zosConnect-2.0 Applies to zosConnect-2.0.

Create an API project. If your API project is not yet open in the API editor, in the Project Explorer view, open the package.xml file located in your API project.

Procedure

  1. Import your service archive (.sar) file or files to your API project. Right-click an API project and click > Import z/OS Connect Services.
  2. In the API editor, specify a path.
    You can add a URI path parameter with curly brackets ({}). For example, the following path uses patID as a path parameter:
    /Patient/{patID}
    Multiple path parameters can be added to the path:
    /Patient/{patID}/{caseNum}

    You can add paths by selecting the Add icon icon next to Path.

    Tips:
    • A URI path parameter applies to all HTTP methods in the path. You can customize the data type for each HTTP method later in the mapping editor when you define the HTTP-to-JSON mapping for request and response messages. Specify a path parameter if it is applicable to all operations. Otherwise, use a query parameter, which is specific to an operation. Query parameters are specified in the mapping editor.
    • When you save your changes (Ctrl + S), package.xml is updated, and the changes are reflected in swagger.json.
  3. Add methods.

    By default, the POST, GET, PUT, and DELETE methods are listed. You can add methods by clicking the Add icon icon next to Methods.

    HTTP method Description
    POST Adds a new instance of the specified resource.
    GET Retrieves details about the specified resource.
    PUT Updates information for the specified resource.
    DELETE Deletes information for the specified resource.
    PATCH Applies partial updates to the specified resource.
    HEAD Retrieves the response identical to what a GET request would retrieve about the specified resource but without the response body.
  4. Assign a service to a method by clicking Service, then select a z/OS Connect service or import one from your Workspace or File System.
    Tip: If a service is changed after the API is created, upon re-importing the changed service, the impact of the changes is analyzed and reported. For more information, see Re-importing changed services.

What to do next

Define HTTP-to-JSON mapping in the mapping editor.