Fix API route generation for all cases