autorest 0,2 travis-ci ruby gulp npm

Swagger (OpenAPI) Specification code generator featuring C# and Razor templates. Supports C#, Java, Node.js, TypeScript, Python and Ruby.

Repo Status Issue Stats Issue Stats


The AutoRest tool generates client libraries for accessing RESTful web services. Input to AutoRest is a spec that describes the REST API using the Open API Initiative format.

##Getting AutoRest The AutoRest tools can be installed with Nuget for use in a Visual Studio project: AutoRest NuGet

Alternatively it can be installed from Chocolatey by running: AutoRest Chocolatey

choco install autorest

Nightlies are available via MyGet: AutoRest MyGet

AutoRest can be run on OSX and Unix using Mono or by running Docker container:

docker pull azuresdk/autorest:latest

Building AutoRest

AutoRest is developed primarily in C# but generates code for multiple languages. See this link to build and test AutoRest.

Hint: There is a powershell script (verify-settings.ps1) in the Tools folder that can verify that you have the required compilers/tools/libraries installed on your development system before trying to build.

Hello World

For this version of Hello World, we will use AutoRest to generate a client library and use it to call a web service. The trivial web service that just returns a string is defined as follows:

public class HelloWorldController : ApiController
    // GET: api/HelloWorld
    public string Get()
        return "Hello via AutoRest.";

By convention, Swagger documents are exposed by web services with the name swagger.json. The title property of the info object is used by AutoRest as the name of the client object in the generated library. The host + path of the operation corresponds to the URL of the operation endpoint. The operationId is used as the method name. The spec declares that a GET request will return an HTTP 200 status code with content of mime-type application/json and the body will be a string. For a more in-depth overview of swagger processing, refer to Defining Clients With Swagger section of the documentation.

  "swagger": "2.0",
  "info": {
    "title": "MyClient",
    "version": "1.0.0"
  "host": "",
  "paths": {
    "/api/HelloWorld": {
      "get": {
        "operationId": "GetGreeting",
        "produces": [
        "responses": {
          "200": {
            "description": "GETs a greeting.",
            "schema": {
              "type": "string"

Next, we invoke AutoRest.exe with this swagger document to generate client library code (see Command Line Interface documentation for details).

AutoRest is extensible and can support multiple types of input and output. AutoRest.exe comes with the AutoRest.json configuration file that defines the available inputs (Modelers) and outputs (CodeGenerators). When invoking AutoRest.exe, if you don’t specify the -Modeler then Swagger is assumed and if you don’t specify -CodeGenerator then CSharp is used.

The Swagger schema is language agnostic and doesn’t include the notion of namespace, but for generating code, AutoRest requires -Namespace be specified. By default, the CodeGenerator will place output in a directory named Generated. This can be overridden by providing the -OutputDirectory parameter.

AutoRest.exe -CodeGenerator CSharp -Modeler Swagger -Input swagger.json -Namespace MyNamespace

Now, we will use the generated code to call the web service.

Create a console application called HelloWorld. Add the generated files to it. They won’t compile until you add the NuGet package the generated code depends on: Microsoft.Rest.ClientRuntime.

You can add it to the Visual Studio project using the NuGet package manager or in the Package Manager Console with this command:

Install-Package Microsoft.Rest.ClientRuntime

Add the namespace that was given to AutoRest.

using MyNamespace;

Access the REST API with very little code (see Client Initialization and Client Operations for details).

var myClient = new MyClient();
var salutation = myClient.GetGreeting();

Running the console app shows the greeting retrieved from the service API.

Hello via AutoRest.

With that same basic pattern in place, you can now explore how different REST API operations and payloads are described in Swagger and exposed in the code generated by AutoRest.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Related Repositories



Swagger (OpenAPI) Specification code generator featuring C# and Razor templates. Supports C#, Java, Node.js, TypeScript, Python and Ruby. ...



This package implements an HTTP request pipeline suitable for use across multiple go-routines and provides the shared routines relied on by AutoRest (see generated Go code. ...



AutoREST Nominatim [jre, gwt, android, jee] example ...



Swagger documented API and Autorest generated client with Auth0 ...



JAX-RS service interface generator for Open API specification ...

Top Contributors

stankovski amarzavery jianghaolu hovsepm annatisch yugangw-msft devigned nicklebedev37 markcowl matt-gibbs xingwu1 tbombach vishrutshah daschult begoldsm matthchr haocs NiklasGustafsson lmazuel John-Hart fearthecowboy BretJohnson brjohnstmsft dmitriy-barkalov ogail jhancock93 veronicagg abhivijay96 brodyberg cormacpayne


package version
@types/request 0.0.39
@types/shelljs ^0.6.0
http-proxy-agent ^1.0.0
https-proxy-agent ^1.0.0
linq-es2015 ^2.4.13
request ^2.79.0
semver ^5.3.0
shelljs ^0.7.6
streamsink ^1.2.0
tar.gz2 ^1.0.0
tmp 0.0.31
unzipper ^0.8.4
yauzl ^2.7.0
dev @types/node ^7.0.5
@types/semver ^5.3.30
@types/tmp 0.0.32
chalk ^1.1.2
coffee-script ^1.11.1
del ^2.2.2
gulp ^3.9.1
gulp-dependencies-changed ^1.0.2
gulp-eol ^0.1.2
gulp-filter ^5.0.0
gulp-github-release ^1.2.1
gulp-line-ending-corrector ^1.0.1
gulp-rename ^1.2.2
gulp-unzip ^0.2.0
gulp-zip ^4.0.0
iced-coffee-script *
marked ^0.3.6
marked-terminal ^2.0.0
moment ^2.17.1
run-sequence *
shelljs ^0.7.6
through2-parallel ^0.1.3
typescript 2.3.3
vinyl-paths ^2.1.0
vinyl-fs ^2.4.4
yargs ^6.6.0


-   rb-v0.2.1 zip tar
-   rb-v0.2.0 zip tar
-   rb-v0.1.2 zip tar
-   rb-v0.1.1 zip tar
-   ms_rest_azure-v0.6.0 zip tar
-   ms_rest_azure-v0.5.0 zip tar
-   ms_rest_azure-v0.4.0 zip tar
-   ms_rest_azure-v0.3.1 zip tar
-   ms_rest_azure-v0.3.0 zip tar
-   ms_rest_azure-v0.2.3 zip tar
-   ms_rest-v0.6.0 zip tar
-   ms_rest-v0.5.0 zip tar
-   ms_rest-v0.4.0 zip tar
-   ms_rest-v0.3.1 zip tar
-   ms_rest-v0.3.0 zip tar
-   java-1.0.0-beta1 zip tar
-   azrb-v0.2.2 zip tar
-   azrb-v0.2.1 zip tar
-   azrb-v0.2.0 zip tar
-   azrb-v0.1.2 zip tar
-   azrb-v0.1.1 zip tar
-   ClientRuntime20_Clie zip tar
-   ClientRuntime.2.3.2 zip tar
-   ClientRuntime_2.3.1 zip tar
-   ClientRuntime_2.3.0 zip tar
-   ClientRuntime_2.2.0 zip tar
-   ClientRuntime_2.1.0 zip tar
-   ClientRuntime_2.0.1 zip tar
-   ClientRuntime1.8.2_C zip tar
-   ClientRuntime0.9.4 zip tar