Last active
July 13, 2021 17:04
-
-
Save azizkale/e7a32bf99a8da8b84921e64db453d8f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @swagger | |
* /posts/{id}: | |
* get: | |
* summary: gets posts by id | |
* tags: [Posts] | |
* parameters: | |
* - in : path | |
* name: id | |
* description: id of post | |
* schema: | |
* type: integer | |
* required: true | |
* responses: | |
* 200: | |
* description: posts by its id | |
* content: | |
* application/json: | |
* schema: | |
* $ref: '#/components/schemas/Post' | |
* 400: | |
* description: post can not be found | |
*/ | |
postRouter.get("/:id", (req, res) => { | |
const post = data.find((post) => post.id === +req.params.id); | |
if (!post) { | |
res.sendStatus(404); | |
} | |
res.send(post); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment