Coder Social home page Coder Social logo

swagger2's Introduction

NAME

Swagger2 - Swagger RESTful API Documentation

VERSION

0.66

DESCRIPTION

Swagger2 is a module for generating, parsing and transforming swagger API specification. It has support for reading swagger specification in JSON notation and as well YAML format.

Please read http://thorsen.pm/perl/programming/2015/07/05/mojolicious-swagger2.html for an introduction to Swagger and reasons for why you would to use it.

Mojolicious server side code generator

This distribution comes with a Mojolicious plugin, Mojolicious::Plugin::Swagger2, which can set up routes and perform input and output validation.

Mojolicious client side code generator

Swagger2 also comes with a Swagger2::Client generator, which converts the client spec to perl code in memory.

RECOMMENDED MODULES

SYNOPSIS

use Swagger2;
my $swagger = Swagger2->new("/path/to/api-spec.yaml");

# Access the raw specification values
print $swagger->api_spec->get("/swagger");

# Returns the specification as a POD document
print $swagger->pod->to_string;

ATTRIBUTES

api_spec

$pointer = $self->api_spec;
$self = $self->api_spec(Mojo::JSON::Pointer->new({}));

Holds a Mojo::JSON::Pointer object containing your API specification.

base_url

$mojo_url = $self->base_url;

Mojo::URL object that holds the location to the API endpoint. Note: This might also just be a dummy URL to http://example.com/.

specification

DEPRECATED. If you need to change this, then you probably want JSON::Validator instead.

tree

DEPRECATED. Use "api_spec" instead.

ua

$ua = $self->ua;
$self = $self->ua(Mojo::UserAgent->new);

A Mojo::UserAgent used to fetch remote documentation.

url

$mojo_url = $self->url;

Mojo::URL object that holds the location to the documentation file. This can be both a location on disk or an URL to a server. A remote resource will be fetched using Mojo::UserAgent.

METHODS

expand

$swagger = $self->expand;

This method returns a new Swagger2 object, where all the references are resolved.

load

$self = $self->load;
$self = $self->load($url);

Used to load the content from $url or "url". This method will try to guess the content type (JSON or YAML) by looking at the content of the $url.

new

$self = Swagger2->new($url);
$self = Swagger2->new(%attributes);
$self = Swagger2->new(\%attributes);

Object constructor.

parse

$self = $self->parse($text);

Used to parse $text instead of loading data from "url".

The type of input text can be either JSON or YAML. It will default to YAML, but parse the text as JSON if it starts with "{".

pod

$pod_object = $self->pod;

Returns a Swagger2::POD object.

to_string

$json = $self->to_string;
$json = $self->to_string("json");
$yaml = $self->to_string("yaml");

This method can transform this object into Swagger spec.

validate

@errors = $self->validate;

Will validate "api_spec" against Swagger RESTful API Documentation Specification, and return a list with all the errors found. See also "validate" in JSON::Validator.

COPYRIGHT AND LICENSE

Copyright (C) 2014-2015, Jan Henning Thorsen

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

AUTHOR

Jan Henning Thorsen - [email protected]

swagger2's People

Contributors

jeneric avatar kberov avatar leejo avatar mrenvoize avatar stephan48 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.