mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-22 12:01:32 +00:00
feat(apidocs): use real version number
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
8ee2d809c7
commit
d52fc55ef3
3 changed files with 16 additions and 7 deletions
|
@ -18,6 +18,8 @@ export class ServerVersion {
|
|||
preRelease?: string;
|
||||
@ApiProperty()
|
||||
commit?: string;
|
||||
@ApiProperty()
|
||||
fullString: string;
|
||||
}
|
||||
|
||||
export class ServerStatusDto extends BaseDto {
|
||||
|
|
|
@ -22,11 +22,15 @@ export async function getServerVersionFromPackageJson(): Promise<ServerVersion>
|
|||
const versionParts: number[] = packageInfo.version
|
||||
.split('.')
|
||||
.map((x) => parseInt(x, 10));
|
||||
const preRelease = 'dev'; // TODO: Replace this?
|
||||
versionCache = {
|
||||
major: versionParts[0],
|
||||
minor: versionParts[1],
|
||||
patch: versionParts[2],
|
||||
preRelease: 'dev', // TODO: Replace this?
|
||||
preRelease: preRelease,
|
||||
fullString: `${versionParts[0]}.${versionParts[1]}.${versionParts[2]}${
|
||||
preRelease ? '-' + preRelease : ''
|
||||
}`,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,13 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|||
|
||||
import { PrivateApiModule } from '../api/private/private-api.module';
|
||||
import { PublicApiModule } from '../api/public/public-api.module';
|
||||
import { getServerVersionFromPackageJson } from './serverVersion';
|
||||
|
||||
export function setupPublicApiDocs(app: INestApplication): void {
|
||||
export async function setupPublicApiDocs(app: INestApplication): Promise<void> {
|
||||
const version = await getServerVersionFromPackageJson();
|
||||
const publicApiOptions = new DocumentBuilder()
|
||||
.setTitle('HedgeDoc Public API')
|
||||
// TODO: Use real version
|
||||
.setVersion('2.0-dev')
|
||||
.setVersion(version.fullString)
|
||||
.addSecurity('token', {
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
|
@ -25,11 +26,13 @@ export function setupPublicApiDocs(app: INestApplication): void {
|
|||
SwaggerModule.setup('apidoc', app, publicApi);
|
||||
}
|
||||
|
||||
export function setupPrivateApiDocs(app: INestApplication): void {
|
||||
export async function setupPrivateApiDocs(
|
||||
app: INestApplication,
|
||||
): Promise<void> {
|
||||
const version = await getServerVersionFromPackageJson();
|
||||
const privateApiOptions = new DocumentBuilder()
|
||||
.setTitle('HedgeDoc Private API')
|
||||
// TODO: Use real version
|
||||
.setVersion('2.0-dev')
|
||||
.setVersion(version.fullString)
|
||||
.build();
|
||||
|
||||
const privateApi = SwaggerModule.createDocument(app, privateApiOptions, {
|
||||
|
|
Loading…
Reference in a new issue