mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-24 22:35:23 +00:00
36 lines
941 B
JavaScript
36 lines
941 B
JavaScript
const {writeFileSync, readFileSync} = require('fs');
|
|
// import {mergeSwaggerSchema} from "../../src";
|
|
|
|
const swaggerV3 = JSON.parse(readFileSync('../nocodb/src/schema/swagger-v3.json', 'utf8'), (key, value) => {
|
|
if (key === '$ref') {
|
|
return value.replace(/^(#\/components\/schemas\/)(\w+)$/, '$1$2V3');
|
|
}
|
|
return value;
|
|
});
|
|
swaggerV3.components.schemas = Object.entries(swaggerV3.components.schemas).reduce((acc, [key, value]) => {
|
|
return {
|
|
[key + 'V3']: value,
|
|
...acc
|
|
}
|
|
}, {})
|
|
|
|
const swaggerCE = JSON.parse(readFileSync('../nocodb/src/schema/swagger.json', 'utf8'));
|
|
const swagger = {
|
|
...swaggerCE,
|
|
paths: {
|
|
...swaggerCE.paths,
|
|
},
|
|
components: {
|
|
...swaggerCE.components,
|
|
schemas: {
|
|
...swaggerV3.components.schemas,
|
|
...swaggerCE.components.schemas,
|
|
},
|
|
responses: {
|
|
...swaggerCE.components.responses,
|
|
},
|
|
},
|
|
};
|
|
|
|
writeFileSync('nc_swagger.json', JSON.stringify(swagger));
|