Skip to content

Commit d75e79d

Browse files
committed
create open api endpoint
1 parent adb55fb commit d75e79d

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ import './v1/voip/omnichannel';
4848
import './v1/voip';
4949
import './v1/federation';
5050
import './v1/moderation';
51+
import './openApi';
5152

5253
export { API, APIClass, defaultRateLimiterOptions } from './api';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { API } from './api';
2+
import { settings } from '../../settings/server';
3+
import { Info } from '../../utils/rocketchat.info';
4+
5+
const openApi = new API.ApiClass({
6+
version: 'json',
7+
useDefaultAuth: false,
8+
prettyJson: false,
9+
enableCors: false,
10+
auth: API.getUserAuth(),
11+
});
12+
13+
openApi.addRoute('/', {
14+
get() {
15+
return {
16+
openapi: '3.0.3',
17+
info: {
18+
title: 'Rocket.Chat API',
19+
description: 'Rocket.Chat API',
20+
version: Info.version,
21+
},
22+
servers: [
23+
{
24+
url: settings.get('Site_Url'),
25+
},
26+
],
27+
components: {
28+
securitySchemes: {
29+
userId: {
30+
type: 'apiKey',
31+
in: 'header',
32+
name: 'X-User-Id',
33+
},
34+
authToken: {
35+
type: 'apiKey',
36+
in: 'header',
37+
name: 'X-Auth-Token',
38+
},
39+
},
40+
schemas: {},
41+
},
42+
paths: API.v1.typedRoutes,
43+
};
44+
},
45+
});

0 commit comments

Comments
 (0)