UNPKG

@protocolnebula/ts-openapi-generator

Version:

Build API and models from Swagger/OpenAPI to use in any project type

22 lines 697 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findInObject = void 0; /** * Find an object inside another object by a given path * @param $ref Path to find EX: '#/level1/level2/level3' * @param fullObject Full instance of the object */ function findInObject($ref, fullObject) { const path = $ref.split('/'); let child = path.shift(); // Skip the root (#) let currentPath = fullObject; while ((child = path.shift())) { if (!currentPath[child]) { return null; } currentPath = currentPath[child]; } return currentPath; } exports.findInObject = findInObject; //# sourceMappingURL=objects.util.js.map