Procházet zdrojové kódy

Add ObjectId schema references across various API routes and models

Yuki Takei před 10 měsíci
rodič
revize
bed7bb872e

+ 10 - 0
apps/app/src/server/models/openapi/object-id.ts

@@ -0,0 +1,10 @@
+/**
+ * @swagger
+ *
+ *  components:
+ *    schemas:
+ *      ObjectId:
+ *        type: string
+ *        description: Object ID
+ *        example: 5ae5fccfc5577b0004dbd8ab
+ */

+ 1 - 3
apps/app/src/server/models/openapi/page.ts

@@ -8,9 +8,7 @@
  *        type: object
  *        type: object
  *        properties:
  *        properties:
  *          _id:
  *          _id:
- *            type: string
- *            description: page ID
- *            example: 5e07345972560e001761fa63
+ *            $ref: '#/components/schemas/ObjectId'
  *          __v:
  *          __v:
  *            type: number
  *            type: number
  *            description: DB record version
  *            description: DB record version

+ 1 - 1
apps/app/src/server/routes/apiv3/bookmarks.js

@@ -42,7 +42,7 @@ const router = express.Router();
  *          page:
  *          page:
  *            $ref: '#/components/schemas/Page'
  *            $ref: '#/components/schemas/Page'
  *          user:
  *          user:
- *            $ref: '#/components/schemas/User/properties/_id'
+ *            $ref: '#/components/schemas/ObjectId'
  *      Bookmarks:
  *      Bookmarks:
  *        description: User Root Bookmarks
  *        description: User Root Bookmarks
  *        type: object
  *        type: object

+ 5 - 5
apps/app/src/server/routes/apiv3/page/index.ts

