@@ -303,7 +303,7 @@ function build (schema, options) {
303
303
schema . type = inferTypeByKeyword ( schema )
304
304
}
305
305
306
- const { code, laterCode } = buildValue ( '' , 'main' , 'input' , location , false )
306
+ const { code, laterCode } = buildValue ( '' , 'main' , 'input' , location )
307
307
const contextFunctionCode = `
308
308
'use strict'
309
309
function main (input) {
@@ -738,7 +738,7 @@ function buildCode (location, code, laterCode, locationPath) {
738
738
json += ${ asString } + ':'
739
739
`
740
740
741
- const result = buildValue ( laterCode , locationPath + key , `obj[${ JSON . stringify ( key ) } ]` , mergeLocation ( propertyLocation , { schema : schema . properties [ key ] } ) , false )
741
+ const result = buildValue ( laterCode , locationPath + key , `obj[${ JSON . stringify ( key ) } ]` , mergeLocation ( propertyLocation , { schema : schema . properties [ key ] } ) )
742
742
code += result . code
743
743
laterCode = result . laterCode
744
744
@@ -970,7 +970,7 @@ function buildArray (location, code, functionName, locationPath, isObjectPropert
970
970
const accessor = '[i]'
971
971
if ( Array . isArray ( schema . items ) ) {
972
972
result = schema . items . reduce ( ( res , item , i ) => {
973
- const tmpRes = buildValue ( laterCode , locationPath + accessor + i , 'obj[i]' , mergeLocation ( location , { schema : item } ) , true )
973
+ const tmpRes = buildValue ( laterCode , locationPath + accessor + i , 'obj[i]' , mergeLocation ( location , { schema : item } ) )
974
974
const condition = `i === ${ i } && ${ buildArrayTypeCondition ( item . type , accessor ) } `
975
975
return {
976
976
code : `${ res . code }
@@ -983,7 +983,7 @@ function buildArray (location, code, functionName, locationPath, isObjectPropert
983
983
} , result )
984
984
985
985
if ( schema . additionalItems ) {
986
- const tmpRes = buildValue ( laterCode , locationPath + accessor , 'obj[i]' , mergeLocation ( location , { schema : schema . items } ) , true )
986
+ const tmpRes = buildValue ( laterCode , locationPath + accessor , 'obj[i]' , mergeLocation ( location , { schema : schema . items } ) )
987
987
result . code += `
988
988
else if (i >= ${ schema . items . length } ) {
989
989
${ tmpRes . code }
@@ -997,7 +997,7 @@ function buildArray (location, code, functionName, locationPath, isObjectPropert
997
997
}
998
998
`
999
999
} else {
1000
- result = buildValue ( laterCode , locationPath + accessor , 'obj[i]' , mergeLocation ( location , { schema : schema . items } ) , true )
1000
+ result = buildValue ( laterCode , locationPath + accessor , 'obj[i]' , mergeLocation ( location , { schema : schema . items } ) )
1001
1001
}
1002
1002
1003
1003
if ( isObjectProperty ) {
@@ -1104,7 +1104,7 @@ function generateFuncName () {
1104
1104
return 'anonymous' + genFuncNameCounter ++
1105
1105
}
1106
1106
1107
- function buildValue ( laterCode , locationPath , input , location , isArray ) {
1107
+ function buildValue ( laterCode , locationPath , input , location ) {
1108
1108
let schema = location . schema
1109
1109
1110
1110
if ( schema . $ref ) {
@@ -1162,7 +1162,7 @@ function buildValue (laterCode, locationPath, input, location, isArray) {
1162
1162
// beware: dereferenceOfRefs has side effects and changes schema.anyOf
1163
1163
const locations = dereferenceOfRefs ( location , schema . anyOf ? 'anyOf' : 'oneOf' )
1164
1164
locations . forEach ( ( location , index ) => {
1165
- const nestedResult = buildValue ( laterCode , locationPath + 'i' + index , input , location , isArray )
1165
+ const nestedResult = buildValue ( laterCode , locationPath + 'i' + index , input , location )
1166
1166
// Since we are only passing the relevant schema to ajv.validate, it needs to be full dereferenced
1167
1167
// otherwise any $ref pointing to an external schema would result in an error.
1168
1168
// Full dereference of the schema happens as side effect of two functions:
@@ -1216,7 +1216,7 @@ function buildValue (laterCode, locationPath, input, location, isArray) {
1216
1216
sortedTypes . forEach ( ( type , index ) => {
1217
1217
const statement = index === 0 ? 'if' : 'else if'
1218
1218
const tempSchema = Object . assign ( { } , schema , { type } )
1219
- const nestedResult = buildValue ( laterCode , locationPath , input , mergeLocation ( location , { schema : tempSchema } ) , isArray )
1219
+ const nestedResult = buildValue ( laterCode , locationPath , input , mergeLocation ( location , { schema : tempSchema } ) )
1220
1220
switch ( type ) {
1221
1221
case 'string' : {
1222
1222
code += `
0 commit comments