78 lines
1.6 KiB
JavaScript
78 lines
1.6 KiB
JavaScript
import path from "path";
|
|
import fs from "fs";
|
|
import upload from "./upload.js";
|
|
import user from "./user.js";
|
|
import profile from "./profile.js";
|
|
import admin from "./admin.js";
|
|
import location from "./location.js";
|
|
import assignment from "./assignment.js";
|
|
import partner from "./partner.js";
|
|
import venue from "./venue.js";
|
|
import product from "./product.js";
|
|
import vendor from "./vendor.js";
|
|
|
|
const GENERAL_CONFIG = {
|
|
openapi: "3.0.1",
|
|
info: {
|
|
title: "Attica Server Application v1",
|
|
description: "Version 1 of Attica Server Application API",
|
|
license: {
|
|
name: "MIT",
|
|
url: "https://opensource.org/licenses/MIT",
|
|
},
|
|
version: "1.0.0",
|
|
},
|
|
servers: [
|
|
{
|
|
url: "http://localhost:3000/v0",
|
|
},
|
|
{
|
|
url: "https://erp-server.triadkube.com/v0",
|
|
},
|
|
],
|
|
security: [
|
|
{
|
|
bearerAuth: [],
|
|
},
|
|
],
|
|
components: {
|
|
securitySchemes: {
|
|
bearerAuth: {
|
|
type: "http",
|
|
scheme: "bearer",
|
|
bearerFormat: "JWT",
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
let paths = {
|
|
...user,
|
|
...profile,
|
|
...location,
|
|
...upload,
|
|
...admin,
|
|
...assignment,
|
|
...partner,
|
|
...venue,
|
|
...product,
|
|
...vendor,
|
|
};
|
|
|
|
const getSwaggerDocument = () => {
|
|
const swaggerDocument = {
|
|
...GENERAL_CONFIG,
|
|
paths,
|
|
};
|
|
const fileContent = JSON.stringify(swaggerDocument, null, 2);
|
|
const docPath = path.resolve(path.join(__dirname, "documentation.json"));
|
|
const existingContent = fs.readFileSync(docPath, "utf8");
|
|
|
|
if (existingContent !== fileContent) {
|
|
console.log("Swagger documentation updated");
|
|
fs.writeFileSync(docPath, fileContent);
|
|
}
|
|
};
|
|
|
|
export default getSwaggerDocument;
|