Преглед изворни кода

Merge pull request #9740 from goofmint/fix/doc-v3-user-group

support(jsdoc): add swagger document to user-group.js
Yuki Takei пре 1 година
родитељ
комит
b5e4f4a5f5
1 измењених фајлова са 183 додато и 24 уклоњено
  1. 183 24
      apps/app/src/server/routes/apiv3/user-group.js

+ 183 - 24
apps/app/src/server/routes/apiv3/user-group.js

@@ -89,9 +89,36 @@ module.exports = (crowi) => {
    *    /user-groups:
    *    /user-groups:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getUserGroup
    *        operationId: getUserGroup
    *        summary: /user-groups
    *        summary: /user-groups
    *        description: Get usergroups
    *        description: Get usergroups
+   *        parameters:
+   *          - name: page
+   *            in: query
+   *            required: false
+   *            description: page number
+   *            schema:
+   *              type: number
+   *          - name: limit
+   *            in: query
+   *            required: false
+   *            description: number of items per page
+   *            schema:
+   *              type: number
+   *          - name: offset
+   *            in: query
+   *            required: false
+   *            description: offset
+   *            schema:
+   *              type: number
+   *          - name: pagination
+   *            in: query
+   *            required: false
+   *            description: whether to paginate
+   *            schema:
+   *              type: boolean
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: usergroups are fetched
    *            description: usergroups are fetched
@@ -102,6 +129,12 @@ module.exports = (crowi) => {
    *                    userGroups:
    *                    userGroups:
    *                      type: object
    *                      type: object
    *                      description: a result of `UserGroup.find`
    *                      description: a result of `UserGroup.find`
+   *                    totalUserGroups:
+   *                      type: number
+   *                      description: the number of userGroups
+   *                    pagingLimit:
+   *                      type: number
+   *                      description: the number of items per page
    */
    */
   router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
   router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
     const { query } = req;
     const { query } = req;
@@ -129,11 +162,13 @@ module.exports = (crowi) => {
    * @swagger
    * @swagger
    *
    *
    *  paths:
    *  paths:
-   *    /ancestors:
+   *    /user-groups/ancestors:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getAncestorUserGroups
    *        operationId: getAncestorUserGroups
-   *        summary: /ancestors
+   *        summary: /user-groups/ancestors
    *        description: Get ancestor user groups.
    *        description: Get ancestor user groups.
    *        parameters:
    *        parameters:
    *          - name: groupId
    *          - name: groupId
@@ -149,7 +184,7 @@ module.exports = (crowi) => {
    *              application/json:
    *              application/json:
    *                schema:
    *                schema:
    *                  properties:
    *                  properties:
-   *                    userGroups:
+   *                    ancestorUserGroups:
    *                      type: array
    *                      type: array
    *                      items:
    *                      items:
    *                        type: object
    *                        type: object
@@ -170,6 +205,50 @@ module.exports = (crowi) => {
     }
     }
   });
   });
 
 
