diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-04 09:16:23 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-04 09:21:46 +0200 |
commit | 1333ab1f2d4ec495084c5368df25610683582ae3 (patch) | |
tree | 4d2b6f5b36d2acfacd5e5f6c3a9d35a9c7101658 /server | |
parent | 1c627fd8d2e60d4d790353886006485343d70084 (diff) | |
download | PeerTube-1333ab1f2d4ec495084c5368df25610683582ae3.tar.gz PeerTube-1333ab1f2d4ec495084c5368df25610683582ae3.tar.zst PeerTube-1333ab1f2d4ec495084c5368df25610683582ae3.zip |
add operationId doc middleware to so API endpoints
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/abuse.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/config.ts | 13 | ||||
-rw-r--r-- | server/controllers/api/jobs.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/oauth-clients.ts | 3 | ||||
-rw-r--r-- | server/controllers/api/plugins.ts | 6 | ||||
-rw-r--r-- | server/controllers/api/search.ts | 3 | ||||
-rw-r--r-- | server/controllers/api/users/token.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 4 |
8 files changed, 32 insertions, 5 deletions
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts index 108627f81..ba5b94840 100644 --- a/server/controllers/api/abuse.ts +++ b/server/controllers/api/abuse.ts | |||
@@ -24,6 +24,7 @@ import { | |||
24 | deleteAbuseMessageValidator, | 24 | deleteAbuseMessageValidator, |
25 | ensureUserHasRight, | 25 | ensureUserHasRight, |
26 | getAbuseValidator, | 26 | getAbuseValidator, |
27 | openapiOperationDoc, | ||
27 | paginationValidator, | 28 | paginationValidator, |
28 | setDefaultPagination, | 29 | setDefaultPagination, |
29 | setDefaultSort | 30 | setDefaultSort |
@@ -33,6 +34,7 @@ import { AccountModel } from '../../models/account/account' | |||
33 | const abuseRouter = express.Router() | 34 | const abuseRouter = express.Router() |
34 | 35 | ||
35 | abuseRouter.get('/', | 36 | abuseRouter.get('/', |
37 | openapiOperationDoc({ operationId: 'getAbuses' }), | ||
36 | authenticate, | 38 | authenticate, |
37 | ensureUserHasRight(UserRight.MANAGE_ABUSES), | 39 | ensureUserHasRight(UserRight.MANAGE_ABUSES), |
38 | paginationValidator, | 40 | paginationValidator, |
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 1f2a5f2da..9bd8c21c5 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -10,26 +10,32 @@ import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '.. | |||
10 | import { objectConverter } from '../../helpers/core-utils' | 10 | import { objectConverter } from '../../helpers/core-utils' |
11 | import { CONFIG, reloadConfig } from '../../initializers/config' | 11 | import { CONFIG, reloadConfig } from '../../initializers/config' |
12 | import { ClientHtml } from '../../lib/client-html' | 12 | import { ClientHtml } from '../../lib/client-html' |
13 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 13 | import { asyncMiddleware, authenticate, ensureUserHasRight, openapiOperationDoc } from '../../middlewares' |
14 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 14 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
15 | 15 | ||
16 | const configRouter = express.Router() | 16 | const configRouter = express.Router() |
17 | 17 | ||
18 | const auditLogger = auditLoggerFactory('config') | 18 | const auditLogger = auditLoggerFactory('config') |
19 | 19 | ||
20 | configRouter.get('/about', getAbout) | ||
21 | |||
22 | configRouter.get('/', | 20 | configRouter.get('/', |
21 | openapiOperationDoc({ operationId: 'getConfig' }), | ||
23 | asyncMiddleware(getConfig) | 22 | asyncMiddleware(getConfig) |
24 | ) | 23 | ) |
25 | 24 | ||
25 | configRouter.get('/about', | ||
26 | openapiOperationDoc({ operationId: 'getAbout' }), | ||
27 | getAbout | ||
28 | ) | ||
29 | |||
26 | configRouter.get('/custom', | 30 | configRouter.get('/custom', |
31 | openapiOperationDoc({ operationId: 'getCustomConfig' }), | ||
27 | authenticate, | 32 | authenticate, |
28 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), | 33 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), |
29 | getCustomConfig | 34 | getCustomConfig |
30 | ) | 35 | ) |
31 | 36 | ||
32 | configRouter.put('/custom', | 37 | configRouter.put('/custom', |
38 | openapiOperationDoc({ operationId: 'putCustomConfig' }), | ||
33 | authenticate, | 39 | authenticate, |
34 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), | 40 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), |
35 | customConfigUpdateValidator, | 41 | customConfigUpdateValidator, |
@@ -37,6 +43,7 @@ configRouter.put('/custom', | |||
37 | ) | 43 | ) |
38 | 44 | ||
39 | configRouter.delete('/custom', | 45 | configRouter.delete('/custom', |
46 | openapiOperationDoc({ operationId: 'delCustomConfig' }), | ||
40 | authenticate, | 47 | authenticate, |
41 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), | 48 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), |
42 | asyncMiddleware(deleteCustomConfig) | 49 | asyncMiddleware(deleteCustomConfig) |
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts index d7cee1605..9e333322b 100644 --- a/server/controllers/api/jobs.ts +++ b/server/controllers/api/jobs.ts | |||
@@ -9,6 +9,7 @@ import { | |||
9 | authenticate, | 9 | authenticate, |
10 | ensureUserHasRight, | 10 | ensureUserHasRight, |
11 | jobsSortValidator, | 11 | jobsSortValidator, |
12 | openapiOperationDoc, | ||
12 | paginationValidatorBuilder, | 13 | paginationValidatorBuilder, |
13 | setDefaultPagination, | 14 | setDefaultPagination, |
14 | setDefaultSort | 15 | setDefaultSort |
@@ -18,6 +19,7 @@ import { listJobsValidator } from '../../middlewares/validators/jobs' | |||
18 | const jobsRouter = express.Router() | 19 | const jobsRouter = express.Router() |
19 | 20 | ||
20 | jobsRouter.get('/:state?', | 21 | jobsRouter.get('/:state?', |
22 | openapiOperationDoc({ operationId: 'getJobs' }), | ||
21 | authenticate, | 23 | authenticate, |
22 | ensureUserHasRight(UserRight.MANAGE_JOBS), | 24 | ensureUserHasRight(UserRight.MANAGE_JOBS), |
23 | paginationValidatorBuilder([ 'jobs' ]), | 25 | paginationValidatorBuilder([ 'jobs' ]), |
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts index 48a10d31f..15bbf5c4d 100644 --- a/server/controllers/api/oauth-clients.ts +++ b/server/controllers/api/oauth-clients.ts | |||
@@ -3,12 +3,13 @@ import { OAuthClientLocal } from '../../../shared' | |||
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { CONFIG } from '../../initializers/config' | 5 | import { CONFIG } from '../../initializers/config' |
6 | import { asyncMiddleware } from '../../middlewares' | 6 | import { asyncMiddleware, openapiOperationDoc } from '../../middlewares' |
7 | import { OAuthClientModel } from '../../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../../models/oauth/oauth-client' |
8 | 8 | ||
9 | const oauthClientsRouter = express.Router() | 9 | const oauthClientsRouter = express.Router() |
10 | 10 | ||
11 | oauthClientsRouter.get('/local', | 11 | oauthClientsRouter.get('/local', |
12 | openapiOperationDoc({ operationId: 'getOAuthClient' }), | ||
12 | asyncMiddleware(getLocalClient) | 13 | asyncMiddleware(getLocalClient) |
13 | ) | 14 | ) |
14 | 15 | ||
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index b64062287..1e6a02c49 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts | |||
@@ -8,6 +8,7 @@ import { | |||
8 | authenticate, | 8 | authenticate, |
9 | availablePluginsSortValidator, | 9 | availablePluginsSortValidator, |
10 | ensureUserHasRight, | 10 | ensureUserHasRight, |
11 | openapiOperationDoc, | ||
11 | paginationValidator, | 12 | paginationValidator, |
12 | pluginsSortValidator, | 13 | pluginsSortValidator, |
13 | setDefaultPagination, | 14 | setDefaultPagination, |
@@ -35,6 +36,7 @@ import { | |||
35 | const pluginRouter = express.Router() | 36 | const pluginRouter = express.Router() |
36 | 37 | ||
37 | pluginRouter.get('/available', | 38 | pluginRouter.get('/available', |
39 | openapiOperationDoc({ operationId: 'getAvailablePlugins' }), | ||
38 | authenticate, | 40 | authenticate, |
39 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | 41 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), |
40 | listAvailablePluginsValidator, | 42 | listAvailablePluginsValidator, |
@@ -46,6 +48,7 @@ pluginRouter.get('/available', | |||
46 | ) | 48 | ) |
47 | 49 | ||
48 | pluginRouter.get('/', | 50 | pluginRouter.get('/', |
51 | openapiOperationDoc({ operationId: 'getPlugins' }), | ||
49 | authenticate, | 52 | authenticate, |
50 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | 53 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), |
51 | listPluginsValidator, | 54 | listPluginsValidator, |
@@ -84,6 +87,7 @@ pluginRouter.get('/:npmName', | |||
84 | ) | 87 | ) |
85 | 88 | ||
86 | pluginRouter.post('/install', | 89 | pluginRouter.post('/install', |
90 | openapiOperationDoc({ operationId: 'addPlugin' }), | ||
87 | authenticate, | 91 | authenticate, |
88 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | 92 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), |
89 | installOrUpdatePluginValidator, | 93 | installOrUpdatePluginValidator, |
@@ -91,6 +95,7 @@ pluginRouter.post('/install', | |||
91 | ) | 95 | ) |
92 | 96 | ||
93 | pluginRouter.post('/update', | 97 | pluginRouter.post('/update', |
98 | openapiOperationDoc({ operationId: 'updatePlugin' }), | ||
94 | authenticate, | 99 | authenticate, |
95 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | 100 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), |
96 | installOrUpdatePluginValidator, | 101 | installOrUpdatePluginValidator, |
@@ -98,6 +103,7 @@ pluginRouter.post('/update', | |||
98 | ) | 103 | ) |
99 | 104 | ||
100 | pluginRouter.post('/uninstall', | 105 | pluginRouter.post('/uninstall', |
106 | openapiOperationDoc({ operationId: 'uninstallPlugin' }), | ||
101 | authenticate, | 107 | authenticate, |
102 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | 108 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), |
103 | uninstallPluginValidator, | 109 | uninstallPluginValidator, |
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index a3b66b2a6..c975c5c3c 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts | |||
@@ -18,6 +18,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../lib/ac | |||
18 | import { | 18 | import { |
19 | asyncMiddleware, | 19 | asyncMiddleware, |
20 | commonVideosFiltersValidator, | 20 | commonVideosFiltersValidator, |
21 | openapiOperationDoc, | ||
21 | optionalAuthenticate, | 22 | optionalAuthenticate, |
22 | paginationValidator, | 23 | paginationValidator, |
23 | setDefaultPagination, | 24 | setDefaultPagination, |
@@ -34,6 +35,7 @@ import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../ | |||
34 | const searchRouter = express.Router() | 35 | const searchRouter = express.Router() |
35 | 36 | ||
36 | searchRouter.get('/videos', | 37 | searchRouter.get('/videos', |
38 | openapiOperationDoc({ operationId: 'searchVideos' }), | ||
37 | paginationValidator, | 39 | paginationValidator, |
38 | setDefaultPagination, | 40 | setDefaultPagination, |
39 | videosSearchSortValidator, | 41 | videosSearchSortValidator, |
@@ -45,6 +47,7 @@ searchRouter.get('/videos', | |||
45 | ) | 47 | ) |
46 | 48 | ||
47 | searchRouter.get('/video-channels', | 49 | searchRouter.get('/video-channels', |
50 | openapiOperationDoc({ operationId: 'searchChannels' }), | ||
48 | paginationValidator, | 51 | paginationValidator, |
49 | setDefaultPagination, | 52 | setDefaultPagination, |
50 | videoChannelsSearchSortValidator, | 53 | videoChannelsSearchSortValidator, |
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts index 863a3d74c..e636f44f6 100644 --- a/server/controllers/api/users/token.ts +++ b/server/controllers/api/users/token.ts | |||
@@ -7,7 +7,7 @@ import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPa | |||
7 | import { handleOAuthToken } from '@server/lib/auth/oauth' | 7 | import { handleOAuthToken } from '@server/lib/auth/oauth' |
8 | import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model' | 8 | import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model' |
9 | import { Hooks } from '@server/lib/plugins/hooks' | 9 | import { Hooks } from '@server/lib/plugins/hooks' |
10 | import { asyncMiddleware, authenticate } from '@server/middlewares' | 10 | import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares' |
11 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | 11 | import { ScopedToken } from '@shared/models/users/user-scoped-token' |
12 | 12 | ||
13 | const tokensRouter = express.Router() | 13 | const tokensRouter = express.Router() |
@@ -19,10 +19,12 @@ const loginRateLimiter = RateLimit({ | |||
19 | 19 | ||
20 | tokensRouter.post('/token', | 20 | tokensRouter.post('/token', |
21 | loginRateLimiter, | 21 | loginRateLimiter, |
22 | openapiOperationDoc({ operationId: 'getOAuthToken' }), | ||
22 | asyncMiddleware(handleToken) | 23 | asyncMiddleware(handleToken) |
23 | ) | 24 | ) |
24 | 25 | ||
25 | tokensRouter.post('/revoke-token', | 26 | tokensRouter.post('/revoke-token', |
27 | openapiOperationDoc({ operationId: 'revokeOAuthToken' }), | ||
26 | authenticate, | 28 | authenticate, |
27 | asyncMiddleware(handleTokenRevocation) | 29 | asyncMiddleware(handleTokenRevocation) |
28 | ) | 30 | ) |
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index ca2b85ea5..530e17965 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -9,6 +9,7 @@ import { | |||
9 | authenticate, | 9 | authenticate, |
10 | blacklistSortValidator, | 10 | blacklistSortValidator, |
11 | ensureUserHasRight, | 11 | ensureUserHasRight, |
12 | openapiOperationDoc, | ||
12 | paginationValidator, | 13 | paginationValidator, |
13 | setBlacklistSort, | 14 | setBlacklistSort, |
14 | setDefaultPagination, | 15 | setDefaultPagination, |
@@ -23,6 +24,7 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c | |||
23 | const blacklistRouter = express.Router() | 24 | const blacklistRouter = express.Router() |
24 | 25 | ||
25 | blacklistRouter.post('/:videoId/blacklist', | 26 | blacklistRouter.post('/:videoId/blacklist', |
27 | openapiOperationDoc({ operationId: 'addVideoBlock' }), | ||
26 | authenticate, | 28 | authenticate, |
27 | ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), | 29 | ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), |
28 | asyncMiddleware(videosBlacklistAddValidator), | 30 | asyncMiddleware(videosBlacklistAddValidator), |
@@ -30,6 +32,7 @@ blacklistRouter.post('/:videoId/blacklist', | |||
30 | ) | 32 | ) |
31 | 33 | ||
32 | blacklistRouter.get('/blacklist', | 34 | blacklistRouter.get('/blacklist', |
35 | openapiOperationDoc({ operationId: 'getVideoBlocks' }), | ||
33 | authenticate, | 36 | authenticate, |
34 | ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), | 37 | ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), |
35 | paginationValidator, | 38 | paginationValidator, |
@@ -48,6 +51,7 @@ blacklistRouter.put('/:videoId/blacklist', | |||
48 | ) | 51 | ) |
49 | 52 | ||
50 | blacklistRouter.delete('/:videoId/blacklist', | 53 | blacklistRouter.delete('/:videoId/blacklist', |
54 | openapiOperationDoc({ operationId: 'delVideoBlock' }), | ||
51 | authenticate, | 55 | authenticate, |
52 | ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), | 56 | ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), |
53 | asyncMiddleware(videosBlacklistRemoveValidator), | 57 | asyncMiddleware(videosBlacklistRemoveValidator), |