NodeJS Swagger API Documentation Tutorial Using Swagger JSDoc

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ม.ค. 2021
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksimivanov.com/s/ytd
    In this video we'll build an ExpressJS CRUD application and document it using Swagger. We'll
    use swagger-jsdoc to write the specs and express-swagger-ui to show the Swagger interface.
    🐦 Twitter: / ivanov_dev
    I write about React and TypeScript there
    Code: github.com/satansdeer/swagger...
    Codesandbox: codesandbox.io/s/swagger-api-...
    Video About Testing React Query Components: • How To Test React Quer...
    My discord: / discord
    Follow me on Odysee: odysee.com/$/invite/@stepbyst...

ความคิดเห็น • 150

  • @raymondabid3258
    @raymondabid3258 2 ปีที่แล้ว +3

    the best tutorial on the internet. did it all under 30 minutes. others tried and took them 10 videos to explain what you did in that time. well done and thanks for the help!

  • @codekomali1760
    @codekomali1760 2 ปีที่แล้ว +18

    Nice tutorial! For those who have a working restful service(s) and want to learn only the swagger part, you may safely skip to 9:50

  • @damonwu9658
    @damonwu9658 3 ปีที่แล้ว +2

    Thanks Maksim, good stuff, and yup, I'd love to see some typescript knowledge share ~~

  • @saboya700
    @saboya700 2 ปีที่แล้ว +2

    Hey Maksim, thank you so much for this content. Found in a very good timing because my team will start to use swagger and its routes/documentation soon. I had the opportunity to put in practice and also meet that great channel of yours. I started following and subscribed the newsletter. Hope to learn more with your explanations (specially in TS) here. Best regards

    • @Tom-vr5yv
      @Tom-vr5yv 2 ปีที่แล้ว +1

      name: maksim

  • @adrianzinko6292
    @adrianzinko6292 2 ปีที่แล้ว

    This tutorial was very helpful for me, thank you. I'd like to see more of your tutorials in TS.

  • @ilyacherkasov9251
    @ilyacherkasov9251 3 ปีที่แล้ว +4

    Oh yes, good idea! I'd like to see examples in TypeScript

  • @rafa_veiga
    @rafa_veiga 2 ปีที่แล้ว

    Hi Maksim! Thanks for sharing your knowledge, it helped me a lot with my new job. A big hug from Brazil.

  • @mitchelleuzonna4523
    @mitchelleuzonna4523 ปีที่แล้ว +1

    Amazing tutorial. Using typescript would be a welcome development.

  • @syammohan3039
    @syammohan3039 2 ปีที่แล้ว +2

    Found this very much useful for me as I am a beginner to Swagger :-)

  • @avoidloves
    @avoidloves 3 ปีที่แล้ว +2

    Thanks for the tutorial!! Make a typescript playlist man.

  • @feijobruno
    @feijobruno 3 ปีที่แล้ว +1

    This video helped me a lot. Thanks for the tutorial!!!

  • @hieu_nguyen_20
    @hieu_nguyen_20 2 ปีที่แล้ว

    Easy to follow coding and awesome. Keep it up !

  • @adventurer2395
    @adventurer2395 2 ปีที่แล้ว +6

    Awesome tutorial! Really like your examples. Any chance you could do another swagger tutorial with with typescript and mongoose/mongo?

  • @wimveldhuis1828
    @wimveldhuis1828 2 ปีที่แล้ว

    Great tutorial, thanks Maksim!

  • @raymondmichael4987
    @raymondmichael4987 ปีที่แล้ว

    Been searching for this, I’ll try to play with it when I got a chance, thanks 😊

  • @JackSomethingTheShow
    @JackSomethingTheShow ปีที่แล้ว +8

    For anyone struggling with lowdb, change the declaration to
    import cors from 'cors';
    import express from 'express';
    import morgan from 'morgan';
    import { Low, JSONFile } from 'lowdb';
    import { dirname } from 'path';
    import { fileURLToPath } from 'url';
    import { join } from 'path';
    const __dirname = dirname(fileURLToPath(import.meta.url));
    const file = join(__dirname, 'db.json');
    const adapter = new JSONFile(file);
    const db = new Low(adapter);
    const PORT = process.env.PORT || 4000;
    db.defaults({ books: [] }).write();
    Remeber to add type: module to your package.json file

  • @prasadphule
    @prasadphule 3 ปีที่แล้ว +18

    I'd love to see some Typescript in future for your code example.

  • @linclicin3326
    @linclicin3326 2 ปีที่แล้ว

    Thank you very much for such an awesome tutorial. Yes, Please use Typescript

  • @berakoc8556
    @berakoc8556 3 ปีที่แล้ว

    This video helped me a lot. Thanks.

  • @Dgiulian
    @Dgiulian 3 ปีที่แล้ว

    Great video. I would like to see more TS videos.

  • @artless-soul
    @artless-soul 3 ปีที่แล้ว

    Thank you for nice tutorial! typescript examples in future +1

  • @yossiarye6886
    @yossiarye6886 ปีที่แล้ว

    Thank you, typescript will be great

  • @lewissheridan
    @lewissheridan 9 หลายเดือนก่อน

    Nice job. Be great to add in the authentication bit. I managed to refer to the docs for that.

  • @andriisen1892
    @andriisen1892 2 ปีที่แล้ว

    Максим! Спасибо огромное за суперское видео, поделюсь с братьями по стажировке)

  • @mehdigozar9627
    @mehdigozar9627 ปีที่แล้ว

    Thank you. It was very good

  • @HovhannesGasparyan-ex4el
    @HovhannesGasparyan-ex4el หลายเดือนก่อน

    Thank you for the useful video)

  • @objectObject212
    @objectObject212 2 ปีที่แล้ว +1

    Hi, thanks for great video, definitely I am gonna be using swagger! I have just one question, why only post / route has try catch block and 500 response? Is there any reason for that or it is just by example?

  • @CodePremier2000
    @CodePremier2000 11 หลายเดือนก่อน

    Thank you so much❤❤
    Very helpful

  • @sede189
    @sede189 11 หลายเดือนก่อน

    Excellent tutorial

  • @raidalmoued664
    @raidalmoued664 2 ปีที่แล้ว

    Very Good tutorial. Many thanks

  • @esmaeilmirzaee
    @esmaeilmirzaee 3 ปีที่แล้ว +1

    Using TypeScript as the programming language would be so nice.

  • @eliasnacherfernandez9237
    @eliasnacherfernandez9237 2 ปีที่แล้ว

    So clear code, nice work

  • @samyh40
    @samyh40 3 ปีที่แล้ว

    Pure gold! Thank you

  • @sergeykahnwald6640
    @sergeykahnwald6640 ปีที่แล้ว

    Nice doing man!

  • @xanyula2738
    @xanyula2738 2 ปีที่แล้ว +2

    Suppose I keep the schemas from mongoose in a separate file from routes, how do I instruct swagger-jsdoc to parse schema instructions from there ? just add the path to apis section in the options object ? Or is there anything wrong with doing that

  • @anvarichn
    @anvarichn ปีที่แล้ว +2

    Yes, TS would be great! Or, at least using ESM modules in JS - that would be great as well! Let’s forget those old require() stuff and use imports!

  • @alint
    @alint 3 ปีที่แล้ว

    Thank you for the very informative video, loved the pace of the the scripting and the explanations! subscribed!

  • @brendanduffy827
    @brendanduffy827 2 ปีที่แล้ว

    great video thank you. maybe a mix of JS and TypeScript...for variety.

  • @bushranikhat2326
    @bushranikhat2326 2 ปีที่แล้ว

    Thanks for this tutorial

  • @galiprandi
    @galiprandi 2 ปีที่แล้ว

    I love typescript too!

  • @pguti778
    @pguti778 3 ปีที่แล้ว

    I'm using your example for a jobposting ! let's see what they say ! ;)

  • @carloemil
    @carloemil 2 ปีที่แล้ว

    Yes, TypeScript would be better. Thanks for the video!

  • @abedaarabi3014
    @abedaarabi3014 3 ปีที่แล้ว

    great job !

  • @igormundim
    @igormundim 9 หลายเดือนก่อน

    Thank you very much! 🇧🇷

  • @kiddosknowledgewizbyakshit9954
    @kiddosknowledgewizbyakshit9954 ปีที่แล้ว

    Very helpful video....Thanks a lot
    Kindly make some video for authorization with the same

  • @techguy6049
    @techguy6049 3 ปีที่แล้ว

    And i thought it will be about swagger. And it was. Lol. Robotic tutorial!

  • @vladmacovei1619
    @vladmacovei1619 2 ปีที่แล้ว +2

    I believe that adding components schemas to the definitions object inside options is a little bit neater. This way you avoid having orphan jsdoc comments in route files (i actually don't know if swagger-jsdoc is able to merge multiple components schemas into one). Also if you add it to the definitions object the syntax is js not yaml nonsense, much easier to write in vscode.

  • @tusharcitrusbug4912
    @tusharcitrusbug4912 ปีที่แล้ว

    a perfect video for me

  • @personal1935
    @personal1935 3 ปีที่แล้ว +1

    Many thanks for this video tutorial, I personally use your tutorial a lot and help me to understand them more easily, I have a question, for backend with node I can see you use expressjs, would you recommend this for production or do you know or can point me for a better choice? do you know any page which compares different tools/libs for node backend technology?

    • @satansdeer1
      @satansdeer1  3 ปีที่แล้ว +2

      hi, well two major backend libs for node are expressjs and nestjs. The problem with express is that it is a like a constructor kit, it is very minimalistic. You have to make lots of decisions when working with it and likely use a bunch of other libraries.
      Nest is more like a combine. It has a lot of decisions made for you and you got to learn the way the creators of the lib intended it to be used.
      Hope this helps

    • @personal1935
      @personal1935 3 ปีที่แล้ว

      @@satansdeer1 Many thanks, I will check the NestJS

  • @2cents2go
    @2cents2go 2 ปีที่แล้ว

    cool example! I guess no one has done a video on how to customize swagger-ui-react documentation is scarce

  • @JawadAli-xi5wh
    @JawadAli-xi5wh 3 ปีที่แล้ว +1

    Great tutorial. But a good readable theme (particularly for swagger comments) of the code editor would help to read the code.

    • @satansdeer1
      @satansdeer1  3 ปีที่แล้ว +1

      do you know of any?

    • @runyalen
      @runyalen ปีที่แล้ว

      yhea good idea... everything was gray... it wasn't super neet to see code

  • @Beats4needs
    @Beats4needs 3 ปีที่แล้ว +20

    If you want to follow this tutorial then make sure you install swagger-jsdoc like this: npm i swagger-jsdoc@6.0.1
    Otherwise, it won't work with the current version 7 of swagger-jsdoc which breaks everything and is a pain in the ass to setup.

    • @satansdeer1
      @satansdeer1  3 ปีที่แล้ว +3

      Thanks for this update

    • @darcy4487
      @darcy4487 3 ปีที่แล้ว +2

      You deserve a dollar

    • @TheIGORYA76
      @TheIGORYA76 3 ปีที่แล้ว +3

      Had similar issue with lowdb had to go back and use npm i lowdb@1.0.0

    • @fromkotahujan
      @fromkotahujan 2 ปีที่แล้ว

      @@TheIGORYA76 great thanks 👍

  • @ilfan_muratov
    @ilfan_muratov 3 ปีที่แล้ว +5

    Подписался пока только из-за твоего лица на обложках видео 😂

  • @Huntergaming-ci7un
    @Huntergaming-ci7un 3 ปีที่แล้ว +1

    Hi, Thanks for video. I love your VS color scheme, can you please provide it so I can use it for myself?

  • @segunthemarketer2195
    @segunthemarketer2195 ปีที่แล้ว

    JavaScript please! Great video… Love it

  • @jonathannieto9203
    @jonathannieto9203 3 ปีที่แล้ว +1

    Me encantarían ejemplos con typescript

  • @tobaojo2292
    @tobaojo2292 ปีที่แล้ว

    Nice tutorial. Can we have one which includes the authorization header?

  • @drlambo
    @drlambo 2 ปีที่แล้ว

    what do you use to auto generate line comments, spaces, etc? I've been trying a few vscode plugins but none seemed to work like yours

  • @roba998877
    @roba998877 ปีที่แล้ว

    +1 to Typescript

  • @rutvikmehta4657
    @rutvikmehta4657 3 ปีที่แล้ว

    i think your update documentation does not affect the database, i tried that. same query with postman fire perfectly worked!

  • @nguyenvanai6872
    @nguyenvanai6872 2 ปีที่แล้ว

    can you tell me? what is theme and fonts you use for Vscode? thank you so much

  • @mrugeshprajapati6406
    @mrugeshprajapati6406 ปีที่แล้ว

    Hi Maksim, thanks for Tutorial. It worked perfectly on localhost, but after deploying it shows "No operations defined in spec!" and no requests are shown. Please help me out with this issue.

  • @supermt4793
    @supermt4793 3 ปีที่แล้ว

    Thanks !

  • @farenrai576
    @farenrai576 2 ปีที่แล้ว

    is it possible swagger notation define in separate file ? not in route section if more then 1000 or 2000 routes

  • @adamtak3128
    @adamtak3128 3 ปีที่แล้ว +2

    at 7:14 you say you cut a corner and that you're only doing this because it's an example project. What would you be doing in a real-world app instead?

    • @juanjoseordonez8669
      @juanjoseordonez8669 2 ปีที่แล้ว

      You need to define a specific model, because in the way he did it any format is valid, that isnt correct in a real project

  • @Eibon1599
    @Eibon1599 ปีที่แล้ว

    Hi your tutorial is amazing, i have a problem, the swagger when a running in my local show the swagger page and the APIS, but when a try run the swagger in my server AWS this show nothing.
    what will be the problem so that it does not show anything in the server

  • @oluwatoyinbalogun1684
    @oluwatoyinbalogun1684 3 ปีที่แล้ว

    Thanks alot for the video. I would prefer Typescript

  • @LaSombraDeMuerte
    @LaSombraDeMuerte 2 ปีที่แล้ว

    Telll me please what color them for editor you use, thanks

  • @manthanguptaa
    @manthanguptaa 3 ปีที่แล้ว

    What if my application is exposed to localhost:8081 and I want to serve my swagger docs on localhost:8080?

  • @octaviusbytes
    @octaviusbytes 2 ปีที่แล้ว

    This may require more video editing but, I would be nice if you make video's using typescript as it's trending towards the standard. Then add javascript comment alt post edit, just for future proofing.

  • @ryannichols1798
    @ryannichols1798 ปีที่แล้ว

    may be a bit late but I'd like the typescript content much more

  • @smolahloe
    @smolahloe 2 ปีที่แล้ว

    More codes with TypeScript please

  • @albertoarriaga9611
    @albertoarriaga9611 3 ปีที่แล้ว

    TypeScript yes!!

  • @Stevexupen
    @Stevexupen ปีที่แล้ว

    how do you get the auto indenting inside the multi-line comment to work in vscode?

  • @AsSoBuT
    @AsSoBuT 3 ปีที่แล้ว

    How can you use require in an es module?

  • @j.k.ravshanovich
    @j.k.ravshanovich 2 ปีที่แล้ว +2

    I am getting an error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
    Any suggestions?

  • @luzaw4957
    @luzaw4957 2 ปีที่แล้ว +2

    For those who comes here to learn swagger, it starts at 9:52

  • @BheemuR
    @BheemuR 2 ปีที่แล้ว

    Nice programming skill.
    I am new to nodejs and looking for swagger api documentation, please share this code with me so that I will explore more on this.

    • @helloworld9655
      @helloworld9655 2 ปีที่แล้ว

      Check descriptions

    • @BheemuR
      @BheemuR 2 ปีที่แล้ว

      @@helloworld9655 please create video on node with typescript swagger.

  • @RealEstate3D
    @RealEstate3D ปีที่แล้ว

    Of course TypeScript is the way to go.

  • @thegrind9628
    @thegrind9628 ปีที่แล้ว

    Even if I press Execute button @16:37, I'm not shown the response. Whereas I am able to see the correct response from RESPONSE TAB from the browser dev tools. Why is that

  • @tonygeorge7482
    @tonygeorge7482 3 ปีที่แล้ว

    hi when i call post request only id is created title and author is not adding what is the issue
    i use ...req.body

  • @deepgandhi1106
    @deepgandhi1106 2 ปีที่แล้ว

    1) Suppose, I have a schema for Project model which contains 20 properties. Now for my project-dropdown API I only need 3 properties from the schema then how I can refer the schema and pick few properties only?
    2) I have 2 schemas, one for Project with 20 properties and another one is Task with 10 properties. Now for ProjectDetails API I have response something like { id: 1, name: "ProjectName", tasks: [ {id: 1, name: "TaskName"} ] } Now how I can accomplish this nested object by referring both individual schema which are Project and Task
    3) Can I have search box in Swagger UI to filter APIs?

  • @nguyenvanai6872
    @nguyenvanai6872 2 ปีที่แล้ว

    how injection style sheet for swagger? thanks you

  • @ofjdaz
    @ofjdaz 3 ปีที่แล้ว

    ruquire lol, the library by RuPaul :)

  • @runyalen
    @runyalen ปีที่แล้ว +1

    what happend if I have several files with swagger code(Like at least 18 different files).. Where should i add them into my rooter ??

  • @bbz9002
    @bbz9002 3 ปีที่แล้ว +4

    If you have - "Error [ERR_REQUIRE_ESM]..."
    In package.json
    Downgrade:
    "swagger-jsdoc": "6.0.0"
    "lowdb": "1.0.0"
    Upgrade dependencies, execute in console (project directory)
    $ rm -rf node_modules/
    $ npm install

  • @silvesterwali6565
    @silvesterwali6565 2 ปีที่แล้ว

    can you also create video for fastify swagger ?

  • @rafatanzeem4040
    @rafatanzeem4040 ปีที่แล้ว

    nice video, I am looking for authentication Video using swagger

  • @mrkhoros
    @mrkhoros 3 ปีที่แล้ว

    would you recommend lowdb over mongodb?

    • @satansdeer1
      @satansdeer1  3 ปีที่แล้ว +1

      not by any means

    • @satansdeer1
      @satansdeer1  3 ปีที่แล้ว +2

      lowdb is used here only because it's easier to setup

  • @HinhTranVan
    @HinhTranVan ปีที่แล้ว

    wow theme beautiful . Can you tell me the name of this extension?

  • @abhik9077
    @abhik9077 6 หลายเดือนก่อน

    Hey how to use bearer token ? in swagger

  • @mddanish8704
    @mddanish8704 2 ปีที่แล้ว

    please make the same video in typescript 🙏

  • @AhmedIbrahim-wx8sm
    @AhmedIbrahim-wx8sm 2 ปีที่แล้ว

    how can i add bearer token in header to the request

  • @hypersudo8092
    @hypersudo8092 3 ปีที่แล้ว

    Getting swagger jsdoc import error please help to fix.

  • @rolando_d3v
    @rolando_d3v 3 ปีที่แล้ว

    QUE THEME ESTAS USANDO PARA VISUAL STUDIO CODE

    • @satansdeer1
      @satansdeer1  3 ปีที่แล้ว +3

      Estou usando material theme ocean dark. E español ou português?

  • @umarabdullahi3811
    @umarabdullahi3811 3 ปีที่แล้ว

    👍

  • @rebeccaburch3334
    @rebeccaburch3334 2 ปีที่แล้ว

    what vscode theme is that? yes, i'm that person. love themes 😅

  • @martindm6019
    @martindm6019 2 ปีที่แล้ว

    How remove a book in lowdb version 3.0?. The method remove, not exists.

  • @KonstantinMiami
    @KonstantinMiami 3 ปีที่แล้ว

    Hi every one, great job! Only one thing, when I was use method POST, it was created new book but not added in db.json so I was changed // res.send(book) -->
    res.send(req.app.db.get("books")
    and now all working well for me.

  • @_hasib_
    @_hasib_ 3 ปีที่แล้ว

    what's the name of VSCode theme ?