Skip to content

Commit 2442bf1

Browse files
authored
Remove ajv check (#320)
1 parent be7fa47 commit 2442bf1

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

index.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,8 @@ function build (schema, options) {
146146
return ${main}
147147
`
148148

149-
const dependencies = []
150-
const dependenciesName = []
151-
if (dependsOnAjv(schema)) {
152-
dependencies.push(new Ajv(options.ajv))
153-
dependenciesName.push('ajv')
154-
}
155-
149+
const dependencies = [new Ajv(options.ajv)]
150+
const dependenciesName = ['ajv']
156151
dependenciesName.push(code)
157152

158153
if (options.debugMode) {
@@ -223,23 +218,6 @@ function inferTypeByKeyword (schema) {
223218
return schema.type
224219
}
225220

226-
function dependsOnAjv (schema) {
227-
const str = JSON.stringify(schema)
228-
switch (true) {
229-
case /"if":{.*"then":{/.test(str):
230-
case /"(anyOf|oneOf)":\[/.test(str):
231-
case /"const"/.test(str):
232-
case /"\$ref"/.test(str):
233-
{
234-
return true
235-
}
236-
237-
default: {
238-
return false
239-
}
240-
}
241-
}
242-
243221
const stringSerializerMap = {
244222
'date-time': '$asDatetime',
245223
date: '$asDate',

0 commit comments

Comments
 (0)