Top RAML Interview Interview Questions (2021) | CodeUsingJava








Most frequently asked RAML Interview Questions


  1. What is RAML?
  2. Why we use RAML?
  3. What are the various HTTP methods supported by RAML?
  4. What are Extensions in RAML?
  5. What Is ResourceTypes?
  6. How to declare resourceTypes With HTTP Methods GET and POST?
  7. How to define Resource Types with HTTP methods?
  8. What is the difference between RAML and Swagger?
  9. What Is Traits?
  10. How can you call Traits From ResourceTypes?
  11. What is the difference between resource type and traits?


What is RAML?

RESTful API Modeling Language is a YAML-based language for describing RESTful APIs.It includes all of the information needed to define RESTful APIs.RAML is identical to WSDL it includes the endpoint URL, request/response schema, HTTP methods, as well as query and URI parameters.

Why we use RAML?

  • RAML informs the client about the service and how all the operations can be invoked.
  • It supports the developer in the creation of the API's initial structure.
  • For documentation purpose,RAML can also be used
  • RAML can be used to create an interface.


What are the various HTTP methods supported by RAML?

The following are the HTTP methods that RAML supports:
  • GET:used to describe retrieving of data.
  • PUT: This is a method for updating data.
  • PATCH:used to describe to partial Update/Modify
  • POST:used to add new record
  • DELETE:used to describe the act of deleting a record.


What are Extensions in RAML?

The extension can be used to expand or override the API's behavior. RAML 1.0 Extension as an example
Extensions, as the name suggests, are used to extend an API by adding new behaviors and/or changing existing behaviors. A subclass extending a superclass, where the subclass can add new methods and/or override existing methods, is an object-oriented programming analogy. Non-functional parts of an API can also be extended by an extension
For example, to specify additional resources that are only visible to a limited number of users, such as administrators or users who have been assigned a specific role. An extension could also be used to add functionality to a newer API version.

What Is ResourceTypes?

ResourceTypes are similar to resources in that they allow you to specify descriptions, methods, and parameters. The nodes of a resource that uses resourceTypes can be inherited.
ResourceType is a template for defining descriptions, methods, and parameters that may be used by different resources without having to write duplicate or repetitive code.

How to declare resourceTypes With HTTP Methods GET and POST?


resourceTypes: 
  accouontcollection:
    usage: Thisis used by <<resourcePathName>>
    description: This is used to fetch <<resourcePathName>>
    get:
    post:
  


How to define Resource Types with HTTP methods?

resourceTypes: 
  collection:
    usage: This is used by <<resourcePathName>>
    description: This is used to fetch and create <<resourcePathName>>
    get:
      description: This is used to fetch <<resourcePathName>>
      responses: 
        200:
          body: 
            application/json:
              example: |
                <<examplereference1>>
    post:
      description: This is used to create <<resourcePathName>>
      body: 
        application/json:
          example: |
            <<exampleReference2>>
      responses: 
        201:
          body: 
            application/json:
              example: |
                {"message":"<<resourcePathName>> created"}


What is the difference between RAML and Swagger?

  1. RAML
  2. The purpose of RAML is to offer critical information to RESTful APIs in order to simplify API design.
  3. Mulesoft, Intuit, AngulasJs, PayPal, Programmable Web and API Service, Cisco, VMWare, etc support RAML.
  4. Because of its API specification, design principles, and code reusability, as well as the fact that it is human readable, RAML is chosen by developers.
  5. RAML allows the user to see how the API appears while creating simple, easy-to-read .
  6. RAML is compatible with JSON schema and W3C XML.
  7. Swagger
  8. The goal of Swagger is to keep documentation, client libraries, and source code in sync.
  9. Google, IBM, Atlassian, and Microsoft all support Swagger.
  10. Swagger is used because it is free to use, open-source, and capable of executing API calls directly from documentation.
  11. Swagger is a developer-only documentation tool, which means that only the user who created the API can document the project.
  12. Swagger does not support XML and only uses a subset of JSON in version 1.2.


What is Traits?

Traits are similar to functions and they are used to specify common attributes for HTTP methods (GET, PUT, POST, PATCH, DELETE, etc), such as whether they are filterable, searchable, or pageable.

How can you call Traits From ResourceTypes?

By using "is" keyword Traits can be used to invoke from ResourceTypes.
traits: 
    responseMessage:
      responses: 
        200:
          body: 
            application/json:
              example: |
                {"message":"<<resourcePathName>> Created"}
resourceTypes: 
  collection:
    usage: This is used by <<resourcePathName>>
    description: This is used to fetch and create <<resourcePathName>>
    get:
      description: This is used to fetch and create <<resourcePathName>>
      responses: 
        200:
          body: 
            application/json:
              example: |
                <<exampleReference1>>
    post:
      description: This is used to create <<resourcePathName>>
      body: 
        application/json:
          example: |
            <<exampleReference2>>
      is: [responseMessage]



What is the difference between resource type and traits?

Resource Type is used to extract patterns from resource definitions(Ex. /user, /user/{id}), whereas a Trait is used to extract patterns from method definitions that are common across resources (GET, POST, DELETE, PUT).