Giter Club home page Giter Club logo

webapitestclient's Introduction

WebApiTestClient

For ASP.Net Web API projects. Use to automatically generate a UI in the browser for testing the APIs.

  • Good for quickly testing your APIs as you develop them
  • Good for QA teams that need to test your API
  • Good for using web app automation tools like web driver or phantomjs for testing the API

How to use:

  1. Install the matthewcv.WebApiTestClient NuGet package into your Web API Project.
  2. If it's not already there, install the Microsoft.AspNet.WebApi.HelpPage NuGet Package.
  3. In your web app under /Ares/HelpPage/Views/Help there should be a view called Api.cshtml. Add this code to the bottom of that file:
     @section scripts
     {
    		<script type="text/javascript" src="/Scripts/WebApiTestClient.js"></script>
     }
    
    Pay careful attention to the src attribute in that script element there. If your API project is not at the root of the web host, you'll need to adjust it.
  4. Register the route. In your Global.asax or where ever you register your routes add this line: WebApiTestClient.WebApiTestClientHttpMessageHandler.RegisterRouteForTestClient(GlobalConfiguration.Configuration);. This route must be registered first before any other routes.
  5. Browse to one of the generated Help pages for an API. The WebApiTestClient will initialize automatically and after a moment you will see a "Test this API" link at the bottom rigt of the window if you click it, a UI will be generated that matches the inputs for that API. Fill them in and click the 'send request' button.
  • it uses handlebars to generate the UI. Handlebars is not included with the package. Rather, it loads it from CDNJS.
  • this is just an initial version and doesn't do very much. There may be bugs and it may not handle all your routes or parameters. You can add an issue for a bug or feature request or send a pull reqest on the GitHub repo.
  • right now it does need the WebApi Help page but later on, I'll remove that requirement.
  • it doesn't do any kind of validation right now so you can easily put bad inputs that could cause unexpected bahavior on the client or server.

webapitestclient's People

Contributors

matthewcv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.