+  /**
+   * @swagger
+   *    paths:
+   *      /user-groups/children:
+   *        get:
+   *          tags: [UserGroups]
+   *          security:
+   *            - cookieAuth: []
+   *          operationId: getUserGroupChildren
+   *          summary: /user-groups/children
+   *          description: Get child user groups
+   *          parameters:
+   *            - name: parentIds
+   *              in: query
+   *              required: false
+   *              description: IDs of parent user groups
+   *              schema:
+   *                type: array
+   *                items:
+   *                  type: string
+   *            - name: includeGrandChildren
+   *              in: query
+   *              required: false
+   *              description: Whether to include grandchild user groups
+   *              schema:
+   *                type: boolean
+   *          responses:
+   *            200:
+   *              description: Child user groups are fetched
+   *              content:
+   *                application/json:
+   *                  schema:
+   *                    properties:
+   *                      childUserGroups:
+   *                        type: array
+   *                        items:
+   *                          type: object
+   *                        description: Child user group objects
+   *                      grandChildUserGroups:
+   *                        type: array
+   *                        items:
+   *                          type: object
+   *                        description: Grandchild user group objects
+   */
   router.get('/children', loginRequiredStrictly, adminRequired, validator.listChildren, async(req, res) => {
   router.get('/children', loginRequiredStrictly, adminRequired, validator.listChildren, async(req, res) => {
     try {
     try {
       const { parentIds, includeGrandChildren = false } = req.query;
       const { parentIds, includeGrandChildren = false } = req.query;
@@ -195,6 +274,8 @@ module.exports = (crowi) => {
    *    /user-groups:
    *    /user-groups:
    *      post:
    *      post:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: createUserGroup
    *        operationId: createUserGroup
    *        summary: /user-groups
    *        summary: /user-groups
    *        description: Adds userGroup
    *        description: Adds userGroup
@@ -207,6 +288,12 @@ module.exports = (crowi) => {
    *                  name:
    *                  name:
    *                    type: string
    *                    type: string
    *                    description: name of the userGroup trying to be added
    *                    description: name of the userGroup trying to be added
+   *                  description:
+   *                    type: string
+   *                    description: description of the userGroup trying to be added
+   *                  parentId:
+   *                    type: string
+   *                    description: parentId of the userGroup trying to be added
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: userGroup is added
    *            description: userGroup is added
@@ -245,6 +332,8 @@ module.exports = (crowi) => {
    *    /selectable-parent-groups:
    *    /selectable-parent-groups:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getSelectableParentGroups
    *        operationId: getSelectableParentGroups
    *        summary: /selectable-parent-groups
    *        summary: /selectable-parent-groups
    *        description: Get selectable parent UserGroups
    *        description: Get selectable parent UserGroups
@@ -262,7 +351,7 @@ module.exports = (crowi) => {
    *              application/json:
    *              application/json:
    *                schema:
    *                schema:
    *                  properties:
    *                  properties:
-   *                    userGroups:
+   *                    selectableParentGroups:
    *                      type: array
    *                      type: array
    *                      items:
    *                      items:
    *                        type: object
    *                        type: object
@@ -294,6 +383,8 @@ module.exports = (crowi) => {
    *    /selectable-child-groups:
    *    /selectable-child-groups:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getSelectableChildGroups
    *        operationId: getSelectableChildGroups
    *        summary: /selectable-child-groups
    *        summary: /selectable-child-groups
    *        description: Get selectable child UserGroups
    *        description: Get selectable child UserGroups
@@ -311,7 +402,7 @@ module.exports = (crowi) => {
    *              application/json:
    *              application/json:
    *                schema:
    *                schema:
    *                  properties:
    *                  properties:
-   *                    userGroups:
+   *                    selectableChildGroups:
    *                      type: array
    *                      type: array
    *                      items:
    *                      items:
    *                        type: object
    *                        type: object
@@ -346,6 +437,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}:
    *    /user-groups/{id}:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getUserGroupFromGroupId
    *        operationId: getUserGroupFromGroupId
    *        summary: /user-groups/{id}
    *        summary: /user-groups/{id}
    *        description: Get UserGroup from Group ID
    *        description: Get UserGroup from Group ID
@@ -388,6 +481,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}:
    *    /user-groups/{id}:
    *      delete:
    *      delete:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: deleteUserGroup
    *        operationId: deleteUserGroup
    *        summary: /user-groups/{id}
    *        summary: /user-groups/{id}
    *        description: Deletes userGroup
    *        description: Deletes userGroup
@@ -408,6 +503,11 @@ module.exports = (crowi) => {
    *            description: userGroup id that will be transferred to
    *            description: userGroup id that will be transferred to
    *            schema:
    *            schema:
    *              type: string
    *              type: string
+   *          - name: transferToUserGroupType
+   *            in: query
+   *            description: userGroup type that will be transferred to
+   *            schema:
+   *              type: string
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: userGroup is removed
    *            description: userGroup is removed
@@ -452,6 +552,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}:
    *    /user-groups/{id}:
    *      put:
    *      put:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: updateUserGroups
    *        operationId: updateUserGroups
    *        summary: /user-groups/{id}
    *        summary: /user-groups/{id}
    *        description: Update userGroup
    *        description: Update userGroup
@@ -462,6 +564,24 @@ module.exports = (crowi) => {
    *            description: id of userGroup
    *            description: id of userGroup
    *            schema:
    *            schema:
    *              type: string
    *              type: string
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  name:
+   *                    type: string
+   *                    description: name of the userGroup trying to be updated
+   *                  description:
+   *                    type: string
+   *                    description: description of the userGroup trying to be updated
+   *                  parentId:
+   *                    type: string
+   *                    description: parentId of the userGroup trying to be updated
+   *                  forceUpdateParents:
+   *                    type: boolean
+   *                    description: whether to update parent groups
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: userGroup is updated
    *            description: userGroup is updated
@@ -502,6 +622,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}/users:
    *    /user-groups/{id}/users:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getUsersUserGroups
    *        operationId: getUsersUserGroups
    *        summary: /user-groups/{id}/users
    *        summary: /user-groups/{id}/users
    *        description: Get users related to the userGroup
    *        description: Get users related to the userGroup
@@ -522,7 +644,7 @@ module.exports = (crowi) => {
    *                    users:
    *                    users:
    *                      type: array
    *                      type: array
    *                      items:
    *                      items:
-   *                        type: object
+   *                        $ref: '#/components/schemas/User'
    *                      description: user objects
    *                      description: user objects
    */
    */
   router.get('/:id/users', loginRequiredStrictly, adminRequired, async(req, res) => {
   router.get('/:id/users', loginRequiredStrictly, adminRequired, async(req, res) => {
@@ -553,6 +675,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}/unrelated-users:
    *    /user-groups/{id}/unrelated-users:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getUnrelatedUsersUserGroups
    *        operationId: getUnrelatedUsersUserGroups
    *        summary: /user-groups/{id}/unrelated-users
    *        summary: /user-groups/{id}/unrelated-users
    *        description: Get users unrelated to the userGroup
    *        description: Get users unrelated to the userGroup
@@ -563,6 +687,26 @@ module.exports = (crowi) => {
    *            description: id of userGroup
    *            description: id of userGroup
    *            schema:
    *            schema:
    *              type: string
    *              type: string
+   *          - name: searchWord
+   *            in: query
+   *            description: search word
+   *            schema:
+   *              type: string
+   *          - name: searchType
+   *            in: query
+   *            description: search type
+   *            schema:
+   *              type: string
+   *          - name: isAlsoNameSearched
+   *            in: query
+   *            description: whether name is also searched
+   *            schema:
+   *              type: boolean
+   *          - name: isAlsoMailSearched
+   *            in: query
+   *            description: whether mail is also searched
+   *            schema:
+   *              type: boolean
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: users are fetched
    *            description: users are fetched
@@ -573,7 +717,7 @@ module.exports = (crowi) => {
    *                    users:
    *                    users:
    *                      type: array
    *                      type: array
    *                      items:
    *                      items:
-   *                        type: object
+   *                        $ref: '#/components/schemas/User'
    *                      description: user objects
    *                      description: user objects
    */
    */
   router.get('/:id/unrelated-users', loginRequiredStrictly, adminRequired, async(req, res) => {
   router.get('/:id/unrelated-users', loginRequiredStrictly, adminRequired, async(req, res) => {
@@ -611,11 +755,13 @@ module.exports = (crowi) => {
    * @swagger
    * @swagger
    *
    *
    *  paths:
    *  paths:
-   *    /user-groups/{id}/users:
+   *    /user-groups/{id}/users/{username}:
    *      post:
    *      post:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: addUserUserGroups
    *        operationId: addUserUserGroups
-   *        summary: /user-groups/{id}/users
+   *        summary: /user-groups/{id}/users/{username}
    *        description: Add a user to the userGroup
    *        description: Add a user to the userGroup
    *        parameters:
    *        parameters:
    *          - name: id
    *          - name: id
@@ -624,6 +770,12 @@ module.exports = (crowi) => {
    *            description: id of userGroup
    *            description: id of userGroup
    *            schema:
    *            schema:
    *              type: string
    *              type: string
+   *          - name: username
+   *            in: path
+   *            required: true
+   *            description: username of the user
+   *            schema:
+   *              type: string
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: a user is added
    *            description: a user is added
@@ -633,14 +785,11 @@ module.exports = (crowi) => {
    *                  type: object
    *                  type: object
    *                  properties:
    *                  properties:
    *                    user:
    *                    user:
-   *                      type: object
+   *                      $ref: '#/components/schemas/User'
    *                      description: the user added to the group
    *                      description: the user added to the group
-   *                    userGroup:
-   *                      type: object
-   *                      description: the group to which a user was added
-   *                    userGroupRelation:
-   *                      type: object
-   *                      description: the associative entity between user and userGroup
+   *                    createdRelationCount:
+   *                      type: number
+   *                      description: the number of relations created
    */
    */
   router.post('/:id/users/:username', loginRequiredStrictly, adminRequired, validator.users.post, apiV3FormValidator, addActivity, async(req, res) => {
   router.post('/:id/users/:username', loginRequiredStrictly, adminRequired, validator.users.post, apiV3FormValidator, addActivity, async(req, res) => {
     const { id, username } = req.params;
     const { id, username } = req.params;
@@ -678,11 +827,13 @@ module.exports = (crowi) => {
    * @swagger
    * @swagger
    *
    *
    *  paths:
    *  paths:
-   *    /user-groups/{id}/users:
+   *    /user-groups/{id}/users/{username}:
    *      delete:
    *      delete:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: deleteUsersUserGroups
    *        operationId: deleteUsersUserGroups
-   *        summary: /user-groups/{id}/users
+   *        summary: /user-groups/{id}/users/{username}
    *        description: remove a user from the userGroup
    *        description: remove a user from the userGroup
    *        parameters:
    *        parameters:
    *          - name: id
    *          - name: id
@@ -691,6 +842,12 @@ module.exports = (crowi) => {
    *            description: id of userGroup
    *            description: id of userGroup
    *            schema:
    *            schema:
    *              type: string
    *              type: string
+   *          - name: username
+   *            in: path
+   *            required: true
+   *            description: username of the user
+   *            schema:
+   *              type: string
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: a user was removed
    *            description: a user was removed
@@ -701,13 +858,11 @@ module.exports = (crowi) => {
    *                  properties:
    *                  properties:
    *                    user:
    *                    user:
    *                      type: object
    *                      type: object
+   *                      $ref: '#/components/schemas/User'
    *                      description: the user removed from the group
    *                      description: the user removed from the group
-   *                    userGroup:
-   *                      type: object
-   *                      description: the group from which a user was removed
-   *                    userGroupRelation:
-   *                      type: object
-   *                      description: the associative entity between user and userGroup
+   *                    deletedGroupsCount:
+   *                      type: number
+   *                      description: the number of groups from which the user was removed
    */
    */
   router.delete('/:id/users/:username', loginRequiredStrictly, adminRequired, validator.users.delete, apiV3FormValidator, async(req, res) => {
   router.delete('/:id/users/:username', loginRequiredStrictly, adminRequired, validator.users.delete, apiV3FormValidator, async(req, res) => {
     const { id: userGroupId, username } = req.params;
     const { id: userGroupId, username } = req.params;
@@ -733,6 +888,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}/user-group-relations:
    *    /user-groups/{id}/user-group-relations:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getUserGroupRelationsUserGroups
    *        operationId: getUserGroupRelationsUserGroups
    *        summary: /user-groups/{id}/user-group-relations
    *        summary: /user-groups/{id}/user-group-relations
    *        description: Get the user group relations for the userGroup
    *        description: Get the user group relations for the userGroup
@@ -780,6 +937,8 @@ module.exports = (crowi) => {
    *    /user-groups/{id}/pages:
    *    /user-groups/{id}/pages:
    *      get:
    *      get:
    *        tags: [UserGroups]
    *        tags: [UserGroups]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: getPagesUserGroups
    *        operationId: getPagesUserGroups
    *        summary: /user-groups/{id}/pages
    *        summary: /user-groups/{id}/pages
    *        description: Get closed pages for the userGroup
    *        description: Get closed pages for the userGroup