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

add API reference related to revision

Ryu Sato 6 лет назад
Родитель
Сommit
07d054f432
2 измененных файлов с 155 добавлено и 35 удалено
  1. 0 35
      src/server/routes/page.js
  2. 155 0
      src/server/routes/revision.js

+ 0 - 35
src/server/routes/page.js

@@ -85,41 +85,6 @@
  *            description: date updated at
  *            description: date updated at
  *            example: 2010-01-01T00:00:00.000Z
  *            example: 2010-01-01T00:00:00.000Z
  *
  *
- *      Revision:
- *        type: object
- *        properties:
- *          _id:
- *            type: string
- *            description: revision ID
- *            example: 5e0734e472560e001761fa68
- *          __v:
- *            type: integer
- *            description: DB record version
- *            example: 0
- *          author:
- *            type: object
- *            description: author
- *            example: nil
- *          body:
- *            type: string
- *            description: content body
- *            example: |
- *              \# test
- *
- *              test
- *          createdAt:
- *            type: string
- *            description: date created at
- *            example: 2010-01-01T00:00:00.000Z
- *          format:
- *            type: string
- *            description: format
- *            example: markdown
- *          path:
- *            type: string
- *            description: path
- *            example: /user/alice/test
- *
  *      UpdatePost:
  *      UpdatePost:
  *        type: object
  *        type: object
  *        properties:
  *        properties:

+ 155 - 0
src/server/routes/revision.js

@@ -1,3 +1,50 @@
+/**
+ * @swagger
+ *  tags:
+ *    name: Revisions
+ */
+
+/**
+ * @swagger
+ *
+ *  components:
+ *    schemas:
+ *      Revision:
+ *        type: object
+ *        properties:
+ *          _id:
+ *            type: string
+ *            description: revision ID
+ *            example: 5e0734e472560e001761fa68
+ *          __v:
+ *            type: integer
+ *            description: DB record version
+ *            example: 0
+ *          author:
+ *            type: object
+ *            description: author
+ *            example: nil
+ *          body:
+ *            type: string
+ *            description: content body
+ *            example: |
+ *              \# test
+ *
+ *              test
+ *          createdAt:
+ *            type: string
+ *            description: date created at
+ *            example: 2010-01-01T00:00:00.000Z
+ *          format:
+ *            type: string
+ *            description: format
+ *            example: markdown
+ *          path:
+ *            type: string
+ *            description: path
+ *            example: /user/alice/test
+ */
+
 module.exports = function(crowi, app) {
 module.exports = function(crowi, app) {
   const debug = require('debug')('growi:routes:revision');
   const debug = require('debug')('growi:routes:revision');
   const logger = require('@alias/logger')('growi:routes:revision');
   const logger = require('@alias/logger')('growi:routes:revision');
@@ -9,6 +56,42 @@ module.exports = function(crowi, app) {
   const actions = {};
   const actions = {};
   actions.api = {};
   actions.api = {};
 
 
+  /**
+   * @swagger
+   *
+   *    /_api/revisions.get:
+   *      get:
+   *        tags: [Revisions]
+   *        description: Get revision
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  page_id:
+   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                  revision_id:
+   *                    $ref: '#/components/schemas/Revision/properties/_id'
+   *                required:
+   *                  - page_id
+   *                  - revision_id
+   *        responses:
+   *          200:
+   *            description: Succeeded to get revision.
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  properties:
+   *                    ok:
+   *                      $ref: '#/components/schemas/V1Response/ok'
+   *                    revision:
+   *                      $ref: '#/components/schemas/Revision'
+   *          403:
+   *            $ref: '#/components/responses/403'
+   *          500:
+   *            $ref: '#/components/responses/500'
+   */
   /**
   /**
    * @api {get} /revisions.get Get revision
    * @api {get} /revisions.get Get revision
    * @apiName GetRevision
    * @apiName GetRevision
@@ -41,6 +124,41 @@ module.exports = function(crowi, app) {
     }
     }
   };
   };
 
 
+  /**
+   * @swagger
+   *
+   *    /_api/revisions.ids:
+   *      get:
+   *        tags: [Revisions]
+   *        description: Get revision id list of the page
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  page_id:
+   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                required:
+   *                  - page_id
+   *        responses:
+   *          200:
+   *            description: Succeeded to get revision id list of the page.
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  properties:
+   *                    ok:
+   *                      $ref: '#/components/schemas/V1Response/ok'
+   *                    revisions:
+   *                      type: array
+   *                      items:
+   *                        $ref: '#/components/schemas/Revision'
+   *          403:
+   *            $ref: '#/components/responses/403'
+   *          500:
+   *            $ref: '#/components/responses/500'
+   */
   /**
   /**
    * @api {get} /revisions.ids Get revision id list of the page
    * @api {get} /revisions.ids Get revision id list of the page
    * @apiName ids
    * @apiName ids
@@ -69,6 +187,43 @@ module.exports = function(crowi, app) {
     }
     }
   };
   };
 
 
+  /**
+   * @swagger
+   *
+   *    /_api/revisions.list:
+   *      get:
+   *        tags: [Revisions]
+   *        description: Get revisions
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                properties:
+   *                  page_id:
+   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                  revision_ids:
+   *                    type: string
+   *                    description: revision ids
+   *                    example: 5e0734e472560e001761fa68,5e079a0a0afa6700170a75fb
+   *        responses:
+   *          200:
+   *            description: Succeeded to get revisions.
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  properties:
+   *                    ok:
+   *                      $ref: '#/components/schemas/V1Response/ok'
+   *                    revisions:
+   *                      type: array
+   *                      items:
+   *                        $ref: '#/components/schemas/Revision'
+   *          403:
+   *            $ref: '#/components/responses/403'
+   *          500:
+   *            $ref: '#/components/responses/500'
+   */
   /**
   /**
    * @api {get} /revisions.list Get revisions
    * @api {get} /revisions.list Get revisions
    * @apiName ListRevision
    * @apiName ListRevision