Automatic Swagger Documentation with Node & Express

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • Learn how to automatically generate Swagger API documentation for your node.js & express application.
    Don't forget to Subscribe here: / @krisfoster1
    Swagger: swagger.io
    Code: github.com/kri...

Комментарии • 49

  • @taylorreeves3642
    @taylorreeves3642 2 года назад +3

    This is bugging me, it's hardly "automatic" when you need to manually write the documentation...

  • @benonyoutube
    @benonyoutube 3 года назад +1

    Whilst this is a fine tutorial, the keyswitches are unecessary. If you wanna slap your keyboard, that's fine, but at times I can barely hear you over it, and makes it quite unbeatable. Sorry bud.

  • @evandropadua4577
    @evandropadua4577 3 года назад +2

    Please, someone get this error on import swagger-jsdoc? Any idea how can I fix it?
    node_modules\swagger-jsdoc\index.js:1
    import { prepare, extract, organize, finalize } from './src/specification.js';
    SyntaxError: Cannot use import statement outside a module
    My import:
    const swaggerJsDoc = require('swagger-jsdoc');

    • @ons3435
      @ons3435 3 года назад +1

      am facing the same probleme!!

    • @nagavadlapudi
      @nagavadlapudi 3 года назад +3

      same here, no idea as of now on how to fix it.
      EDIT: It worked when I used this config.
      "devDependencies": {
      "swagger-jsdoc": "6.0.0",
      "swagger-ui-express": "^4.1.6"
      }

    • @evandropadua4577
      @evandropadua4577 3 года назад

      ​@@nagavadlapudi Nice!!! I'll try! Tks for share! :)

    • @evandropadua4577
      @evandropadua4577 3 года назад +1

      @@nagavadlapudi It worked for me too!!! I was trying to use the latest version of the "swagger-jsdoc".

  • @paulsotelo4010
    @paulsotelo4010 3 года назад +2

    what if i wan't to document another file? i try writing the comment @swagger, but it doesn't work

    • @rand0mtv660
      @rand0mtv660 3 года назад

      Maybe just add it to "apis" field in the swaggerOptions object? I guess all files need to be added separately or maybe it supports some wildcard there. Haven't tested it myself.

  • @gihanrangana6248
    @gihanrangana6248 3 года назад +1

    hey nice tutorial
    i have express app. i'm creating routes automatically when create the folder inside the model folder.route method pass from the file inside the folder. do you have any idea to add swagger docs to it? because i want to create fully automated api package.

  • @СейтекБегалиев
    @СейтекБегалиев 3 года назад +1

    Your tutorial about swagger is the best! Dude... it was really difficult to find it on russian. But your words so easy to getting it. Thank u very much

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Glad you enjoyed, thank you for the feedback!

  • @lyawileh.a8741
    @lyawileh.a8741 3 года назад +2

    Good teacher, you are hitting the target. You are one of the best teachers on the internet.

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Thank you for the feedback @Semicolon

  • @lehoangtrong9803
    @lehoangtrong9803 12 дней назад

    automatic ????????????????????

  • @gethermedel3620
    @gethermedel3620 2 года назад

    is there a cleaner way for this? having just 4 fields is looking ugly already. what happens if you have 10 fields?
    this is cool I just wanted to know a cleaner way

  • @lehoangtrong9803
    @lehoangtrong9803 12 дней назад

    title is very bad

  • @yogeshgautam4873
    @yogeshgautam4873 9 месяцев назад

    as simple as it can be

  • @bobbyandthomas
    @bobbyandthomas 2 года назад

    But its lot of effort to add all these information for each API.

  • @mretineh1172
    @mretineh1172 Год назад

    Thank you so very much. This save my bug

  • @melissa.heying
    @melissa.heying 3 года назад +2

    This was great, thanks!

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Glad it helped @Melissa Heying

  • @FacterNerz
    @FacterNerz 3 года назад +1

    Hey, thanks for another great-value video dude!
    My question is: when you write out the body structure for a post request. Does swagger-jsdoc also validate incoming requests against that structure for you? Or do you still have to use something like Joi to do that (and write out the same structure there too)?

    • @RealRurik
      @RealRurik 2 года назад

      i recommend you to use ajv if you wanna do schema validation, it has a version in ts and its very easy to implement

    • @FacterNerz
      @FacterNerz 2 года назад

      @@RealRurik At the time I asked that I was looking for a way to only have to define schema once. I solved that using express-openapi-validator

  • @pankajkhadse9197
    @pankajkhadse9197 3 года назад

    Is there any option if I don't want to put swagger attribute and all other details (description, response) on the function. moved to some separate file?

    • @rand0mtv660
      @rand0mtv660 3 года назад

      Why would you want that? That is just a comment above your api endpoint, you usually want it to live close to the code and not in a separate file. Same as with other regular comments, you wouldn't define a comment describing something in a separate file, you would place it as close to the code as possible.

  • @ashleymavericks
    @ashleymavericks 3 года назад +1

    Great tutorial, clean and concise! Thanks.

  • @jeancarloscampos8636
    @jeancarloscampos8636 8 месяцев назад

    YOU ARE AMAZING BRO!!! THANKS SO MUCH

  • @briangeraghty6455
    @briangeraghty6455 2 года назад

    Great tutorial! Would there be more Swagger in the future? Possibly connecting it to a database or a live feed?

  • @rnt802
    @rnt802 3 года назад

    I get "No operations defined in spec!"

  • @bhargavikakanuri2936
    @bhargavikakanuri2936 Год назад

    Thank you soooooo much for this video

  • @rohanaslam2592
    @rohanaslam2592 2 года назад

    You my friend are life saver!!!!! Thank you!

  • @ChannaGun
    @ChannaGun 3 года назад

    Thank you very much for making this easy to follow! Got it working on my own code in about as much time as it took me to watch the tutorial!

  • @juhandvan
    @juhandvan 4 года назад +1

    Very helpful. thank bro

  • @marlonscastro
    @marlonscastro 3 года назад +1

    Great man.. i was looking for this!!!!

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Glad you enjoyed @Marlon Castro

  • @alirastegar4724
    @alirastegar4724 2 года назад

    so useful for me, thanks.

  • @jrggroberto
    @jrggroberto 3 года назад

    Thanks, very nice tutorial

  • @PabloMartinezfr
    @PabloMartinezfr 3 года назад

    OMGOOOOOOOD. You are a hero!!!

  • @anand.prasad502
    @anand.prasad502 3 года назад

    Can i share the documentation

  • @adriansanchezguerrero4557
    @adriansanchezguerrero4557 2 года назад

    Great tut. Thanks! :D

  • @dominickasanga2460
    @dominickasanga2460 2 года назад

    Thanks chief

  • @Dedilm
    @Dedilm 3 года назад

    You are the best!!!

  • @user-hy4sz8lx5z
    @user-hy4sz8lx5z 3 года назад

    Thank you very much!

  • @Jahangirkhan-ig1wj
    @Jahangirkhan-ig1wj 3 года назад

    Great video

  • @personaldsentidades1540
    @personaldsentidades1540 3 года назад

    Good work! 😃