MCPcopy Index your code
hub / github.com/rapi-doc/RapiDoc / mergePropertyExamples

Function mergePropertyExamples

src/utils/schema-utils.js:455–474  ·  view source on GitHub ↗
(obj, propertyName, propExamples)

Source from the content-addressed store, hash-verified

453}
454
455function 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) */
477export function schemaToSampleObj(schema, config = { }) {

Callers 1

schemaToSampleObjFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…