In this work, we have investigated the process $D_s^+to K^+ K^- pi^+$, taking into account the contributions from the $S$-wave pseudoscalar-pseudoscalar interaction within the chiral unitary approach, and also the intermediate $phi$ resonance. By analyzing the BESIII and {it BABAR} measurements, we conclude that the $f_0(980)$ state, dynamically generated from the $S$-wave pseudoscalar-pseudoscalar interaction, gives the dominant contribution close to the $K^+K^-$ threshold in the $K^+K^-$ invariant mass distribution of the decay $D_s^+to K^+ K^- pi^+$ in $S$-wave. On the other hand, our results imply that the lineshape adopted by BESIII and {it BABAR} for the resonances $a_0(980)$ and $f_0(980)$ is not advisable in the fit to the data close to the $K^+K^-$ threshold.