Просмотр исходного кода

Change to typescript file and fix swagger comments

arvid-e 8 месяцев назад
Родитель
Сommit
e18e05e318

+ 0 - 114
apps/app/bin/openapi/definition-apiv3.js

@@ -49,120 +49,6 @@ module.exports = {
         in: 'header',
         in: 'header',
         name: 'x-growi-transfer-key',
         name: 'x-growi-transfer-key',
       },
       },
-      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',
-        description: 'Standard error response format for API failures.',
-        properties: {
-          message: {
-            type: 'string',
-            description: 'A human-readable message providing details about the error.',
-          },
-          status: {
-            type: 'number',
-            description: 'The HTTP status code associated with the error (e.g., 400, 401, 500).',
-          },
-        },
-      },
-      MarkdownParams: {
-        type: 'object',
-        description: 'All current Markdown rendering settings.',
-        properties: {
-          isEnabledLinebreaks: { type: 'boolean', description: 'Controls if line breaks are enabled in Markdown.' },
-          isEnabledLinebreaksInComments: { type: 'boolean', description: 'Controls if line breaks are enabled in Markdown comments.' },
-          adminPreferredIndentSize: { type: 'number', enum: [2, 4], description: 'Preferred indent size for Markdown, either 2 or 4 spaces.' },
-          isIndentSizeForced: { type: 'boolean', description: 'If true, forces the preferred indent size across all users.' },
-          isEnabledXss: { type: 'boolean', description: 'Controls if XSS prevention is enabled.' },
-          xssOption: { type: 'string', description: 'The XSS prevention option.' },
-          tagWhitelist: { type: 'array', items: { type: 'string' }, description: 'List of HTML tags allowed if XSS prevention is enabled.' },
-          attrWhitelist: { type: 'string', description: 'Stringified JSON object of allowed attributes for whitelisted tags.' },
-        },
-      },
-      LineBreakParams: {
-        type: 'object',
-        description: 'Parameters for Markdown line break settings.',
-        properties: {
-          isEnabledLinebreaks: { type: 'boolean', description: 'Enable or disable line breaks.' },
-          isEnabledLinebreaksInComments: { type: 'boolean', description: 'Enable or disable line breaks in comments.' },
-        },
-      },
-      IndentParams: {
-        type: 'object',
-        description: 'Parameters for Markdown indent settings.',
-        properties: {
-          adminPreferredIndentSize: { type: 'number', enum: [2, 4], description: 'The preferred indent size (2 or 4).' },
-          isIndentSizeForced: { type: 'boolean', description: 'Force preferred indent size for all users.' },
-        },
-      },
-      XssParams: {
-        type: 'object',
-        description: 'Parameters for Markdown XSS prevention settings.',
-        properties: {
-          isEnabledXss: { type: 'boolean', description: 'Enable or disable XSS prevention.' },
-          xssOption: { type: 'string', description: 'XSS prevention option (e.g., "permissive", "strict").' }, // Adjust enum if known values exist
-          tagWhitelist: { type: 'array', items: { type: 'string' }, description: 'Array of whitelisted HTML tags.' },
-          attrWhitelist: { type: 'string', description: 'Stringified JSON of whitelisted HTML attributes.' },
-        },
-      },
     },
     },
     parameters: {
     parameters: {
       MimeTypePathParam: {
       MimeTypePathParam: {

+ 3 - 101
apps/app/src/server/routes/apiv3/content-disposition-settings.js → apps/app/src/server/routes/apiv3/content-disposition-settings.ts

@@ -9,7 +9,7 @@ import loggerFactory from '~/utils/logger';
 
 
 import { CONFIGURABLE_MIME_TYPES_FOR_DISPOSITION } from './configurable-mime-types';
 import { CONFIGURABLE_MIME_TYPES_FOR_DISPOSITION } from './configurable-mime-types';
 
 
-const logger = loggerFactory('growi:routes:apiv3:markdown-setting');
+const logger = loggerFactory('growi:routes:apiv3:content-disposition-settings');
 const express = require('express');
 const express = require('express');
 
 
 const router = express.Router();
 const router = express.Router();
@@ -36,84 +36,14 @@ const validator = {
  * @swagger
  * @swagger
  *
  *
  *  components:
  *  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:
  *    schemas:
- *      ErrorResponse:
- *        type: object
- *        properties:
- *          message:
- *            type: string
- *            description: Error message
- *          status:
- *            type: number
- *            description: HTTP status code
  *    parameters:
  *    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
+ *      - $ref: '#/components/parameters/MimeTypePathParam'
   */
   */
 module.exports = (crowi) => {
 module.exports = (crowi) => {
   const loginRequiredStrictly = require('~/server/middlewares/login-required')(crowi);
   const loginRequiredStrictly = require('~/server/middlewares/login-required')(crowi);
   const adminRequired = require('~/server/middlewares/admin-required')(crowi);
   const adminRequired = require('~/server/middlewares/admin-required')(crowi);
-  const addActivity = generateAddActivityMiddleware(crowi);
+  const addActivity = generateAddActivityMiddleware();
   const activityEvent = crowi.event('activity');
   const activityEvent = crowi.event('activity');
 
 
   /**
   /**
@@ -123,10 +53,8 @@ module.exports = (crowi) => {
  *   get:
  *   get:
  *     tags: [Content-Disposition Settings]
  *     tags: [Content-Disposition Settings]
  *     summary: Get content disposition settings for configurable MIME types
  *     summary: Get content disposition settings for configurable MIME types
- *     description: Retrieve the current `inline` or `attachment` disposition setting for each configurable MIME type.
  *     security:
  *     security:
  *       - cookieAuth: []
  *       - cookieAuth: []
- *       - adminRequired: []
  *     responses:
  *     responses:
  *       200:
  *       200:
  *         description: Successfully retrieved content disposition settings.
  *         description: Successfully retrieved content disposition settings.
@@ -141,16 +69,6 @@ module.exports = (crowi) => {
  *                   additionalProperties:
  *                   additionalProperties:
  *                     type: boolean
  *                     type: boolean
  *                     description: true if inline, false if attachment.
  *                     description: true if inline, false if attachment.
- *                     example:
- *                       image/png: true
- *                       application/pdf: false
- *                       text/plain: true
- *       401:
- *         $ref: '#/components/responses/401'
- *       403:
- *         $ref: '#/components/responses/403'
- *       500:
- *         $ref: '#/components/responses/500'
  *
  *
  */
  */
   router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
   router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
@@ -188,10 +106,8 @@ module.exports = (crowi) => {
  *      put:
  *      put:
  *        tags: [Content Disposition Settings]
  *        tags: [Content Disposition Settings]
  *        summary: Update content disposition setting for a specific MIME type
  *        summary: Update content disposition setting for a specific MIME type
- *        description: Set the `inline` or `attachment` disposition for a given configurable MIME type
  *        security:
  *        security:
  *          - cookieAuth: []
  *          - cookieAuth: []
- *          - adminRequired: []
  *        parameters:
  *        parameters:
  *          - $ref: '#/components/parameters/MimeTypePathParam'
  *          - $ref: '#/components/parameters/MimeTypePathParam'
  *        requestBody:
  *        requestBody:
@@ -206,8 +122,6 @@ module.exports = (crowi) => {
  *                  isInline:
  *                  isInline:
  *                     type: boolean
  *                     type: boolean
  *                     description: 'Set to `true` for inline disposition, `false` for attachment disposition (e g , prompts download) '
  *                     description: 'Set to `true` for inline disposition, `false` for attachment disposition (e g , prompts download) '
- *                     example: true
- *        operationId: putContentDispositionSettingsByMimeType
  *        responses:
  *        responses:
  *          200:
  *          200:
  *            description: Successfully updated content disposition setting
  *            description: Successfully updated content disposition setting
@@ -221,20 +135,8 @@ module.exports = (crowi) => {
  *                       properties:
  *                       properties:
  *                         mimeType:
  *                         mimeType:
  *                           type: string
  *                           type: string
- *                           example: 'application/pdf'
  *                         isInline:
  *                         isInline:
  *                           type: boolean
  *                           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(
   router.put(
     '/:mimeType(*)',
     '/:mimeType(*)',