Hey there, everyone.
This year it's almost 2:00 in the night, so we're going to handle just one more case tonight and the
rest of the videos we'll do tomorrow.
So what we're going to do in this one, in this one, we'll learn that how we can handle a raise, not
just the ordinary areas, areas which are a little bit complex and you'll be seeing this kind of area
more often.
So in this case, we have already defined the arrays with just doesn't hold the string but actually
holds a complex object, which is in itself an object.
So how we're going to do that first, we're going to define a new route for it and we're going to throw
back this array as it is.
So we're going to just make a copy of this one.
Let's get some space and here let's go ahead and call this out as probably causes.
So there we go.
OC code says, there we go.
Okay.
In the course we won't be handling anything complex.
We don't have knowledge anyways to handle much of the complex as of now.
Yes, we will design the complex APIs and infrastructure of that, but not right now.
Right now the only goal is to understand the documentation.
So now my route is all clear.
Now I can go into the swagger and obviously I need to create another route so I will copy.
As you know, I love this one.
This saves me a whole lot of time.
This is how this is going to be.
Let's go ahead and hit an enter.
There we go.
Now I will have a route which will be courses.
This will be in itself an array.
Again, you can name as many tags or if you can use reuse some of the tags previously mentioned, it
will grow them together.
The summary It doesn't return a unique course, but it returns all courses, courses like that.
Now we will be working on just one response which is 200.
So description, all good success.
The content type is of application JSON because although we haven't sent any of the JSON here, we are
just using resource and I don't want to use the another middleware and stuff.
So you get the idea how it is being done.
Now, the schema this time it is not a type object but rather a type of array.
Remember I told you in the previous video that although you can say that in the array, also further
properties are there, it can be a string or a couple of numbers.
Yes, technically they are also called as properties, but usually in the documentation.
As soon as the object comes in, then only the properties can be used.
So in the case of array, obviously the rather the perfect word for calling anything that is inside
the array are items and that's what exactly being used.
I'm telling you this because it's not compulsory to remember, but these talks actually help you to
remember things for a longer run.
So in here we are going to say that inside this array we do have items and once you have these items,
then you have to define that what each item looks like.
So in my case, the item I have to mention the type.
Now here I can go ahead and say that, hey, this array is returning all the strings or numbers or something
like that.
But in this case, I'll just move on to the same line.
Yeah.
What I'm coming back is the object.
Now, once you have defined that, okay, the type is object, then I can introduce my properties to
further define that how this is looking like.
But this is not a correct way of indentation.
So I'll just select and I'll use control and the square arrow square brackets.
So control and square bracket and this will indent it properly, make sure you keep an eye on the indentation,
otherwise it will hurt you badly.
And debugging is a little bit painful in this documentation.
Let's save that and see that if we are doing any good here to reload and of course the root is now here
it is a get root.
Of course we have courses, returns, all that and we see it's all good success, application, JSON,
nice and easy and we are having a schema.
So notice it says array and then we have the object inside this one which is exactly same as we define.
And we can also check out the schema that this is how the schema looks like.
We have an array a little bit difficult to see from here.
This is like little bit hidden, but I'll try to zoom it a little bit.
We get the same schema that we have defined and we can just go ahead and try out execute and it turns
me entirety 30 of the array that we have seen.
So this is good.
And again, it doesn't really matter.
Even if I write don't write properties or I say items that are going to get is a string.
Yes, I can technically write that, but when the request is being made to the server, the response
we are getting, it can be different.
It shouldn't be different, but it can be different in the majority of the cases.
In fact, in all the cases you want them to be as closely as what result we are going to get.
There is no explicit check being mentioned that the documentation are properly mentioned or correct
or not.
Okay, so now you know that a couple of things you can handle.
You can handle strings, you can handle objects and array as well.
Definitely there is a lot more to understand, a whole lot of post requests and a whole bunch of other
things that I'm going to do tomorrow.
But you can just click on the next video and watch it next up.
So let's go ahead and catch up in the next video.