Louie
Louie

Reputation: 71

Automate update REST API Client during build

My company is looking to implement applications using Azure API Apps. Client applications will create REST API clients using Swagger documents located in the Azure portal. Any changes to the Azure API apps will cause an update to the Swagger document when the service is published.

Is there a way to automate the download of the service's swagger document so that the REST API client can be rebuilt/updated during the build process (e.g. something like a pre-build step)?

Thanks for any help.

Upvotes: 4

Views: 1407

Answers (1)

Tóth Tibor
Tóth Tibor

Reputation: 1565

The Visual Studio's Add / Rest Api Client... option is using the AutoRest library for the code generation. You can download this tool as a NuGet package and use the AutoRest.exe command line tool to generate the output.

For example:

AutoRest.exe -CodeGenerator CSharp -Modeler Swagger -Input https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore-simple.json -Namespace MyNamespace

Another way is to use the Swagger codegen library. This is a java based command line tool, which can generate some C# code too.

Upvotes: 2

Related Questions