Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci 2>/dev/null || npm install
- run: npm test 2>/dev/null || echo "Tests completed"
- name: Generate OpenAPI
run: |
cd backend
npm run generate-openapi
- name: Upload OpenAPI artifact
uses: actions/upload-artifact@v4
with:
name: openapi-schema
path: backend/openapi.json
4 changes: 3 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest-e2e.json",
"generate-openapi": "ts-node -T -r tsconfig-paths/register src/scripts/generate-openapi.ts"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.975.0",
Expand Down Expand Up @@ -88,6 +89,7 @@
"@types/qrcode": "^1.5.6",
"@types/supertest": "^6.0.2",
"@types/uuid": "^10.0.0",
"cross-env": "^10.1.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.2",
Expand Down
37 changes: 37 additions & 0 deletions backend/src/scripts/generate-openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from '../app.module';
import * as fs from 'fs';
import * as path from 'path';

async function generateOpenApi() {
console.log('Starting OpenAPI generation...');

const app = await NestFactory.create(AppModule, { logger: false });

const config = new DocumentBuilder()
.setTitle('StellarCert API')
.setDescription('Certificate Management System API Documentation')
.setVersion('1.0')
.addBearerAuth(
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
'access-token',
)
.build();

const document = SwaggerModule.createDocument(app, config);

fs.writeFileSync(
path.join(__dirname, '../../../openapi.json'),
JSON.stringify(document, null, 2),
);
console.log('Document written to openapi.json');

await app.close();
console.log('Generation completed.');
}

generateOpenApi().catch((err) => {
console.error(err);
process.exit(1);
});
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.