const express = require('express'); const fishCtrl = require('../controller/fishController'); /** * @swagger * tags: * name: Fish * description: Fish managing api */ /** * @swagger * components: * schemas: * fish: * type: object * required: * - name * - color * - length * - speed * properties: * name: * type: string * description: fish name * color: * type: string * description: fish color * length: * type: string * description: fish length * speed: * type: string * description: fish speed * example: * fish: * name: 'toto' * color: 'red' * length: 'very smoll' * speed: 'fasted in the jar' */ exports.fishRouter = (opts) => { const router = express.Router(); /** * @swagger * /fish/{id}: * get: * summary: route to get a fish by id * tags: [Fish] * parameters: * - in: path * name: id * schema: * type: integer * required: true * description: Numeric ID of the fish to get * responses: * 200: * description: Success adding a fish */ router.get('/:id([0-9]+)', fishCtrl.getFish(opts)); /** * @swagger * /fish/: * get: * summary: route to get all the fishes * tags: [Fish] * responses: * 200: * description: Got all the fishes */ router.get('/', fishCtrl.getAllFish(opts)); /** * @swagger * /fish/add: * post: * summary: route to add a fish * tags: [Fish] * requestBody: * required: true * content: * application/json: * schema: * $ref: '#/components/schemas/fish' * responses: * 200: * description: Success adding a fish */ router.post('/add', fishCtrl.addFish(opts)); /** * @swagger * /fish/{id}: * put: * summary: route to update a fish * tags: [Fish] * parameters: * - in: path * name: id * schema: * type: integer * required: true * description: Numeric ID of the fish to get * requestBody: * required: true * content: * application/json: * schema: * $ref: '#/components/schemas/fish' * responses: * 200: * description: Success updating the fish */ router.put('/:id([0-9]+)', fishCtrl.updateFish(opts)); /** * @swagger * /fish/{id}: * delete: * summary: route to delete a fish * tags: [Fish] * parameters: * - in: path * name: id * schema: * type: integer * required: true * description: Numeric ID of the fish to update * responses: * 200: * description: Success deleting a fish */ router.delete('/:id([0-9]+)', fishCtrl.deleteFish(opts)); return router }