Closed pillsilly closed 2 months ago
draft implementation
diff --git a/node_modules/ng-openapi-gen/lib/ng-openapi-gen.js b/node_modules/ng-openapi-gen/lib/ng-openapi-gen.js
index aca9882..38c6cfe 100644
--- a/node_modules/ng-openapi-gen/lib/ng-openapi-gen.js
+++ b/node_modules/ng-openapi-gen/lib/ng-openapi-gen.js
@@ -286,6 +286,24 @@ function runNgOpenApiGen() {
}
}
});
+
+ function filterPaths(paths, excludeTags, excludePaths) {
+ const filteredPaths = {};
+ for (const key in paths) {
+ const tags = paths[key].get?.tags || [];
+
+ if (excludePaths.includes(key) || tags.some(tag => excludeTags.includes(tag))) {
+ console.log(`Path ${key} is excluded`);
+ continue;
+ }
+
+ filteredPaths[key] = paths[key];
+ }
+ return filteredPaths;
+ }
+ const {excludetags = [], excludePaths = []} = options;
+ const filteredPaths = filterPaths(openApi.paths, excludetags, excludePaths);
+ openApi.paths = filteredPaths;
const gen = new NgOpenApiGen(openApi, options);
gen.generate();
}
Can you send a PR for this with a test?
I will try to prepare a pr
Hi My working project is across multiple teams and the work-flow above REST defs can be quite heavy.
Each domain might use different technology, different gen-tools for tolerancing same input yaml can be different.
e.g some of the definitions(though the swagger standard are well followed) works for team A(who use technology X) , but it might not work for team B(who use technology Y)
team B might get affected(as all defs are in the same files) by this even though team B doesn't care about definitions serves for Team A.
ng-openapi-gen
does provide some feature that to exclude certain API that client doesn't care,but it requires
ng-openapi-gen
still tries to read/parse the whole yaml,json when processing it, and if some part of the content are not understandable byng-openapi-gen
the execution goes failed.so my rough ideas are about 1.give
ng-openapi-gen
capability(e.g in the config file) that to exclude contents without having have to actually write tags in REST yml, every client can then freely select things to generate/not-generate with more agile way. 2.perform the exclusion logic's earlier during the process so that the no.2 problem can be avoided.@luisfpg