Raml Basics -Part2

Mule 4 Indepth Api led connectivity and RAML Design
27 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.35
List Price:  €96.21
You save:  €28.86
£55.83
List Price:  £79.77
You save:  £23.93
CA$100.76
List Price:  CA$143.95
You save:  CA$43.19
A$112.23
List Price:  A$160.33
You save:  A$48.10
S$95.14
List Price:  S$135.93
You save:  S$40.78
HK$543.62
List Price:  HK$776.63
You save:  HK$233.01
CHF 63.04
List Price:  CHF 90.06
You save:  CHF 27.02
NOK kr797.48
List Price:  NOK kr1,139.30
You save:  NOK kr341.82
DKK kr502.49
List Price:  DKK kr717.87
You save:  DKK kr215.38
NZ$124.10
List Price:  NZ$177.29
You save:  NZ$53.19
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,361.55
List Price:  ৳11,945.58
You save:  ৳3,584.03
₹5,962.79
List Price:  ₹8,518.63
You save:  ₹2,555.84
RM314.04
List Price:  RM448.65
You save:  RM134.61
₦108,335.42
List Price:  ₦154,771.52
You save:  ₦46,436.10
₨19,495.71
List Price:  ₨27,852.21
You save:  ₨8,356.49
฿2,390.81
List Price:  ฿3,415.60
You save:  ฿1,024.78
₺2,467.44
List Price:  ₺3,525.07
You save:  ₺1,057.62
B$434.14
List Price:  B$620.23
You save:  B$186.09
R1,296.68
List Price:  R1,852.48
You save:  R555.80
Лв131.68
List Price:  Лв188.12
You save:  Лв56.44
₩102,198.93
List Price:  ₩146,004.73
You save:  ₩43,805.79
₪256.56
List Price:  ₪366.53
You save:  ₪109.97
₱4,090.81
List Price:  ₱5,844.26
You save:  ₱1,753.45
¥10,994.99
List Price:  ¥15,707.80
You save:  ¥4,712.81
MX$1,408.98
List Price:  MX$2,012.91
You save:  MX$603.93
QR255.09
List Price:  QR364.43
You save:  QR109.34
P967.82
List Price:  P1,382.66
You save:  P414.84
KSh9,046.20
List Price:  KSh12,923.70
You save:  KSh3,877.50
E£3,562.49
List Price:  E£5,089.49
You save:  E£1,527
ብር8,907.19
List Price:  ብር12,725.10
You save:  ብር3,817.91
Kz63,830.88
List Price:  Kz91,190.88
You save:  Kz27,360
CLP$69,323.69
List Price:  CLP$99,038.09
You save:  CLP$29,714.40
CN¥510.80
List Price:  CN¥729.75
You save:  CN¥218.94
RD$4,245.36
List Price:  RD$6,065.06
You save:  RD$1,819.70
DA9,465.07
List Price:  DA13,522.10
You save:  DA4,057.03
FJ$162.39
List Price:  FJ$232
You save:  FJ$69.60
Q539.11
List Price:  Q770.19
You save:  Q231.08
GY$14,638.77
List Price:  GY$20,913.42
You save:  GY$6,274.65
ISK kr9,772.70
List Price:  ISK kr13,961.60
You save:  ISK kr4,188.90
DH703.98
List Price:  DH1,005.73
You save:  DH301.75
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,143.97
List Price:  ден5,920.21
You save:  ден1,776.24
MOP$559.97
List Price:  MOP$800
You save:  MOP$240.02
N$1,289.45
List Price:  N$1,842.15
You save:  N$552.70
C$2,574.80
List Price:  C$3,678.44
You save:  C$1,103.64
रु9,534.71
List Price:  रु13,621.60
You save:  रु4,086.89
S/260.99
List Price:  S/372.86
You save:  S/111.86
K283.85
List Price:  K405.52
You save:  K121.66
SAR262.91
List Price:  SAR375.60
You save:  SAR112.69
ZK1,936.45
List Price:  ZK2,766.47
You save:  ZK830.02
L335.12
List Price:  L478.77
You save:  L143.64
Kč1,694.03
List Price:  Kč2,420.15
You save:  Kč726.12
Ft27,771.44
List Price:  Ft39,675.18
You save:  Ft11,903.74
SEK kr774.38
List Price:  SEK kr1,106.30
You save:  SEK kr331.92
ARS$71,792.58
List Price:  ARS$102,565.23
You save:  ARS$30,772.64
Bs484.55
List Price:  Bs692.24
You save:  Bs207.69
COP$307,165.41
List Price:  COP$438,826.54
You save:  COP$131,661.12
₡35,530.54
List Price:  ₡50,760.09
You save:  ₡15,229.55
L1,777.33
List Price:  L2,539.15
You save:  L761.82
₲546,250
List Price:  ₲780,390.60
You save:  ₲234,140.59
$U3,115.91
List Price:  $U4,451.49
You save:  $U1,335.58
zł287.82
List Price:  zł411.19
You save:  zł123.37
Already have an account? Log In

