Bladeren bron

support(jsdoc): Add swagger document to activity.ts

Atsushi Nakatsugawa 1 jaar geleden
bovenliggende
commit
8f51fa0b62
2 gewijzigde bestanden met toevoegingen van 175 en 1 verwijderingen
  1. 1 0
      apps/app/bin/swagger-jsdoc/definition-apiv3.js
  2. 174 1
      apps/app/src/server/routes/apiv3/activity.ts

+ 1 - 0
apps/app/bin/swagger-jsdoc/definition-apiv3.js

@@ -63,6 +63,7 @@ module.exports = {
       name: 'System Management API',
       tags: [
         'Home',
+        'Activity',
         'AdminHome',
         'AppSettings',
         'ExternalUserGroups',

+ 174 - 1
apps/app/src/server/routes/apiv3/activity.ts

@@ -27,13 +27,186 @@ const validator = {
   ],
 };
 
+/**
+ * @swagger
+ *
+ * components:
+ *   schemas:
+ *     ActivityResponse:
+ *       type: object
+ *       properties:
+ *         serializedPaginationResult:
+ *           type: object
+ *           properties:
+ *             docs:
+ *               type: array
+ *               items:
+ *                 type: object
+ *                 properties:
+ *                   _id:
+ *                     type: string
+ *                     example: "67e33da5d97e8d3b53e99f95"
+ *                   id:
+ *                     type: string
+ *                     example: "67e33da5d97e8d3b53e99f95"
+ *                   ip:
+ *                     type: string
+ *                     example: "::ffff:172.18.0.1"
+ *                   endpoint:
+ *                     type: string
+ *                     example: "/_api/pages.remove"
+ *                   targetModel:
+ *                     type: string
+ *                     example: "Page"
+ *                   target:
+ *                     type: string
+ *                     example: "675547e97f208f8050a361d4"
+ *                   action:
+ *                     type: string
+ *                     example: "PAGE_DELETE_COMPLETELY"
+ *                   snapshot:
+ *                     type: object
+ *                     properties:
+ *                       username:
+ *                         type: string
+ *                         example: "growi"
+ *                       _id:
+ *                         type: string
+ *                         example: "67e33da5d97e8d3b53e99f96"
+ *                   createdAt:
+ *                     type: string
+ *                     format: date-time
+ *                     example: "2025-03-25T23:35:01.584Z"
+ *                   __v:
+ *                     type: integer
+ *                     example: 0
+ *                   user:
+ *                     type: object
+ *                     properties:
+ *                       _id:
+ *                         type: string
+ *                         example: "669a5aa48d45e62b521d00e4"
+ *                       isGravatarEnabled:
+ *                         type: boolean
+ *                         example: false
+ *                       isEmailPublished:
+ *                         type: boolean
+ *                         example: true
+ *                       lang:
+ *                         type: string
+ *                         example: "ja_JP"
+ *                       status:
+ *                         type: integer
+ *                         example: 2
+ *                       admin:
+ *                         type: boolean
+ *                         example: true
+ *                       readOnly:
+ *                         type: boolean
+ *                         example: false
+ *                       isInvitationEmailSended:
+ *                         type: boolean
+ *                         example: false
+ *                       isQuestionnaireEnabled:
+ *                         type: boolean
+ *                         example: true
+ *                       name:
+ *                         type: string
+ *                         example: "Taro"
+ *                       username:
+ *                         type: string
+ *                         example: "grow"
+ *                       createdAt:
+ *                         type: string
+ *                         format: date-time
+ *                         example: "2024-07-19T12:23:00.806Z"
+ *                       updatedAt:
+ *                         type: string
+ *                         format: date-time
+ *                         example: "2025-03-25T23:34:04.362Z"
+ *                       __v:
+ *                         type: integer
+ *                         example: 0
+ *                       imageUrlCached:
+ *                         type: string
+ *                         example: "/images/icons/user.svg"
+ *                       lastLoginAt:
+ *                         type: string
+ *                         format: date-time
+ *                         example: "2025-03-25T23:34:04.355Z"
+ *                       email:
+ *                         type: string
+ *                         example: "test@example.com"
+ *             totalDocs:
+ *               type: integer
+ *               example: 3
+ *             offset:
+ *               type: integer
+ *               example: 0
+ *             limit:
+ *               type: integer
+ *               example: 10
+ *             totalPages:
+ *               type: integer
+ *               example: 1
+ *             page:
+ *               type: integer
+ *               example: 1
+ *             pagingCounter:
+ *               type: integer
+ *               example: 1
+ *             hasPrevPage:
+ *               type: boolean
+ *               example: false
+ *             hasNextPage:
+ *               type: boolean
+ *               example: false
+ *             prevPage:
+ *               type: integer
+ *               nullable: true
+ *               example: null
+ *             nextPage:
+ *               type: integer
+ *               nullable: true
+ *               example: null
+ */
+
 module.exports = (crowi: Crowi): Router => {
   const adminRequired = require('../../middlewares/admin-required')(crowi);
   const loginRequiredStrictly = require('../../middlewares/login-required')(crowi);
 
   const router = express.Router();
 
-  // eslint-disable-next-line max-len
+  /**
+   * @swagger
+   *
+   * /activity:
+   *   get:
+   *     summary: /activity
+   *     tags: [Activity]
+   *     security:
+   *       - api_key: []
+   *     parameters:
+   *       - name: limit
+   *         in: query
+   *         required: false
+   *         type: integer
+   *       - name: offset
+   *         in: query
+   *         required: false
+   *         type: integer
+   *       - name: searchFilter
+   *         in: query
+   *         required: false
+   *         type: string
+   *     responses:
+   *       200:
+   *         description: Activity fetched successfully
+   *         content:
+   *           application/json:
+   *             schema:
+   *               $ref: '#/components/schemas/ActivityResponse'
+   */
   router.get('/', accessTokenParser, loginRequiredStrictly, adminRequired, validator.list, apiV3FormValidator, async(req: Request, res: ApiV3Response) => {
     const auditLogEnabled = configManager.getConfig('app:auditLogEnabled');
     if (!auditLogEnabled) {