@onlineapps/conn-orch-api-mapper 1.0.3 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ApiMapper.js +17 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-orch-api-mapper",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "API mapping connector for OA Drive - maps cookbook operations to HTTP endpoints",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/ApiMapper.js CHANGED
@@ -348,10 +348,24 @@ class ApiMapper {
348
348
  }
349
349
  });
350
350
 
351
- // Add request body if present
352
- if (operation.requestBody && input.body) {
353
- request.data = input.body;
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;