def _walk()

in src/rpdk/core/jsonutils/flattener.py [0:0]


    def _walk(self, sub_schema, property_path):

        # have we already seen this path?
        if property_path in self._schema_map:
            return {"$ref": property_path}

        # placeholder so as to not reprocess
        self._schema_map[property_path] = None

        # work on shallow copy to avoid modifying the schema
        sub_schema = dict(sub_schema)

        # is it a reference?
        try:
            ref_path = sub_schema["$ref"]
        except KeyError:
            # schemas without type are assumed to be objects
            json_type = sub_schema.get("type", "object")
            if json_type == "array":
                sub_schema = self._flatten_array_type(sub_schema, property_path)

            elif json_type == "object":
                sub_schema = self._flatten_object_type(sub_schema, property_path)
        else:
            sub_schema = self._flatten_ref_type(ref_path)

        # if the path was never added to the schema map, remove placeholder
        if self._schema_map[property_path] is None:
            self._schema_map.pop(property_path)

        # for primitive types, we are done processing
        return sub_schema