Query parameters in raml


#1

Hi, I am new to this RAML. i am trying to create raml using query parameters. when i am hitting the url with the query parameter value which is provided in the body of the example, i am getting the response. when i am trying to hit the url with the value which is not provided in the body, then also i am getting same response instead of error. please help me in this.

#%RAML 1.0
title: firstApi
version: 1.0
baseUri: https://mocksvc.mulesoft.com/mocks/555a499c-89d1-4469-9030-da7410048946/employee # baseUri: http://firstapi.com/employee
/employee:
  description: describes the employee details
  get:
    queryParameters: 
      place:
        description: place of the employee
        type: string
        required: true
    responses: 
      200:
        body: 
          application/json:
            example: |
            
              {
              "id": 601,
              "name":"deeksha",
              "section":"A",
              "place":"pune",
              "department":"cse"
              }
      404:
        body: 
          application/json:
            example: |
              {
                "message":"Employee id is not recognized"
              }

#2

I would first say you probably need a 400 response type added… to handle the case of a Bad Request, which in the case of you requiring a query parameter and it not being part of the URL, would be the proper error response. I am however not sure if the mock service will “ignore” required fields IF you do not provide the correct response in the definition. Try adding a 400 and see if that solves it. If not, then maybe there is a setting in the mock service to ignore required properties that needs to be changed.


#3

so you’re hitting /employee without ?place and it still returns 200? if so, then yes that’s probably a bug with whatever tools you are using.