Sitelet https://web.archive.org/web/20210124213608/https://github.com/tma/wadl_generator
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 

README.markdown

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="/sitelet?url=http%3A%2F%2Fapigee.com%2F%26lt%3Buser%26gt%3B%2Fembed%2Fconsole%2F%26lt%3Bname%26gt%3B" 
          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

About

Simple WADL Generator targeted on REST APIs with optional Apigee Flavour

Resources

Packages

No packages published

Languages