Autorest client in a single file


Autorest client in a single file

Carl Rasmus Wriedt Bønnebæk
26 feb 2021

So this post will be in English

If you don’t care about all the trouble I have been through not understanding the toolset I have ben using, and just want AutoRest to generate a single file api client for your OpenApi / swagger spec Go Here (or in really really short just –v2)

I literally spent hours solving this plain and simple issue, that was caused by the my lack of knowledge.

Since I discovered Swagger / OpenApi, I have had the pleasure of using auto generated apis, first using, but for the last 2 years I have been using the “Create Rest Client” feature in Visual studio. The feature is not the built in one, It didn’t work when VS2019 was launched, so I have always used Christian Helles plugin for VS. It worked smooth and simple. And well, Just worked.

Lately (Since feb 2021) when I tried to regenerate my clients using AutoRest in Christians plugin, nothing worked. First the version of AutoRest was wrong, and when I solved that nothing still worked.

As I had to figure out what and how Autorest worked, I was led to the solution, just use the command line. (That would suit just fine with my devops as well), and I tried and I tried, updating AutoRest, Updating AutorestCore etc. but nothing worked with the –output-file option, all I got was a set of generated files and a solution.. This could be great in some solutions, but all mine are dependent of all the api functionality is stored in a single file I can throw my httpClient at.

The solution. (After one week of considering new architecture, Nswag etc.)

Keep it simple – use –v2 then it all works.

So the solution in my case was to use the command line :

autorest --csharp --input-file=http://MYSITE/docs/v1 --output-file=[MySolutiondir\filename.cs] --namespace=My.NameSpace.Api --v2

And please note the –v2. This was the solution for me, if not specified it was impssible to generate anything other than a folder of solution files.

So the next thing for me is to disover the right way to do this. This is the soliton if you are (as me) looking for single file Api Client, but im uncertain if this is the Correct solution.



Carl Bønnebæk
Hej, Jeg er
Carl Bønnebæk

Jeg udvikler webløsninger baseret på Umbraco, .Net & .Net Core.

Dette er mit lille aftryk, hvor jeg giver udtryk for hvad jeg synes der er hot eller not inden for teknik og livet som selvstændig :-)

Seneste posts

Kom bare nærmere

Skal vi mødes og drikke en kop kaffe, eller tage et hurtigt teams møde, så sig til


København / Amager


Tlf: +45 60200656