├── .gitignore ├── LICENSE.md ├── README.md ├── WebApiTestClient ├── .nuget │ ├── NuGet.Config │ ├── NuGet.exe │ └── NuGet.targets ├── WebApiTestClient.sln └── WebApiTestClient │ ├── Areas │ └── HelpPage │ │ ├── TestClient.css │ │ └── Views │ │ └── Help │ │ └── DisplayTemplates │ │ ├── TestClientDialogs.cshtml.pp │ │ └── TestClientReferences.cshtml │ ├── Scripts │ └── WebApiTestClient.js │ ├── WebApiTestClient.1.1.2.nuspec │ ├── WebApiTestClient.csproj │ ├── WebApiTestClient.nuspec │ ├── WebApiTestOnHelpPage.1.2.2.nuspec │ ├── WebApiTestOnHelpPage.1.3.0.nuspec │ ├── WebApiTestOnHelpPage.1.3.4.nuspec │ ├── readme.txt │ └── tools │ ├── Install.ps1 │ └── Uninstall.ps1 └── docs └── images └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | *.user 4 | /TestResults 5 | *.vspscc 6 | *.vssscc 7 | deploy 8 | deploy/* 9 | *.suo 10 | *.cache 11 | *.docstates 12 | _ReSharper.* 13 | *.csproj.user 14 | *[Rr]e[Ss]harper.user 15 | _ReSharper.*/ 16 | packages/* 17 | artifacts/* 18 | msbuild.log 19 | PublishProfiles/ 20 | *.psess 21 | *.vsp 22 | *.pidb 23 | *.userprefs 24 | *DS_Store 25 | *.ncrunchsolution 26 | *.log 27 | *.vspx 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you 2 | may not use this file except in compliance with the License. You may 3 | obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 10 | implied. See the License for the specific language governing permissions 11 | and limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Web API Test Client 2 | 3 | ASP.NET Web API 在线测试工具,依赖说 ASP.NET Web API Help Page. 4 | 5 | ![demo](docs/images/demo.gif) 6 | 7 | 8 | forked form https://github.com/yaohuang/WebApiTestClient 9 | 10 | ## change log 11 | V1.2 work for ASP.NET Web API Help Page >=5.1, at 2014.6.18 12 | 13 | 14 | ## Documentation 15 | http://blogs.msdn.com/b/yaohuang1/archive/2012/12/04/10373804.aspx 16 | 17 | ## Get it on NuGet.org 18 | 19 | Install-Package WebApiTestOnHelpPage 20 | 21 | ## LICENSE 22 | [Apache 2.0 License](https://github.com/yaohuang/WebApiTestClient/blob/master/LICENSE.md) 23 | 24 | ## Building the package 25 | Open and build WebApiTestClient.sln. A NuGet package will be generated as part of the build process and it can be found under the bin folder. 26 | -------------------------------------------------------------------------------- /WebApiTestClient/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WebApiTestClient/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuchang/WebApiTestClient/8350903a6e6be3f5a3de9d5c068f6317b9bf7124/WebApiTestClient/.nuget/NuGet.exe -------------------------------------------------------------------------------- /WebApiTestClient/.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 30 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 31 | 32 | 33 | 34 | 35 | $(SolutionDir).nuget 36 | packages.config 37 | 38 | 39 | 40 | 41 | $(NuGetToolsPath)\nuget.exe 42 | @(PackageSource) 43 | 44 | "$(NuGetExePath)" 45 | mono --runtime=v4.0.30319 $(NuGetExePath) 46 | 47 | $(TargetDir.Trim('\\')) 48 | 49 | -RequireConsent 50 | 51 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " 52 | $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols 53 | 54 | 55 | 56 | RestorePackages; 57 | $(ResolveReferencesDependsOn); 58 | 59 | 60 | 61 | 62 | $(BuildDependsOn); 63 | BuildPackage; 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiTestClient", "WebApiTestClient\WebApiTestClient.csproj", "{55E16CDA-4832-43F8-822E-5BE81A9845C9}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{2FA01D6C-C367-4702-BBC0-60097A6CAAB3}" 7 | ProjectSection(SolutionItems) = preProject 8 | .nuget\NuGet.Config = .nuget\NuGet.Config 9 | .nuget\NuGet.exe = .nuget\NuGet.exe 10 | .nuget\NuGet.targets = .nuget\NuGet.targets 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {55E16CDA-4832-43F8-822E-5BE81A9845C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {55E16CDA-4832-43F8-822E-5BE81A9845C9}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {55E16CDA-4832-43F8-822E-5BE81A9845C9}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {55E16CDA-4832-43F8-822E-5BE81A9845C9}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/Areas/HelpPage/TestClient.css: -------------------------------------------------------------------------------- 1 | .httpMethod { 2 | width: 20%; 3 | } 4 | 5 | .uriPath { 6 | width: 70%; 7 | } 8 | 9 | .sampleArea { 10 | width: 95%; 11 | } 12 | 13 | #testClientButton { 14 | position: fixed; 15 | right: 0; 16 | bottom: 0; 17 | width: 150px; 18 | font-size: x-large; 19 | } 20 | 21 | select { 22 | margin-top: 10px; 23 | } 24 | 25 | .panel { 26 | max-height: 120px; 27 | overflow: auto; 28 | } 29 | 30 | .panel input { 31 | width: 150px; 32 | } 33 | 34 | .uriParameterLabel { 35 | width: 100px; 36 | float: left; 37 | border: none; 38 | } -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/Areas/HelpPage/Views/Help/DisplayTemplates/TestClientDialogs.cshtml.pp: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using $rootnamespace$.Areas.HelpPage.Models 3 | @model HelpPageApiModel 4 | 5 | @{ 6 | var description = Model.ApiDescription; 7 | string applicationPath = Request.ApplicationPath; 8 | if (!applicationPath.EndsWith("/")) 9 | { 10 | applicationPath += "/"; 11 | } 12 | } 13 | 14 | 15 |
16 | 17 | 18 |
19 |
URI parameters
20 |
21 |
22 |
23 | 24 | = 25 | 26 | 27 |
28 |
29 |
30 |
31 |
Headers | Add header 32 |
33 |
34 |
35 |
36 | 37 | : 38 | 39 | Delete 40 |
41 |
42 |
43 |
44 | Body
45 |
46 |
47 | Samples: 48 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |
56 |
Status
57 | 58 |
59 |
60 |
Headers
61 | 62 |
63 |
64 |
Body
65 | 66 |
67 |
68 | 69 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/Areas/HelpPage/Views/Help/DisplayTemplates/TestClientReferences.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Text.RegularExpressions 2 | 3 | 4 | @* Automatically grabs the installed version of JQuery/JQueryUI/KnockoutJS *@ 5 | @{var filePattern = @"(jquery-[0-9]+.[0-9]+.[0-9]+.js|jquery-ui-[0-9]+.[0-9]+.[0-9]+.js|knockout-[0-9]+.[0-9]+.[0-9]+.js)";} 6 | @foreach (var item in Directory.GetFiles(Server.MapPath(@"~/Scripts")).Where(f => Regex.IsMatch(f, filePattern))) 7 | { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/Scripts/WebApiTestClient.js: -------------------------------------------------------------------------------- 1 | var testClientModel; 2 | var emptyTestClientModel = 3 | { 4 | HttpMethod: '', 5 | UriPathTemplate: '', 6 | Samples: {}, 7 | UriParameters: [], 8 | BaseAddress: '/' 9 | }; 10 | 11 | (function () { 12 | function BuildUriPath(template, uriParameters) { 13 | var path = template; 14 | for (var i in uriParameters) { 15 | var parameter = uriParameters[i]; 16 | if (parameter.enabled()) { 17 | var parameterValue = parameter.value(); 18 | if (parameterValue != "") { 19 | var variableName = '{' + parameter.name + '}'; 20 | path = path.replace(variableName, parameterValue); 21 | } 22 | } 23 | else { 24 | path = RemoveUriParameter(path, parameter.name) 25 | } 26 | } 27 | 28 | // cleanup path 29 | path = path.replace("/?", "?"); 30 | path = path.replace("?&", "?"); 31 | 32 | // remove trailing '?' 33 | if (path.charAt(path.length - 1) == '?') { 34 | path = path.substr(0, path.length - 1); 35 | } 36 | // remove trailing '&' 37 | if (path.charAt(path.length - 1) == '&') { 38 | path = path.substr(0, path.length - 1); 39 | } 40 | 41 | return path; 42 | } 43 | 44 | function RemoveUriParameter(template, parameterToRemove) { 45 | var path = template; 46 | var urlParameter = '{' + parameterToRemove + '}'; 47 | var queryParameter = parameterToRemove + '=' + urlParameter; 48 | path = path.replace(queryParameter, ""); 49 | path = path.replace(urlParameter, ""); 50 | return path; 51 | } 52 | 53 | function TestClientViewModel(data) { 54 | var self = this; 55 | self.HttpMethod = ko.observable(data.HttpMethod); 56 | self.UriPathTemplate = data.UriPathTemplate; 57 | self.UriPath = ko.observable(self.UriPathTemplate); 58 | 59 | self.UriParameters = new Array(); 60 | for (var i in data.UriParameters) { 61 | var uriParameter = data.UriParameters[i]; 62 | var uriParameterValue = ko.observable(uriParameter.value); 63 | var parameterEnabled = ko.observable(true); 64 | uriParameterValue.subscribe(function () { 65 | self.UriPath(BuildUriPath(self.UriPathTemplate, self.UriParameters)); 66 | }); 67 | parameterEnabled.subscribe(function () { 68 | self.UriPath(BuildUriPath(self.UriPathTemplate, self.UriParameters)); 69 | }); 70 | self.UriParameters.push({ name: uriParameter.name, value: uriParameterValue, enabled: parameterEnabled }); 71 | } 72 | 73 | self.RequestHeaders = ko.observableArray(); 74 | 75 | self.RequestMediaType = ko.observable(); 76 | 77 | var sampleTypes = new Array(); 78 | for (var index in data.Samples) { 79 | sampleTypes.push(index); 80 | }; 81 | self.SampleTypes = sampleTypes; 82 | 83 | self.ShouldShowBody = ko.observable(sampleTypes.length > 0); 84 | 85 | self.RequestBody = ko.observable(); 86 | 87 | self.RequestMediaType.subscribe(function () { 88 | self.RequestBody(decodeSample(data.Samples[self.RequestMediaType()]) || ""); 89 | var headers = self.RequestHeaders; 90 | var mediaType = self.RequestMediaType(); 91 | if (mediaType && mediaType != "") { 92 | addOrReplaceHeader(headers, "content-type", mediaType); 93 | } 94 | }); 95 | 96 | self.RequestBody.subscribe(function () { 97 | var headers = self.RequestHeaders; 98 | var contentLengh = self.RequestBody().length; 99 | addOrReplaceHeader(headers, "content-length", contentLengh); 100 | }); 101 | 102 | self.addHeader = function () { 103 | self.RequestHeaders.splice(0, 0, { name: "", value: "" }); 104 | }; 105 | 106 | self.removeHeader = function (header) { 107 | self.RequestHeaders.remove(header); 108 | }; 109 | 110 | self.response = ko.observable(); 111 | 112 | self.sendRequest = function () { 113 | var uriPath = self.UriPath(); 114 | var http = "http://"; 115 | var https = "https://"; 116 | 117 | // Just take the entire uriPath if it's an absolute URI. 118 | var uri = (uriPath.slice(0, http.length) == http || uriPath.slice(0, https.length) == https) ? 119 | uriPath : 120 | data.BaseAddress + uriPath; 121 | 122 | var httpMethod = self.HttpMethod(); 123 | var headers = self.RequestHeaders(); 124 | var requestBody = self.ShouldShowBody() ? self.RequestBody() : null; 125 | SendRequest(httpMethod, uri, headers, requestBody, function (httpRequest) { 126 | var httpResponse = getHttpResponse(httpRequest); 127 | self.response(httpResponse); 128 | $("#testClientResponseDialog").dialog("open"); 129 | }); 130 | }; 131 | 132 | $("#testClientDialog").dialog({ 133 | autoOpen: false, 134 | height: "auto", 135 | width: "700", 136 | modal: true, 137 | open: function () { 138 | jQuery('.ui-widget-overlay').bind('click', function () { 139 | jQuery('#testClientDialog').dialog('close'); 140 | }) 141 | }, 142 | buttons: { 143 | "Send": function () { 144 | self.sendRequest(); 145 | } 146 | } 147 | }); 148 | 149 | $("#testClientResponseDialog").dialog({ 150 | autoOpen: false, 151 | height: "auto", 152 | width: "550", 153 | modal: true, 154 | open: function () { 155 | jQuery('.ui-widget-overlay').bind('click', function () { 156 | jQuery('#testClientResponseDialog').dialog('close'); 157 | }) 158 | } 159 | }); 160 | 161 | $("#testClientButton").click(function () { 162 | $("#testClientDialog").dialog("open"); 163 | }); 164 | } 165 | 166 | // Initiate the Knockout bindings 167 | var initialModel = testClientModel || emptyTestClientModel; 168 | ko.applyBindings(new TestClientViewModel(initialModel)); 169 | })(); 170 | 171 | function decodeSample(sampleString) { 172 | return unescape(sampleString).replace(/\+/gi, " ").replace(/\r\n/gi, "\n"); 173 | } 174 | 175 | function addOrReplaceHeader(headers, headerName, headerValue) { 176 | var headerList = headers(); 177 | for (var i in headerList) { 178 | if (headerList[i].name.toLowerCase() == headerName) { 179 | headers.replace(headerList[i], { name: headerList[i].name, value: headerValue }); 180 | return; 181 | } 182 | } 183 | headers.push({ name: headerName, value: headerValue }); 184 | } 185 | 186 | function SendRequest(httpMethod, url, requestHeaders, requestBody, handleResponse) { 187 | if (httpMethod.length == 0) { 188 | alert("HTTP Method should not be empty"); 189 | return false; 190 | } 191 | 192 | if (url.length == 0) { 193 | alert("Url should not be empty"); 194 | return false; 195 | } 196 | 197 | var httpRequest = new XMLHttpRequest(); 198 | try { 199 | httpRequest.open(httpMethod, encodeURI(url), false); 200 | } 201 | catch (e) { 202 | alert("Cannot send request. Check the security setting of your browser if you are sending request to a different domain."); 203 | return false; 204 | } 205 | 206 | try { 207 | for (var i in requestHeaders) { 208 | var header = requestHeaders[i]; 209 | httpRequest.setRequestHeader(header.name, header.value); 210 | } 211 | } catch (e) { 212 | alert("Invalid header."); 213 | return false; 214 | } 215 | 216 | httpRequest.onreadystatechange = function () { 217 | switch (this.readyState) { 218 | case 4: 219 | handleResponse(httpRequest); 220 | break; 221 | default: 222 | break; 223 | } 224 | } 225 | 226 | httpRequest.ontimeout = function () { 227 | alert("Request timed out."); 228 | } 229 | 230 | try { 231 | httpRequest.send(requestBody); 232 | } catch (e) { 233 | alert(e); 234 | return false; 235 | } 236 | 237 | return true; 238 | } 239 | 240 | function getHttpResponse(httpRequest) { 241 | var statusCode = httpRequest.status; 242 | var statusText = httpRequest.statusText; 243 | var responseHeaders = httpRequest.getAllResponseHeaders(); 244 | var rawResponse = httpRequest.responseText; 245 | 246 | // IE - #1450: sometimes returns 1223 when it should be 204 247 | if (statusCode === 1223) { 248 | statusCode = 204; 249 | statusText = "No Content"; 250 | } 251 | 252 | var responseStatus = statusCode + "/" + statusText; 253 | 254 | return { status: responseStatus, headers: responseHeaders, content: rawResponse }; 255 | } -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/WebApiTestClient.1.1.2.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WebApiTestClient 5 | 1.1.2 6 | A Simple Test Client for ASP.NET Web API 7 | yaohuang 8 | https://github.com/yaohuang/WebApiTestClient/blob/master/LICENSE.md 9 | https://github.com/yaohuang/WebApiTestClient 10 | true 11 | A simple Test Client built on top of ASP.NET Web API Help Page. 12 | A simple Test Client built on top of ASP.NET Web API Help Page. 13 | en-US 14 | ASP.NET Web API Test Client 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/WebApiTestClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {55E16CDA-4832-43F8-822E-5BE81A9845C9} 8 | Library 9 | Properties 10 | WebApiTestClient 11 | WebApiTestClient 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Designer 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/WebApiTestClient.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WebApiTestOnHelpPage 5 | 1.2 6 | ASP.NET Web API Test Client For Web API HelpPage 7 | wuchangx@gmail.com 8 | https://github.com/wuchang/WebApiTestClient/blob/master/LICENSE.md 9 | https://github.com/wuchang/WebApiTestClient 10 | false 11 | A simple Test Client built on top of ASP.NET Web API Help Page. 12 | A simple Test Client built on top of ASP.NET Web API Help Page. 13 | en-US 14 | ASP.NET Web API Test Client 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/WebApiTestOnHelpPage.1.2.2.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WebApiTestOnHelpPage 5 | 1.2.2 6 | ASP.NET Web API Test Client For Web API HelpPage 7 | wuchangx@gmail.com 8 | https://github.com/wuchang/WebApiTestClient/blob/master/LICENSE.md 9 | https://github.com/wuchang/WebApiTestClient 10 | false 11 | A simple Test Client built on top of ASP.NET Web API Help Page. 12 | A simple Test Client built on top of ASP.NET Web API Help Page. 13 | en-US 14 | ASP.NET Web API Test Client 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/WebApiTestOnHelpPage.1.3.0.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WebApiTestOnHelpPage 5 | 1.3.0 6 | ASP.NET Web API Test Client For Web API HelpPage 7 | wuchangx@gmail.com 8 | https://github.com/wuchang/WebApiTestClient/blob/master/LICENSE.md 9 | https://github.com/wuchang/WebApiTestClient 10 | false 11 | A simple Test Client built on top of ASP.NET Web API Help Page. 12 | A simple Test Client built on top of ASP.NET Web API Help Page. 13 | en-US 14 | ASP.NET Web API Test Client 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/WebApiTestOnHelpPage.1.3.4.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WebApiTestOnHelpPage 5 | 1.3.4 6 | ASP.NET Web API Test Client For Web API HelpPage 7 | wuchangx@gmail.com 8 | https://github.com/wuchang/WebApiTestClient/blob/master/LICENSE.md 9 | https://github.com/wuchang/WebApiTestClient 10 | false 11 | A simple Test Client built on top of ASP.NET Web API Help Page. 12 | A simple Test Client built on top of ASP.NET Web API Help Page. 13 | en-US 14 | ASP.NET Web API Test Client 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/readme.txt: -------------------------------------------------------------------------------- 1 | ------------------- 2 | Web API Test Client 3 | ------------------- 4 | A simple Test Client built on top of ASP.NET Web API Help Page. 5 | 6 | Upon installation, the package will automatically attempt to inject 7 | the following test client code into Areas\HelpPage\Views\Help\Api.cshtml 8 | @Html.DisplayForModel("TestClientDialogs") 9 | @Html.DisplayForModel("TestClientReferences") 10 | That's it. No additional setup required when it's completed successfully. -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/tools/Install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | $file = $project.ProjectItems.Item("Areas").ProjectItems.Item("HelpPage").ProjectItems.Item("Views").ProjectItems.Item("Help").ProjectItems.Item("Api.cshtml") 3 | if($file) { 4 | $file.Open() 5 | $file.Document.Activate() 6 | $file.Document.Selection.StartOfDocument() 7 | if(!$file.Document.MarkText("@Html.DisplayForModel(`"TestClientDialogs`")")) 8 | { 9 | $file.Document.ReplaceText("@model HelpPageApiModel", "@model HelpPageApiModel`n@section Scripts {`n @Html.DisplayForModel(`"TestClientDialogs`")`n @Html.DisplayForModel(`"TestClientReferences`")`n}") 10 | $file.Save() 11 | } 12 | else 13 | { 14 | $file.Document.ClearBookmarks() 15 | } 16 | } -------------------------------------------------------------------------------- /WebApiTestClient/WebApiTestClient/tools/Uninstall.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | $file = $project.ProjectItems.Item("Areas").ProjectItems.Item("HelpPage").ProjectItems.Item("Views").ProjectItems.Item("Help").ProjectItems.Item("Api.cshtml") 3 | if($file) { 4 | $file.Open() 5 | $file.Document.Activate() 6 | $file.Document.Selection.StartOfDocument() 7 | $file.Document.ReplaceText( "@model HelpPageApiModel`n@section Scripts {`n @Html.DisplayForModel(`"TestClientDialogs`")`n @Html.DisplayForModel(`"TestClientReferences`")`n}","@model HelpPageApiModel") 8 | $file.Save() 9 | } -------------------------------------------------------------------------------- /docs/images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuchang/WebApiTestClient/8350903a6e6be3f5a3de9d5c068f6317b9bf7124/docs/images/demo.gif --------------------------------------------------------------------------------