Skip to content

Working with AutoRest

Srikanta edited this page Jun 25, 2020 · 8 revisions

AutoRest is the name of the tool we use to generate the communication layer that lies beneath the API we expose to our users. AutoRest saves us from having to write a lot of network communication code, and instead we can direct our focus towards building a great user experience on top of this generated code. Our goal should be to expose as little, and ideally none, of the generated code to the user.

Getting started with AutoRest is as simple as following these steps:

  1. Fork and clone this GitHub repo and switch to the "v4" branch.
git clone https://github.com/Azure/autorest.java.git
git checkout v4
  1. Build the package using Maven
mvn clean package -Dlocal
  1. Run npm install. You need v10 version of Node.JS installed.
  2. Run npm install -g autorest.
  3. Run AutoRest commands like this:
autorest --java --use=C:\work\autorest.java\ C:\swagger\updated\Blob\readme.md --output-folder=C:\work\azure-sdk-for-java\storage\client\ --namespace=com.azure.storage.blob --sync-methods=none --generate-client-interfaces=false --enable-xml --required-parameter-client-methods

Notes:

  1. --use=<path to your autorest.java clone>
  2. If the input is a JSON spec, use --input-file=<local path of URL of JSON file>, if it's a README.md file, remove --input-file=
  3. --enable-xml --required-parameter-client-methods are not needed for services other than Storage
Clone this wiki locally