Nav

To Add a Fragment to an API

  1. In Design Center, select a RAML API Specification project. For example, select the placeholder project. On the line following application/json for the /userbyid resource, remove the example.

  2. Click Exchange Dependencies Dependencies.

  3. In Dependencies, click Plus icon adds a dependency.

  4. In Consume API Fragment, find the fragment you want to add to the API, and add it to your API Specification:

    • Find and check myfragment for example.

    • Click Add 1 Dependency.

      consume api fragment
    • Click the dependency and choose Show In Files.

    • Click Copy path to clipboard.

    • In Files, select the API Specification placeholder.raml file.

      The API specification appears in the editor.

    • On the line following application/json for the /userbyid resource, indent, and add the following line:

      *example: !include *

    • Insert a space after the exclamation point and paste the clipboard contents:

      example: !include <clipboard contents>

      The path to the example fragment in exchange appears in the API specification:

      #%RAML 1.0
      title: placeholder
      version: 1.0.development
      baseUri: http://jsonplaceholder.typicode.com
      /users:
        get:
          description: Retrieve a list of all the users
          responses:
            200:
              body:
                application/json:
                  example: !include user-example.json
        /userbyid:
          get:
            description: Get information about a particular user
            queryParameters:
              id:
                description: Specify the id of the user you want to retrieve
                type:        integer
                required:    false
                example: 3
            responses:
              200:
                body:
                  application/json:
                    example: !include exchange_modules/c275897a-e10d-4aa8-bd34-e89f758a79ea/myfragment/1.0.0/myfragment.raml

In this topic: