2017 © Pedro Peláez
 

library swagger-php

swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations

image

zircote/swagger-php

swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations

  • Friday, June 29, 2018
  • by bfanger
  • Repository
  • 103 Watchers
  • 2143 Stars
  • 4,040,394 Installations
  • PHP
  • 117 Dependents
  • 5 Suggesters
  • 448 Forks
  • 66 Open issues
  • 45 Versions
  • 16 % Grown

The README.md

Build Status Total Downloads License, (*1)

swagger-php

Generate interactive OpenAPI documentation for your RESTful API using PHP attributes (preferred) or doctrine annotations (requires additional doctrine/annotations library)., (*2)

See the documentation website for supported attributes and annotations., (*3)

Annotations are deprecated and may be removed in a future release of swagger-php., (*4)

Features

  • Compatible with the OpenAPI 3.0 and 3.1 specification.
  • Extracts information from code & existing phpdoc annotations.
  • Command-line interface available.
  • Documentation site with a getting started guide.
  • Exceptional error reporting (with hints, context)
  • As of PHP 8.1 all annotations are also available as PHP attributes

OpenAPI version support

swagger-php allows to generate specs either for OpenAPI 3.0.0 or OpenAPI 3.1.0. By default the spec will be in version 3.0.0. The command line option --version may be used to change this to 3.1.0., (*5)

Programmatically, the method Generator::setVersion() can be used to change the version., (*6)

Requirements

swagger-php requires at least PHP 7.2 for annotations and PHP 8.1 for using attributes., (*7)

Installation (with Composer)

composer require zircote/swagger-php

For cli usage from anywhere install swagger-php globally and make sure to place the ~/.composer/vendor/bin directory in your PATH so the openapi executable can be located by your system., (*8)

composer global require zircote/swagger-php

doctrine/annotations

As of version 4.8 the doctrine annotations library is optional and no longer installed by default., (*9)

To use PHPDoc annotations this needs to be installed on top of swagger-php:, (*10)

composer require doctrine/annotations

If your code uses PHPDoc annotations you will need to install this as well:, (*11)

composer require doctrine/annotations

Usage

Add annotations to your php files., (*12)

/**
 * @OA\Info(title="My First API", version="0.1")
 */

/**
 * @OA\Get(
 *     path="/api/resource.json",
 *     @OA\Response(response="200", description="An example resource")
 * )
 */

Visit the Documentation website for the Getting started guide or look at the Examples directory for more examples., (*13)

Usage from php

Generate always-up-to-date documentation., (*14)

<?php
require("vendor/autoload.php");
$openapi = \OpenApi\Generator::scan(['/path/to/project']);
header('Content-Type: application/x-yaml');
echo $openapi->toYaml();

Documentation of how to use the Generator class can be found in the Generator reference., (*15)

Usage from the Command Line Interface

The openapi command line interface can be used to generate the documentation to a static yaml/json file., (*16)

./vendor/bin/openapi --help

Starting with version 4 the default analyser used on the command line is the new ReflectionAnalyser., (*17)

Using the --legacy flag (-l) the legacy TokenAnalyser can still be used., (*18)

Usage from the Deserializer

Generate the OpenApi annotation object from a json string, which makes it easier to manipulate objects programmatically., (*19)

<?php

use OpenApi\Serializer;

$serializer = new Serializer();
$openapi = $serializer->deserialize($jsonString, 'OpenApi\Annotations\OpenApi');
echo $openapi->toJson();

Contributing

More on OpenApi & Swagger

The Versions

29/06 2018

3.x-dev

3.9999999.9999999.9999999-dev https://github.com/zircote/swagger-php/

swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

26/01 2018

dev-master

9999999-dev https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

26/01 2018

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

24/01 2018

dev-related-projects

dev-related-projects https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

01/12 2017

2.0.13

2.0.13.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

27/11 2017

dev-example-dynamic-references

dev-example-dynamic-references https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

27/10 2017

2.0.12

2.0.12.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

16/08 2017

2.0.11

2.0.11.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

26/05 2017

dev-testrun

dev-testrun https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

13/05 2017

2.0.10

2.0.10.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

23/02 2017

2.0.9

2.0.9.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

16/12 2016

2.0.8

2.0.8.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

27/05 2016

2.0.7

2.0.7.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

13/02 2016

2.0.6

2.0.6.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

15/01 2016

2.0.5

2.0.5.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

13/11 2015

2.0.4

2.0.4.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

18/10 2015

2.0.3

2.0.3.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

17/09 2015

2.0.2

2.0.2.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

04/08 2015

2.0.1

2.0.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

04/07 2015

2.0.0

2.0.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json rest service discovery

25/04 2015

1.0.0

1.0.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

11/10 2014

0.9.6

0.9.6.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

04/09 2014

0.9.5

0.9.5.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

28/05 2014

0.9.4

0.9.4.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

11/05 2014

0.9.3

0.9.3.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

26/03 2014

0.9.2

0.9.2.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

21/03 2014

0.9.1

0.9.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

22/01 2014

0.9.0

0.9.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

15/12 2013

0.8.3

0.8.3.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

30/11 2013

0.8.2

0.8.2.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

30/10 2013

0.8.1

0.8.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

16/10 2013

0.8.0

0.8.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

08/10 2013

0.7.3

0.7.3.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

12/09 2013

0.7.2

0.7.2.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

02/09 2013

0.7.1

0.7.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

18/08 2013

0.7.0

0.7.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

12/06 2013

0.6.1

0.6.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

09/05 2013

0.6.0

0.6.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

17/12 2012

0.4.2

0.4.2.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

17/12 2012

0.4.3

0.4.3.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

15/12 2012

0.4.1

0.4.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery

19/04 2012

0.1.0

0.1.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

The Requires

  • php >=5.2.4

 

api json service discovery

01/04 2012

0.2.1

0.2.1.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

  • php >=5.3.3

 

api json service discovery

01/04 2012

0.3.0

0.3.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

  • php >=5.3.3

 

api json service discovery

01/04 2012

0.4.0

0.4.0.0 https://github.com/zircote/swagger-php/

Swagger-PHP library implementing the swagger.wordnik.com specification to describe web services, operations/actions and models enabling a uniform means of producing, consuming, and visualizing RESTful web services.

  Sources   Download

Apache2

The Requires

 

The Development Requires

api json service discovery