ondc-code-generator 0.7.6 → 0.7.8

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.
@@ -49,11 +49,11 @@ export class GoGenerator extends CodeGenerator {
49
49
  validationCode: await this.createValidationLogicCode(testObject),
50
50
  successCode: testObject[TestObjectSyntax.SuccessCode] ?? 200,
51
51
  errorCode: testObject[TestObjectSyntax.ErrorCode] ?? 30000,
52
- testName: testObject[TestObjectSyntax.Name],
52
+ testName: stringToCaps(testObject[TestObjectSyntax.Name]),
53
53
  TEST_OBJECT: `${JSON.stringify(testObject)}`,
54
54
  };
55
55
  return {
56
- funcName: testObject[TestObjectSyntax.Name],
56
+ funcName: stringToCaps(testObject[TestObjectSyntax.Name]),
57
57
  code: Mustache.render(template, view),
58
58
  };
59
59
  };
@@ -3,6 +3,9 @@
3
3
  package validationutils
4
4
 
5
5
  import (
6
+ "fmt"
7
+ "strings"
8
+
6
9
  "github.com/AsaiYusuke/jsonpath"
7
10
  )
8
11
 
@@ -26,8 +29,10 @@ func isListOfStringsOrNull(variable interface{}) bool {
26
29
 
27
30
  // GetJsonPath queries a payload using JSONPath and returns the results
28
31
  func GetJsonPath(payload interface{}, path string, flattenResult bool) []interface{} {
29
- output, err := jsonpath.Retrieve(path, payload)
32
+ resolvedPath, resolvedData, err := resolveJSONPathData(path, payload)
33
+ output, err := jsonpath.Retrieve(resolvedPath, resolvedData)
30
34
  if err != nil {
35
+ fmt.Printf("Error retrieving JSONPath %s: %v\n", path, err)
31
36
  return []interface{}{}
32
37
  }
33
38
 
@@ -61,3 +66,18 @@ func flattenSlice(slice []interface{}) []interface{} {
61
66
  }
62
67
  return result
63
68
  }
69
+
70
+
71
+
72
+ func resolveJSONPathData(path string, data interface{}) (string, interface{}, error) {
73
+ if input, ok := data.(ValidationInput); ok {
74
+ if strings.HasPrefix(path, "$._EXTERNAL._SELF") {
75
+ resolvedPath := strings.Replace(path, "$._EXTERNAL._SELF", "$", 1)
76
+ return resolvedPath, input.ExternalData.Self, nil
77
+ }else if( strings.HasPrefix(path, "$._EXTERNAL")){
78
+ resolvedPath := strings.Replace(path, "$._EXTERNAL", "$", 1)
79
+ return resolvedPath, input.ExternalData, nil
80
+ }
81
+ }
82
+ return path, data, nil
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ondc-code-generator",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "generate code from build.yaml ",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",