@aimeloic/monkey-tester 4.0.2 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/monkey.js +19 -15
  2. package/package.json +1 -1
package/monkey.js CHANGED
@@ -101,21 +101,25 @@ function parseStack(stack, detectedEndpoints, prefix = '') {
101
101
  }
102
102
 
103
103
  let bodyFields = [];
104
- if (['POST', 'PUT', 'PATCH'].includes(httpMethod)) {
105
- const handlers = (layer.route.stack || []).map(sl => sl.handle).filter(Boolean);
106
- for (const handler of handlers) {
107
- bodyFields.push(...extractBodyFields(handler));
108
- }
109
- const seen = new Map();
110
- bodyFields = bodyFields.filter(f => {
111
- if (seen.has(f.name)) return false;
112
- seen.set(f.name, true);
113
- return true;
114
- });
115
- if (bodyFields.length === 0) {
116
- bodyFields = fallbackFields(fullPath);
117
- }
118
- }
104
+ // Inside your parseStack function in monkey.js, update this block:
105
+ if (['POST', 'PUT', 'PATCH'].includes(httpMethod)) {
106
+ const handlers = (layer.route.stack || []).map(sl => sl.handle).filter(Boolean);
107
+ for (const handler of handlers) {
108
+ bodyFields.push(...extractBodyFields(handler));
109
+ }
110
+
111
+ const seen = new Map();
112
+ bodyFields = bodyFields.filter(f => {
113
+ if (seen.has(f.name)) return false;
114
+ seen.set(f.name, true);
115
+ return true;
116
+ });
117
+
118
+ // CHANGE THIS: Only apply generic fallbacks if there are no explicit path parameters
119
+ if (bodyFields.length === 0 && pathParams.length === 0) {
120
+ bodyFields = fallbackFields(fullPath);
121
+ }
122
+ }
119
123
 
120
124
  detectedEndpoints[key] = {
121
125
  method: httpMethod,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aimeloic/monkey-tester",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Auto route scanning visual runner dashboard.",
5
5
  "main": "index.js",
6
6
  "type": "module",