2017 © Pedro Peláez
 

library spec-generator

Woohoo Labs. Spec Generator

image

woohoolabs/spec-generator

Woohoo Labs. Spec Generator

  • Friday, March 17, 2017
  • by woohoolabs
  • Repository
  • 1 Watchers
  • 5 Stars
  • 56 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Woohoo Labs. Spec Generator

Generate various specifications (e.g. Swagger Spec 2.0) in perfect sync with your real code via object-oriented PHP!, (*1)

Introduction

This library aims to foster creating configurations and specifications which would be written in structured data formats (like JSON, XML, YML). Not only these files can grow extremely long, but they can easily become a nightmare from a maintenance point of view. For example, let's take the Swagger 2.0 specification: the documentation of an API with only a handful of resources can easily go over one thousand of lines. That's why it requires a great effort to have a good overview on the document., (*2)

Another problem is that the live software and its specification usually diverges from each other over time as the maintaining staff is too busy/negligent/forgetful to synchronize them. Woohoo Labs. Spec Generator tries to shorten the gap between them: the main idea is to generate documents supported by the glorious object-oriented features right from your application's code!, (*3)

When talking about creating documentations, you could ask what the point is in writing these documents by hand, when some of them (e.g. Swagger docs) could be generated by frameworks which use annotations for the definitions. While this is a valid point, there are yet some major drawbacks of this approach (it is called reverse-engineering): - It is not forward-engineering: Sometimes you need to design something before you ship it :) - Your specification/documentation will be fragmented: there won't be any single place to look for these definitions. That's why if you need to change something in multiple places then it won't be easy. - You won't benefit from the capabilities of PHP: You can't extend classes, can't read data from files or even constants, can't have code completion from your IDE etc. This undermines real consistency., (*4)

Features

  • Support for Swagger 2.0 API documentation
  • Different output formats (array, JSON, XML, YML)
  • Specification can be cached for improved performance

Basic Usage

Advanced Usage

Caching

use Doctrine\Common\Cache\MemcachedCache;
use WoohooLabs\SpecGenerator\Swagger2\SwaggerSpec;
use WoohooLabs\SpecGenerator\Swagger2\Info\Contact;
use WoohooLabs\SpecGenerator\Swagger2\Info\MitLicense;

$memcached = new \Memcached();
$memcached->addServer("localhost", 11211);
$cache = new MemcachedCache();
$cache->setMemcached($memcached);

SwaggerSpec::getSpecification(
    function(SwaggerSpec $swagger) {
        $info= Info::create()
            ->setTitle("API Title")
            ->setVersion("1.0.0")
            ->setDescription("API Description")
            ->setContact(new Contact("Sam Support", "123-456-789", "samsupport@example.com"))
            ->setLicense(new MitLicense())
        ;

        return $swagger
            ->setInfo($info)
            ->setBasePath("/")
            ->setConsumes(["application/json"])
            ->setSchemes(["http"])
            ->setProduces(["application/vnd.hal+json"])
            ->generate();
    },
    $cache     
);

License

The MIT License (MIT). Please see the License File for more information., (*5)

The Versions

17/03 2017

dev-master

9999999-dev

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

09/07 2016

0.5.0

0.5.0.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

29/06 2016

0.4.4

0.4.4.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

09/05 2015

0.4.3

0.4.3.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

04/05 2015

0.4.2

0.4.2.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

18/04 2015

0.4.1

0.4.1.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

16/04 2015

0.4.0

0.4.0.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

26/10 2014

0.3.2

0.3.2.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

25/10 2014

0.3.1

0.3.1.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.

23/10 2014

0.3

0.3.0.0

Woohoo Labs. Spec Generator

  Sources   Download

MIT

The Requires

 

by Máté Kocsis

generator swagger specification woohoo labs.