Explorar el Código

support(jsdoc): fix/doc v3 healthcheck

Atsushi Nakatsugawa hace 1 año
padre
commit
f31852eeae

+ 126 - 0
apps/app/src/server/routes/apiv3/healthcheck.ts

@@ -13,6 +13,70 @@ const logger = loggerFactory('growi:routes:apiv3:healthcheck');
 
 const router = express.Router();
 
+/**
+ * @swagger
+ *
+ *  components:
+ *    schemas:
+ *      HealthcheckInfo:
+ *        description: Information of middlewares
+ *        type: object
+ *        properties:
+ *          mongo:
+ *            type: string
+ *            description: 'OK'
+ *            example: 'OK'
+ *          searchInfo:
+ *            type: object
+ *            properties:
+ *              cluster_name:
+ *                type: string
+ *                example: elasticsearch
+ *              status:
+ *                type: string
+ *                enum: [green, yellow, red]
+ *                example: yellow
+ *              timed_out:
+ *                type: boolean
+ *                example: false
+ *              number_of_nodes:
+ *                type: integer
+ *                example: 1
+ *              number_of_data_nodes:
+ *                type: integer
+ *                example: 1
+ *              active_primary_shards:
+ *                type: integer
+ *                example: 2
+ *              active_shards:
+ *                type: integer
+ *                example: 2
+ *              relocating_shards:
+ *                type: integer
+ *                example: 0
+ *              initializing_shards:
+ *                type: integer
+ *                example: 0
+ *              unassigned_shards:
+ *                type: integer
+ *                example: 1
+ *              delayed_unassigned_shards:
+ *                type: integer
+ *                example: 0
+ *              number_of_pending_tasks:
+ *                type: integer
+ *                example: 0
+ *              number_of_in_flight_fetch:
+ *                type: integer
+ *                example: 0
+ *              task_max_waiting_in_queue_millis:
+ *                type: integer
+ *                example: 0
+ *              active_shards_percent_as_number:
+ *                type: number
+ *                format: float
+ *                example: 66.66666666666666
+ */
 /** @param {import('~/server/crowi').default} crowi Crowi instance */
 module.exports = (crowi) => {
 
@@ -40,6 +104,68 @@ module.exports = (crowi) => {
     }
   }
 
+  /**
+   * @swagger
+   *
+   *  /healthcheck:
+   *    get:
+   *      tags: [Healthcheck]
+   *      security: []
+   *      operationId: getHealthcheck
+   *      summary: /healthcheck
+   *      description: Check whether the server is healthy or not
+   *      parameters:
+   *        - name: checkServices
+   *          in: query
+   *          description: The list of services to check health
+   *          schema:
+   *            type: array
+   *            items:
+   *              type: string
+   *              enum:
+   *                - mongo
+   *                - search
+   *        - name: strictly
+   *          in: query
+   *          description: Check services and responds 503 if either of these is unhealthy
+   *          schema:
+   *            type: boolean
+   *      responses:
+   *        200:
+   *          description: Healthy
+   *          content:
+   *            application/json:
+   *              schema:
+   *                oneOf:
+   *                  - type: object
+   *                    description: "Don't select checkServices"
+   *                    properties:
+   *                      status:
+   *                        type: string
+   *                  - type: object
+   *                    description: "Select checkServices"
+   *                    properties:
+   *                      info:
+   *                        $ref: '#/components/schemas/HealthcheckInfo'
+   *        503:
+   *          description: "errors occurs when using checkServicesStrictly"
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  errors:
+   *                    type: array
+   *                    description: Errors
+   *                    items:
+   *                      type: object
+   *                      properties:
+   *                        message:
+   *                          type: string
+   *                        code:
+   *                          type: string
+   *                  info:
+   *                    $ref: '#/components/schemas/HealthcheckInfo'
+   */
   router.get('/', nocache(), async(req, res: ApiV3Response) => {
     let checkServices = (() => {
       if (req.query.checkServices == null) return [];

+ 1 - 58
apps/app/src/server/routes/apiv3/staffs.js

@@ -21,66 +21,9 @@ const compareFunction = function(a, b) {
   return a.order - b.order;
 };
 
-/**
- * @swagger
- *
- * components:
- *   schemas:
- *     Staff:
- *       type: object
- *       properties:
- *         order:
- *           type: integer
- *           example: 1
- *         sectionName:
- *           type: string
- *           example: GROWI VILLAGE
- *         additionalClass:
- *           type: string
- *           example: ""
- *         memberGroups:
- *           type: array
- *           items:
- *             type: object
- *             properties:
- *               additionalClass:
- *                 type: string
- *                 example: col-md-12 my-4
- *               members:
- *                 type: array
- *                 items:
- *                   type: object
- *                   properties:
- *                     position:
- *                       type: string
- *                       example: Founder
- *                     name:
- *                       type: string
- *                       example: yuki-takei
- */
 /** @param {import('~/server/crowi').default} crowi Crowi instance */
 module.exports = (crowi) => {
-  /**
-   * @swagger
-   *
-   * /staffs:
-   *   get:
-   *     summary: Get staffs
-   *     security: []
-   *     tags: [Staff]
-   *     responses:
-   *       200:
-   *         description: Staffs fetched successfully
-   *         content:
-   *           application/json:
-   *             schema:
-   *               type: object
-   *               properties:
-   *                 contributors:
-   *                   type: array
-   *                   items:
-   *                     $ref: '#/components/schemas/Staff'
-   */
+
   router.get('/', async(req, res) => {
     const now = new Date();
     const growiCloudUri = await crowi.configManager.getConfig('app:growiCloudUri');