All Projects → fredwu → Api_taster

fredwu / Api_taster

A quick and easy way to visually test your Rails application's API.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Api taster

Awesome Django Rest Framework
💻😍Tools, processes and resources you need to create an awesome API with Django REST Framework
Stars: ✭ 689 (-6.51%)
Mutual labels:  api
Mtrans
Multi-source Translation
Stars: ✭ 711 (-3.53%)
Mutual labels:  api
Ppgo apiadmin
go-API-manage
Stars: ✭ 728 (-1.22%)
Mutual labels:  api
Graphql Framework Experiment
Code-First Type-Safe GraphQL Framework
Stars: ✭ 698 (-5.29%)
Mutual labels:  api
Opentelemetry Js
OpenTelemetry JavaScript Client
Stars: ✭ 700 (-5.02%)
Mutual labels:  api
Nodeapi
Simple RESTful API implementation on Node.js + MongoDB.
Stars: ✭ 719 (-2.44%)
Mutual labels:  api
Python Plexapi
Python bindings for the Plex API.
Stars: ✭ 682 (-7.46%)
Mutual labels:  api
Goinsta
Unofficial Instagram API written in Golang
Stars: ✭ 733 (-0.54%)
Mutual labels:  api
Java Almanac
The history and future of Java.
Stars: ✭ 710 (-3.66%)
Mutual labels:  api
Stein
Use Google Sheets as your no-setup database
Stars: ✭ 726 (-1.49%)
Mutual labels:  api
Instagram Web Api
🤳 Instagram Private Web API client for Node
Stars: ✭ 694 (-5.83%)
Mutual labels:  api
Wobike
Documentation of Bike Sharing APIs 🚴🛴🛵
Stars: ✭ 705 (-4.34%)
Mutual labels:  api
Json Ld.org
JSON for Linked Data
Stars: ✭ 722 (-2.04%)
Mutual labels:  api
Koa2 Api Scaffold
一个基于Koa2的轻量级RESTful API Server脚手架。
Stars: ✭ 694 (-5.83%)
Mutual labels:  api
Inkwell
It's a New Kind of Wrapper for Exposing LLVM (Safely)
Stars: ✭ 732 (-0.68%)
Mutual labels:  api
Iex Api
The IEX API provides any individual or academic, public or private institution looking to develop applications that require stock market data to access near real-time quote and trade data for all stocks trading on IEX.
Stars: ✭ 683 (-7.33%)
Mutual labels:  api
Tartiflette
GraphQL Engine built with Python 3.6+ / asyncio
Stars: ✭ 719 (-2.44%)
Mutual labels:  api
Glasscord
[BUGFIXES ONLY, SUPPORT WILL DROP MAR 1, 2021] Injecting composition effects into Electron applications!
Stars: ✭ 737 (+0%)
Mutual labels:  api
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+831.34%)
Mutual labels:  api
Sonoff Homekit
Make your Sonoff Switch compatible with Apple Homekit! 🎉
Stars: ✭ 722 (-2.04%)
Mutual labels:  api

ApiTaster endorse Build Status Dependency Status

NOTE

If you want to use this gem with Rails 3x/4.0 please specify version 0.7.0 in your Gemfile.

Version 0.8 of this gem is compatible only with Rails 4.1.

A quick and easy way to visually test your Rails application's API.

Why?

There are already many awesome API clients (such as Postman), so why reinvent the wheel?

API Taster compared to alternatives, have the following advantages:

  • API endpoints are automatically generated from your Rails routes definition
  • Defining params is as easy as defining routes
  • Params can be shared with your test factories

Usage

Add API Taster in your gemfile:

gem 'api_taster'

Mount API Taster, this will allow you to visit API Taster from within your app. For example:

Rails.application.routes.draw do
  mount ApiTaster::Engine => "/api_taster" if Rails.env.development?
end

In lib/api_tasters/routes.rb, define parameters for each API endpoint after the normal routes definition block. For example:

if Rails.env.development?
  ApiTaster.routes do
    desc 'Get a __list__ of users'
    get '/users'

    post '/users', {
      :user => {
        :name => 'Fred'
      }
    }

    get '/users/:id', {
      :id => 1
    }

    put '/users/:id', {
      :id => 1, :user => {
        :name => 'Awesome'
      }
    }

    delete '/users/:id', {
      :id => 1
    }
  end
end

You can change the default lib/api_tasters/routes.rb path by creating config/initializers/api_taster.rb with the content below:

ApiTaster.route_path = Rails.root.to_s + "/app/api_tasters" # just an example

Share Params with Test Factories

If you use a test factory such as FactoryGirl, you can require your test factories and share the params. For example in FactoryGirl you can use the attributes_for(:name_of_factory) method.

Custom Headers

If there are certain headers (such as auth token) that need to be present to consume an API endpoint, you may set then in APITaster.global_headers before APITaster.routes:

ApiTaster.global_headers = {
  'Authorization' => 'Token token=teGpfbVitpnUwm7qStf9'
}

ApiTaster.routes do
  # your route definitions
end

Global Params

If there are certain params (such as API version and auth token) that need to be present in every API endpoint, you may set them in ApiTaster.global_params before ApiTaster.routes:

ApiTaster.global_params = {
  :version    => 1,
  :auth_token => 'teGpfbVitpnUwm7qStf9'
}

ApiTaster.routes do
  # your route definitions
end

Commenting API Endpoints

Before each route definitions, you may use desc to add some comments. Markdown is supported.

desc 'Get a __list__ of users'
get '/users'

Metadata for API Endpoints

For each route definition, you may supply an optional third parameter (hash) as metadata:

get '/users', {}, { :meta => 'data' }

The metadata option is useful for passing in arbitrary data for a route definition. For example, you could specify response expectations so that your test suite could tap into them.

Metadata for every route definition are stored in ApiTaster::Route.metadata. Please read the source code to find out how to get metadata for a particular route.

Missing Route Definitions Detection

Instead of manually finding out which route definitions you need, API Taster provides a warning page that shows you all the missing definitions.

Obsolete / Mismatched Route Definitions Detection

APIs evolve - especially during the development stage. To keep ApiTaster.routes in sync with your route definitions, API Taster provides a warning page that shows you the definitions that are obsolete/mismatched therefore you could correct or remove them.

License

This gem is released under the MIT License.

Author

Fred Wu, originally built for Locomote.

Bitdeli Badge

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].