Skip to content

Commit ca9dbc7

Browse files
authored
fix: avoid collision
Signed-off-by: francesco <[email protected]>
1 parent d433cda commit ca9dbc7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,15 @@ function buildInnerObject (context, location) {
374374
addComma = '!addComma && (addComma = true) || (json += JSON_STR_COMMA)'
375375
}
376376

377+
let counterValue = 0
377378
for (const key of propertiesKeys) {
378379
let propertyLocation = propertiesLocation.getPropertyLocation(key)
379380
if (propertyLocation.schema.$ref) {
380381
propertyLocation = resolveRef(context, propertyLocation)
381382
}
382383

383384
const sanitizedKey = JSON.stringify(key)
384-
const value = 'value_' + key.replace(/[^a-zA-Z0-9]/g, '_')
385+
const value = 'value_' + key.replace(/[^a-zA-Z0-9]/g, '_') + '_' + (counterValue++)
385386
const defaultValue = propertyLocation.schema.default
386387
const isRequired = requiredProperties.includes(key)
387388

0 commit comments

Comments
 (0)