diff --git a/.gulp/regeneration.iced b/.gulp/regeneration.iced
index 0a0342cf7..bf0216cb2 100644
--- a/.gulp/regeneration.iced
+++ b/.gulp/regeneration.iced
@@ -18,9 +18,17 @@ task 'regenerate', 'regenerate samples', (done) ->
ShellString(stdout).to(path.join(outputFolder, "stdout.txt"))
ShellString(stderr).to(path.join(outputFolder, "stderr.txt"))
- # sanitize generated files (source maps and shell stuff may contain file:/// paths)
+ # sanitize generated files
+
+ ## clear out generated sources; it's language owner's job to ensure quality of the content,
+ ## we just check for existence and basic structure to detect core problems (URI resolution, file emitting, ...)
(find path.join(each.path, ".."))
- .filter((file) -> file.match(/.(map|txt)$/))
+ .filter((file) -> file.match(/\.(cs|go|java|js|ts|php|py|rb)$/))
+ .forEach((file) -> "SRC".to(file))
+
+ ## source maps and shell stuff (contains platform/folder dependent stuff)
+ (find path.join(each.path, ".."))
+ .filter((file) -> file.match(/\.(map|txt)$/))
.forEach((file) ->
sed "-i", /\bfile:\/\/[^\s]*\/autorest[^\/\\]*/g, "", file # blame locations
sed "-i", /\sat .*/g, "at ...", file # exception stack traces
@@ -32,7 +40,7 @@ task 'regenerate', 'regenerate samples', (done) ->
)
(find path.join(each.path, ".."))
- .filter((file) -> file.match(/.(yaml)$/))
+ .filter((file) -> file.match(/\.(yaml)$/))
.forEach((file) ->
sed "-i", /.*autorest[a-zA-Z0-9]*.src.*/ig, "", file # source file names
)
diff --git a/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs b/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs
index 5993f0818..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs
+++ b/Samples/1a-code-generation-minimal/Client/ISwaggerPetstore.cs
@@ -1,406 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore
-{
- using Microsoft.Rest;
- using Models;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// This is a sample server Petstore server. You can find out more about
- /// Swagger at <a
- /// href="http://swagger.io">http://swagger.io</a> or on
- /// irc.freenode.net, #swagger. For this sample, you can use the api key
- /// "special-key" to test the authorization filters
- ///
- public partial interface ISwaggerPetstore : System.IDisposable
- {
- ///
- /// The base URI of the service.
- ///
- System.Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets json serialization settings.
- ///
- JsonSerializerSettings SerializationSettings { get; }
-
- ///
- /// Gets or sets json deserialization settings.
- ///
- JsonSerializerSettings DeserializationSettings { get; }
-
-
- ///
- /// Fake endpoint to test byte array in body parameter for adding a new
- /// pet to the store
- ///
- ///
- /// Pet object in the form of byte array
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task AddPetUsingByteArrayWithHttpMessagesAsync(string body = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Add a new pet to the store
- ///
- ///
- /// Adds a new pet to the store. You may receive an HTTP invalid input
- /// if your pet is invalid.
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task AddPetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Update an existing pet
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task UpdatePetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Finds Pets by status
- ///
- ///
- /// Multiple status values can be provided with comma seperated strings
- ///
- ///
- /// Status values that need to be considered for filter
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task>> FindPetsByStatusWithHttpMessagesAsync(IList status = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Finds Pets by tags
- ///
- ///
- /// Muliple tags can be provided with comma seperated strings. Use
- /// tag1, tag2, tag3 for testing.
- ///
- ///
- /// Tags to filter by
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Fake endpoint to test byte array return by 'Find pet by ID'
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will
- /// simulate API error conditions
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task> FindPetsWithByteArrayWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Find pet by ID
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will
- /// simulate API error conditions
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Updates a pet in the store with form data
- ///
- ///
- /// ID of pet that needs to be updated
- ///
- ///
- /// Updated name of the pet
- ///
- ///
- /// Updated status of the pet
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task UpdatePetWithFormWithHttpMessagesAsync(string petId, string name = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Deletes a pet
- ///
- ///
- /// Pet id to delete
- ///
- ///
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// uploads an image
- ///
- ///
- /// ID of pet to update
- ///
- ///
- /// Additional data to pass to server
- ///
- ///
- /// file to upload
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task UploadFileWithHttpMessagesAsync(long petId, string additionalMetadata = default(string), Stream file = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Returns pet inventories by status
- ///
- ///
- /// Returns a map of status codes to quantities
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Place an order for a pet
- ///
- ///
- /// order placed for purchasing the pet
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task> PlaceOrderWithHttpMessagesAsync(Order body = default(Order), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Find purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value <= 5 or > 10.
- /// Other values will generated exceptions
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Delete purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value < 1000. Anything
- /// above 1000 or nonintegers will generate API errors
- ///
- ///
- /// ID of the order that needs to be deleted
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Create user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// Created user object
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task CreateUserWithHttpMessagesAsync(User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// List of user object
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// List of user object
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task CreateUsersWithListInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Logs user into the system
- ///
- ///
- /// The user name for login
- ///
- ///
- /// The password for login in clear text
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task> LoginUserWithHttpMessagesAsync(string username = default(string), string password = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Logs out current logged in user session
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Get user by user name
- ///
- ///
- /// The name that needs to be fetched. Use user1 for testing.
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Updated user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// name that need to be deleted
- ///
- ///
- /// Updated user object
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task UpdateUserWithHttpMessagesAsync(string username, User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Delete user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The name that needs to be deleted
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/Models/Category.cs b/Samples/1a-code-generation-minimal/Client/Models/Category.cs
index 297a1b321..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/Models/Category.cs
+++ b/Samples/1a-code-generation-minimal/Client/Models/Category.cs
@@ -1,90 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore.Models
-{
- using Newtonsoft.Json;
- using System.Linq;
- using System.Xml;
- using System.Xml.Linq;
-
- public partial class Category
- {
- ///
- /// Initializes a new instance of the Category class.
- ///
- public Category()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the Category class.
- ///
- public Category(long? id = default(long?), string name = default(string))
- {
- Id = id;
- Name = name;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- ///
- [JsonProperty(PropertyName = "id")]
- public long? Id { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "name")]
- public string Name { get; set; }
-
- ///
- /// Serializes the object to an XML node
- ///
- internal XElement XmlSerialize(XElement result)
- {
- if( null != Id )
- {
- result.Add(new XElement("id", Id) );
- }
- if( null != Name )
- {
- result.Add(new XElement("name", Name) );
- }
- return result;
- }
- ///
- /// Deserializes an XML node to an instance of Category
- ///
- internal static Category XmlDeserialize(string payload)
- {
- // deserialize to xml and use the overload to do the work
- return XmlDeserialize( XElement.Parse( payload ) );
- }
- internal static Category XmlDeserialize(XElement payload)
- {
- var result = new Category();
- var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e);
- long? resultId;
- if (deserializeId(payload, "id", out resultId))
- {
- result.Id = resultId;
- }
- var deserializeName = XmlSerialization.ToDeserializer(e => (string)e);
- string resultName;
- if (deserializeName(payload, "name", out resultName))
- {
- result.Name = resultName;
- }
- return result;
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/Models/Order.cs b/Samples/1a-code-generation-minimal/Client/Models/Order.cs
index 063d938e2..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/Models/Order.cs
+++ b/Samples/1a-code-generation-minimal/Client/Models/Order.cs
@@ -1,158 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore.Models
-{
- using Newtonsoft.Json;
- using System.Linq;
- using System.Xml;
- using System.Xml.Linq;
-
- public partial class Order
- {
- ///
- /// Initializes a new instance of the Order class.
- ///
- public Order()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the Order class.
- ///
- /// Order Status. Possible values include:
- /// 'placed', 'approved', 'delivered'
- public Order(long? id = default(long?), long? petId = default(long?), int? quantity = default(int?), System.DateTime? shipDate = default(System.DateTime?), string status = default(string), bool? complete = default(bool?))
- {
- Id = id;
- PetId = petId;
- Quantity = quantity;
- ShipDate = shipDate;
- Status = status;
- Complete = complete;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- ///
- [JsonProperty(PropertyName = "id")]
- public long? Id { get; private set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "petId")]
- public long? PetId { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "quantity")]
- public int? Quantity { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "shipDate")]
- public System.DateTime? ShipDate { get; set; }
-
- ///
- /// Gets or sets order Status. Possible values include: 'placed',
- /// 'approved', 'delivered'
- ///
- [JsonProperty(PropertyName = "status")]
- public string Status { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "complete")]
- public bool? Complete { get; set; }
-
- ///
- /// Serializes the object to an XML node
- ///
- internal XElement XmlSerialize(XElement result)
- {
- if( null != Id )
- {
- result.Add(new XElement("id", Id) );
- }
- if( null != PetId )
- {
- result.Add(new XElement("petId", PetId) );
- }
- if( null != Quantity )
- {
- result.Add(new XElement("quantity", Quantity) );
- }
- if( null != ShipDate )
- {
- result.Add(new XElement("shipDate", ShipDate) );
- }
- if( null != Status )
- {
- result.Add(new XElement("status", Status) );
- }
- if( null != Complete )
- {
- result.Add(new XElement("complete", Complete) );
- }
- return result;
- }
- ///
- /// Deserializes an XML node to an instance of Order
- ///
- internal static Order XmlDeserialize(string payload)
- {
- // deserialize to xml and use the overload to do the work
- return XmlDeserialize( XElement.Parse( payload ) );
- }
- internal static Order XmlDeserialize(XElement payload)
- {
- var result = new Order();
- var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e);
- long? resultId;
- if (deserializeId(payload, "id", out resultId))
- {
- result.Id = resultId;
- }
- var deserializePetId = XmlSerialization.ToDeserializer(e => (long?)e);
- long? resultPetId;
- if (deserializePetId(payload, "petId", out resultPetId))
- {
- result.PetId = resultPetId;
- }
- var deserializeQuantity = XmlSerialization.ToDeserializer(e => (int?)e);
- int? resultQuantity;
- if (deserializeQuantity(payload, "quantity", out resultQuantity))
- {
- result.Quantity = resultQuantity;
- }
- var deserializeShipDate = XmlSerialization.ToDeserializer(e => (System.DateTime?)e);
- System.DateTime? resultShipDate;
- if (deserializeShipDate(payload, "shipDate", out resultShipDate))
- {
- result.ShipDate = resultShipDate;
- }
- var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e);
- string resultStatus;
- if (deserializeStatus(payload, "status", out resultStatus))
- {
- result.Status = resultStatus;
- }
- var deserializeComplete = XmlSerialization.ToDeserializer(e => (bool?)e);
- bool? resultComplete;
- if (deserializeComplete(payload, "complete", out resultComplete))
- {
- result.Complete = resultComplete;
- }
- return result;
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/Models/Pet.cs b/Samples/1a-code-generation-minimal/Client/Models/Pet.cs
index 0e909c572..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/Models/Pet.cs
+++ b/Samples/1a-code-generation-minimal/Client/Models/Pet.cs
@@ -1,197 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore.Models
-{
- using Microsoft.Rest;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml;
- using System.Xml.Linq;
-
- ///
- /// A pet
- ///
- ///
- /// A group of properties representing a pet.
- ///
- public partial class Pet
- {
- ///
- /// Initializes a new instance of the Pet class.
- ///
- public Pet()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the Pet class.
- ///
- /// The id of the pet.
- /// pet status in the store. Possible values
- /// include: 'available', 'pending', 'sold'
- public Pet(string name, IList photoUrls, long? id = default(long?), Category category = default(Category), IList tags = default(IList), string status = default(string))
- {
- Id = id;
- Category = category;
- Name = name;
- PhotoUrls = photoUrls;
- Tags = tags;
- Status = status;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- /// Gets or sets the id of the pet.
- ///
- ///
- /// A more detailed description of the id of the pet.
- ///
- [JsonProperty(PropertyName = "id")]
- public long? Id { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "category")]
- public Category Category { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "name")]
- public string Name { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "photoUrls")]
- public IList PhotoUrls { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "tags")]
- public IList Tags { get; set; }
-
- ///
- /// Gets or sets pet status in the store. Possible values include:
- /// 'available', 'pending', 'sold'
- ///
- [JsonProperty(PropertyName = "status")]
- public string Status { get; set; }
-
- ///
- /// Validate the object.
- ///
- ///
- /// Thrown if validation fails
- ///
- public virtual void Validate()
- {
- if (Name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "Name");
- }
- if (PhotoUrls == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls");
- }
- }
- ///
- /// Serializes the object to an XML node
- ///
- internal XElement XmlSerialize(XElement result)
- {
- if( null != Id )
- {
- result.Add(new XElement("id", Id) );
- }
- if( null != Category )
- {
- result.Add(Category.XmlSerialize(new XElement( "category" )));
- }
- if( null != Name )
- {
- result.Add(new XElement("name", Name) );
- }
- if( null != PhotoUrls )
- {
- var seq = new XElement("photoUrl");
- foreach( var value in PhotoUrls ){
- seq.Add(new XElement( "photoUrl", value ) );
- }
- result.Add(seq);
- }
- if( null != Tags )
- {
- var seq = new XElement("tag");
- foreach( var value in Tags ){
- seq.Add(value.XmlSerialize( new XElement( "tag") ) );
- }
- result.Add(seq);
- }
- if( null != Status )
- {
- result.Add(new XElement("status", Status) );
- }
- return result;
- }
- ///
- /// Deserializes an XML node to an instance of Pet
- ///
- internal static Pet XmlDeserialize(string payload)
- {
- // deserialize to xml and use the overload to do the work
- return XmlDeserialize( XElement.Parse( payload ) );
- }
- internal static Pet XmlDeserialize(XElement payload)
- {
- var result = new Pet();
- var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e);
- long? resultId;
- if (deserializeId(payload, "id", out resultId))
- {
- result.Id = resultId;
- }
- var deserializeCategory = XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e));
- Category resultCategory;
- if (deserializeCategory(payload, "category", out resultCategory))
- {
- result.Category = resultCategory;
- }
- var deserializeName = XmlSerialization.ToDeserializer(e => (string)e);
- string resultName;
- if (deserializeName(payload, "name", out resultName))
- {
- result.Name = resultName;
- }
- var deserializePhotoUrls = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => (string)e), "photoUrl");
- IList resultPhotoUrls;
- if (deserializePhotoUrls(payload, "photoUrl", out resultPhotoUrls))
- {
- result.PhotoUrls = resultPhotoUrls;
- }
- var deserializeTags = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Tag.XmlDeserialize(e)), "tag");
- IList resultTags;
- if (deserializeTags(payload, "tag", out resultTags))
- {
- result.Tags = resultTags;
- }
- var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e);
- string resultStatus;
- if (deserializeStatus(payload, "status", out resultStatus))
- {
- result.Status = resultStatus;
- }
- return result;
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/Models/Tag.cs b/Samples/1a-code-generation-minimal/Client/Models/Tag.cs
index 9573b2f59..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/Models/Tag.cs
+++ b/Samples/1a-code-generation-minimal/Client/Models/Tag.cs
@@ -1,90 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore.Models
-{
- using Newtonsoft.Json;
- using System.Linq;
- using System.Xml;
- using System.Xml.Linq;
-
- public partial class Tag
- {
- ///
- /// Initializes a new instance of the Tag class.
- ///
- public Tag()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the Tag class.
- ///
- public Tag(long? id = default(long?), string name = default(string))
- {
- Id = id;
- Name = name;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- ///
- [JsonProperty(PropertyName = "id")]
- public long? Id { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "name")]
- public string Name { get; set; }
-
- ///
- /// Serializes the object to an XML node
- ///
- internal XElement XmlSerialize(XElement result)
- {
- if( null != Id )
- {
- result.Add(new XElement("id", Id) );
- }
- if( null != Name )
- {
- result.Add(new XElement("name", Name) );
- }
- return result;
- }
- ///
- /// Deserializes an XML node to an instance of Tag
- ///
- internal static Tag XmlDeserialize(string payload)
- {
- // deserialize to xml and use the overload to do the work
- return XmlDeserialize( XElement.Parse( payload ) );
- }
- internal static Tag XmlDeserialize(XElement payload)
- {
- var result = new Tag();
- var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e);
- long? resultId;
- if (deserializeId(payload, "id", out resultId))
- {
- result.Id = resultId;
- }
- var deserializeName = XmlSerialization.ToDeserializer(e => (string)e);
- string resultName;
- if (deserializeName(payload, "name", out resultName))
- {
- result.Name = resultName;
- }
- return result;
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/Models/User.cs b/Samples/1a-code-generation-minimal/Client/Models/User.cs
index 29310acd3..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/Models/User.cs
+++ b/Samples/1a-code-generation-minimal/Client/Models/User.cs
@@ -1,188 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore.Models
-{
- using Newtonsoft.Json;
- using System.Linq;
- using System.Xml;
- using System.Xml.Linq;
-
- public partial class User
- {
- ///
- /// Initializes a new instance of the User class.
- ///
- public User()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the User class.
- ///
- /// User Status
- public User(long? id = default(long?), string username = default(string), string firstName = default(string), string lastName = default(string), string email = default(string), string password = default(string), string phone = default(string), int? userStatus = default(int?))
- {
- Id = id;
- Username = username;
- FirstName = firstName;
- LastName = lastName;
- Email = email;
- Password = password;
- Phone = phone;
- UserStatus = userStatus;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- ///
- [JsonProperty(PropertyName = "id")]
- public long? Id { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "username")]
- public string Username { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "firstName")]
- public string FirstName { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "lastName")]
- public string LastName { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "email")]
- public string Email { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "password")]
- public string Password { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "phone")]
- public string Phone { get; set; }
-
- ///
- /// Gets or sets user Status
- ///
- [JsonProperty(PropertyName = "userStatus")]
- public int? UserStatus { get; set; }
-
- ///
- /// Serializes the object to an XML node
- ///
- internal XElement XmlSerialize(XElement result)
- {
- if( null != Id )
- {
- result.Add(new XElement("id", Id) );
- }
- if( null != Username )
- {
- result.Add(new XElement("username", Username) );
- }
- if( null != FirstName )
- {
- result.Add(new XElement("firstName", FirstName) );
- }
- if( null != LastName )
- {
- result.Add(new XElement("lastName", LastName) );
- }
- if( null != Email )
- {
- result.Add(new XElement("email", Email) );
- }
- if( null != Password )
- {
- result.Add(new XElement("password", Password) );
- }
- if( null != Phone )
- {
- result.Add(new XElement("phone", Phone) );
- }
- if( null != UserStatus )
- {
- result.Add(new XElement("userStatus", UserStatus) );
- }
- return result;
- }
- ///
- /// Deserializes an XML node to an instance of User
- ///
- internal static User XmlDeserialize(string payload)
- {
- // deserialize to xml and use the overload to do the work
- return XmlDeserialize( XElement.Parse( payload ) );
- }
- internal static User XmlDeserialize(XElement payload)
- {
- var result = new User();
- var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e);
- long? resultId;
- if (deserializeId(payload, "id", out resultId))
- {
- result.Id = resultId;
- }
- var deserializeUsername = XmlSerialization.ToDeserializer(e => (string)e);
- string resultUsername;
- if (deserializeUsername(payload, "username", out resultUsername))
- {
- result.Username = resultUsername;
- }
- var deserializeFirstName = XmlSerialization.ToDeserializer(e => (string)e);
- string resultFirstName;
- if (deserializeFirstName(payload, "firstName", out resultFirstName))
- {
- result.FirstName = resultFirstName;
- }
- var deserializeLastName = XmlSerialization.ToDeserializer(e => (string)e);
- string resultLastName;
- if (deserializeLastName(payload, "lastName", out resultLastName))
- {
- result.LastName = resultLastName;
- }
- var deserializeEmail = XmlSerialization.ToDeserializer(e => (string)e);
- string resultEmail;
- if (deserializeEmail(payload, "email", out resultEmail))
- {
- result.Email = resultEmail;
- }
- var deserializePassword = XmlSerialization.ToDeserializer(e => (string)e);
- string resultPassword;
- if (deserializePassword(payload, "password", out resultPassword))
- {
- result.Password = resultPassword;
- }
- var deserializePhone = XmlSerialization.ToDeserializer(e => (string)e);
- string resultPhone;
- if (deserializePhone(payload, "phone", out resultPhone))
- {
- result.Phone = resultPhone;
- }
- var deserializeUserStatus = XmlSerialization.ToDeserializer(e => (int?)e);
- int? resultUserStatus;
- if (deserializeUserStatus(payload, "userStatus", out resultUserStatus))
- {
- result.UserStatus = resultUserStatus;
- }
- return result;
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs b/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs
index 45cec452f..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs
+++ b/Samples/1a-code-generation-minimal/Client/Models/XmlSerialization.cs
@@ -1,89 +1 @@
-namespace Petstore
-{
- using System.Collections;
- using System.Collections.Generic;
- using System.Xml;
- using System.Xml.Linq;
- internal static class XmlSerialization
- {
- internal delegate bool XmlRootDeserializer( XElement root, out T result );
- internal delegate bool XmlDeserializer( XElement parent, string propertyName, out T result );
- internal static XmlRootDeserializer Root( XmlDeserializer deserializer ) =>
- (XElement root, out T result) => deserializer(new XElement("artificialRoot", root), root.Name.LocalName, out result);
- private static XmlDeserializer Unroot( XmlRootDeserializer deserializer )
- {
- return (XElement parent, string propertyName, out T result) => {
- result = default(T);
- var element = parent.Element(propertyName);
- if (element == null)
- {
- return false;
- }
- return deserializer(element, out result);
- };
- }
- private static XmlRootDeserializer ToRootDeserializer( System.Func unsafeDeserializer )
- => (XElement root, out T result) => {
- try
- {
- result = unsafeDeserializer(root);
- return true;
- }
- catch
- {
- result = default(T);
- return false;
- }};
- internal static XmlDeserializer ToDeserializer( System.Func unsafeDeserializer )
- => Unroot(ToRootDeserializer(unsafeDeserializer));
- internal static XmlDeserializer> CreateListXmlDeserializer( XmlDeserializer elementDeserializer, string elementTagName = null /*if isWrapped = false*/ )
- {
- if (elementTagName != null)
- {
- // create non-wrapped deserializer and forward
- var slave = CreateListXmlDeserializer( elementDeserializer );
- return (XElement parent, string propertyName, out IList result) => {
- result = null;
- var wrapper = parent.Element(propertyName);
- return wrapper != null && slave(wrapper, elementTagName, out result);
- };
- }
- var rootElementDeserializer = Root(elementDeserializer);
- return (XElement parent, string propertyName, out IList result) => {
- result = new List();
- foreach (var element in parent.Elements(propertyName))
- {
- T elementResult;
- if (!rootElementDeserializer(element, out elementResult))
- {
- return false;
- }
- result.Add(elementResult);
- }
- return true;
- };
- }
- internal static XmlDeserializer> CreateDictionaryXmlDeserializer( XmlDeserializer elementDeserializer )
- {
- return (XElement parent, string propertyName, out IDictionary result) => {
- result = null;
- var childElement = parent.Element(propertyName);
- if (childElement == null)
- {
- return false;
- }
- result = new Dictionary();
- foreach (var element in childElement.Elements())
- {
- T elementResult;
- if (!elementDeserializer(childElement, element.Name.LocalName, out elementResult))
- {
- return false;
- }
- result.Add(element.Name.LocalName, elementResult);
- }
- return true;
- };
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs b/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs
index 6d8f5c437..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs
+++ b/Samples/1a-code-generation-minimal/Client/SwaggerPetstore.cs
@@ -1,2946 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Serialization;
- using Models;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// This is a sample server Petstore server. You can find out more about
- /// Swagger at <a
- /// href="http://swagger.io">http://swagger.io</a> or on
- /// irc.freenode.net, #swagger. For this sample, you can use the api key
- /// "special-key" to test the authorization filters
- ///
- public partial class SwaggerPetstore : ServiceClient, ISwaggerPetstore
- {
- ///
- /// The base URI of the service.
- ///
- public System.Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets json serialization settings.
- ///
- public JsonSerializerSettings SerializationSettings { get; private set; }
-
- ///
- /// Gets or sets json deserialization settings.
- ///
- public JsonSerializerSettings DeserializationSettings { get; private set; }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- public SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- public SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (baseUri == null)
- {
- throw new System.ArgumentNullException("baseUri");
- }
- BaseUri = baseUri;
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
- {
- if (baseUri == null)
- {
- throw new System.ArgumentNullException("baseUri");
- }
- BaseUri = baseUri;
- }
-
- ///
- /// An optional partial-method to perform custom initialization.
- ///
- partial void CustomInitialize();
- ///
- /// Initializes client properties.
- ///
- private void Initialize()
- {
- BaseUri = new System.Uri("http://petstore.swagger.io/v2");
- SerializationSettings = new JsonSerializerSettings
- {
- Formatting = Newtonsoft.Json.Formatting.Indented,
- DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
- DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
- NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
- ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
- ContractResolver = new ReadOnlyJsonContractResolver(),
- Converters = new List
- {
- new Iso8601TimeSpanConverter()
- }
- };
- DeserializationSettings = new JsonSerializerSettings
- {
- DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
- DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
- NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
- ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
- ContractResolver = new ReadOnlyJsonContractResolver(),
- Converters = new List
- {
- new Iso8601TimeSpanConverter()
- }
- };
- CustomInitialize();
- }
- ///
- /// Fake endpoint to test byte array in body parameter for adding a new pet to
- /// the store
- ///
- ///
- /// Pet object in the form of byte array
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task AddPetUsingByteArrayWithHttpMessagesAsync(string body = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "AddPetUsingByteArray", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 405)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Add a new pet to the store
- ///
- ///
- /// Adds a new pet to the store. You may receive an HTTP invalid input if your
- /// pet is invalid.
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task AddPetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (body != null)
- {
- body.Validate();
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "AddPet", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 405)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Update an existing pet
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task UpdatePetWithHttpMessagesAsync(Pet body = default(Pet), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (body != null)
- {
- body.Validate();
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "UpdatePet", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("PUT");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 405 && (int)_statusCode != 404 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Finds Pets by status
- ///
- ///
- /// Multiple status values can be provided with comma seperated strings
- ///
- ///
- /// Status values that need to be considered for filter
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task>> FindPetsByStatusWithHttpMessagesAsync(IList status = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("status", status);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "FindPetsByStatus", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByStatus").ToString();
- List _queryParameters = new List();
- if (status != null)
- {
- _queryParameters.Add(string.Format("status={0}", System.Uri.EscapeDataString(string.Join(",", status))));
- }
- if (_queryParameters.Count > 0)
- {
- _url += "?" + string.Join("&", _queryParameters);
- }
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse>();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- IList _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), null))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Finds Pets by tags
- ///
- ///
- /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2,
- /// tag3 for testing.
- ///
- ///
- /// Tags to filter by
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task>> FindPetsByTagsWithHttpMessagesAsync(IList tags = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("tags", tags);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "FindPetsByTags", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/findByTags").ToString();
- List _queryParameters = new List();
- if (tags != null)
- {
- _queryParameters.Add(string.Format("tags={0}", System.Uri.EscapeDataString(string.Join(",", tags))));
- }
- if (_queryParameters.Count > 0)
- {
- _url += "?" + string.Join("&", _queryParameters);
- }
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse>();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- IList _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), null))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Fake endpoint to test byte array return by 'Find pet by ID'
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
- /// error conditions
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task> FindPetsWithByteArrayWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("petId", petId);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "FindPetsWithByteArray", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString();
- _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"')));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- string _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Find pet by ID
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
- /// error conditions
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task> GetPetByIdWithHttpMessagesAsync(long petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("petId", petId);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetPetById", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString();
- _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"')));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- Pet _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Updates a pet in the store with form data
- ///
- ///
- /// ID of pet that needs to be updated
- ///
- ///
- /// Updated name of the pet
- ///
- ///
- /// Updated status of the pet
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task UpdatePetWithFormWithHttpMessagesAsync(string petId, string name = default(string), string status = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (petId == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "petId");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("petId", petId);
- tracingParameters.Add("name", name);
- tracingParameters.Add("status", status);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "UpdatePetWithForm", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString();
- _url = _url.Replace("{petId}", System.Uri.EscapeDataString(petId));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- List> values = new List>();
- if(name != null)
- {
- values.Add("name", name);
- }
- if(status != null)
- {
- values.Add("status", status);
- }
- FormUrlEncodedContent _formContent = new FormUrlEncodedContent(values);
- _httpRequest.Content = _formContent;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 405)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Deletes a pet
- ///
- ///
- /// Pet id to delete
- ///
- ///
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task DeletePetWithHttpMessagesAsync(long petId, string apiKey = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("apiKey", apiKey);
- tracingParameters.Add("petId", petId);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "DeletePet", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}").ToString();
- _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"')));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("DELETE");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
- if (apiKey != null)
- {
- if (_httpRequest.Headers.Contains("api_key"))
- {
- _httpRequest.Headers.Remove("api_key");
- }
- _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey);
- }
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// uploads an image
- ///
- ///
- /// ID of pet to update
- ///
- ///
- /// Additional data to pass to server
- ///
- ///
- /// file to upload
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task UploadFileWithHttpMessagesAsync(long petId, string additionalMetadata = default(string), Stream file = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("petId", petId);
- tracingParameters.Add("additionalMetadata", additionalMetadata);
- tracingParameters.Add("file", file);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "UploadFile", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pet/{petId}/uploadImage").ToString();
- _url = _url.Replace("{petId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(petId, SerializationSettings).Trim('"')));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- MultipartFormDataContent _multiPartContent = new MultipartFormDataContent();
- if (additionalMetadata != null)
- {
- StringContent _additionalMetadata = new StringContent(additionalMetadata, System.Text.Encoding.UTF8);
- _multiPartContent.Add(_additionalMetadata, "additionalMetadata");
- }
- if (file != null)
- {
- StreamContent _file = new StreamContent(file);
- _file.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
- FileStream _fileAsFileStream = file as FileStream;
- if (_fileAsFileStream != null)
- {
- ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-data");
- _contentDispositionHeaderValue.Name = "file";
- _contentDispositionHeaderValue.FileName = _fileAsFileStream.Name;
- _file.Headers.ContentDisposition = _contentDispositionHeaderValue;
- }
- _multiPartContent.Add(_file, "file");
- }
- _httpRequest.Content = _multiPartContent;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if (!_httpResponse.IsSuccessStatusCode)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Returns pet inventories by status
- ///
- ///
- /// Returns a map of status codes to quantities
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task>> GetInventoryWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetInventory", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/inventory").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse>();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- IDictionary _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => (int?)e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Place an order for a pet
- ///
- ///
- /// order placed for purchasing the pet
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task> PlaceOrderWithHttpMessagesAsync(Order body = default(Order), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "PlaceOrder", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- Order _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Find purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value <= 5 or > 10. Other
- /// values will generated exceptions
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task> GetOrderByIdWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (orderId == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "orderId");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("orderId", orderId);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetOrderById", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString();
- _url = _url.Replace("{orderId}", System.Uri.EscapeDataString(orderId));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- Order _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Delete purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value < 1000. Anything above
- /// 1000 or nonintegers will generate API errors
- ///
- ///
- /// ID of the order that needs to be deleted
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task DeleteOrderWithHttpMessagesAsync(string orderId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (orderId == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "orderId");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("orderId", orderId);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "DeleteOrder", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "store/order/{orderId}").ToString();
- _url = _url.Replace("{orderId}", System.Uri.EscapeDataString(orderId));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("DELETE");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Create user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// Created user object
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task CreateUserWithHttpMessagesAsync(User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "CreateUser", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if (!_httpResponse.IsSuccessStatusCode)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// List of user object
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task CreateUsersWithArrayInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithArrayInput", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithArray").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if (!_httpResponse.IsSuccessStatusCode)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// List of user object
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task CreateUsersWithListInputWithHttpMessagesAsync(IList body = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "CreateUsersWithListInput", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/createWithList").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("POST");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if (!_httpResponse.IsSuccessStatusCode)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Logs user into the system
- ///
- ///
- /// The user name for login
- ///
- ///
- /// The password for login in clear text
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task> LoginUserWithHttpMessagesAsync(string username = default(string), string password = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("username", username);
- tracingParameters.Add("password", password);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "LoginUser", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/login").ToString();
- List _queryParameters = new List();
- if (username != null)
- {
- _queryParameters.Add(string.Format("username={0}", System.Uri.EscapeDataString(username)));
- }
- if (password != null)
- {
- _queryParameters.Add(string.Format("password={0}", System.Uri.EscapeDataString(password)));
- }
- if (_queryParameters.Count > 0)
- {
- _url += "?" + string.Join("&", _queryParameters);
- }
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- string _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Logs out current logged in user session
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task LogoutUserWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "LogoutUser", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/logout").ToString();
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if (!_httpResponse.IsSuccessStatusCode)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Get user by user name
- ///
- ///
- /// The name that needs to be fetched. Use user1 for testing.
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task> GetUserByNameWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (username == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "username");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("username", username);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "GetUserByName", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString();
- _url = _url.Replace("{username}", System.Uri.EscapeDataString(username));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("GET");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 200 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- // Deserialize Response
- if ((int)_statusCode == 200)
- {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- User _tmp_ = null;
- if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" &&
- XmlSerialization.Root(XmlSerialization.ToDeserializer(e => User.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_))
- {
- _result.Body = _tmp_;
- }
- else
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
- }
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
- }
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Updated user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// name that need to be deleted
- ///
- ///
- /// Updated user object
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task UpdateUserWithHttpMessagesAsync(string username, User body = default(User), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (username == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "username");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("username", username);
- tracingParameters.Add("body", body);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "UpdateUser", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString();
- _url = _url.Replace("{username}", System.Uri.EscapeDataString(username));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("PUT");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- if(body != null)
- {
- _requestContent = SafeJsonConvert.SerializeObject(body, SerializationSettings);
- _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
- _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
- }
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- ///
- /// Delete user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The name that needs to be deleted
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task DeleteUserWithHttpMessagesAsync(string username, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- if (username == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "username");
- }
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("username", username);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "DeleteUser", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "user/{username}").ToString();
- _url = _url.Replace("{username}", System.Uri.EscapeDataString(username));
- // Create HTTP transport objects
- var _httpRequest = new HttpRequestMessage();
- HttpResponseMessage _httpResponse = null;
- _httpRequest.Method = new HttpMethod("DELETE");
- _httpRequest.RequestUri = new System.Uri(_url);
- // Set Headers
-
-
- if (customHeaders != null)
- {
- foreach(var _header in customHeaders)
- {
- if (_httpRequest.Headers.Contains(_header.Key))
- {
- _httpRequest.Headers.Remove(_header.Key);
- }
- _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
- }
- }
-
- // Serialize Request
- string _requestContent = null;
- // Send Request
- if (_shouldTrace)
- {
- ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
- }
- cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
- if (_shouldTrace)
- {
- ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
- }
- HttpStatusCode _statusCode = _httpResponse.StatusCode;
- cancellationToken.ThrowIfCancellationRequested();
- string _responseContent = null;
- if ((int)_statusCode != 404 && (int)_statusCode != 400)
- {
- var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
- if (_httpResponse.Content != null) {
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- }
- else {
- _responseContent = string.Empty;
- }
- ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
- ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
- if (_shouldTrace)
- {
- ServiceClientTracing.Error(_invocationId, ex);
- }
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw ex;
- }
- // Create Result
- var _result = new HttpOperationResponse();
- _result.Request = _httpRequest;
- _result.Response = _httpResponse;
- if (_shouldTrace)
- {
- ServiceClientTracing.Exit(_invocationId, _result);
- }
- return _result;
- }
-
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs b/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs
index 6167ed58b..9d6cafc2c 100644
--- a/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs
+++ b/Samples/1a-code-generation-minimal/Client/SwaggerPetstoreExtensions.cs
@@ -1,839 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace Petstore
-{
- using Models;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- /// Extension methods for SwaggerPetstore.
- ///
- public static partial class SwaggerPetstoreExtensions
- {
- ///
- /// Fake endpoint to test byte array in body parameter for adding a new pet to
- /// the store
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet object in the form of byte array
- ///
- public static void AddPetUsingByteArray(this ISwaggerPetstore operations, string body = default(string))
- {
- operations.AddPetUsingByteArrayAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Fake endpoint to test byte array in body parameter for adding a new pet to
- /// the store
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet object in the form of byte array
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task AddPetUsingByteArrayAsync(this ISwaggerPetstore operations, string body = default(string), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.AddPetUsingByteArrayWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Add a new pet to the store
- ///
- ///
- /// Adds a new pet to the store. You may receive an HTTP invalid input if your
- /// pet is invalid.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- public static void AddPet(this ISwaggerPetstore operations, Pet body = default(Pet))
- {
- operations.AddPetAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Add a new pet to the store
- ///
- ///
- /// Adds a new pet to the store. You may receive an HTTP invalid input if your
- /// pet is invalid.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task AddPetAsync(this ISwaggerPetstore operations, Pet body = default(Pet), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.AddPetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Update an existing pet
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- public static void UpdatePet(this ISwaggerPetstore operations, Pet body = default(Pet))
- {
- operations.UpdatePetAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Update an existing pet
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet object that needs to be added to the store
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task UpdatePetAsync(this ISwaggerPetstore operations, Pet body = default(Pet), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.UpdatePetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Finds Pets by status
- ///
- ///
- /// Multiple status values can be provided with comma seperated strings
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Status values that need to be considered for filter
- ///
- public static IList FindPetsByStatus(this ISwaggerPetstore operations, IList status = default(IList))
- {
- return operations.FindPetsByStatusAsync(status).GetAwaiter().GetResult();
- }
-
- ///
- /// Finds Pets by status
- ///
- ///
- /// Multiple status values can be provided with comma seperated strings
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Status values that need to be considered for filter
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task> FindPetsByStatusAsync(this ISwaggerPetstore operations, IList status = default(IList), CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.FindPetsByStatusWithHttpMessagesAsync(status, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Finds Pets by tags
- ///
- ///
- /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2,
- /// tag3 for testing.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Tags to filter by
- ///
- public static IList FindPetsByTags(this ISwaggerPetstore operations, IList tags = default(IList))
- {
- return operations.FindPetsByTagsAsync(tags).GetAwaiter().GetResult();
- }
-
- ///
- /// Finds Pets by tags
- ///
- ///
- /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2,
- /// tag3 for testing.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Tags to filter by
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task> FindPetsByTagsAsync(this ISwaggerPetstore operations, IList tags = default(IList), CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.FindPetsByTagsWithHttpMessagesAsync(tags, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Fake endpoint to test byte array return by 'Find pet by ID'
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
- /// error conditions
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- public static string FindPetsWithByteArray(this ISwaggerPetstore operations, long petId)
- {
- return operations.FindPetsWithByteArrayAsync(petId).GetAwaiter().GetResult();
- }
-
- ///
- /// Fake endpoint to test byte array return by 'Find pet by ID'
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
- /// error conditions
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task FindPetsWithByteArrayAsync(this ISwaggerPetstore operations, long petId, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.FindPetsWithByteArrayWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Find pet by ID
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
- /// error conditions
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- public static Pet GetPetById(this ISwaggerPetstore operations, long petId)
- {
- return operations.GetPetByIdAsync(petId).GetAwaiter().GetResult();
- }
-
- ///
- /// Find pet by ID
- ///
- ///
- /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
- /// error conditions
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetPetByIdAsync(this ISwaggerPetstore operations, long petId, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetPetByIdWithHttpMessagesAsync(petId, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Updates a pet in the store with form data
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be updated
- ///
- ///
- /// Updated name of the pet
- ///
- ///
- /// Updated status of the pet
- ///
- public static void UpdatePetWithForm(this ISwaggerPetstore operations, string petId, string name = default(string), string status = default(string))
- {
- operations.UpdatePetWithFormAsync(petId, name, status).GetAwaiter().GetResult();
- }
-
- ///
- /// Updates a pet in the store with form data
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be updated
- ///
- ///
- /// Updated name of the pet
- ///
- ///
- /// Updated status of the pet
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task UpdatePetWithFormAsync(this ISwaggerPetstore operations, string petId, string name = default(string), string status = default(string), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.UpdatePetWithFormWithHttpMessagesAsync(petId, name, status, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Deletes a pet
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet id to delete
- ///
- ///
- ///
- public static void DeletePet(this ISwaggerPetstore operations, long petId, string apiKey = default(string))
- {
- operations.DeletePetAsync(petId, apiKey).GetAwaiter().GetResult();
- }
-
- ///
- /// Deletes a pet
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Pet id to delete
- ///
- ///
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task DeletePetAsync(this ISwaggerPetstore operations, long petId, string apiKey = default(string), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.DeletePetWithHttpMessagesAsync(petId, apiKey, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// uploads an image
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet to update
- ///
- ///
- /// Additional data to pass to server
- ///
- ///
- /// file to upload
- ///
- public static void UploadFile(this ISwaggerPetstore operations, long petId, string additionalMetadata = default(string), Stream file = default(Stream))
- {
- operations.UploadFileAsync(petId, additionalMetadata, file).GetAwaiter().GetResult();
- }
-
- ///
- /// uploads an image
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet to update
- ///
- ///
- /// Additional data to pass to server
- ///
- ///
- /// file to upload
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task UploadFileAsync(this ISwaggerPetstore operations, long petId, string additionalMetadata = default(string), Stream file = default(Stream), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.UploadFileWithHttpMessagesAsync(petId, additionalMetadata, file, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Returns pet inventories by status
- ///
- ///
- /// Returns a map of status codes to quantities
- ///
- ///
- /// The operations group for this extension method.
- ///
- public static IDictionary GetInventory(this ISwaggerPetstore operations)
- {
- return operations.GetInventoryAsync().GetAwaiter().GetResult();
- }
-
- ///
- /// Returns pet inventories by status
- ///
- ///
- /// Returns a map of status codes to quantities
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task> GetInventoryAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetInventoryWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Place an order for a pet
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// order placed for purchasing the pet
- ///
- public static Order PlaceOrder(this ISwaggerPetstore operations, Order body = default(Order))
- {
- return operations.PlaceOrderAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Place an order for a pet
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// order placed for purchasing the pet
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task PlaceOrderAsync(this ISwaggerPetstore operations, Order body = default(Order), CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.PlaceOrderWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Find purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value <= 5 or > 10. Other
- /// values will generated exceptions
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- public static Order GetOrderById(this ISwaggerPetstore operations, string orderId)
- {
- return operations.GetOrderByIdAsync(orderId).GetAwaiter().GetResult();
- }
-
- ///
- /// Find purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value <= 5 or > 10. Other
- /// values will generated exceptions
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of pet that needs to be fetched
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetOrderByIdAsync(this ISwaggerPetstore operations, string orderId, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetOrderByIdWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Delete purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value < 1000. Anything above
- /// 1000 or nonintegers will generate API errors
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of the order that needs to be deleted
- ///
- public static void DeleteOrder(this ISwaggerPetstore operations, string orderId)
- {
- operations.DeleteOrderAsync(orderId).GetAwaiter().GetResult();
- }
-
- ///
- /// Delete purchase order by ID
- ///
- ///
- /// For valid response try integer IDs with value < 1000. Anything above
- /// 1000 or nonintegers will generate API errors
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// ID of the order that needs to be deleted
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task DeleteOrderAsync(this ISwaggerPetstore operations, string orderId, CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.DeleteOrderWithHttpMessagesAsync(orderId, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Create user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Created user object
- ///
- public static void CreateUser(this ISwaggerPetstore operations, User body = default(User))
- {
- operations.CreateUserAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Create user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// Created user object
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task CreateUserAsync(this ISwaggerPetstore operations, User body = default(User), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.CreateUserWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// List of user object
- ///
- public static void CreateUsersWithArrayInput(this ISwaggerPetstore operations, IList body = default(IList))
- {
- operations.CreateUsersWithArrayInputAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// List of user object
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task CreateUsersWithArrayInputAsync(this ISwaggerPetstore operations, IList body = default(IList), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.CreateUsersWithArrayInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// List of user object
- ///
- public static void CreateUsersWithListInput(this ISwaggerPetstore operations, IList body = default(IList))
- {
- operations.CreateUsersWithListInputAsync(body).GetAwaiter().GetResult();
- }
-
- ///
- /// Creates list of users with given input array
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// List of user object
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task CreateUsersWithListInputAsync(this ISwaggerPetstore operations, IList body = default(IList), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.CreateUsersWithListInputWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Logs user into the system
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The user name for login
- ///
- ///
- /// The password for login in clear text
- ///
- public static string LoginUser(this ISwaggerPetstore operations, string username = default(string), string password = default(string))
- {
- return operations.LoginUserAsync(username, password).GetAwaiter().GetResult();
- }
-
- ///
- /// Logs user into the system
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The user name for login
- ///
- ///
- /// The password for login in clear text
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task LoginUserAsync(this ISwaggerPetstore operations, string username = default(string), string password = default(string), CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.LoginUserWithHttpMessagesAsync(username, password, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Logs out current logged in user session
- ///
- ///
- /// The operations group for this extension method.
- ///
- public static void LogoutUser(this ISwaggerPetstore operations)
- {
- operations.LogoutUserAsync().GetAwaiter().GetResult();
- }
-
- ///
- /// Logs out current logged in user session
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task LogoutUserAsync(this ISwaggerPetstore operations, CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.LogoutUserWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Get user by user name
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The name that needs to be fetched. Use user1 for testing.
- ///
- public static User GetUserByName(this ISwaggerPetstore operations, string username)
- {
- return operations.GetUserByNameAsync(username).GetAwaiter().GetResult();
- }
-
- ///
- /// Get user by user name
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The name that needs to be fetched. Use user1 for testing.
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task GetUserByNameAsync(this ISwaggerPetstore operations, string username, CancellationToken cancellationToken = default(CancellationToken))
- {
- using (var _result = await operations.GetUserByNameWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
- }
-
- ///
- /// Updated user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// name that need to be deleted
- ///
- ///
- /// Updated user object
- ///
- public static void UpdateUser(this ISwaggerPetstore operations, string username, User body = default(User))
- {
- operations.UpdateUserAsync(username, body).GetAwaiter().GetResult();
- }
-
- ///
- /// Updated user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// name that need to be deleted
- ///
- ///
- /// Updated user object
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task UpdateUserAsync(this ISwaggerPetstore operations, string username, User body = default(User), CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.UpdateUserWithHttpMessagesAsync(username, body, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- ///
- /// Delete user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The name that needs to be deleted
- ///
- public static void DeleteUser(this ISwaggerPetstore operations, string username)
- {
- operations.DeleteUserAsync(username).GetAwaiter().GetResult();
- }
-
- ///
- /// Delete user
- ///
- ///
- /// This can only be done by the logged in user.
- ///
- ///
- /// The operations group for this extension method.
- ///
- ///
- /// The name that needs to be deleted
- ///
- ///
- /// The cancellation token.
- ///
- public static async Task DeleteUserAsync(this ISwaggerPetstore operations, string username, CancellationToken cancellationToken = default(CancellationToken))
- {
- (await operations.DeleteUserWithHttpMessagesAsync(username, null, cancellationToken).ConfigureAwait(false)).Dispose();
- }
-
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs
index 0b8342e64..9d6cafc2c 100644
--- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs
+++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/ISwaggerPetstore.cs
@@ -1,100 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace cowstore
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Models;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
-
- ///
- ///
- public partial interface ISwaggerPetstore : System.IDisposable
- {
- ///
- /// The base URI of the service.
- ///
- System.Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets json serialization settings.
- ///
- JsonSerializerSettings SerializationSettings { get; }
-
- ///
- /// Gets or sets json deserialization settings.
- ///
- JsonSerializerSettings DeserializationSettings { get; }
-
- ///
- /// Credentials needed for the client to connect to Azure.
- ///
- ServiceClientCredentials Credentials { get; }
-
- ///
- /// Gets or sets the preferred language for the response.
- ///
- string AcceptLanguage { get; set; }
-
- ///
- /// Gets or sets the retry timeout in seconds for Long Running
- /// Operations. Default value is 30.
- ///
- int? LongRunningOperationRetryTimeout { get; set; }
-
- ///
- /// When set to true a unique x-ms-client-request-id value is generated
- /// and included in each request. Default is true.
- ///
- bool? GenerateClientRequestId { get; set; }
-
-
- ///
- /// List all pets
- ///
- ///
- /// How many items to return at one time (max 100)
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task,ListPetsHeadersInner>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Create a pet
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task CreatePetsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- /// Info for a specific pet
- ///
- ///
- /// The id of the pet to retrieve
- ///
- ///
- /// The headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- Task>> ShowPetByIdWithHttpMessagesAsync(string petId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
-
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs
index b9ab4bcbc..9d6cafc2c 100644
--- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs
+++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/Error.cs
@@ -1,62 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace cowstore.Models
-{
- using Microsoft.Rest;
- using Newtonsoft.Json;
- using System.Linq;
-
- public partial class Error
- {
- ///
- /// Initializes a new instance of the Error class.
- ///
- public Error()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the Error class.
- ///
- public Error(int code, string message)
- {
- Code = code;
- Message = message;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- ///
- [JsonProperty(PropertyName = "code")]
- public int Code { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "message")]
- public string Message { get; set; }
-
- ///
- /// Validate the object.
- ///
- ///
- /// Thrown if validation fails
- ///
- public virtual void Validate()
- {
- if (Message == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "Message");
- }
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs
index 732613f31..9d6cafc2c 100644
--- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs
+++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ErrorException.cs
@@ -1,57 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace cowstore.Models
-{
- using Microsoft.Rest;
-
- ///
- /// Exception thrown for an invalid response with Error information.
- ///
- public class ErrorException : RestException
- {
- ///
- /// Gets information about the associated HTTP request.
- ///
- public HttpRequestMessageWrapper Request { get; set; }
-
- ///
- /// Gets information about the associated HTTP response.
- ///
- public HttpResponseMessageWrapper Response { get; set; }
-
- ///
- /// Gets or sets the body object.
- ///
- public Error Body { get; set; }
-
- ///
- /// Initializes a new instance of the ErrorException class.
- ///
- public ErrorException()
- {
- }
-
- ///
- /// Initializes a new instance of the ErrorException class.
- ///
- /// The exception message.
- public ErrorException(string message)
- : this(message, null)
- {
- }
-
- ///
- /// Initializes a new instance of the ErrorException class.
- ///
- /// The exception message.
- /// Inner exception.
- public ErrorException(string message, System.Exception innerException)
- : base(message, innerException)
- {
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs
index 54fb59ddc..9d6cafc2c 100644
--- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs
+++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/ListPetsHeadersInner.cs
@@ -1,47 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace cowstore.Models
-{
- using Newtonsoft.Json;
- using System.Linq;
-
- ///
- /// Defines headers for listPets operation.
- ///
- public partial class ListPetsHeadersInner
- {
- ///
- /// Initializes a new instance of the ListPetsHeadersInner class.
- ///
- public ListPetsHeadersInner()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the ListPetsHeadersInner class.
- ///
- /// A link to the next page of responses
- public ListPetsHeadersInner(string xNext = default(string))
- {
- XNext = xNext;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- /// Gets or sets a link to the next page of responses
- ///
- [JsonProperty(PropertyName = "x-next")]
- public string XNext { get; set; }
-
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs
index d32527e2c..9d6cafc2c 100644
--- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs
+++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/Models/PetInner.cs
@@ -1,68 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace cowstore.Models
-{
- using Microsoft.Rest;
- using Newtonsoft.Json;
- using System.Linq;
-
- public partial class PetInner
- {
- ///
- /// Initializes a new instance of the PetInner class.
- ///
- public PetInner()
- {
- CustomInit();
- }
-
- ///
- /// Initializes a new instance of the PetInner class.
- ///
- public PetInner(long id, string name, string tag = default(string))
- {
- Id = id;
- Name = name;
- Tag = tag;
- CustomInit();
- }
-
- ///
- /// An initialization method that performs custom operations like setting defaults
- ///
- partial void CustomInit();
-
- ///
- ///
- [JsonProperty(PropertyName = "id")]
- public long Id { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "name")]
- public string Name { get; set; }
-
- ///
- ///
- [JsonProperty(PropertyName = "tag")]
- public string Tag { get; set; }
-
- ///
- /// Validate the object.
- ///
- ///
- /// Thrown if validation fails
- ///
- public virtual void Validate()
- {
- if (Name == null)
- {
- throw new ValidationException(ValidationRules.CannotBeNull, "Name");
- }
- }
- }
-}
+SRC
\ No newline at end of file
diff --git a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs
index 60211ca12..9d6cafc2c 100644
--- a/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs
+++ b/Samples/1b-code-generation-multilang/Azure.CSharp.Fluent/SwaggerPetstore.cs
@@ -1,772 +1 @@
-//
-// Code generated by Microsoft (R) AutoRest Code Generator.
-// Changes may cause incorrect behavior and will be lost if the code is
-// regenerated.
-//
-
-namespace cowstore
-{
- using Microsoft.Rest;
- using Microsoft.Rest.Azure;
- using Microsoft.Rest.Serialization;
- using Models;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Threading;
- using System.Threading.Tasks;
-
- public partial class SwaggerPetstore : ServiceClient, ISwaggerPetstore, IAzureClient
- {
- ///
- /// The base URI of the service.
- ///
- public System.Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets json serialization settings.
- ///
- public JsonSerializerSettings SerializationSettings { get; private set; }
-
- ///
- /// Gets or sets json deserialization settings.
- ///
- public JsonSerializerSettings DeserializationSettings { get; private set; }
-
- ///
- /// Credentials needed for the client to connect to Azure.
- ///
- public ServiceClientCredentials Credentials { get; private set; }
-
- ///
- /// Gets or sets the preferred language for the response.
- ///
- public string AcceptLanguage { get; set; }
-
- ///
- /// Gets or sets the retry timeout in seconds for Long Running Operations.
- /// Default value is 30.
- ///
- public int? LongRunningOperationRetryTimeout { get; set; }
-
- ///
- /// When set to true a unique x-ms-client-request-id value is generated and
- /// included in each request. Default is true.
- ///
- public bool? GenerateClientRequestId { get; set; }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- protected SwaggerPetstore(params DelegatingHandler[] handlers) : base(handlers)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- protected SwaggerPetstore(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
- {
- Initialize();
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- protected SwaggerPetstore(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (baseUri == null)
- {
- throw new System.ArgumentNullException("baseUri");
- }
- BaseUri = baseUri;
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- protected SwaggerPetstore(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
- {
- if (baseUri == null)
- {
- throw new System.ArgumentNullException("baseUri");
- }
- BaseUri = baseUri;
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public SwaggerPetstore(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public SwaggerPetstore(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
- {
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public SwaggerPetstore(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
- {
- if (baseUri == null)
- {
- throw new System.ArgumentNullException("baseUri");
- }
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- BaseUri = baseUri;
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// Initializes a new instance of the SwaggerPetstore class.
- ///
- ///
- /// Optional. The base URI of the service.
- ///
- ///
- /// Required. Credentials needed for the client to connect to Azure.
- ///
- ///
- /// Optional. The http client handler used to handle http transport.
- ///
- ///
- /// Optional. The delegating handlers to add to the http client pipeline.
- ///
- ///
- /// Thrown when a required parameter is null
- ///
- public SwaggerPetstore(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
- {
- if (baseUri == null)
- {
- throw new System.ArgumentNullException("baseUri");
- }
- if (credentials == null)
- {
- throw new System.ArgumentNullException("credentials");
- }
- BaseUri = baseUri;
- Credentials = credentials;
- if (Credentials != null)
- {
- Credentials.InitializeServiceClient(this);
- }
- }
-
- ///
- /// An optional partial-method to perform custom initialization.
- ///
- partial void CustomInitialize();
- ///
- /// Initializes client properties.
- ///
- private void Initialize()
- {
- BaseUri = new System.Uri("http://petstore.swagger.io/v1");
- AcceptLanguage = "en-US";
- LongRunningOperationRetryTimeout = 30;
- GenerateClientRequestId = true;
- SerializationSettings = new JsonSerializerSettings
- {
- Formatting = Newtonsoft.Json.Formatting.Indented,
- DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
- DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
- NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
- ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
- ContractResolver = new ReadOnlyJsonContractResolver(),
- Converters = new List
- {
- new Iso8601TimeSpanConverter()
- }
- };
- DeserializationSettings = new JsonSerializerSettings
- {
- DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
- DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
- NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
- ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
- ContractResolver = new ReadOnlyJsonContractResolver(),
- Converters = new List
- {
- new Iso8601TimeSpanConverter()
- }
- };
- CustomInitialize();
- DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
- }
- ///
- /// List all pets
- ///
- ///
- /// How many items to return at one time (max 100)
- ///
- ///
- /// Headers that will be added to request.
- ///
- ///
- /// The cancellation token.
- ///
- ///
- /// Thrown when the operation returned an invalid status code
- ///
- ///
- /// Thrown when unable to deserialize the response
- ///
- ///
- /// A response object containing the response body and response headers.
- ///
- public async Task,ListPetsHeadersInner>> ListPetsWithHttpMessagesAsync(int? limit = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- // Tracing
- bool _shouldTrace = ServiceClientTracing.IsEnabled;
- string _invocationId = null;
- if (_shouldTrace)
- {
- _invocationId = ServiceClientTracing.NextInvocationId.ToString();
- Dictionary tracingParameters = new Dictionary();
- tracingParameters.Add("limit", limit);
- tracingParameters.Add("cancellationToken", cancellationToken);
- ServiceClientTracing.Enter(_invocationId, this, "ListPets", tracingParameters);
- }
- // Construct URL
- var _baseUrl = BaseUri.AbsoluteUri;
- var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "pets").ToString();
- List _queryParameters = new List