[IMPR] Improve api._generators and avoid similar code
Change-Id: I5959bfe9686d918774529b98d45a3ac084848366