Why does Visual Studio 2017 fail to generate REST API client for Swagger Petstore?

Visual Studio 2017 is using a very old version of AutoRest. The issue you are seeing is this one which was fixed in AutoRest v. 1.0. As explained in the comments in that issue:

Are you referring to the autorest version that's built-into visual studio? -- That's incredibly old, and we didn't update that (we've changed the whole way autorest works).

You are going to need to install node and use autorest from the command line.

Looks like it's not possible to update AutoRest used by Visual Studio 2017, so you'll need to call AutoRest directly.