openapi-graph-core
Version:
A TS library to manage large API projects defined by OpenAPIv3 specification.
26 lines (25 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Analyzer = void 0;
const Analyzer = class AnalyzerImpl {
constructor(graphs) {
this.graphs = graphs.builder.graphs;
}
getUnusedSchemas() {
const unusedSchemas = {};
Object.keys(this.graphs).forEach((path) => {
const schemas = this.graphs[path].nodes.schemas;
unusedSchemas[path] = Object.values(schemas).filter((schema) => !schema.isInline && Object.values(schema.referencedBy).length === 0);
});
return unusedSchemas;
}
getDeprecatedSchemasBeingUsed() {
const deprecatedSchemasBeingUsed = {};
Object.keys(this.graphs).forEach((path) => {
const schemas = this.graphs[path].nodes.schemas;
deprecatedSchemasBeingUsed[path] = Object.values(schemas).filter((schema) => schema.content.type !== 'array' && schema.content.deprecated);
});
return deprecatedSchemasBeingUsed;
}
};
exports.Analyzer = Analyzer;