0
votes

I have below requirement for designing simple RAML. I’m newbie in RAML coding so would like to know if my code is according to requirement or not

Requirement:

  • Has at least 1 endpoint with a GET and POST method.
  • Includes description attribute of the API
  • Includes description attribute of the method
  • The GET request takes a query parameter of "mulesoft"
  • Define the response with an object that contains least a string and integer data type
  • Includes an example for a 200 response code that matches the definition’s response object from above

My code:

#%RAML 1.0
title: Coding_Champions
version: 1.0.development
baseUri: http://localhost:8004/api
description: This API displays and adds Organisation with details

types:
  Org:
    type: object
    properties:
      name: string
      address: string
      pincode: integer
/details:
  displayName: Company Details
  description: Coding challenge which takes query parameter of "mulesoft"

  get:
    description: Retrieve a list of all the Orgs
    queryParameters:
      mulesoft: 
       description: Specify the Org name that you want to retrieve
       type:    boolean
       required: true
    responses:
      200:
        body:
          application/json:
            type: Org
            examples:
              MuleSoft:
                name: MuleSoft
                address: 77 Geary Street, Suite 400
                pincode: 94108
  post:
      description: Add a Org to list
      body: 
        application/json: 
            type: Org
            examples:
              Cognizant:
                name: Cognizant
                address: DLF
                pincode: 9771
      responses: 
        201:
          body: 
            application/json:
              example: |
                {
                "message":"New Org updated but not really"
                }                    

I’m more of concerned with one of point in the requirement

"The GET request takes a query parameter of “mulesoft”

Does it mean I should give mulesoft as parameter dynamically in my url, If yes then other than mulesoft is passed as parameter then it should throw an error ?

(or)

Does it mean i need to hard code “mulesoft” in my RAML code as I have done now ?

Can you please clear me on this ?

1
The description for query param mulesoft shows " Specify the Org name that you want to retrieve" but type is "boolean".How can a name be boolean? - Mahesh_Loya
thanks for reply.. description part you can ignore.. i ended of writing something ... - Rahul

1 Answers

0
votes

Does it mean I need to hard code “mulesoft” in my RAML code as I have done now ?

Yes.You should define that in RAML as you are doing right now.Since its required parameter,its presence could be validated in implementation.