def update_yaml()

in packages/autorest.python/autorest/m4reformatter/__init__.py [0:0]


    def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
        """Convert in place the YAML str."""
        # there can only be one namespace and client from swagger
        namespace = self._autorestapi.get_value("namespace") or to_snake_case(
            yaml_data["info"]["title"].replace(" ", "")
        )
        # First we update the types, so we can access for when we're creating parameters etc.
        for type_group, types in yaml_data["schemas"].items():
            for t in types:
                if type_group == "objects" and t["language"]["default"]["name"] == "CloudError":
                    # we don't generate cloud error
                    continue
                update_type(t)
        yaml_data["namespace"] = namespace
        yaml_data["subnamespaceToClients"] = {}
        yaml_data["clients"] = [self.update_client(yaml_data)]
        yaml_data["clients"][0]["operationGroups"] = [
            self.update_operation_group(og) for og in yaml_data["operationGroups"]
        ]
        yaml_data["types"] = list(ORIGINAL_ID_TO_UPDATED_TYPE.values()) + list(KNOWN_TYPES.values())
        if yaml_data.get("globalParameters"):
            del yaml_data["globalParameters"]
        del yaml_data["info"]
        del yaml_data["language"]
        del yaml_data["protocol"]
        del yaml_data["operationGroups"]
        if yaml_data.get("schemas"):
            del yaml_data["schemas"]
        if yaml_data.get("security"):
            del yaml_data["security"]
        ORIGINAL_ID_TO_UPDATED_TYPE.clear()