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

Merge pull request #9742 from goofmint/fix/doc-v3-personal-setting

support(jsdoc): add swagger document to personal-setting.js
Yuki Takei 1 год назад
Родитель
Сommit
dda54b82ca

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

@@ -73,6 +73,7 @@ module.exports = {
         'Export',
         'MongoDB',
         'NotificationSetting',
+        'QuestionnaireSetting',
         'SlackIntegrationSettings',
         'SlackIntegrationSettings (with proxy)',
         'SlackIntegrationSettings (without proxy)',

+ 89 - 19
apps/app/src/server/routes/apiv3/personal-setting.js

@@ -39,6 +39,8 @@ const router = express.Router();
  *            type: string
  *          isEmailPublished:
  *            type: boolean
+ *          slackMemberId:
+ *            type: string
  *      Passwords:
  *        description: passwords for update
  *        type: object
@@ -183,6 +185,10 @@ module.exports = (crowi) => {
    *                  properties:
    *                    isPasswordSet:
    *                      type: boolean
+   *                      description: Whether a password has been set
+   *                    minPasswordLength:
+   *                      type: number
+   *                      description: Minimum password length
    */
   router.get('/is-password-set', accessTokenParser, loginRequiredStrictly, async(req, res) => {
     const { username } = req.user;
@@ -222,7 +228,7 @@ module.exports = (crowi) => {
    *              application/json:
    *                schema:
    *                  properties:
-   *                    currentUser:
+   *                    updatedUser:
    *                      type: object
    *                      description: personal params
    */
@@ -266,6 +272,13 @@ module.exports = (crowi) => {
    *        operationId: putUserImageType
    *        summary: /personal-setting/image-type
    *        description: Update user image type
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              properties:
+   *                isGravatarEnabled:
+   *                  type: boolean
    *        responses:
    *          200:
    *            description: succeded to update user image type
@@ -341,8 +354,11 @@ module.exports = (crowi) => {
    *          required: true
    *          content:
    *            application/json:
-   *              schema:
-   *                $ref: '#/components/schemas/Passwords'
+   *              properties:
+   *                oldPassword:
+   *                  type: string
+   *                newPassword:
+   *                  type: string
    *        responses:
    *          200:
    *            description: user password
@@ -382,6 +398,8 @@ module.exports = (crowi) => {
    *    /personal-setting/api-token:
    *      put:
    *        tags: [GeneralSetting]
+   *        security:
+   *          - cookieAuth: []
    *        operationId: putUserApiToken
    *        summary: /personal-setting/api-token
    *        description: Update user api token
@@ -428,7 +446,9 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schema:
-   *                $ref: '#/components/schemas/AssociateUser'
+   *                properties:
+   *                  username:
+   *                    type: string
    *        responses:
    *          200:
    *            description: succeded to associate Ldap account
@@ -524,18 +544,30 @@ module.exports = (crowi) => {
    *      put:
    *        tags: [EditorSetting]
    *        operationId: putEditorSettings
-   *        summary: /editor-setting
+   *        summary: /personal-setting/editor-settings
    *        description: Put editor preferences
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  theme:
+   *                    type: string
+   *                  keymapMode:
+   *                    type: string
+   *                  styleActiveLine:
+   *                    type: boolean
+   *                  autoFormatMarkdownTable:
+   *                    type: boolean
    *        responses:
    *          200:
    *            description: params of editor settings
    *            content:
    *              application/json:
    *                schema:
-   *                  properties:
-   *                    currentUser:
-   *                      type: object
-   *                      description: editor settings
+   *                  type: object
+   *                  description: editor settings
    */
   router.put('/editor-settings', accessTokenParser, loginRequiredStrictly, addActivity, validator.editorSettings, apiV3FormValidator, async(req, res) => {
     const query = { userId: req.user.id };
@@ -574,7 +606,7 @@ module.exports = (crowi) => {
    *      get:
    *        tags: [EditorSetting]
    *        operationId: getEditorSettings
-   *        summary: /editor-setting
+   *        summary: /personal-setting/editor-settings
    *        description: Get editor preferences
    *        responses:
    *          200:
@@ -582,10 +614,8 @@ module.exports = (crowi) => {
    *            content:
    *              application/json:
    *                schema:
-   *                  properties:
-   *                    currentUser:
-   *                      type: object
-   *                      description: editor settings
+   *                  type: object
+   *                  description: editor settings
    */
   router.get('/editor-settings', accessTokenParser, loginRequiredStrictly, async(req, res) => {
     try {
@@ -606,18 +636,30 @@ module.exports = (crowi) => {
    *      put:
    *        tags: [InAppNotificationSettings]
    *        operationId: putInAppNotificationSettings
-   *        summary: personal-setting/in-app-notification-settings
+   *        summary: /personal-setting/in-app-notification-settings
    *        description: Put InAppNotificationSettings
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  subscribeRules:
+   *                    type: array
+   *                    items:
+   *                      type: object
+   *                      properties:
+   *                        name:
+   *                          type: string
+   *                        isEnabled:
+   *                          type: boolean
    *        responses:
    *          200:
    *            description: params of InAppNotificationSettings
    *            content:
    *              application/json:
    *                schema:
-   *                  properties:
-   *                    currentUser:
-   *                      type: object
-   *                      description: in-app-notification-settings
+   *                 type: object
    */
   // eslint-disable-next-line max-len
   router.put('/in-app-notification-settings', accessTokenParser, loginRequiredStrictly, addActivity, validator.inAppNotificationSettings, apiV3FormValidator, async(req, res) => {
@@ -675,6 +717,34 @@ module.exports = (crowi) => {
     }
   });
 
+  /**
+   * @swagger
+   *   /personal-setting/questionnaire-settings:
+   *     put:
+   *       tags: [QuestionnaireSetting]
+   *       operationId: putQuestionnaireSetting
+   *       summary: /personal-setting/questionnaire-settings
+   *       description: Update the questionnaire settings for the current user
+   *       requestBody:
+   *         required: true
+   *         content:
+   *           application/json:
+   *             schema:
+   *               properties:
+   *                 isQuestionnaireEnabled:
+   *                   type: boolean
+   *       responses:
+   *         200:
+   *           description: Successfully updated questionnaire settings
+   *           content:
+   *             application/json:
+   *               schema:
+   *                 properties:
+   *                   message:
+   *                     type: string
+   *                   isQuestionnaireEnabled:
+   *                     type: boolean
+   */
   // eslint-disable-next-line max-len
   router.put('/questionnaire-settings', accessTokenParser, loginRequiredStrictly, validator.questionnaireSettings, apiV3FormValidator, async(req, res) => {
     const { isQuestionnaireEnabled } = req.body;