Ver Fonte

Merge pull request #9794 from goofmint/fix/doc-v3-statistics

support(jsdoc): Add swagger document to statistics.js
Yuki Takei há 1 ano atrás
pai
commit
ab1a670669
1 ficheiros alterados com 45 adições e 4 exclusões
  1. 45 4
      apps/app/src/server/routes/apiv3/statistics.js

+ 45 - 4
apps/app/src/server/routes/apiv3/statistics.js

@@ -16,6 +16,48 @@ const USER_STATUS_MASTER = {
   5: 'invited',
   5: 'invited',
 };
 };
 
 
+/**
+ * @swagger
+ *   components:
+ *     schemas:
+ *       StatisticsUserResponse:
+ *         type: object
+ *         properties:
+ *           data:
+*             type: object
+*             properties:
+*               total:
+*                 type: integer
+*                 example: 1
+*               active:
+*                 type: object
+*                 properties:
+*                   total:
+*                     type: integer
+*                     example: 1
+*                   admin:
+*                     type: integer
+*                     example: 1
+*               inactive:
+*                 type: object
+*                 properties:
+*                   total:
+*                     type: integer
+*                     example: 0
+*                   registered:
+*                     type: integer
+*                     example: 0
+*                   suspended:
+*                     type: integer
+*                     example: 0
+*                   deleted:
+*                     type: integer
+*                     example: 0
+*                   invited:
+*                     type: integer
+*                     example: 0
+*/
+
 /** @param {import('~/server/crowi').default} crowi Crowi instance */
 /** @param {import('~/server/crowi').default} crowi Crowi instance */
 module.exports = (crowi) => {
 module.exports = (crowi) => {
 
 
@@ -78,6 +120,7 @@ module.exports = (crowi) => {
    *  /statistics/user:
    *  /statistics/user:
    *    get:
    *    get:
    *      tags: [Statistics]
    *      tags: [Statistics]
+   *      security: []
    *      operationId: getStatisticsUser
    *      operationId: getStatisticsUser
    *      summary: /statistics/user
    *      summary: /statistics/user
    *      description: Get statistics for user
    *      description: Get statistics for user
@@ -87,10 +130,8 @@ module.exports = (crowi) => {
    *          content:
    *          content:
    *            application/json:
    *            application/json:
    *              schema:
    *              schema:
-   *                properties:
-   *                  data:
-   *                    type: object
-   *                    description: Statistics for all user
+   *                description: Statistics for all user
+   *                $ref: '#/components/schemas/StatisticsUserResponse'
    */
    */
   router.get('/user', noCache(), async(req, res) => {
   router.get('/user', noCache(), async(req, res) => {
     const data = req.user == null ? await getUserStatisticsForNotLoggedIn() : await getUserStatistics();
     const data = req.user == null ? await getUserStatisticsForNotLoggedIn() : await getUserStatistics();