0.0
No commit activity in last 3 years
No release in over 3 years
Simple WADL Generator targeted on REST APIs with optional Apigee Flavour
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

WADL Generator

Installation

# Gemfile
gem 'wadl_generator'

Usage / Example

config/routes.rb

namespace 'api' do
  namespace 'v1' do
    get 'description.:format' => 'base#description'
    resources :posts, :only => [:index, :show]
  end
end

app/controllers/api/v1/base_controller.rb

class Api::V1::BaseController < ApplicationController
  def description
    respond_to do |format|
      format.html do
        render :text => %q{<iframe src="http://apigee.com/<user>/embed/console/<name>" 
          width="100%" height="95%"></iframe>}
      end

      format.wadl do
        render :text => WADL::Generator.new(wadl_description, :apigee => true), 
          :content_type => 'application/xml'
      end
    end
  end

  private

  def wadl_description
    {
      :base => "#{request.url.gsub('/description.wadl', '')}",
      :resources => {
        'posts' => {
          :index => true,
          :index_formats => {
            :json => 'application/json',
          },
          :show => true,
          :show_formats => {
            :json => 'application/json',
            :html => 'application/html',
            :pdf => 'application/pdf',
          },
          :example_id => 28,
        },
        'categories' => {
          :index => true,
          :index_formats => {
            :json => 'application/json',
          },
        }
      }
    }
  end
end

Todos

  • Add tests

License

MIT License - Thomas Maurer