Skip to content

Commit a636e88

Browse files
committed
feat: export core type as schema
1 parent b10ce3b commit a636e88

File tree

18 files changed

+62
-13
lines changed

18 files changed

+62
-13
lines changed

apps/meteor/app/api/server/ApiClass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Logger } from '@rocket.chat/logger';
55
import { Users } from '@rocket.chat/models';
66
import { Random } from '@rocket.chat/random';
77
import type { JoinPathPattern, Method } from '@rocket.chat/rest-typings';
8-
import { ajv } from '@rocket.chat/rest-typings/src/v1/Ajv';
8+
import { ajv } from '@rocket.chat/rest-typings';
99
import { wrapExceptions } from '@rocket.chat/tools';
1010
import type { ValidateFunction } from 'ajv';
1111
import { Accounts } from 'meteor/accounts-base';

apps/meteor/app/api/server/default/openApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { schemas } from '@rocket.chat/core-typings';
12
import type { Route } from '@rocket.chat/http-router';
23
import { isOpenAPIJSONEndpoint } from '@rocket.chat/rest-typings';
34
import express from 'express';
@@ -65,8 +66,9 @@ const makeOpenAPIResponse = (paths: Record<string, Record<string, Route>>) => ({
6566
name: 'X-Auth-Token',
6667
},
6768
},
68-
schemas: {},
69+
schemas: schemas.components.schemas,
6970
},
71+
schemas: schemas.components.schemas,
7072
paths,
7173
});
7274

apps/meteor/app/api/server/v1/custom-sounds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ICustomSound } from '@rocket.chat/core-typings';
22
import { CustomSounds } from '@rocket.chat/models';
33
import type { PaginatedRequest, PaginatedResult } from '@rocket.chat/rest-typings';
4-
import { ajv } from '@rocket.chat/rest-typings/src/v1/Ajv';
4+
import { ajv } from '@rocket.chat/rest-typings';
55
import { escapeRegExp } from '@rocket.chat/string-helpers';
66

77
import type { ExtractRoutesFromAPI } from '../ApiClass';

apps/meteor/app/api/server/v1/federation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Federation, FederationEE } from '@rocket.chat/core-services';
22
import { License } from '@rocket.chat/license';
3-
import { isFederationVerifyMatrixIdProps } from '@rocket.chat/rest-typings';
4-
import { ajv } from '@rocket.chat/rest-typings/src/v1/Ajv';
3+
import { ajv, isFederationVerifyMatrixIdProps } from '@rocket.chat/rest-typings';
54

65
import { API } from '../api';
76

apps/meteor/app/api/server/v1/invites.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { IInvite } from '@rocket.chat/core-typings';
22
import {
3+
ajv,
34
isFindOrCreateInviteParams,
45
isUseInviteTokenProps,
56
isValidateInviteTokenProps,
67
isSendInvitationEmailParams,
78
} from '@rocket.chat/rest-typings';
8-
import { ajv } from '@rocket.chat/rest-typings/src/v1/Ajv';
99

1010
import { findOrCreateInvite } from '../../../invites/server/functions/findOrCreateInvite';
1111
import { listInvites } from '../../../invites/server/functions/listInvites';

apps/meteor/app/api/server/v1/rooms.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { isPrivateRoom, isPublicRoom } from '@rocket.chat/core-typings';
44
import { Messages, Rooms, Users, Uploads, Subscriptions } from '@rocket.chat/models';
55
import type { Notifications } from '@rocket.chat/rest-typings';
66
import {
7+
ajv,
78
isGETRoomsNameExists,
89
isRoomsImagesProps,
910
isRoomsMuteUnmuteUserProps,

apps/meteor/app/api/server/v1/webdav.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { api } from '@rocket.chat/core-services';
22
import type { IWebdavAccount, IWebdavAccountIntegration } from '@rocket.chat/core-typings';
33
import { WebdavAccounts } from '@rocket.chat/models';
4-
import { ajv } from '@rocket.chat/rest-typings/src/v1/Ajv';
4+
import { ajv } from '@rocket.chat/rest-typings';
55
import type { DeleteResult } from 'mongodb';
66

77
import type { ExtractRoutesFromAPI } from '../ApiClass';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { schemas } from '@rocket.chat/core-typings';
2+
import Ajv from 'ajv';
3+
4+
const ajv = new Ajv({
5+
coerceTypes: true,
6+
allowUnionTypes: true,
7+
code: { source: true },
8+
});
9+
10+
export { ajv };
11+
12+
const components = schemas.components?.schemas;
13+
14+
if (components) {
15+
for (const key in components) {
16+
if (Object.prototype.hasOwnProperty.call(components, key)) {
17+
ajv.addSchema(components[key], `#/components/schemas/${key}`);
18+
}
19+
}
20+
}

apps/meteor/app/livechat/server/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './ajv';
12
import './livechat';
23
import './startup';
34
import '../lib/messageTypes';

apps/meteor/ee/app/livechat-enterprise/server/api/outbound.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { IOutboundProvider } from '@rocket.chat/core-typings';
2-
import { ajv } from '@rocket.chat/rest-typings/src/v1/Ajv';
2+
import { ajv } from '@rocket.chat/rest-typings';
33

44
import { API } from '../../../../../app/api/server';
55
import { isGETOutboundProviderParams } from '../outboundcomms/rest';

0 commit comments

Comments
 (0)