瀏覽代碼

Merge pull request #5828 from Atry/get-card-by-id

Add a REST API endpoint to retrieve a card by ID
Lauri Ojansivu 1 天之前
父節點
當前提交
d9fb9f49fd
共有 2 個文件被更改,包括 44 次插入0 次删除
  1. 21 0
      models/cards.js
  2. 23 0
      public/api/wekan.yml

+ 21 - 0
models/cards.js

@@ -3301,6 +3301,27 @@ if (Meteor.isServer) {
     });
   });
 
+  /**
+   * @operation get_card_by_id
+   * @summary Get a Card by Card ID
+   *
+   * @param {string} cardId the card ID
+   * @return_type Cards
+   */
+  JsonRoutes.add(
+    'GET',
+    '/api/cards/:cardId',
+    function(req, res) {
+      const paramCardId = req.params.cardId;
+      card = ReactiveCache.getCard(paramCardId)
+      Authentication.checkBoardAccess(req.userId, card.boardId);
+      JsonRoutes.sendResult(res, {
+        code: 200,
+        data: ReactiveCache.getCard(paramCardId),
+      });
+    },
+  );
+
   /**
    * @operation get_card
    * @summary Get a Card

+ 23 - 0
public/api/wekan.yml

@@ -2612,6 +2612,29 @@ paths:
                 type: integer
               public:
                 type: integer
+  /api/cards/{card}:
+    get:
+      operationId: get_card_by_id
+      summary: Get a Card by Card ID
+      tags:
+        - Cards
+      parameters:
+        - name: card
+          in: path
+          description: |
+            the card ID
+          type: string
+          required: true
+      produces:
+        - application/json
+      security:
+          - UserSecurity: []
+      responses:
+        '200':
+          description: |-
+            200 response
+          schema:
+            $ref: "#/definitions/Cards"
   /api/users/{user}/boards:
     get:
       operationId: get_boards_from_user