REST APIs

Applies to ReadyAPI 3.57, last modified on December 20, 2024

In the Navigator panel, you can work with REST APIs to organize them for better accessibility and readability. REST APIs are organized in the following way:

REST API Structure

Click the image to enlarge it.

REST service

A REST service is a top-level node of the REST services in the Navigator panel. Select it to see and modify resources, endpoints, and the service’s specification:

Resources

REST resource is an abstract entity that represents an object of a REST service that you can work with. Resources are listed as child nodes of a REST service:

REST API Resources page
Add resources
  1. Click Plusnext to the REST API node and select Resource:

    Show image

    — or —

    Right-click the API in the Navigator and select New Resource:

    Show image

  2. In the Add Resource dialog, specify the resource name and select which methods this resource should support. Click New Resource to specify additional resources to create:

    Testing REST API in ReadyAPI: Adding new REST resource

    Click the image to enlarge it.

  3. Click Add.

Endpoints

The Endpoints page is the central place where you manage endpoints used in the REST API.

Testing REST APIs in ReadyAPI: The Endpoints page

Click the image to enlarge it.

You can configure the following options:

Option Description

Endpoint

The endpoint URL or destination.

The host cannot contain underscores.

Environment

An environment associated with the endpoint.

You can create only one endpoint associated with each environment. When you add a new endpoint associated to the same environment, the new endpoint will overwrite the existing one.
No Environments should be selected if you need to hit different endpoints in the same test case. The base API will remain the same, but will also allow for flexibility when configuring the requests contained in the functional tests.

Authorization Profile

An authorization profile used to access the endpoint.

Work with environments

When you do not use an environment, you can assign any endpoint that is not associated with an environment to REST API requests. In this case, the request or test step will send a request to the specified endpoint. Once you change the endpoint, it will be updated in all the requests and test steps using it:

Testing REST APIs in ReadyAPI: Set endpoins without environments

Click the image to enlarge it.

When you set an environment, all the API requests and test steps will use the endpoint associated with this environment:

Testing REST APIs in ReadyAPI: Set endpoins with environments

Click the image to enlarge it.

Specification

The Specification page of the REST Service editor shows the OpenAPI, Swagger or WADL definition of the service that is currently selected in the Navigator panel.

Note: RAML and Swagger 1.x specs are converted to WADL internally.
The Specification page

Click the image to enlarge it.

The content page lists available resources, methods, representations, and the specification. The specification will be updated when you add new resources and methods to the API.

Toolbar commands

Organize REST service

You can reorganize all the items in the API: requests, methods, resources and services.

Moving items

To move an item, copy it and delete the original item, or move several items and delete the ones you do not need:

  1. Select several items.

  2. Right-click them and select Move REST <Items>.

  3. In the subsequent dialog, select a target destination from the drop-down list.

Copying items

In ReadyAPI terms, cloning means creating an exact copy of an item. To clone test steps, test cases, or test suites:

  • In the Navigator panel, press Ctrl and drag the desired test step, case, or suite to a new location.

– or –

  1. Select one or multiple items in the Navigator panel. Right-click the selection and choose the Clone ... command from the context menu. Depending on the type of the selected items, the command text can be Clone Test Steps, Clone Test Case, or Clone Test Suite. If you selected items of different types, the context menu will contain a command for the last selected item type.

  2. ReadyAPI will display the Clone dialog, where you can specify the target project, test suite, and test case.

Renaming items

To rename an item:

  1. Right-click it in the Navigator panel and select Rename.

  2. Enter a new item name.

Renaming items does not affect the API definition, it affects only item representation in ReadyAPI.

Renaming an item of a composite project will change the matching item's file name.

Deleting items

To delete a item, select it in the Navigator panel and press Shift+Delete, then confirm you no longer need it.

Changing the item order

You can drag most items to the position you need in the Navigator panel. The item order does not affect your tests.

Note: Methods cannot be reordered.

Request specific tasks

Adding requests to functional tests

To add a request to a functional test:

  1. Right-click the request in the Navigator panel and select Add to Test Case.
    – or –
    Open the request editor and click Add to Test Case on the toolbar.

  2. Select the test case to add the created test step to. You can also create a new test case or test suite and place the request there. Click OK.

Adding requests as virtual responses

To add a request as a virtual response in a functional test:

  • Right-click the request in the Navigator panel and select Add as REST VirtResponse Step.

  • Select the test case to add the created test step to. You can also create a new test case or test suite and place the request there. Click OK.

ReadyAPI will add the latest response to the created REST VirtResponse test step.

Generate test suites

To create a test suite and test cases based on the service definition, do the following:

  1. Right-click the service and select Generate Test Suite.

  2. Use the Generate Test Suite dialog to configure how ReadyAPI should create test cases:

    Generate TestSuite dialog
    • Test Suite – Specifies the test suite to which the created test cases will be added.

    • Style – Specifies how ReadyAPI organizes the created test cases:

      • One test case for each resource – ReadyAPI creates REST Request test steps for each method in the selected resources and organizes them into several test cases.

      • Single test case with one request for each method – ReadyAPI creates REST Request test steps for each method in the selected resources and organizes them into a single test case.

    • Resources – Selects resources to generate test cases.

    • Create Load Test – Specifies whether ReadyAPI creates a load test for each created test case.

  3. Click OK.

ReadyAPI will create new test cases and name them based on the definition.

See Also

REST Service Interface
Working With APIs

Watch the video
 
Highlight search results