@@ -197,7 +197,7 @@ module.exports = (crowi) => {
    *            in: query
    *            in: query
    *            description: page id
    *            description: page id
    *            schema:
    *            schema:
-   *              $ref: '#/components/schemas/Page/properties/_id'
+   *              $ref: '#/components/schemas/ObjectId'
    *          - name: path
    *          - name: path
    *            in: query
    *            in: query
    *            description: page path
    *            description: page path
@@ -365,9 +365,9 @@ module.exports = (crowi) => {
    *                  body:
    *                  body:
    *                    $ref: '#/components/schemas/Revision/properties/body'
    *                    $ref: '#/components/schemas/Revision/properties/body'
    *                  pageId:
    *                  pageId:
-   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                  revisionId:
    *                  revisionId:
-   *                    $ref: '#/components/schemas/Revision/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                  grant:
    *                  grant:
    *                    $ref: '#/components/schemas/Page/properties/grant'
    *                    $ref: '#/components/schemas/Page/properties/grant'
    *                  userRelatedGrantUserGroupIds:
    *                  userRelatedGrantUserGroupIds:
@@ -538,7 +538,7 @@ module.exports = (crowi) => {
    *            in: query
    *            in: query
    *            description: page id
    *            description: page id
    *            schema:
    *            schema:
-   *              $ref: '#/components/schemas/Page/properties/_id'
+   *              $ref: '#/components/schemas/ObjectId'
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: Successfully retrieved current grant data.
    *            description: Successfully retrieved current grant data.
@@ -1011,7 +1011,7 @@ module.exports = (crowi) => {
    *              schema:
    *              schema:
    *                properties:
    *                properties:
    *                  pageId:
    *                  pageId:
-   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: Succeeded to update subscription status.
    *            description: Succeeded to update subscription status.

+ 3 - 3
apps/app/src/server/routes/apiv3/pages/index.js

@@ -234,7 +234,7 @@ module.exports = (crowi) => {
    *              schema:
    *              schema:
    *                properties:
    *                properties:
    *                  pageId:
    *                  pageId:
-   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                  path:
    *                  path:
    *                    $ref: '#/components/schemas/Page/properties/path'
    *                    $ref: '#/components/schemas/Page/properties/path'
    *                  revisionId:
    *                  revisionId:
@@ -360,7 +360,7 @@ module.exports = (crowi) => {
     *              schema:
     *              schema:
     *                properties:
     *                properties:
     *                  pageId:
     *                  pageId:
-    *                    $ref: '#/components/schemas/Page/properties/_id'
+    *                    $ref: '#/components/schemas/ObjectId'
     *                required:
     *                required:
     *                  - pageId
     *                  - pageId
     *        responses:
     *        responses:
@@ -576,7 +576,7 @@ module.exports = (crowi) => {
    *              schema:
    *              schema:
    *                properties:
    *                properties:
    *                  pageId:
    *                  pageId:
-   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                  pageNameInput:
    *                  pageNameInput:
    *                    $ref: '#/components/schemas/Page/properties/path'
    *                    $ref: '#/components/schemas/Page/properties/path'
    *                  isRecursively:
    *                  isRecursively:

+ 2 - 2
apps/app/src/server/routes/attachment/api.js

@@ -110,7 +110,7 @@ const ApiResponse = require('../../util/apiResponse');
  *            description: original file name
  *            description: original file name
  *            example: profile.png
  *            example: profile.png
  *          creator:
  *          creator:
- *            $ref: '#/components/schemas/User/properties/_id'
+ *            $ref: '#/components/schemas/ObjectId'
  *          page:
  *          page:
  *            type: string
  *            type: string
  *            description: page ID attached at
  *            description: page ID attached at
@@ -289,7 +289,7 @@ export const routesFactory = (crowi) => {
    *              schema:
    *              schema:
    *                properties:
    *                properties:
    *                  attachment_id:
    *                  attachment_id:
-   *                    $ref: '#/components/schemas/Attachment/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                required:
    *                required:
    *                  - attachment_id
    *                  - attachment_id
    *        responses:
    *        responses:

+ 11 - 13
apps/app/src/server/routes/comment.js

@@ -26,19 +26,17 @@ import { preNotifyService } from '../service/pre-notify';
  *        type: object
  *        type: object
  *        properties:
  *        properties:
  *          _id:
  *          _id:
- *            type: string
- *            description: revision ID
- *            example: 5e079a0a0afa6700170a75fb
+ *            $ref: '#/components/schemas/ObjectId'
  *          __v:
  *          __v:
  *            type: number
  *            type: number
  *            description: DB record version
  *            description: DB record version
  *            example: 0
  *            example: 0
  *          page:
  *          page:
- *            $ref: '#/components/schemas/Page/properties/_id'
+ *            $ref: '#/components/schemas/ObjectId'
  *          creator:
  *          creator:
- *            $ref: '#/components/schemas/User/properties/_id'
+ *            $ref: '#/components/schemas/ObjectId'
  *          revision:
  *          revision:
- *            $ref: '#/components/schemas/Revision/properties/_id'
+ *            $ref: '#/components/schemas/ObjectId'
  *          comment:
  *          comment:
  *            type: string
  *            type: string
  *            description: comment
  *            description: comment
@@ -88,11 +86,11 @@ module.exports = function(crowi, app) {
    *          - in: query
    *          - in: query
    *            name: page_id
    *            name: page_id
    *            schema:
    *            schema:
-   *              $ref: '#/components/schemas/Page/properties/_id'
+   *              $ref: '#/components/schemas/ObjectId'
    *          - in: query
    *          - in: query
    *            name: revision_id
    *            name: revision_id
    *            schema:
    *            schema:
-   *              $ref: '#/components/schemas/Revision/properties/_id'
+   *              $ref: '#/components/schemas/ObjectId'
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: Succeeded to get comments of the page of the revision.
    *            description: Succeeded to get comments of the page of the revision.
@@ -190,9 +188,9 @@ module.exports = function(crowi, app) {
    *                    type: object
    *                    type: object
    *                    properties:
    *                    properties:
    *                      page_id:
    *                      page_id:
-   *                        $ref: '#/components/schemas/Page/properties/_id'
+   *                        $ref: '#/components/schemas/ObjectId'
    *                      revision_id:
    *                      revision_id:
-   *                        $ref: '#/components/schemas/Revision/properties/_id'
+   *                        $ref: '#/components/schemas/ObjectId'
    *                      comment:
    *                      comment:
    *                        $ref: '#/components/schemas/Comment/properties/comment'
    *                        $ref: '#/components/schemas/Comment/properties/comment'
    *                      comment_position:
    *                      comment_position:
@@ -336,11 +334,11 @@ module.exports = function(crowi, app) {
    *                        type: object
    *                        type: object
    *                        properties:
    *                        properties:
    *                          page_id:
    *                          page_id:
-   *                            $ref: '#/components/schemas/Page/properties/_id'
+   *                            $ref: '#/components/schemas/ObjectId'
    *                          revision_id:
    *                          revision_id:
-   *                            $ref: '#/components/schemas/Revision/properties/_id'
+   *                            $ref: '#/components/schemas/ObjectId'
    *                          comment_id:
    *                          comment_id:
-   *                            $ref: '#/components/schemas/Comment/properties/_id'
+   *                            $ref: '#/components/schemas/ObjectId'
    *                          comment:
    *                          comment:
    *                            $ref: '#/components/schemas/Comment/properties/comment'
    *                            $ref: '#/components/schemas/Comment/properties/comment'
    *                required:
    *                required:

+ 1 - 1
apps/app/src/server/routes/page.js

@@ -149,7 +149,7 @@ module.exports = function(crowi, app) {
    *          - in: query
    *          - in: query
    *            name: pageId
    *            name: pageId
    *            schema:
    *            schema:
-   *              $ref: '#/components/schemas/Page/properties/_id'
+   *              $ref: '#/components/schemas/ObjectId'
    *        responses:
    *        responses:
    *          200:
    *          200:
    *            description: Succeeded to get page tags.
    *            description: Succeeded to get page tags.

+ 2 - 2
apps/app/src/server/routes/tag.js

@@ -109,9 +109,9 @@ module.exports = function(crowi, app) {
    *              schema:
    *              schema:
    *                properties:
    *                properties:
    *                  pageId:
    *                  pageId:
-   *                    $ref: '#/components/schemas/Page/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                  revisionId:
    *                  revisionId:
-   *                    $ref: '#/components/schemas/Revision/properties/_id'
+   *                    $ref: '#/components/schemas/ObjectId'
    *                  tags:
    *                  tags:
    *                    $ref: '#/components/schemas/Tags'
    *                    $ref: '#/components/schemas/Tags'
    *        responses:
    *        responses: