PHPackages                             tyesty/swagger-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. tyesty/swagger-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

tyesty/swagger-php
==================

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

3.0.3.1(6y ago)110.3k[1 PRs](https://github.com/tyesty/swagger-php/pulls)Apache-2.0PHPPHP &gt;=7.2

Since Apr 1Pushed 1y agoCompare

[ Source](https://github.com/tyesty/swagger-php)[ Packagist](https://packagist.org/packages/tyesty/swagger-php)[ Docs](https://github.com/zircote/swagger-php/)[ RSS](/packages/tyesty-swagger-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (6)Versions (49)Used By (0)

[![Total Downloads](https://camo.githubusercontent.com/510817544c7e9c7b2f0933c40056463db5aabdb346c4dad4651244253459b8bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7479657374792f737761676765722d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tyesty/swagger-php)[![License](https://camo.githubusercontent.com/b89cba305c99c2dfde6231572de7b70bd58c854ee6ca8c2b6c8b1a92a51d6426/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865322e302d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE-2.0.txt)

swagger-php
===========

[](#swagger-php)

Generate interactive [OpenAPI](https://www.openapis.org) documentation for your RESTful API using [doctrine annotations](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html).

About this fork
---------------

[](#about-this-fork)

This fork adds the option to determine enum values by specifying an enumCallback attribute.

```
/**
 * @OA\Property(type="string", enumCallback="\My\Class::myMethod")
 */
```

will automatically set the `enum` attribute to the `array_values()` of the array provided by `\MyClass\::myMethod()` method.

Features
--------

[](#features)

- Compatible with the OpenAPI 3.0 specification.
- Extracts information from code &amp; existing phpdoc annotations.
- Command-line interface available.
- [Documentation site](http://zircote.com/swagger-php/) with a getting started guide.
- Exceptional error reporting (with hints, context)

Installation (with [Composer](https://getcomposer.org))
-------------------------------------------------------

[](#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.

```
composer global require zircote/swagger-php
```

Usage
-----

[](#usage)

Add annotations to your php files.

```
/**
 * @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](http://zircote.com/swagger-php/) for the [Getting started guide](http://zircote.com/swagger-php/Getting-started.html) or look at the [Examples directory](Examples/) for more examples.

### Usage from php

[](#usage-from-php)

Generate always-up-to-date documentation.

```
