(obj, propertyName, propExamples)
| 453 | } |
| 454 | |
| 455 | function mergePropertyExamples(obj, propertyName, propExamples) { |
| 456 | // Create an example for each variant of the propertyExample, merging them with the current (parent) example |
| 457 | let i = 0; |
| 458 | const maxCombinations = 10; |
| 459 | const mergedObj = {}; |
| 460 | for (const exampleKey in obj) { |
| 461 | for (const propExampleKey in propExamples) { |
| 462 | mergedObj[`example-${i}`] = { ...obj[exampleKey] }; |
| 463 | mergedObj[`example-${i}`][propertyName] = propExamples[propExampleKey]; |
| 464 | i++; |
| 465 | if (i >= maxCombinations) { |
| 466 | break; |
| 467 | } |
| 468 | } |
| 469 | if (i >= maxCombinations) { |
| 470 | break; |
| 471 | } |
| 472 | } |
| 473 | return mergedObj; |
| 474 | } |
| 475 | |
| 476 | /* For changing JSON-Schema to a Sample Object, as per the schema (to generate examples based on schema) */ |
| 477 | export function schemaToSampleObj(schema, config = { }) { |
no outgoing calls
no test coverage detected
searching dependent graphs…