@@ -18,16 +18,49 @@ import { updateOAuthApp } from '../../../oauth2-server-config/server/admin/metho
1818import type { ExtractRoutesFromAPI } from '../ApiClass' ;
1919import { API } from '../api' ;
2020
21- API . v1 . addRoute (
21+ const oauthAppsListEndpoints = API . v1 . get (
2222 'oauth-apps.list' ,
23- { authRequired : true , permissionsRequired : [ 'manage-oauth-apps' ] } ,
2423 {
25- async get ( ) {
26- return API . v1 . success ( {
27- oauthApps : await OAuthApps . find ( ) . toArray ( ) ,
28- } ) ;
24+ authRequired : true ,
25+ query : ajv . compile < { uid ?: string } > ( {
26+ type : 'object' ,
27+ properties : {
28+ uid : {
29+ type : 'string' ,
30+ } ,
31+ } ,
32+ additionalProperties : false ,
33+ } ) ,
34+ permissionsRequired : [ 'manage-oauth-apps' ] ,
35+ response : {
36+ 400 : validateBadRequestErrorResponse ,
37+ 401 : validateUnauthorizedErrorResponse ,
38+ 403 : validateForbiddenErrorResponse ,
39+ 200 : ajv . compile < { oauthApps : IOAuthApps [ ] } > ( {
40+ type : 'object' ,
41+ properties : {
42+ oauthApps : {
43+ type : 'array' ,
44+ items : {
45+ $ref : '#/components/schemas/IOAuthApps' ,
46+ } ,
47+ } ,
48+ success : {
49+ type : 'boolean' ,
50+ enum : [ true ] ,
51+ } ,
52+ } ,
53+ required : [ 'oauthApps' , 'success' ] ,
54+ additionalProperties : false ,
55+ } ) ,
2956 } ,
3057 } ,
58+
59+ async function action ( ) {
60+ return API . v1 . success ( {
61+ oauthApps : await OAuthApps . find ( ) . toArray ( ) ,
62+ } ) ;
63+ } ,
3164) ;
3265
3366API . v1 . addRoute (
@@ -152,9 +185,13 @@ const oauthAppsCreateEndpoints = API.v1.post(
152185
153186type OauthAppsCreateEndpoints = ExtractRoutesFromAPI < typeof oauthAppsCreateEndpoints > ;
154187
155- export type OAuthAppsEndpoints = OauthAppsCreateEndpoints ;
188+ type OauthAppsListEndpoints = ExtractRoutesFromAPI < typeof oauthAppsListEndpoints > ;
189+
190+ export type OAuthAppsEndpoints = OauthAppsCreateEndpoints | OauthAppsListEndpoints ;
156191
157192declare module '@rocket.chat/rest-typings' {
158193 // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
159194 interface Endpoints extends OauthAppsCreateEndpoints { }
195+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
196+ interface Endpoints extends OauthAppsListEndpoints { }
160197}
0 commit comments