mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
Swagger: Split public and private API
Fixes #759 Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
932cb636ff
commit
3ba64f15f1
2 changed files with 45 additions and 12 deletions
39
src/utils/swagger.ts
Normal file
39
src/utils/swagger.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { PrivateApiModule } from '../api/private/private-api.module';
|
||||
import { PublicApiModule } from '../api/public/public-api.module';
|
||||
|
||||
export function setupPublicApiDocs(app: INestApplication) {
|
||||
const publicApiOptions = new DocumentBuilder()
|
||||
.setTitle('HedgeDoc Public API')
|
||||
// TODO: Use real version
|
||||
.setVersion('2.0-dev')
|
||||
.addSecurity('token', {
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
})
|
||||
.build();
|
||||
const publicApi = SwaggerModule.createDocument(app, publicApiOptions, {
|
||||
include: [PublicApiModule],
|
||||
});
|
||||
SwaggerModule.setup('apidoc', app, publicApi);
|
||||
}
|
||||
|
||||
export function setupPrivateApiDocs(app: INestApplication) {
|
||||
const privateApiOptions = new DocumentBuilder()
|
||||
.setTitle('HedgeDoc Private API')
|
||||
// TODO: Use real version
|
||||
.setVersion('2.0-dev')
|
||||
.build();
|
||||
|
||||
const privateApi = SwaggerModule.createDocument(app, privateApiOptions, {
|
||||
include: [PrivateApiModule],
|
||||
});
|
||||
SwaggerModule.setup('private/apidoc', app, privateApi);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue