arvid-e 9 месяцев назад
Родитель
Сommit
cd7c62ae1c
1 измененных файлов с 137 добавлено и 126 удалено
  1. 137 126
      apps/app/src/server/routes/apiv3/content-disposition-settings.js

+ 137 - 126
apps/app/src/server/routes/apiv3/content-disposition-settings.js

@@ -5,8 +5,8 @@ import { SupportedAction } from '~/interfaces/activity';
 import { configManager } from '~/server/service/config-manager';
 import loggerFactory from '~/utils/logger';
 
-import { generateAddActivityMiddleware } from '../../middlewares/add-activity';
-import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
+import { generateAddActivityMiddleware } from '//middlewares/add-activity';
+import { apiV3FormValidator } from '//middlewares/apiv3-form-validator';
 
 import { CONFIGURABLE_MIME_TYPES_FOR_DISPOSITION } from './configurable-mime-types';
 
@@ -29,81 +29,87 @@ const validator = {
   ],
 };
 
- /**
- * @swagger
- *
- * components:
- *   securitySchemes:
- *     adminRequired:
- *       type: http
- *       scheme: bearer
- *       bearerFormat: AdminAccess
- *       description: Requires an authenticated user with admin privileges.
- *   responses:
- *     400:
- *       description: Bad Request
- *       content:
- *         application/json:
- *           schema:
- *             $ref: '#/components/schemas/ErrorResponse'
- *     401:
- *       description: Unauthorized
- *       content:
- *         application/json:
- *           schema:
- *             $ref: '#/components/schemas/ErrorResponse'
- *     403:
- *       description: Forbidden
- *       content:
- *         application/json:
- *           schema:
- *             $ref: '#/components/schemas/ErrorResponse'
- *     500:
- *       description: Internal Server Error
- *       content:
- *         application/json:
- *           schema:
- *             $ref: '#/components/schemas/ErrorResponse'
- *   schemas:
- *     ErrorResponse:
- *       type: object
- *       properties:
- *         message:
- *           type: string
- *           description: Error message
- *         status:
- *           type: number
- *           description: HTTP status code
- *   parameters:
- *     MimeTypePathParam:
- *       name: mimeType
- *       in: path
- *       required: true
- *       description: Configurable MIME type (e.g., image/png, application/pdf)
- *       schema:
- *         type: string
- *         enum:
- *           - application/pdf
- *           - image/png
- *           - image/jpeg
- *           - image/gif
- *           - text/plain
- *           - text/html
- *           - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
- *           - application/vnd.openxmlformats-officedocument.wordprocessingml.document
- *           - application/vnd.openxmlformats-officedocument.presentationml.presentation
- *           - application/msword
- *           - application/vnd.ms-excel
- *           - application/vnd.ms-powerpoint
- *           - application/zip
- *           - application/x-rar-compressed
- *           - audio/mpeg
- *           - video/mp4
- *           - application/octet-stream
- */
+/*
+  * @swagger
+  *
+  * components:
+  *    securitySchemes:
+  *      adminRequired:
+  *        type: http
+  *        scheme: bearer
+  *        bearerFormat: AdminAccess
+  *        description: Requires an authenticated user with admin privileges
+  *    responses:
+  *      400:
+  *        description: Bad Request
+  *        content:
+  *          application/json:
+  *            schema:
+  *              $ref: '#/components/schemas/ErrorResponse'
+  *      401:
+  *        description: Unauthorized
+  *        content:
+  *          application/json:
+  *            schema:
+  *              $ref: '#/components/schemas/ErrorResponse'
+  *      403:
+  *        description: Forbidden
+  *        content:
+  *          application/json:
+  *            schema:
+  *              $ref: '#/components/schemas/ErrorResponse'
+  *      404:
+  *        description: Not Found
+  *        content:
+  *          application/json:
+  *            schema:
+  *              $ref: '#/components/schemas/ErrorResponse'
+  *      500:
+  *        description: Internal Server Error
+  *        content:
+  *          application/json:
+  *            schema:
+  *              $ref: '#/components/schemas/ErrorResponse'
+  *    schemas:
+  *      ErrorResponse:
+  *        type: object
+  *        properties:
+  *          message:
+  *            type: string
+  *            description: Error message
+  *          status:
+  *            type: number
+  *            description: HTTP status code
+  *    parameters:
+  *      MimeTypePathParam:
+  *        name: mimeType
+  *        in: path
+  *        required: true
+  *        description: Configurable MIME type (e g , image/png, application/pdf)
+  *        schema:
+  *          type: string
+  *          enum:
+  *            - application/pdf
+  *            - image/png
+  *            - image/jpeg
+  *            - image/gif
+  *            - text/plain
+  *            - text/html
+  *            - application/vnd openxmlformats-officedocument spreadsheetml sheet
+  *            - application/vnd openxmlformats-officedocument wordprocessingml document
+  *            - application/vnd openxmlformats-officedocument presentationml presentation
+  *            - application/msword
+  *            - application/vnd ms-excel
+  *            - application/vnd ms-powerpoint
+  *            - application/zip
+  *            - application/x-rar-compressed
+  *            - audio/mpeg
+  *            - video/mp4
+  *            - application/octet-stream
+  */
 module.exports = (crowi) => {
-  const loginRequiredStrictly = require('../../middlewares/login-required')(crowi);
-  const adminRequired = require('../../middlewares/admin-required')(crowi);
+  const loginRequiredStrictly = require('//middlewares/login-required')(crowi);
+  const adminRequired = require('//middlewares/admin-required')(crowi);
   const addActivity = generateAddActivityMiddleware(crowi);
   const activityEvent = crowi.event('activity');
 
@@ -170,56 +176,61 @@ module.exports = (crowi) => {
   });
 
 
