|
|
@@ -8,6 +8,26 @@ const axios = require('axios');
|
|
|
|
|
|
const ApiResponse = require('../util/apiResponse');
|
|
|
|
|
|
+/**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * components:
|
|
|
+ * schemas:
|
|
|
+ * Hackmd:
|
|
|
+ * description: Hackmd
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * pageIdOnHackmd:
|
|
|
+ * type: string
|
|
|
+ * description: page ID on HackMD
|
|
|
+ * example: qLnodHLxT6C3hVEVczvbDQ
|
|
|
+ * revisionIdHackmdSynced:
|
|
|
+ * $ref: '#/components/schemas/Revision/properties/_id'
|
|
|
+ * hasDraftOnHackmd:
|
|
|
+ * type: boolean
|
|
|
+ * description: has draft on HackMD
|
|
|
+ * example: false
|
|
|
+ */
|
|
|
module.exports = function(crowi, app) {
|
|
|
const Page = crowi.models.Page;
|
|
|
const pageEvent = crowi.event('page');
|
|
|
@@ -105,6 +125,44 @@ module.exports = function(crowi, app) {
|
|
|
next();
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /_api/hackmd.integrate:
|
|
|
+ * post:
|
|
|
+ * tags: [Hackmd]
|
|
|
+ * operationId: integrateHackmd
|
|
|
+ * summary: /_api/hackmd.integrate
|
|
|
+ * description: Integrate hackmd
|
|
|
+ * requestBody:
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * pageId:
|
|
|
+ * $ref: '#/components/schemas/Page/properties/_id'
|
|
|
+ * page:
|
|
|
+ * $ref: '#/components/schemas/Hackmd'
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: Succeeded to integrate HackMD.
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * ok:
|
|
|
+ * $ref: '#/components/schemas/V1Response/properties/ok'
|
|
|
+ * pageIdOnHackmd:
|
|
|
+ * $ref: '#/components/schemas/Hackmd/properties/pageIdOnHackmd'
|
|
|
+ * revisionIdHackmdSynced:
|
|
|
+ * $ref: '#/components/schemas/Hackmd/properties/revisionIdHackmdSynced'
|
|
|
+ * hasDraftOnHackmd:
|
|
|
+ * $ref: '#/components/schemas/Hackmd/properties/hasDraftOnHackmd'
|
|
|
+ * 403:
|
|
|
+ * $ref: '#/components/responses/403'
|
|
|
+ * 500:
|
|
|
+ * $ref: '#/components/responses/500'
|
|
|
+ */
|
|
|
/**
|
|
|
* POST /_api/hackmd.integrate
|
|
|
*
|
|
|
@@ -180,6 +238,44 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /_api/hackmd.discard:
|
|
|
+ * post:
|
|
|
+ * tags: [Hackmd]
|
|
|
+ * operationId: discardHackmd
|
|
|
+ * summary: /_api/hackmd.discard
|
|
|
+ * description: Discard hackmd
|
|
|
+ * requestBody:
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * pageId:
|
|
|
+ * $ref: '#/components/schemas/Page/properties/_id'
|
|
|
+ * page:
|
|
|
+ * $ref: '#/components/schemas/Hackmd'
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: Succeeded to integrate HackMD.
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * ok:
|
|
|
+ * $ref: '#/components/schemas/V1Response/properties/ok'
|
|
|
+ * pageIdOnHackmd:
|
|
|
+ * $ref: '#/components/schemas/Hackmd/properties/pageIdOnHackmd'
|
|
|
+ * revisionIdHackmdSynced:
|
|
|
+ * $ref: '#/components/schemas/Hackmd/properties/revisionIdHackmdSynced'
|
|
|
+ * hasDraftOnHackmd:
|
|
|
+ * $ref: '#/components/schemas/Hackmd/properties/hasDraftOnHackmd'
|
|
|
+ * 403:
|
|
|
+ * $ref: '#/components/responses/403'
|
|
|
+ * 500:
|
|
|
+ * $ref: '#/components/responses/500'
|
|
|
+ */
|
|
|
/**
|
|
|
* POST /_api/hackmd.discard
|
|
|
*
|
|
|
@@ -206,6 +302,38 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /_api/hackmd.saveOnHackmd:
|
|
|
+ * post:
|
|
|
+ * tags: [Hackmd]
|
|
|
+ * operationId: saveOnHackmd
|
|
|
+ * summary: /_api/hackmd.saveOnHackmd
|
|
|
+ * description: Receive when save operation triggered on HackMD
|
|
|
+ * requestBody:
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * pageId:
|
|
|
+ * $ref: '#/components/schemas/Page/properties/_id'
|
|
|
+ * page:
|
|
|
+ * $ref: '#/components/schemas/Hackmd'
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: Succeeded to receive when save operation triggered on HackMD.
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * ok:
|
|
|
+ * $ref: '#/components/schemas/V1Response/properties/ok'
|
|
|
+ * 403:
|
|
|
+ * $ref: '#/components/responses/403'
|
|
|
+ * 500:
|
|
|
+ * $ref: '#/components/responses/500'
|
|
|
+ */
|
|
|
/**
|
|
|
* POST /_api/hackmd.saveOnHackmd
|
|
|
*
|