To Design a Resource

This procedure builds on designing the RAML root and data type in visual design mode.

  1. In the navigation pane, click big plus v.

    vd newresource
  2. Select Resource.

  3. In the navigation pane, click /newResource.

    new resource
  4. Set the options that appear to define the resource:

    • Rename the resource from /newResource to /comments.

    • Select one or more HTTP methods. For this example, select GET. You want the API to get comments about posts from the service.

    • Click Documentation and describe the GET method. For example, type Get comments about posts.

    • Click Responses, and then click Add New Response.

    • In Status, accept the default 200-OK.

    • In Description, describe the status. For example, type Success, comments retrieved.

  5. Click Add Body to add a example response.

    This is the kind of response you expect when you call the API.

  6. Click Details to expand the property area and set the following options:

    • In Media Type, accept the default application/json.

    • In Type, select Object.

      The response that you are exemplifying consists of comments formatted as JSON objects.

  7. Click Details.

  8. In Example, click Edit, and add the following code between the curly brackets:

      "postId": 1,
      "id": 1,
      "name": "id labore ex et quam laborum",
      "email": "",
      "body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium"

Next, publish to Exchange and test the design.

In this topic: