Created
December 11, 2025 15:04
-
-
Save cdbkr/9198f609fc11e2e5021248c2b232cd0e to your computer and use it in GitHub Desktop.
groupEndpoints function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const groupEndpoints = (spec) => { | |
| const groups = new Map(); | |
| Object.entries(spec.paths || {}).forEach(([path, methods]) => { | |
| const resource = path.split('/').filter(Boolean)[0] || 'root'; | |
| if (!groups.has(resource)) { | |
| groups.set(resource, []); | |
| } | |
| Object.entries(methods) | |
| .filter(([_, op]) => op && typeof op === 'object') | |
| .forEach(([method, operation]) => { | |
| groups.get(resource).push(extractEndpoint(path, method, operation)); | |
| }); | |
| }); | |
| return groups; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment