diff --git a/backend/src/monitoring/server-status.dto.ts b/backend/src/monitoring/server-status.dto.ts index 541fe7bc7..a4fd7a3a0 100644 --- a/backend/src/monitoring/server-status.dto.ts +++ b/backend/src/monitoring/server-status.dto.ts @@ -18,6 +18,8 @@ export class ServerVersion { preRelease?: string; @ApiProperty() commit?: string; + @ApiProperty() + fullString: string; } export class ServerStatusDto extends BaseDto { diff --git a/backend/src/utils/serverVersion.ts b/backend/src/utils/serverVersion.ts index a5b39fd9b..f73779965 100644 --- a/backend/src/utils/serverVersion.ts +++ b/backend/src/utils/serverVersion.ts @@ -22,11 +22,15 @@ export async function getServerVersionFromPackageJson(): Promise 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 : '' + }`, }; } diff --git a/backend/src/utils/swagger.ts b/backend/src/utils/swagger.ts index 2398d13ba..16675183c 100644 --- a/backend/src/utils/swagger.ts +++ b/backend/src/utils/swagger.ts @@ -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 { + 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 { + 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, {