Transcript

Welcome back. This video is in continuation with part one of ramel. So in this video, let us start understanding how to define custom data types. So basically for my API, I won't define my own data types like suppose if I want a customer to have only these fields, I want my customer data type to contain ID. And prefix action if you see after prefix. There's a question mark that means what it is optional, and I want first name, Middle Name, Last Name suffix is optional.

And you can see here address is of type address and address is its own custom data type again, which is different at the bottom. And similarly for account I want account owner to be area of account owner. account owner is defined here on worry, right. So basically, what I want is I want To create my own data types, let us see how to create my own data types in Gremlin. Very simple. What I will do right now is here I am in bank ap ramel I'll click on plus.

First of all, I will create a new folder called as data types. Okay, and inside this I'll click on this and I'll click on plus now, new file. I want to define user right data type. Here I select and I want my ramel filename to be something like custom error. Message dot RAM is the file extension is dot ramel. Let's say create.

You can see that the file is created but outside datatypes selection of selected data which you should have gone inside, but I will drag and drop this data types this ramble file inside data types inside now if we observe this file here after ramble 1.0 it says the file contains a data type definition. If you observe a meal mean Ramadan after Ramadan 1.0 it is not containing anything that means it's a mean ramify and here there is data type in this data type this contains the data type definition and what type of data type I'm defining I want the type as object and I have defined the properties. So what I want is earlier I give property status code and method is it. Same thing here and copy paste. indentation is very important actually. So we have to indent properly to spaces All right.

So I defined my own data type called as custom error message dot ramel which contains two properties status and message. Similarly I can define other data types like customers etc. But to save some time I have already defined them. So I have a zip file in rambled Oxford or Carla's banking data types. So I want to import this so copy this path how to import an existing zip file. Very simple.

I will first of all select the data types. And then I will click on Import. I can import a file unzip, I can select Choose File and here I have banking different types I am importing all the files will be imported. Let's see Oh, I think I imported the wrong zip. So what I will do is select this and delete this actually unselect this and maybe delete this again I imported wrong file so I deleted login and create a new folder called s data types okay so I want to import again select this and import but actually I will import this there type Allah I have imported this banking data types around one I will import this data types right now. Open inputs Okay, so actually all of them came out so I will drag and drop all of them inside data types Okay.

Let's see customer dot Rama see customer dot rammer. Here's our datatype definition. It has properties like customer ID prefix is optional. It's as an equation mind. first name last name suffix soundless and if you see address is affected address and he had to have address Yes. And also I want you to see account account is having a property called as account ID.

You can see here account type is an enum, which has only all these types you understood how to define an enum is it and one important thing is account owner is an area of account owner type here is an another type called account owner. And these are can specify an array. And also can observe that even is a string and we can even specify the regex pattern here as well. Right? This is a very good example of how to define an enum how to define airy how to define a pattern. Right, very nice example.

Select that I have I have all these different types is it Then once I have a type how to refer to these types in my main ramble. Yep. So what I'll do is I will copy paste this document and I'll explain you the main grammar like copy paste let's see how I am referencing. Here I defined a type I defined a key called as types. And here I gave an alias to customer and see here I'm using exclamation include including what data type slash customer so here I'm giving an alias. And then if you see for GET request of customers, the body I am defining application slash Jason type is what?

