DEV Community

Discussion on: How to Document an Express API with Swagger UI and JSDoc

Collapse
sherwinwater profile image
Shuwen

GET /users/:id doesn't work for me. I change it to GET /users/{id}, which works.

In the api-docs, once I input id number and click execute, here is the difference:

/users/{id}
curl -X GET "localhost:3000/users/1" -H "accept: application/json"

/users/:id
curl -X GET "localhost:3000/users/:id" -H "accept: application/json"

Collapse
habereder profile image
Raphael Habereder

Good find! And also, welcome to DEV :)

As far as I know, swagger implements {} as template delimiters, not colons, but I'm not using node a lot (yet), so maybe I am missing something here.
I can't find any information in the swagger-docs that mention the colon-style, so input from @kabartolo would be great here :)

Collapse
kabartolo profile image
Kate Bartolo Author

Hi Shuwen!
I'm really glad you pointed this out because it's totally a bug. I'm not sure why I thought :id worked, but you're right that it doesn't.

I'll update the tutorial and sample project. Thank you!

Collapse
sherwinwater profile image
Shuwen

Hi Kate, Thank you your article to help me setting up my swagger documentation. One of the best article I find and I've recommend it to my coworkers.

Thread Thread
kabartolo profile image
Kate Bartolo Author

Thank you so much! I'm happy it was helpful