Skip to content

Latest commit

 

History

History
25 lines (23 loc) · 1.15 KB

clients-init.md

File metadata and controls

25 lines (23 loc) · 1.15 KB

#Initialization AutoRest generates a client type based on a name defined in the specification (see swagger specification parsing overview). The generated client inherits from ServiceClient<T> base type available in Microsoft.Rest.ClientRuntime nuget package.

The client is generated with a number of constructors:

  • A default constructor that sets Base URL of the client to the one specified in the specification and configures the client to use anonymous authentication
var myClient = new SwaggerPetstore();
  • A constructor that accepts Base URL
var myClient = new SwaggerPetstore(new Uri("https://contoso.org/myclient"));
var myClient = new SwaggerPetstore(new BasicAuthenticationCredentials
	{
		UserName = "ContosoUser",
		Password = "P@$$w0rd"
	});
  • A constructor that accepts the above parameters and a collection of delegating handlers (see Custom Http Handlers)
var myClient = new SwaggerPetstore(new MyCustomDelegatingHandler());