Hey, everyone had their share and welcome to another video of writing documentation.
So in this video we're going to write a little bit more of the documentation.
We'll try to understand where you can find things when you need them and all of that.
But before that, let's at least write some of the stuff.
So we have already seen that we are going to be using the open API specification of 3.0 or anything
about three.
Now it's not like two is bad.
A lot of companies still use the two specification and that's completely fine.
It's not going to bother you much.
Now, apart from this, we can also mention a couple of info properties or informational properties.
And once you write this info, this is where the biggest challenge comes in.
The JSON is very indentation sensitive.
You might want to install some packages that might help you to get these YAML extensions or help in
the YAML files.
But this is really, really important that you have these extensions or something installed because
if you just go ahead and hit and enter up here and you start writing the things, it might go absolutely
bad.
So take care of the indentation.
So if we're going to first mention the title property here, the title is going to be simple social
app.
Just go for that.
And we don't use commas also in the YAML file.
Let's go ahead and write some of the description.
And as soon as you make any typo, this is going to go all crazy and your entire application will not
be producing any docs.
So stay very cautious on that.
So if we're going to write our first social app at AE, so make sure you write your name after this
as well.
This is going to be interesting one.
So let's go ahead and do that.
It's not going to do anything magic, but just for fun.
And we're also going to specify the version and our version is 1.0.1 this time because we are making
some changes.
As soon as I save this automatically, my node one should be able to recognize that if I hit a reload.
Now we have some more stuff, that this is a social app.
This is the version 1.0.1.
We are supporting the open API specification three some description, but there is no operation that
is being fine.
But the bigger question that comes to the mind is how did I know that I have to write the info and inside
these all these properties.
No, I didn't know it out of the box.
I actually looked in the documentation and this is where they say this in the basic structure.
If you'll go on to the again the second link, remember I told you in the above one.
Yeah.
Here that the basic structure is the one where you'll be spending majority of the time and this is where
we are here.
So moving on, this is the open specification that I've used and after that I have used the info title
description and the version.
This is what I have used the majority of the time.
You actually bring in a whole lot of code from this basic structure.
I will provide you some as well eventually, but majority of the time you'll be coming up directly here.
Let's go ahead and define the servers because this is another important aspect and you'll be using this
a lot.
So let's come back up here and we're going to be just moving up here and paste this.
Now we can see that we are following some of the URLs up here and some of the descriptions as well.
So in this case, we'll be adding up our own URL.
So we're going to be simply saying this is actually for local host and we are running on Port 4000 and
after that slash API slash V one is our general kind of thing.
And after that we'll be going for directly slash Instagram, slash Facebook.
Again, the guidelines for writing the documentation comes from either senior or you decide for yourself
and you stick to that guideline.
So if you say that I'll be writing API V one here, not onto the basic servers, then you follow that.
If you say that no, every single route is going to have this one, then you stick to this one and description.
Let's go ahead and go for something like local local host version of our app, something like this.
Now you might have some of the staging environment production, some of the testing environments, so
you can go ahead and use that.
In this case, I'm going to just do something different in case your API also supports some online version
of it with HTTPS or maybe a local host version of HTTPS, you can go ahead and do that and we're going
to just say that this is just a dummy one.
So we're going to say this is just a.
Dummy API you URL eight.
Doesn't work.
Okay.
So it doesn't work.
There we go.
Okay.
I hope you get the idea that how this is all going on.
So for the let's go back up here and so I get you.
Let's hit the reload and there we go.
Now we support to you URL, whatever the URL use you select, all the requests are going to be going
up to that particular route.
So instead of mentioning localhost, you can put up the actual URL that you have deployed.
But again, be cautious.
Somebody might come up and just hit a lot of requests.
So be cautious on that part.
So this is all done.
One of the more thing that eventually we will be handling is going to come up from this basic structure.
So sometimes you need authentication in your application as well.
And you might want to say that somebody went logs in, I want to store his cookies, their session IDs,
maybe bearer token or something.
APIs specification already know this, that this is a common operation.
You'll be doing it.
So they support this already.
They support the basic they support the beta one as well.
So you can say and they support the cookie authentication and session IDs and all of that.
So you can go ahead and use any of them.
So we're going to come back here and we can see that this is all what we need.
So all we got to do is copy this components and then we have to say security schemas.
There are other schemas as well.
So we support the basic one and the beta one.
We won't be going for the open IDs and OAuth as of now, but if you need, you not know where to find
them.
So we're going to go ahead and copy the structure and coming back up here and let's go ahead and add
these structures so components and save this as soon as you are going to save these ones.
These are really important components.
So if I hit a reload, now you have this authorized and this authorize, if let's just say you have
kind of simulated a login request and you receive a beta token, you can just paste this beta token
and make sure that you click on authorize.
Like I can just write a test here and authorize.
And whenever the next time you make a request, these beta token will already be added to the headers.
That's awesome.
So we're going to just go ahead and close this.
And now you can see that now you're authorized.
If you click in again, you are authorized.
You can do the logout, it will clean up the code, whatever it is, but you get the idea how this works.
So this is the basic stuff.
Again, as I told you, there is so much in these stuff that I definitely cannot cover all of them.
Just to give you more idea that, yes, you can actually go ahead and define the cookies.
So in the components now you have to copy this, only the cookie part and you can go ahead and have
your cookies and sessions and all of that.
So let's keep it this much only.
And in the next video we're going to see that how we can define our verbs, get post and all of that.
And we're going to catch up in the next video.