WEBVTT

00:05.590 --> 00:10.440
Hey, everyone had their share and welcome to another video of writing documentation.

00:10.450 --> 00:13.810
So in this video we're going to write a little bit more of the documentation.

00:13.810 --> 00:17.200
We'll try to understand where you can find things when you need them and all of that.

00:17.200 --> 00:19.930
But before that, let's at least write some of the stuff.

00:20.020 --> 00:25.450
So we have already seen that we are going to be using the open API specification of 3.0 or anything

00:25.450 --> 00:26.230
about three.

00:26.260 --> 00:28.210
Now it's not like two is bad.

00:28.210 --> 00:31.900
A lot of companies still use the two specification and that's completely fine.

00:31.900 --> 00:33.490
It's not going to bother you much.

00:33.610 --> 00:38.830
Now, apart from this, we can also mention a couple of info properties or informational properties.

00:38.830 --> 00:42.760
And once you write this info, this is where the biggest challenge comes in.

00:42.970 --> 00:45.790
The JSON is very indentation sensitive.

00:45.790 --> 00:51.070
You might want to install some packages that might help you to get these YAML extensions or help in

00:51.070 --> 00:51.850
the YAML files.

00:51.850 --> 00:56.830
But this is really, really important that you have these extensions or something installed because

00:56.830 --> 01:01.210
if you just go ahead and hit and enter up here and you start writing the things, it might go absolutely

01:01.210 --> 01:01.480
bad.

01:01.480 --> 01:02.980
So take care of the indentation.

01:03.160 --> 01:07.900
So if we're going to first mention the title property here, the title is going to be simple social

01:07.900 --> 01:08.350
app.

01:08.350 --> 01:09.430
Just go for that.

01:09.490 --> 01:12.670
And we don't use commas also in the YAML file.

01:12.670 --> 01:15.490
Let's go ahead and write some of the description.

01:15.490 --> 01:20.350
And as soon as you make any typo, this is going to go all crazy and your entire application will not

01:20.350 --> 01:21.760
be producing any docs.

01:21.760 --> 01:23.560
So stay very cautious on that.

01:23.560 --> 01:33.010
So if we're going to write our first social app at AE, so make sure you write your name after this

01:33.010 --> 01:33.550
as well.

01:33.550 --> 01:35.050
This is going to be interesting one.

01:35.050 --> 01:36.100
So let's go ahead and do that.

01:36.100 --> 01:38.650
It's not going to do anything magic, but just for fun.

01:38.650 --> 01:44.860
And we're also going to specify the version and our version is 1.0.1 this time because we are making

01:44.860 --> 01:45.760
some changes.

01:45.760 --> 01:51.280
As soon as I save this automatically, my node one should be able to recognize that if I hit a reload.

01:51.280 --> 01:53.830
Now we have some more stuff, that this is a social app.

01:53.830 --> 01:56.440
This is the version 1.0.1.

01:56.440 --> 02:02.410
We are supporting the open API specification three some description, but there is no operation that

02:02.410 --> 02:03.310
is being fine.

02:03.310 --> 02:08.440
But the bigger question that comes to the mind is how did I know that I have to write the info and inside

02:08.440 --> 02:09.730
these all these properties.

02:09.730 --> 02:11.470
No, I didn't know it out of the box.

02:11.470 --> 02:15.970
I actually looked in the documentation and this is where they say this in the basic structure.

02:15.970 --> 02:20.680
If you'll go on to the again the second link, remember I told you in the above one.

02:21.730 --> 02:22.030
Yeah.

02:22.030 --> 02:26.530
Here that the basic structure is the one where you'll be spending majority of the time and this is where

02:26.530 --> 02:27.520
we are here.

02:28.120 --> 02:33.490
So moving on, this is the open specification that I've used and after that I have used the info title

02:33.490 --> 02:34.810
description and the version.

02:34.810 --> 02:37.120
This is what I have used the majority of the time.

02:37.120 --> 02:41.080
You actually bring in a whole lot of code from this basic structure.

02:41.080 --> 02:45.940
I will provide you some as well eventually, but majority of the time you'll be coming up directly here.

02:45.940 --> 02:51.310
Let's go ahead and define the servers because this is another important aspect and you'll be using this

02:51.310 --> 02:51.910
a lot.

02:51.910 --> 02:56.500
So let's come back up here and we're going to be just moving up here and paste this.

02:57.010 --> 03:01.510
Now we can see that we are following some of the URLs up here and some of the descriptions as well.

03:01.510 --> 03:04.000
So in this case, we'll be adding up our own URL.

03:04.000 --> 03:10.210
So we're going to be simply saying this is actually for local host and we are running on Port 4000 and

03:10.210 --> 03:15.100
after that slash API slash V one is our general kind of thing.

03:15.100 --> 03:19.330
And after that we'll be going for directly slash Instagram, slash Facebook.

03:19.330 --> 03:24.460
Again, the guidelines for writing the documentation comes from either senior or you decide for yourself

03:24.460 --> 03:25.900
and you stick to that guideline.