- /**
- * @swagger
- *
- * /content-disposition-settings/{mimeType}:
- *   put:
- *     tags: [Content Disposition Settings]
- *     summary: Update content disposition setting for a specific MIME type
- *     description: Set the `inline` or `attachment` disposition for a given configurable MIME type.
- *     security:
- *       - cookieAuth: []
- *       - adminRequired: []
- *     parameters:
- *       - $ref: '#/components/parameters/MimeTypePathParam'
- *     requestBody:
- *       required: true
- *       content:
- *         application/json:
- *           schema:
- *             type: object
- *             required:
- *               - isInline
- *             properties:
- *               isInline:
- *                 type: boolean
- *                 description: Set to `true` for inline disposition, `false` for attachment disposition (e.g., prompts download).
- *                 example: true
- *   responses:
- *     200:
- *       description: Successfully updated content disposition setting.
- *       content:
- *         application/json:
- *           schema:
- *             type: object
- *             properties:
- *               mimeType:
- *                 type: string
- *                 description: The updated MIME type.
- *                 example: image/png
- *               isInline:
- *                 type: boolean
- *                 description: The new disposition status (`true` for inline, `false` for attachment).
- *                 example: true
- *     400:
- *       $ref: '#/components/responses/400'
- *     401:
- *       $ref: '#/components/responses/401'
- *     403:
- *       $ref: '#/components/responses/403'
- *     500:
- *       $ref: '#/components/responses/500'
+/**
+  * @swagger
+  *
+  * paths:
+  *    /content-disposition-settings/{mimeType}:
+  *      put:
+  *        tags: [Content Disposition Settings]
+  *        summary: Update content disposition setting for a specific MIME type
+  *        description: Set the `inline` or `attachment` disposition for a given configurable MIME type
+  *        security:
+  *          - cookieAuth: []
+  *          - adminRequired: []
+  *        parameters:
+  *          - $ref: '#/components/parameters/MimeTypePathParam'
+  *        requestBody:
+  *          required: true
+  *          content:
+  *            application/json:
+  *              schema:
+  *                type: object
+  *                required:
+  *                  - isInline
+  *                properties:
+  *                  isInline:
+  *                     type: boolean
+  *                     description: 'Set to `true` for inline disposition, `false` for attachment disposition (e g , prompts download) '
+  *                     example: true
+  *      operationId: putContentDispositionSettingsByMimeType
+  *      responses:
+  *        200:
+  *          description: Successfully updated content disposition setting
+  *          content:
+  *            application/json:
+  *              schema:
+  *                type: object
+  *                properties:
+  *                  setting:
+  *                     type: object
+  *                     properties:
+  *                       mimeType:
+  *                         type: string
+  *                         example: 'application/pdf'
+  *                       isInline:
+  *                         type: boolean
+  *                         example: true
+  *        400:
+  *          $ref: '#/components/responses/400'
+  *        401:
+  *          $ref: '#/components/responses/401'
+  *        403:
+  *          $ref: '#/components/responses/403'
+  *        404:
+  *          $ref: '#/components/responses/404'
+  *        500:
+  *          $ref: '#/components/responses/500'
  */
   router.put('/:mimeType(*)',
     loginRequiredStrictly,