@onlineapps/conn-orch-api-mapper 1.0.4 → 1.0.5
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.
- package/package.json +1 -1
- package/src/ApiMapper.js +17 -3
package/package.json
CHANGED
package/src/ApiMapper.js
CHANGED
|
@@ -348,10 +348,24 @@ class ApiMapper {
|
|
|
348
348
|
}
|
|
349
349
|
});
|
|
350
350
|
|
|
351
|
-
//
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
// For operations.json format: input is sent as request body for POST/PUT/PATCH
|
|
352
|
+
// For OpenAPI format: use requestBody if present, otherwise send input as body
|
|
353
|
+
if (['POST', 'PUT', 'PATCH'].includes(operation.method)) {
|
|
354
|
+
if (operation.requestBody) {
|
|
355
|
+
// OpenAPI format: use requestBody structure
|
|
356
|
+
request.data = input.body || input;
|
|
357
|
+
} else {
|
|
358
|
+
// operations.json format or no requestBody: send input directly as body
|
|
359
|
+
request.data = input;
|
|
360
|
+
}
|
|
354
361
|
request.headers['Content-Type'] = 'application/json';
|
|
362
|
+
} else if (operation.method === 'GET' || operation.method === 'DELETE') {
|
|
363
|
+
// For GET/DELETE, add input to query params
|
|
364
|
+
Object.entries(input).forEach(([key, value]) => {
|
|
365
|
+
if (value !== undefined && value !== null) {
|
|
366
|
+
request.params[key] = value;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
355
369
|
}
|
|
356
370
|
|
|
357
371
|
return request;
|