ondc-code-generator 0.8.0 → 0.8.1
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.
|
@@ -119,7 +119,12 @@ export class VariableValidator extends TestObjectValidator {
|
|
|
119
119
|
if (this.targetObject[TestObjectSyntax.Scope]) {
|
|
120
120
|
const scope = this.targetObject[TestObjectSyntax.Scope];
|
|
121
121
|
const pathWithoutDollar = cleanseDollarDot(path);
|
|
122
|
-
|
|
122
|
+
if (pathWithoutDollar.startsWith("[")) {
|
|
123
|
+
path = `${scope}${pathWithoutDollar}`;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
path = `${scope}.${pathWithoutDollar}`;
|
|
127
|
+
}
|
|
123
128
|
}
|
|
124
129
|
const replaced = replaceBracketsWithAsteriskNested(path);
|
|
125
130
|
if (this.minimal)
|
|
@@ -204,10 +209,10 @@ export class ReturnValidator extends TestObjectValidator {
|
|
|
204
209
|
}
|
|
205
210
|
function cleanseDollarDot(path) {
|
|
206
211
|
if (path.startsWith(`$.`)) {
|
|
207
|
-
return path.slice(2);
|
|
212
|
+
return path.slice(2).trim();
|
|
208
213
|
}
|
|
209
214
|
else if (path.startsWith(`$`)) {
|
|
210
|
-
return path.slice(1);
|
|
215
|
+
return path.slice(1).trim();
|
|
211
216
|
}
|
|
212
|
-
return path;
|
|
217
|
+
return path.trim();
|
|
213
218
|
}
|
package/package.json
CHANGED
package/sample.md
CHANGED
|
@@ -271,3 +271,19 @@ This document outlines best practices for writing effective JVAL (JSON Validatio
|
|
|
271
271
|
4. **Inconsistent naming** - stick to snake_case throughout
|
|
272
272
|
5. **Hard-coded values in expressions** - use variables for maintainability
|
|
273
273
|
6. **Too broad JSONPath selectors** - be as specific as possible
|
|
274
|
+
|
|
275
|
+
## some complex test examples
|
|
276
|
+
|
|
277
|
+
```json
|
|
278
|
+
{
|
|
279
|
+
"_NAME_": "ITEMS_RETURNABLE",
|
|
280
|
+
"_SCOPE_": "$.message.catalog['bpp/providers'][*].items[*]",
|
|
281
|
+
"typeCode": "$.tags[?(@.code=='type')].list[*].code",
|
|
282
|
+
"typeValue": "$.tags[?(@.code=='type')].list[*].value",
|
|
283
|
+
"validCode": ["type"],
|
|
284
|
+
"valueValue": ["customization"],
|
|
285
|
+
"attr": "$['@ondc/org/returnable']",
|
|
286
|
+
"_CONTINUE_": "validCode all in typeCode && valueValue all in typeValue",
|
|
287
|
+
"_RETURN_": "attr are present"
|
|
288
|
+
}
|
|
289
|
+
```
|