03:25.900 --> 03:31.690
So if you say that I'll be writing API V one here, not onto the basic servers, then you follow that.

03:31.690 --> 03:37.030
If you say that no, every single route is going to have this one, then you stick to this one and description.

03:37.030 --> 03:46.360
Let's go ahead and go for something like local local host version of our app, something like this.

03:46.360 --> 03:50.410
Now you might have some of the staging environment production, some of the testing environments, so

03:50.410 --> 03:51.850
you can go ahead and use that.

03:51.850 --> 03:57.340
In this case, I'm going to just do something different in case your API also supports some online version

03:57.340 --> 04:03.490
of it with HTTPS or maybe a local host version of HTTPS, you can go ahead and do that and we're going

04:03.490 --> 04:05.620
to just say that this is just a dummy one.

04:05.620 --> 04:08.110
So we're going to say this is just a.

04:09.130 --> 04:13.360
Dummy API you URL eight.

04:15.190 --> 04:17.050
Doesn't work.

04:17.390 --> 04:17.760
Okay.

04:18.130 --> 04:21.250
So it doesn't work.

04:21.280 --> 04:22.120
There we go.

04:22.220 --> 04:22.540
Okay.

04:22.540 --> 04:24.780
I hope you get the idea that how this is all going on.

04:24.790 --> 04:27.500
So for the let's go back up here and so I get you.

04:27.760 --> 04:29.540
Let's hit the reload and there we go.

04:29.560 --> 04:34.960
Now we support to you URL, whatever the URL use you select, all the requests are going to be going

04:34.960 --> 04:36.520
up to that particular route.

04:36.520 --> 04:41.380
So instead of mentioning localhost, you can put up the actual URL that you have deployed.

04:41.380 --> 04:42.460
But again, be cautious.

04:42.460 --> 04:44.740
Somebody might come up and just hit a lot of requests.

04:44.740 --> 04:46.420
So be cautious on that part.

04:47.470 --> 04:48.510
So this is all done.

04:48.520 --> 04:54.190
One of the more thing that eventually we will be handling is going to come up from this basic structure.

04:54.190 --> 04:57.760
So sometimes you need authentication in your application as well.

04:57.820 --> 05:03.880
And you might want to say that somebody went logs in, I want to store his cookies, their session IDs,

05:03.880 --> 05:05.860
maybe bearer token or something.

05:05.960 --> 05:09.790
APIs specification already know this, that this is a common operation.

05:09.790 --> 05:10.540
You'll be doing it.

05:10.540 --> 05:11.920
So they support this already.

05:11.920 --> 05:15.130
They support the basic they support the beta one as well.

05:15.130 --> 05:19.600
So you can say and they support the cookie authentication and session IDs and all of that.

05:19.600 --> 05:21.520
So you can go ahead and use any of them.

05:21.520 --> 05:25.390
So we're going to come back here and we can see that this is all what we need.

05:25.390 --> 05:30.600
So all we got to do is copy this components and then we have to say security schemas.

05:30.610 --> 05:32.410
There are other schemas as well.

05:32.410 --> 05:35.020
So we support the basic one and the beta one.

05:35.260 --> 05:39.850
We won't be going for the open IDs and OAuth as of now, but if you need, you not know where to find

05:39.850 --> 05:40.270
them.

05:40.270 --> 05:46.600
So we're going to go ahead and copy the structure and coming back up here and let's go ahead and add

05:46.600 --> 05:51.910
these structures so components and save this as soon as you are going to save these ones.

05:51.910 --> 05:53.710
These are really important components.

05:53.710 --> 05:58.870
So if I hit a reload, now you have this authorized and this authorize, if let's just say you have

05:58.870 --> 06:04.480
kind of simulated a login request and you receive a beta token, you can just paste this beta token

06:04.480 --> 06:06.130
and make sure that you click on authorize.

06:06.130 --> 06:08.290
Like I can just write a test here and authorize.

06:08.290 --> 06:14.140
And whenever the next time you make a request, these beta token will already be added to the headers.

06:14.140 --> 06:14.980
That's awesome.

06:14.980 --> 06:16.720
So we're going to just go ahead and close this.

06:16.720 --> 06:18.310
And now you can see that now you're authorized.

06:18.310 --> 06:19.870
If you click in again, you are authorized.

06:19.870 --> 06:26.230
You can do the logout, it will clean up the code, whatever it is, but you get the idea how this works.

06:27.220 --> 06:28.630
So this is the basic stuff.

06:28.630 --> 06:34.570
Again, as I told you, there is so much in these stuff that I definitely cannot cover all of them.

06:34.870 --> 06:38.480
Just to give you more idea that, yes, you can actually go ahead and define the cookies.

06:38.480 --> 06:43.090
So in the components now you have to copy this, only the cookie part and you can go ahead and have

06:43.090 --> 06:45.370
your cookies and sessions and all of that.

06:45.610 --> 06:47.320
So let's keep it this much only.

06:47.320 --> 06:51.910
And in the next video we're going to see that how we can define our verbs, get post and all of that.

06:51.910 --> 06:54.070
And we're going to catch up in the next video.
