add operationId doc middleware to so API endpoints
This commit is contained in:
parent
1c627fd8d2
commit
1333ab1f2d
|
@ -24,6 +24,7 @@ import {
|
|||
deleteAbuseMessageValidator,
|
||||
ensureUserHasRight,
|
||||
getAbuseValidator,
|
||||
openapiOperationDoc,
|
||||
paginationValidator,
|
||||
setDefaultPagination,
|
||||
setDefaultSort
|
||||
|
@ -33,6 +34,7 @@ import { AccountModel } from '../../models/account/account'
|
|||
const abuseRouter = express.Router()
|
||||
|
||||
abuseRouter.get('/',
|
||||
openapiOperationDoc({ operationId: 'getAbuses' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_ABUSES),
|
||||
paginationValidator,
|
||||
|
|
|
@ -10,26 +10,32 @@ import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '..
|
|||
import { objectConverter } from '../../helpers/core-utils'
|
||||
import { CONFIG, reloadConfig } from '../../initializers/config'
|
||||
import { ClientHtml } from '../../lib/client-html'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight, openapiOperationDoc } from '../../middlewares'
|
||||
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
|
||||
|
||||
const configRouter = express.Router()
|
||||
|
||||
const auditLogger = auditLoggerFactory('config')
|
||||
|
||||
configRouter.get('/about', getAbout)
|
||||
|
||||
configRouter.get('/',
|
||||
openapiOperationDoc({ operationId: 'getConfig' }),
|
||||
asyncMiddleware(getConfig)
|
||||
)
|
||||
|
||||
configRouter.get('/about',
|
||||
openapiOperationDoc({ operationId: 'getAbout' }),
|
||||
getAbout
|
||||
)
|
||||
|
||||
configRouter.get('/custom',
|
||||
openapiOperationDoc({ operationId: 'getCustomConfig' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
|
||||
getCustomConfig
|
||||
)
|
||||
|
||||
configRouter.put('/custom',
|
||||
openapiOperationDoc({ operationId: 'putCustomConfig' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
|
||||
customConfigUpdateValidator,
|
||||
|
@ -37,6 +43,7 @@ configRouter.put('/custom',
|
|||
)
|
||||
|
||||
configRouter.delete('/custom',
|
||||
openapiOperationDoc({ operationId: 'delCustomConfig' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
|
||||
asyncMiddleware(deleteCustomConfig)
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
authenticate,
|
||||
ensureUserHasRight,
|
||||
jobsSortValidator,
|
||||
openapiOperationDoc,
|
||||
paginationValidatorBuilder,
|
||||
setDefaultPagination,
|
||||
setDefaultSort
|
||||
|
@ -18,6 +19,7 @@ import { listJobsValidator } from '../../middlewares/validators/jobs'
|
|||
const jobsRouter = express.Router()
|
||||
|
||||
jobsRouter.get('/:state?',
|
||||
openapiOperationDoc({ operationId: 'getJobs' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_JOBS),
|
||||
paginationValidatorBuilder([ 'jobs' ]),
|
||||
|
|
|
@ -3,12 +3,13 @@ import { OAuthClientLocal } from '../../../shared'
|
|||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
import { asyncMiddleware } from '../../middlewares'
|
||||
import { asyncMiddleware, openapiOperationDoc } from '../../middlewares'
|
||||
import { OAuthClientModel } from '../../models/oauth/oauth-client'
|
||||
|
||||
const oauthClientsRouter = express.Router()
|
||||
|
||||
oauthClientsRouter.get('/local',
|
||||
openapiOperationDoc({ operationId: 'getOAuthClient' }),
|
||||
asyncMiddleware(getLocalClient)
|
||||
)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
authenticate,
|
||||
availablePluginsSortValidator,
|
||||
ensureUserHasRight,
|
||||
openapiOperationDoc,
|
||||
paginationValidator,
|
||||
pluginsSortValidator,
|
||||
setDefaultPagination,
|
||||
|
@ -35,6 +36,7 @@ import {
|
|||
const pluginRouter = express.Router()
|
||||
|
||||
pluginRouter.get('/available',
|
||||
openapiOperationDoc({ operationId: 'getAvailablePlugins' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
listAvailablePluginsValidator,
|
||||
|
@ -46,6 +48,7 @@ pluginRouter.get('/available',
|
|||
)
|
||||
|
||||
pluginRouter.get('/',
|
||||
openapiOperationDoc({ operationId: 'getPlugins' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
listPluginsValidator,
|
||||
|
@ -84,6 +87,7 @@ pluginRouter.get('/:npmName',
|
|||
)
|
||||
|
||||
pluginRouter.post('/install',
|
||||
openapiOperationDoc({ operationId: 'addPlugin' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
installOrUpdatePluginValidator,
|
||||
|
@ -91,6 +95,7 @@ pluginRouter.post('/install',
|
|||
)
|
||||
|
||||
pluginRouter.post('/update',
|
||||
openapiOperationDoc({ operationId: 'updatePlugin' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
installOrUpdatePluginValidator,
|
||||
|
@ -98,6 +103,7 @@ pluginRouter.post('/update',
|
|||
)
|
||||
|
||||
pluginRouter.post('/uninstall',
|
||||
openapiOperationDoc({ operationId: 'uninstallPlugin' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
uninstallPluginValidator,
|
||||
|
|
|
@ -18,6 +18,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../lib/ac
|
|||
import {
|
||||
asyncMiddleware,
|
||||
commonVideosFiltersValidator,
|
||||
openapiOperationDoc,
|
||||
optionalAuthenticate,
|
||||
paginationValidator,
|
||||
setDefaultPagination,
|
||||
|
@ -34,6 +35,7 @@ import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../
|
|||
const searchRouter = express.Router()
|
||||
|
||||
searchRouter.get('/videos',
|
||||
openapiOperationDoc({ operationId: 'searchVideos' }),
|
||||
paginationValidator,
|
||||
setDefaultPagination,
|
||||
videosSearchSortValidator,
|
||||
|
@ -45,6 +47,7 @@ searchRouter.get('/videos',
|
|||
)
|
||||
|
||||
searchRouter.get('/video-channels',
|
||||
openapiOperationDoc({ operationId: 'searchChannels' }),
|
||||
paginationValidator,
|
||||
setDefaultPagination,
|
||||
videoChannelsSearchSortValidator,
|
||||
|
|
|
@ -7,7 +7,7 @@ import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPa
|
|||
import { handleOAuthToken } from '@server/lib/auth/oauth'
|
||||
import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { asyncMiddleware, authenticate } from '@server/middlewares'
|
||||
import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares'
|
||||
import { ScopedToken } from '@shared/models/users/user-scoped-token'
|
||||
|
||||
const tokensRouter = express.Router()
|
||||
|
@ -19,10 +19,12 @@ const loginRateLimiter = RateLimit({
|
|||
|
||||
tokensRouter.post('/token',
|
||||
loginRateLimiter,
|
||||
openapiOperationDoc({ operationId: 'getOAuthToken' }),
|
||||
asyncMiddleware(handleToken)
|
||||
)
|
||||
|
||||
tokensRouter.post('/revoke-token',
|
||||
openapiOperationDoc({ operationId: 'revokeOAuthToken' }),
|
||||
authenticate,
|
||||
asyncMiddleware(handleTokenRevocation)
|
||||
)
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
authenticate,
|
||||
blacklistSortValidator,
|
||||
ensureUserHasRight,
|
||||
openapiOperationDoc,
|
||||
paginationValidator,
|
||||
setBlacklistSort,
|
||||
setDefaultPagination,
|
||||
|
@ -23,6 +24,7 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c
|
|||
const blacklistRouter = express.Router()
|
||||
|
||||
blacklistRouter.post('/:videoId/blacklist',
|
||||
openapiOperationDoc({ operationId: 'addVideoBlock' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
|
||||
asyncMiddleware(videosBlacklistAddValidator),
|
||||
|
@ -30,6 +32,7 @@ blacklistRouter.post('/:videoId/blacklist',
|
|||
)
|
||||
|
||||
blacklistRouter.get('/blacklist',
|
||||
openapiOperationDoc({ operationId: 'getVideoBlocks' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
|
||||
paginationValidator,
|
||||
|
@ -48,6 +51,7 @@ blacklistRouter.put('/:videoId/blacklist',
|
|||
)
|
||||
|
||||
blacklistRouter.delete('/:videoId/blacklist',
|
||||
openapiOperationDoc({ operationId: 'delVideoBlock' }),
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
|
||||
asyncMiddleware(videosBlacklistRemoveValidator),
|
||||
|
|
Loading…
Reference in New Issue