Skip to content

Commit 6277a72

Browse files
committed
authorization based on access policy for custom endpoints
1 parent 350e9f1 commit 6277a72

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/index.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,24 @@ export default {
8080
swagger.info.description = config.info.description || pkg?.description || swagger.info.description;
8181

8282
// inject custom-endpoints
83-
try {
84-
for (const path in config.paths) {
85-
swagger.paths[path] = config.paths[path];
83+
if (accountability.admin || accountability.user) {
84+
try {
85+
for (const path in config.paths) {
86+
swagger.paths[path] = config.paths[path];
87+
}
88+
89+
for (const tag of config.tags) {
90+
swagger.tags.push(tag);
91+
}
92+
93+
swagger.components = merge(config.components, swagger.components);
94+
} catch (e) {
95+
logger.info('No custom definitions');
8696
}
8797

88-
for (const tag of config.tags) {
89-
swagger.tags.push(tag);
90-
}
91-
92-
swagger.components = merge(config.components, swagger.components);
93-
} catch (e) {
94-
logger.info('No custom definitions');
98+
if (config.publishedTags?.length) filterPaths(config, swagger);
9599
}
96100

97-
if (config.publishedTags?.length) filterPaths(config, swagger);
98-
99101
res.json(swagger);
100102
} catch (error: any) {
101103
return next(new Error(error.message || error[0].message));

0 commit comments

Comments
 (0)