Giter Club home page Giter Club logo

catalyst-controller-swagger's Introduction

NAME

 Catalyst::Controller::Swagger

SYNOPSIS

 package MyApp::Controller::Root;
 use base 'Catalyst::Controller::Swagger';
 use Swagger qw(add_meta);

__PACKAGE__->config(
   swagger => {
     api_version  => '2.2.3',
     info          => {
       title       => 'test project',
       description => 'test description',
     },
   }
 };


 add_meta {
    action => 'test_one',
    params => [
      { name => 'start', type => 'integer' }
    ],
 };

sub test_one_base :Chained('/') :PathPart('test_one') :CaptureArgs(2) {
  my ( $self, $c ) = @_;
}

sub test_one :Chained('test_one_base') :PathPart('foo') :Args(1) :Swagger {
  my ($self, $c) = @_;
  $c->response->body("test_one");
}
# A swagger route can be flagged to be swagger with the :Swagger attribute
sub test_two :Local :Swagger {
  my ($self, $c) = @_;
  $c->response->body('test_two');
}

DESCRIPTION

Add swagger metadata to any Catalyst route. This module will expose an "api_docs" route which will contain JSON that is Swagger 1.2 compatible.

:Swagger Attribute

When this attribute is applied to an action metadata that is implicit to the route will be exposed to the api_docs route. The data that is exposed include the following: path, method, and route nickname. Any additional metadata that would need to be exposed would need to use the Swagger::add_meta function to associate it.

Here is an example of what the default swagger output looks like:

  {
    path         => '/test_two',
    operations   => [{
      method     => 'GET',
      summary    => '',
      notes      => '',
      type => '',
      nickname   => 'GET_/test_two',
      summary    => '',
    }],
  }

api_docs route

This is a route that is exposed that will output a JSON data structure that is Swagger 1.2 compatible.

Swagger::add_meta

The add_meta function allows a developer to associate other allowed swagger metadata. For example params would specify what sort of parameters a route would accept:

 add_meta {
    action => 'test_one', # name of route
    params => [
      { name => 'start', type => 'integer' }
    ],
 };

Swagger

For further information on Swagger and what it is see: http://www.swagger.io

CONTRIBUTING

The code for `catalyst-controller-swagger` is hosted on GitHub at:

  https://github.com/mediamath/catalyst-controller-swagger/

If you would like to contribute code, documentation, tests, or bugfixes, follow these steps:

 1. Fork the project on GitHub.
 2. Clone the fork to your local machine.
 3. Make your changes and push them back up to your GitHub account.
 4. Send a "pull request" with a brief description of your changes, and a link to a JIRA 
 ticket if there is one.

If you are unfamiliar with GitHub, start with their excellent documentation here:

https://help.github.com/articles/fork-a-repo

COPYRIGHT & LICENSE

Copyright 2015, Logan Bell & John Napiorkowski / MediaMath

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

catalyst-controller-swagger's People

Contributors

logie17 avatar pswaminathan avatar

Watchers

 avatar  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.