Set branch name on swagger version

This commit is contained in:
Gabriel Rosa
2022-11-09 14:06:12 -03:00
parent f22d9370db
commit 0422c7a369
2 changed files with 15 additions and 6 deletions
+1 -1
View File
@@ -3257,7 +3257,7 @@
"info": {
"title": "Maestro",
"description": "Documentation for Maestro gateway",
"version": "9.11.2022 - 11:27",
"version": "feat/rest-api",
"contact": {}
},
"tags": [],
+14 -5
View File
@@ -6,6 +6,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { AppModule } from './app.module';
import { writeFile, writeFileSync } from 'fs';
import { exec, ExecException, execSync } from 'child_process';
async function bootstrap() {
DadosferaLogger.setupLogger({
serviceName: 'maestro',
@@ -26,15 +27,23 @@ async function bootstrap() {
app.use(helmet());
const date = new Date();
let swaggerVersion = `${date.getDate()}.${
date.getMonth() + 1
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`;
try {
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.replace('\n', '');
swaggerVersion = branchName;
} catch (error) {
console.log("Can't get branch name", error);
}
const config = new DocumentBuilder()
.setTitle('Maestro')
.setDescription('Documentation for Maestro gateway')
.setVersion(
`${date.getDate()}.${
date.getMonth() + 1
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`,
)
.setVersion(swaggerVersion)
.addBearerAuth(
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
'Authorization',