189 lines
5.1 KiB
JavaScript
189 lines
5.1 KiB
JavaScript
const PermissionsService = require('../services/permissions');
|
|
const PermissionsDBApi = require('../db/api/permissions');
|
|
const { createEntityRouter } = require('../factories/router.factory');
|
|
|
|
/**
|
|
* @swagger
|
|
* components:
|
|
* schemas:
|
|
* Permissions:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* default: name
|
|
*/
|
|
|
|
/**
|
|
* @swagger
|
|
* tags:
|
|
* name: Permissions
|
|
* description: The Permissions managing API
|
|
*/
|
|
|
|
/**
|
|
* @swagger
|
|
* /api/permissions:
|
|
* post:
|
|
* security:
|
|
* - bearerAuth: []
|
|
* tags: [Permissions]
|
|
* summary: Add new item
|
|
* description: Add new item
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* properties:
|
|
* data:
|
|
* description: Data of the updated item
|
|
* type: object
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* responses:
|
|
* 200:
|
|
* description: The item was successfully added
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* 401:
|
|
* $ref: "#/components/responses/UnauthorizedError"
|
|
* 405:
|
|
* description: Invalid input data
|
|
* 500:
|
|
* description: Some server error
|
|
* get:
|
|
* security:
|
|
* - bearerAuth: []
|
|
* tags: [Permissions]
|
|
* summary: Get all permissions
|
|
* description: Get all permissions
|
|
* responses:
|
|
* 200:
|
|
* description: Permissions list successfully received
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* 401:
|
|
* $ref: "#/components/responses/UnauthorizedError"
|
|
* 404:
|
|
* description: Data not found
|
|
* 500:
|
|
* description: Some server error
|
|
*/
|
|
|
|
/**
|
|
* @swagger
|
|
* /api/permissions/{id}:
|
|
* put:
|
|
* security:
|
|
* - bearerAuth: []
|
|
* tags: [Permissions]
|
|
* summary: Update the data of the selected item
|
|
* description: Update the data of the selected item
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* description: Item ID to update
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* description: Set new item data
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* properties:
|
|
* id:
|
|
* description: ID of the updated item
|
|
* type: string
|
|
* data:
|
|
* description: Data of the updated item
|
|
* type: object
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* required:
|
|
* - id
|
|
* responses:
|
|
* 200:
|
|
* description: The item data was successfully updated
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* 400:
|
|
* description: Invalid ID supplied
|
|
* 401:
|
|
* $ref: "#/components/responses/UnauthorizedError"
|
|
* 404:
|
|
* description: Item not found
|
|
* 500:
|
|
* description: Some server error
|
|
* delete:
|
|
* security:
|
|
* - bearerAuth: []
|
|
* tags: [Permissions]
|
|
* summary: Delete the selected item
|
|
* description: Delete the selected item
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* description: Item ID to delete
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: The item was successfully deleted
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* 400:
|
|
* description: Invalid ID supplied
|
|
* 401:
|
|
* $ref: "#/components/responses/UnauthorizedError"
|
|
* 404:
|
|
* description: Item not found
|
|
* 500:
|
|
* description: Some server error
|
|
* get:
|
|
* security:
|
|
* - bearerAuth: []
|
|
* tags: [Permissions]
|
|
* summary: Get selected item
|
|
* description: Get selected item
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* description: ID of item to get
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Selected item successfully received
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: "#/components/schemas/Permissions"
|
|
* 400:
|
|
* description: Invalid ID supplied
|
|
* 401:
|
|
* $ref: "#/components/responses/UnauthorizedError"
|
|
* 404:
|
|
* description: Item not found
|
|
* 500:
|
|
* description: Some server error
|
|
*/
|
|
|
|
module.exports = createEntityRouter(
|
|
'permissions',
|
|
PermissionsService,
|
|
PermissionsDBApi,
|
|
);
|