(context, location, input)
| 1236 | } |
| 1237 | |
| 1238 | function buildValue (context, location, input) { |
| 1239 | let schema = location.schema |
| 1240 | |
| 1241 | if (typeof schema === 'boolean') { |
| 1242 | return `json += JSON.stringify(${input})` |
| 1243 | } |
| 1244 | |
| 1245 | if (schema.$ref) { |
| 1246 | location = resolveRef(context, location) |
| 1247 | schema = location.schema |
| 1248 | } |
| 1249 | |
| 1250 | if (schema.allOf) { |
| 1251 | return buildAllOf(context, location, input) |
| 1252 | } |
| 1253 | |
| 1254 | if (schema.anyOf || schema.oneOf) { |
| 1255 | return buildOneOf(context, location, input) |
| 1256 | } |
| 1257 | |
| 1258 | if (schema.if && schema.then) { |
| 1259 | return buildIfThenElse(context, location, input) |
| 1260 | } |
| 1261 | |
| 1262 | if (schema.type === undefined) { |
| 1263 | const inferredType = inferTypeByKeyword(schema) |
| 1264 | if (inferredType) { |
| 1265 | schema.type = inferredType |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | let code = '' |
| 1270 | |
| 1271 | const type = schema.type |
| 1272 | const nullable = schema.nullable === true |
| 1273 | if (nullable) { |
| 1274 | code += ` |
| 1275 | if (${input} === null) { |
| 1276 | json += JSON_STR_NULL |
| 1277 | } else { |
| 1278 | ` |
| 1279 | } |
| 1280 | |
| 1281 | if (schema.const !== undefined) { |
| 1282 | code += buildConstSerializer(location, input) |
| 1283 | } else if (Array.isArray(type)) { |
| 1284 | code += buildMultiTypeSerializer(context, location, input) |
| 1285 | } else { |
| 1286 | code += buildSingleTypeSerializer(context, location, input) |
| 1287 | } |
| 1288 | |
| 1289 | if (nullable) { |
| 1290 | code += ` |
| 1291 | } |
| 1292 | ` |
| 1293 | } |
| 1294 | |
| 1295 | return code |
no test coverage detected
searching dependent graphs…