Customer array. Don't get confused. This is not The name of the amyl file this is the name of the India's support FAQ here, see here are you care is it so here I'm giving an alias and here I'm using the same alias. Here I'm specifying that the response body content will be of type customer array like this. Similarly for 404 type is custom error message and for 406 customers right. And again for post body was the body forget for slash customers type is what I renamed a C writer you see.

Right. So first body is customer and response headers everywhere. What I did is now wherever I was having custom error message properties, I need visit with my customer. Even for here, get ready request to slash customer slash ID the return type will be see whatever I give right so like that I updated the whole document. Now we have given the types but it'd be good if I can give you examples All right. So how to define an example what I can do is simply I can create a new folder examples and under that I want to do a customer example dot ramble I'll create a new file.

Type is got Here is Example your customer example dot Remo you can observe that grandma example here it is named eggs. sample, the type is named example. So what I'll do is right now I have customer example here and go to examples. I'll open this customer example dot Rama copy all then paste. Yeah. So this is how the customer example will look like this example it should be under examples for right I'll just move it.

Okay, now I want to refer to this example here. We'll go to customer Actually, I'll go to the same indentation actually where our properties that I took it here then I'll type example, there is something called an example. Example of this type, and examples. Examples of this type represented as a string, so I can do a direct one example if I can give an example. And what I can do is right now we can use exclamation include include sorry spelling mistake in Claude. What?

Dot dot slash example slash customer example right. So since I have one example I thought I could use example but here I'm getting another named example fragments must be included in exam polls. Actually this is a known issue when design center right now, actually as there is only one example I could even use example. Now I'll say examples. There's a known issue he should have accepted even if I give example. All right, so here example that's okay.

Now that's our can give example it can even import other examples by selecting example I can select inputs. You can select inside examples have a count example. Okay? So I count example it should go to here, sorry. It's a drag and drop. Now you can login modify account or travel to contain example.

That is okay, I'm not doing it. Okay. So I followed the steps given this document I defined that custom type and also examples Now, lastly, I want to add a documentation fragment how to add documentation. So right now what I'll do is I'll create a folder called as documents. Now, documentation maybe I want to add documentation to my ramble. So what I will do is according to this document, I'll write a file with name Acme bank doc dot ramaa.

Create a new file. But now the file type is what? user documentation and the file name I'll give Acme bank. Doc dot Rommel and here you can see the type is documentation item. Actually, the document is item will appear in the documentation of Roman letter we'll see that so what I'll do is again, meramec Doc's have created documentation folder, Acme bank doc dot ramble, I'll copy this content and paste it here. This is a document content which I want to give.

Similarly I want to create one more document Of course I'll move now to documentation folder. We'll create one I want to import one more document in coach. So the file again under documentation I have is Acme bank headline. Right. So again, drag and drop it to documentation. So to documentation rambles, how to use them in the main ramble?

Let us see I have this file where I will copy paste Yep, so I copy paste. So you can see here right now is a key column documentation where I included two documents. So these are what looks like. Now you'll see the impact of documentation later when I generate the nice UI documentation lead. Okay. Now, I'll follow one more document, which I have created.

Ramble part two. Yep. So here, what I want you to understand is, in this API project, I have created custom data types, custom examples, etc. Right? Maybe in our organization, we might be writing multiple API's. And customer travel, the data type customer account and all the I want them to reuse the data types examples.

I want them to be reusable, how to make reusable API fragments. I want this data types and examples to be published as a separate asset, so that they can be reused across APA projects. How to do that. Let us see. So again, I'll go back to my design center. Now I'll create earlier I selected create API specification.

Now I'll click on Create API fragment. I'll say my banking types as a fragment and what are the current thing it contains data types this fragment contains data type definitions create a fragment project will be created right now. Okay. Now no I don't want to type in each and everything I want to import import. I have a file already given inside my ramel doc there's banking data types zip file, I'll open that import. Let us see what is there in that zip after important.

Yep, here you can see data types and examples. Whatever I want to reuse, is it customer dot ramify. See? It's having the examples included right. So Other data types now I want these to be reusable. So what are reusable assets are there we already understand.

We understood that we can publish them to exchange how to publish any asset to exchange. I just have to click on Publish to exchange. And what's the name of this fragment? I'll say Siva banking types. I said Watson from Watson, it's taken by default publish. So it's publishing my Siva banking tied to API.

