Rafael Nadal was given a massive scare by Fabio Fognini before reaching the semi-finals of the China Open with a 2-6 6-4 6-1 win.