subscribe our youtube channel popup

RAML and Publish to Exchange in MuleSoft

Join us to learn about Basic of RAML and how to publish API to exchange in MuleSoft. We will learn about resourceTypes, Using ! include, types and type in RAML.

When & How to use resourcesTypes?

  • “resourceTypes” refers to a way to define reusable templates or blueprints for different types of resources in your API.
  • Think of them like a set of instructions that you can use to create consistent and standardised resource definitions.
  • Used for Best practices to avoid writing code again and again.
  • The resourceTypes uses some user-defined parameters surrounded by double angle brackets (<< and >>)
  • <resourcePath> – represents the entire URI (not URL)
  • <resourcePathName> – represents the part of URI (the oath of the URI following the right most forward slash)
  • Parameter functions for example:
    !singularize
    !pluralize
    !uppercase
    !lowercase
    !uppercamelcase
    !lowercamelcase
    !upperunderscorecase
    !lowerunderscorecase
    !upperhyphencase
    !lowerhyphencase
  • For example, given the resource /health, where <> evaluates to “health”
    <resourcePathName | !uppercase> ==> “HEALTH”

HANDS-ON

RAML and Publish to Exchange in MuleSoft ( Session 4)

When & How to use traits?

  • “traits” are a kind of resourceTypes
  • Understand this way : resourceTypes are used to extract pattern from “resource” definitions (resource level) , whereas , traits are used to extract patterns from “method” definitions that are common across resources.
  • In simpler terms, traits are defined to use whenever there is a common functionality needs to be implemented across more than one method at-least.

Purpose?

  • First, we need to identify the redundant(repeated) sections of our resources, recognize their patterns, and extract resource types.
  • Then should do the same for the methods that are common across resources to extract traits. Then we will be able to eliminate further redundancies by applying traits to our resource types .
  • To summarize, we use resourceTypes and traits to eliminate writing the same code repeatedly . Instead, Write once and use it across

Summary

Checkout our complete MuleSoft Training to learn all about MuleSoft. We have 15+ session for you with Final Project.

Apex Hours
Apex Hours

Salesforce Apex Hours is a program of the community, for the community, and led by the community. It is a space where Salesforce experts across the globe share their expertise in various arenas with an intent to help the Ohana thrive! Join us and learn about the apex hours team.

Articles: 419

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *