Browse Source

fix: remove openapi-to-postmanv2 dependency

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1840/head
Pranav C 3 years ago
parent
commit
c0c47678ec
  1. 1022
      packages/nocodb/package-lock.json
  2. 1
      packages/nocodb/package.json
  3. 40
      packages/nocodb/src/lib/noco/meta/api/swagger/swaggerApis.ts

1022
packages/nocodb/package-lock.json generated

File diff suppressed because it is too large Load Diff

1
packages/nocodb/package.json

@ -156,7 +156,6 @@
"ncp": "^2.0.0", "ncp": "^2.0.0",
"nocodb-sdk": "file:../nocodb-sdk", "nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10", "nodemailer": "^6.4.10",
"openapi-to-postmanv2": "^3.1.0",
"ora": "^4.0.4", "ora": "^4.0.4",
"os-locale": "^5.0.0", "os-locale": "^5.0.0",
"papaparse": "^5.3.1", "papaparse": "^5.3.1",

40
packages/nocodb/src/lib/noco/meta/api/swagger/swaggerApis.ts

@ -1,12 +1,11 @@
// @ts-ignore // @ts-ignore
import catchError from '../../helpers/catchError'; import catchError from '../../helpers/catchError';
import { Request, Router } from 'express'; import { Router } from 'express';
import Model from '../../../../noco-models/Model'; import Model from '../../../../noco-models/Model';
import getSwaggerJSON from './helpers/getSwaggerJSON'; import getSwaggerJSON from './helpers/getSwaggerJSON';
import Project from '../../../../noco-models/Project'; import Project from '../../../../noco-models/Project';
import swaggerHtml from './swaggerHtml'; import swaggerHtml from './swaggerHtml';
import redocHtml from './redocHtml'; import redocHtml from './redocHtml';
const Converter = require('openapi-to-postmanv2');
async function swaggerJson(req, res) { async function swaggerJson(req, res) {
const project = await Project.get(req.params.projectId); const project = await Project.get(req.params.projectId);
@ -19,39 +18,6 @@ async function swaggerJson(req, res) {
res.json(swagger); res.json(swagger);
} }
async function postmanJson(req: Request, res) {
const project = await Project.get(req.params.projectId);
const models = await Model.list({
project_id: req.params.project_id,
base_id: null
});
const swagger = await getSwaggerJSON(project, models);
swagger.servers = [
{
url: (req as any).ncSiteUrl
}
];
Converter.convert(
{ type: 'json', data: swagger },
{},
(err, conversionResult) => {
if (err) {
res.status(400).json({ msg: err });
}
if (!conversionResult.result) {
res
.status(400)
.json({ msg: 'Could not convert : ' + conversionResult.reason });
} else {
res.json(conversionResult.output[0].data);
}
}
);
}
const router = Router({ mergeParams: true }); const router = Router({ mergeParams: true });
// todo: auth // todo: auth
@ -59,10 +25,6 @@ router.get(
'/api/v1/db/meta/projects/:projectId/swagger.json', '/api/v1/db/meta/projects/:projectId/swagger.json',
catchError(swaggerJson) catchError(swaggerJson)
); );
router.get(
'/api/v1/db/meta/projects/:projectId/postman.json',
catchError(postmanJson)
);
router.get('/api/v1/db/meta/projects/:projectId/swagger', (_req, res) => router.get('/api/v1/db/meta/projects/:projectId/swagger', (_req, res) =>
res.send(swaggerHtml) res.send(swaggerHtml)
); );

Loading…
Cancel
Save