AutoRest

  • Generating clients for your APIs with AutoRest
  • AutoRest Command Line Interface Documentation
  • Install autorest and csharp generator extension / generate

    npm search autorest
    npm install -g autorest @microsoft.azure/autorest.csharp ms-rest ms-rest-azure
    autorest --input-file=http://localhost:63300//swagger/v1.0/swagger.json --namespace=Generated --output-folder=Generated --csharp --client-side-validation=false
    
  • OpenAPI (f.k.a Swagger) Specification code generator.
    • Supports C#, Go, Java, Node.js, TypeScript, Python, Ruby and PHP.
    • Code Generation to consume the API is generated via Autorest and Swagger UI. Will be used for integration tests.
  • How to use Sandcastle type xml comments in your Swagger generated API documentation: summary goes as top right description, remarks is listed as implementation notes, controller Produces attribute mapped to Response Content Type, response messages controlled by a combo of ProducesResponseType attribute and the response xml tag.

      /// <returns>a single feature configuration</returns>
      /// <response code="200">found - body contains data</response>
      /// <response code="404">does not exist</response>
      /// <response code="500">
      /// Internal Server Error. An unhandled exception occurred while processing the request.
      /// <![CDATA[
      /// AmbiguousActionException: Multiple actions matched.
      /// DependencyResolutionException: An error occurred during the activation of a particular registration.
      /// ]]>
      /// </response>
      [HttpGet]
      [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<ResponseDto>))]
      [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(void))]
      [ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(Exception))]
      public async Task<IActionResult> Get()
    
  • Generating a client using AutoRest Sample
  • Azure/autorest tracing