@stackql/provider-utils 0.2.2 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackql/provider-utils",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Utilities for building StackQL providers from OpenAPI specifications.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -35,7 +35,7 @@
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
37
  "@apidevtools/swagger-parser": "^10.1.1",
38
- "@stackql/deno-openapi-dereferencer": "npm:@jsr/stackql__deno-openapi-dereferencer@^0.3.0",
38
+ "@stackql/deno-openapi-dereferencer": "npm:@jsr/stackql__deno-openapi-dereferencer@^0.3.1",
39
39
  "js-yaml": "^4.1.0",
40
40
  "pluralize": "^8.0.0"
41
41
  },
@@ -397,6 +397,28 @@ function getHttpOperationInfo(dereferencedAPI, path, httpVerb, mediaType, openAP
397
397
  };
398
398
  }
399
399
 
400
+ // function getHttpRespBody(schema, objectKey) {
401
+
402
+ // if (schema.type === 'array') {
403
+ // return {
404
+ // respProps: schema.items.properties || {},
405
+ // respDescription: schema.items.description || '',
406
+ // }
407
+ // } else if (schema.type === 'object') {
408
+ // return {
409
+ // respProps: schema.properties || {},
410
+ // respDescription: schema.description || '',
411
+ // };
412
+ // } else {
413
+ // return {
414
+ // respProps: {},
415
+ // respDescription: '',
416
+ // };
417
+ // }
418
+
419
+
420
+ // }
421
+
400
422
  function getHttpRespBody(schema, objectKey) {
401
423
 
402
424
  if (schema.type === 'array') {
@@ -405,18 +427,48 @@ function getHttpRespBody(schema, objectKey) {
405
427
  respDescription: schema.items.description || '',
406
428
  }
407
429
  } else if (schema.type === 'object') {
408
- return {
409
- respProps: schema.properties || {},
410
- respDescription: schema.description || '',
411
- };
430
+ if(objectKey){
431
+ // if objectKey contains [*] print something
432
+ if (objectKey.includes('[*]')) {
433
+ // complex object key
434
+ console.log(`Complex Object Key : ${objectKey}`);
435
+ const parts = objectKey.split('[*]');
436
+ const complexObjectKey = parts[1].replace('.', '');
437
+ console.log(`Item of Interest : ${complexObjectKey}`);
438
+ const respProps = schema.properties.items.additionalProperties.properties[complexObjectKey].items.properties;
439
+ console.info(respProps);
440
+ const respDescription = schema.properties.items.additionalProperties.properties[complexObjectKey].items.description || schema.properties.items.description || '';
441
+ console.log(respDescription);
442
+ return {
443
+ respProps: respProps || {},
444
+ respDescription: respDescription,
445
+ };
446
+
447
+ } else {
448
+ // simple object key
449
+ console.log(`Simple Object Key : ${objectKey}`);
450
+ const simpleObjectKey = objectKey.replace('$.', '');
451
+ const respProps = schema.properties[simpleObjectKey].items.properties;
452
+ console.info(respProps);
453
+ const respDescription = schema.properties[simpleObjectKey].items.description || schema.description || '';
454
+ console.log(respDescription);
455
+ return {
456
+ respProps: respProps || {},
457
+ respDescription: respDescription,
458
+ };
459
+ }
460
+ } else {
461
+ return {
462
+ respProps: schema.properties || {},
463
+ respDescription: schema.description || '',
464
+ };
465
+ }
412
466
  } else {
413
467
  return {
414
468
  respProps: {},
415
469
  respDescription: '',
416
470
  };
417
471
  }
418
-
419
-
420
472
  }
421
473
 
422
474
  function getHttpOperationParams(dereferencedAPI, path, httpVerb) {