diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-04 08:57:07 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-04 09:21:46 +0200 |
commit | 1c627fd8d2e60d4d790353886006485343d70084 (patch) | |
tree | 384fcd80a018eab2ace2a340d028b23359c07dc7 /server/middlewares | |
parent | b96d21b744f3b0714636bd43e7f39fb33c3adb73 (diff) | |
download | PeerTube-1c627fd8d2e60d4d790353886006485343d70084.tar.gz PeerTube-1c627fd8d2e60d4d790353886006485343d70084.tar.zst PeerTube-1c627fd8d2e60d4d790353886006485343d70084.zip |
refactor docMiddleware to support operationId-only form
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/doc.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/server/middlewares/doc.ts b/server/middlewares/doc.ts index aa852cd77..3db85c68d 100644 --- a/server/middlewares/doc.ts +++ b/server/middlewares/doc.ts | |||
@@ -1,13 +1,16 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | 2 | ||
3 | function docMiddleware (docUrl: string) { | 3 | function openapiOperationDoc (options: { |
4 | url?: string | ||
5 | operationId?: string | ||
6 | }) { | ||
4 | return (req: express.Request, res: express.Response, next: express.NextFunction) => { | 7 | return (req: express.Request, res: express.Response, next: express.NextFunction) => { |
5 | res.locals.docUrl = docUrl | 8 | res.locals.docUrl = options.url || 'https://docs.joinpeertube.org/api-rest-reference.html#operation/' + options.operationId |
6 | 9 | ||
7 | if (next) return next() | 10 | if (next) return next() |
8 | } | 11 | } |
9 | } | 12 | } |
10 | 13 | ||
11 | export { | 14 | export { |
12 | docMiddleware | 15 | openapiOperationDoc |
13 | } | 16 | } |