RAML - HelloWorld - Get method with one param


#1

Hello All,

I am a newbie to raml. I am trying to write a helloWorld RAML file with one get method as shown bellow. I am trying to understand what is what. Can some tell me what exactly example: | means and its importance. Please direct me to the link if one already exists.

#%RAML 0.8
title: Helloworld 
version: 0.8
baseUri: http://www.helloworld.com/myapi/{version}

/helloWorld:
  get:
     description: returns default hello world
  
  /{name}:
     get:
         description: Retrieve a specific book title
         responses:
           200:
             body:
               application/json:
                example: |
                   {
                          "returnMessage":"helloReturn"
                   }

If i wanna return just a String (instead of json response), how can i do that.

Thanks in advance.
PSR.


#2

Hi @sp092e, maybe the example here helps you a bit more to understand the different nodes and their meaning. The example node is optional and illustrates what you might expect back from an HTTP request. The | character just indicates a multi-line string, nothing else. If you want to define that your API only response a simple string/text then you might want to replace application/json with text/plain and thats it. You can change the example of course, or remove it.


#3

In short, example is used to represent a request or response format for the API.
Here is a link you can get a clear Idea : - http://raml.org/developers/raml-200-tutorial
| is just to put it into multi line

sample:

responses:
      200:
        body:
          application/json:
            example: |
              "songs": [
                  {
                    "songId": "550e8400-e29b-41d4-a716-446655440000",
                    "songTitle": "Get Lucky"
                  }
                  ]