Exchange. So if I want to see the exchange, I can click on this link. It will show me the server banking types in the exchange Moses right now I'll go back to asset list. Here you can see see what banking touches it and this is an asset from the to learn and if you click on this Provided by mule soft you will see the assets provided by mule soft right now published by wetland These are only a set. Okay, now how to reuse this asset in exchange in my one other API project. Let us go to the designer once more.

Go to design center again, go to my original bank API. Okay. Here you can see that there are two links on the left side first one is files and the second one is exchange dependency. I want something in Excel to be added as a dependency to my project. So click on plus add dependencies and I'll search for See? And Yep, did see that.

My APA fragment which I published here is appearing, yes, I'll add one dependence. Okay. Now I want this dependency to be shown files. I clicked on it, and I'll select this show in files. See, exchange modules are shown in phase, my banking types 1.0 point zero data types. So now, I want this customer to travel to be used.

What I'll do is I'll click on this copy part to clipboard. Then I'll go to my main file. here instead of including the local ones, I'll delete this and I'll paste. See, I'm actually including the ones in exchange modules. Right? Now can I go to data types here and delete my customer data model?

It is no more required locally because it's pointing to the exchange dependency. Yes, I'm deleting the custom model. Right. So like that, what I can do is I can actually delete my whole examples folder and database folder. And I can point everything to exchange dependency. Now you understood how to actually reuse API fragment, how to create API fragments, and also how to reuse the API fragments.

So this we haven't ever done before this document. Yep. So Now let us publish this ramble APA specification. Oops, sorry, this is already done. So it is done. So right now, actually what we want to publish the APA specification itself to exchange.

Okay. After we have published the APA fragment, if you want to publish API specification also to exchanges, click on this. Yeah, my bank API. I'm publishing this also to exchange the words AP versus the one publish example, it will be published to exchange done. Now, if I go to my exchange, and if I refresh, I should see my bank API also. Nice.

So now you understood how to publish. So if I go to this my bank API. Actually, whatever asserts populist in the exchange is local, local to the organization, the customers outside of your organization cannot view the assets in exchange, how to make the assets in your exchange, the API is near exchange to be visible to outside of your organization, what you can do is you can share this API to a public portal. So I can click on this link at the public portal, which version version one ship. So now, this will be published, public portal done, how to see the portal. Go back to the asset list of your excellence.

Here is a link to public portal if I click on it. Now it will take me to the public portal URL where I can see this URL public. portal URL. You can actually share it with somebody and whoever has this. They don't need to be part of your organization, they'll be able to view your API's is that. So here is the summary.

This API, you can clearly see it, right. So one beautiful thing about designer is in designer, we have something called mocking so is on the right side. Actually, we are still in the design phase of our API. We want to get feedback from our stakeholders about the API design. But we didn't implement this API how to get the feedback. So what I can do is I can switch on the mocking service.

Once I switch on the mocking service, you can see that base URI is given Third, this is Margaret, this URL, let me take this UI and using my postman, I will try to give a request. Okay, just wait until postman starts. Yep. So I'll try to give a request to this mock up URL slash customers get request. Hey, I got How did I get it actually? How is it mocking?

Is it the same thing which I gave in my example? Yes, I am getting the response from the mock could URL. The mock server is not doing much it is just giving the response whatever I specified in the example of my customer data type, is that so basically, once I mock my URL, and if I publish it, somebody in my public portal who is seeing My APN public portal, they'll be able to test try out the API as well. Right? This is my portal. And actually right now the base URL is not different, because when I was publishing it, the base URI was not defined.

Actually, what I could have done is out after mocking I should have published to my portal that the best you could have been available. And somebody who is seeing this in portal will be able to try out by clicking on get and click on this one, send a request. I got it got upgraded automatically, right? slash customers. Yep, I got it. See, after mocking, I'll be able to send a mock request and I'll be able to get it on my portal as well.

So somebody who sees this API on the portal, they'll be able to try and they feel as if they're getting the real response. So now we understood about how to publish your assets to exchange and also to Portland how to share your API's to other customers using portals. I'll see you a few more. I'll see few more things in next week. See you next week.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.