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...
This is bugging me, it's hardly "automatic" when you need to manually write the documentation...
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.
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');
am facing the same probleme!!
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"
}
@@nagavadlapudi Nice!!! I'll try! Tks for share! :)
@@nagavadlapudi It worked for me too!!! I was trying to use the latest version of the "swagger-jsdoc".
what if i wan't to document another file? i try writing the comment @swagger, but it doesn't work
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.
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.
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
Glad you enjoyed, thank you for the feedback!
Good teacher, you are hitting the target. You are one of the best teachers on the internet.
Thank you for the feedback @Semicolon
automatic ????????????????????
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
could you show how to do this cleanly?
title is very bad
as simple as it can be
But its lot of effort to add all these information for each API.
Thank you so very much. This save my bug
This was great, thanks!
Glad it helped @Melissa Heying
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)?
i recommend you to use ajv if you wanna do schema validation, it has a version in ts and its very easy to implement
@@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
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?
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.
Great tutorial, clean and concise! Thanks.
YOU ARE AMAZING BRO!!! THANKS SO MUCH
Great tutorial! Would there be more Swagger in the future? Possibly connecting it to a database or a live feed?
I get "No operations defined in spec!"
Thank you soooooo much for this video
You my friend are life saver!!!!! Thank you!
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!
Very helpful. thank bro
Thank you @Juhand Van
Great man.. i was looking for this!!!!
Glad you enjoyed @Marlon Castro
so useful for me, thanks.
Thanks, very nice tutorial
OMGOOOOOOOD. You are a hero!!!
Can i share the documentation
Great tut. Thanks! :D
Thanks chief
You are the best!!!
Thank you very much!
Great video
Good work! 😃