{"action":"created","issue":{"url":"https://api.github.com/repos/NSwag/NSwag/issues/107","repository_url":"https://api.github.com/repos/NSwag/NSwag","labels_url":"https://api.github.com/repos/NSwag/NSwag/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/NSwag/NSwag/issues/107/comments","events_url":"https://api.github.com/repos/NSwag/NSwag/issues/107/events","html_url":"https://github.com/NSwag/NSwag/issues/107","id":154961914,"number":107,"title":"System.Net.HttpClient does not have a 'PatchAsync' built-in method.","user":{"login":"shaunol","id":228220,"avatar_url":"https://avatars.githubusercontent.com/u/228220?v=3","gravatar_id":"","url":"https://api.github.com/users/shaunol","html_url":"https://github.com/shaunol","followers_url":"https://api.github.com/users/shaunol/followers","following_url":"https://api.github.com/users/shaunol/following{/other_user}","gists_url":"https://api.github.com/users/shaunol/gists{/gist_id}","starred_url":"https://api.github.com/users/shaunol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaunol/subscriptions","organizations_url":"https://api.github.com/users/shaunol/orgs","repos_url":"https://api.github.com/users/shaunol/repos","events_url":"https://api.github.com/users/shaunol/events{/privacy}","received_events_url":"https://api.github.com/users/shaunol/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NSwag/NSwag/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/NSwag/NSwag/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-16T05:14:31Z","updated_at":"2016-05-22T20:26:27Z","closed_at":"2016-05-22T20:26:27Z","body":"The CSharp code generator ClientTemplate t4 template uses the `SwaggerOperationMethod` enum converted to a string to determine which http method and System.Net.HttpClient method to use when calling operations.\r\n\r\nThis means the C# HttpClient is used like so:\r\n\r\n```\r\nclient_.GetAsync\r\nclient_.PostAsync\r\nclient_.PutAsync\r\n```\r\n\r\nUnfortunately the System.Net.HttpClient class has no built-in `PatchAsync` method, therefore we need to provide a polyfill (via extension methods) or change the convention for emitting the method calls.\r\n\r\nSee: https://github.com/NSwag/NSwag/blob/master/src/NSwag.CodeGeneration/CodeGenerators/CSharp/Templates/ClientTemplate.tt#L106\r\n\r\nI don't have a solution at this time but am posting a work-around as seen here: http://stackoverflow.com/a/26218765/134869\r\n\r\n```csharp\r\npublic static async Task<HttpResponseMessage> PatchAsync(this HttpClient client, string requestUri, HttpContent content, CancellationToken cancellationToken)\r\n{\r\n    var method = new HttpMethod(\"PATCH\");\r\n    var request = new HttpRequestMessage(method, requestUri)\r\n    {\r\n        Content = content\r\n    };\r\n\r\n    var response = await client.SendAsync(request, cancellationToken);\r\n    return response;\r\n}\r\n```\r\n\r\nWork-around is not exhaustive of all possibilities (ie. no content in request/response). I have also not checked for existence of the other operations on the HttpClient class either.\r\n\r\nRight now this is causing invalid C# code to be generated when generating code from schemas' containing PATCH requests.\r\n\r\nCheers for the great library."},"comment":{"url":"https://api.github.com/repos/NSwag/NSwag/issues/comments/220854196","html_url":"https://github.com/NSwag/NSwag/issues/107#issuecomment-220854196","issue_url":"https://api.github.com/repos/NSwag/NSwag/issues/107","id":220854196,"user":{"login":"rsuter","id":2603405,"avatar_url":"https://avatars.githubusercontent.com/u/2603405?v=3","gravatar_id":"","url":"https://api.github.com/users/rsuter","html_url":"https://github.com/rsuter","followers_url":"https://api.github.com/users/rsuter/followers","following_url":"https://api.github.com/users/rsuter/following{/other_user}","gists_url":"https://api.github.com/users/rsuter/gists{/gist_id}","starred_url":"https://api.github.com/users/rsuter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsuter/subscriptions","organizations_url":"https://api.github.com/users/rsuter/orgs","repos_url":"https://api.github.com/users/rsuter/repos","events_url":"https://api.github.com/users/rsuter/events{/privacy}","received_events_url":"https://api.github.com/users/rsuter/received_events","type":"User","site_admin":false},"created_at":"2016-05-22T20:26:27Z","updated_at":"2016-05-22T20:26:27Z","body":"Fixed in https://github.com/NSwag/NSwag/commit/389caf4a1a309dd06cbeb2e24f539a45fe7277ec"}}
{"actor":{"display_login":"rsuter"}}