PHPackages                             uderline/openapi-php-attributes - 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. [API Development](/categories/api)
4. /
5. uderline/openapi-php-attributes

ActiveLibrary[API Development](/categories/api)

uderline/openapi-php-attributes
===============================

Automatically render your OpenApi 3 file describing your PHP API using attributes

2.1.0(2y ago)2136.3k↓46.9%7[1 PRs](https://github.com/uderline/openapi-php-attributes/pulls)MITPHPPHP &gt;=8.1

Since Aug 5Pushed 2y ago3 watchersCompare

[ Source](https://github.com/uderline/openapi-php-attributes)[ Packagist](https://packagist.org/packages/uderline/openapi-php-attributes)[ Docs](https://uderline.github.io/openapi-php-attributes/)[ RSS](/packages/uderline-openapi-php-attributes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (34)Used By (0)

OpenAPI PHP Attributes Generator
================================

[](#openapi-php-attributes-generator)

This CLI Tool is able to generate an OpenApi JSON file description according to PHP attributes contained in your files.

⚠️ Missing something ?
----------------------

[](#️-missing-something-)

Just open an issue saying what's missing ! Feel free to open a PR but we recommend opening an issue beforehand.

Where to start ?
----------------

[](#where-to-start-)

1 - Install the package openapi-php-attributes-generator with composer.

```
composer require uderline/openapi-php-attributes
```

2 - Describe your API by following this documentation:

3 - Generate the JSON file:

```
php ./vendor/bin/opag /src/files/project openapi.json
```

A new file called `openapi.json` has been generated !

Example
-------

[](#example)

```
#[Controller]
class Controller {
    #[
        GET("/path/{id}", ["Tag1", "Tag2"], "Description of the method"),
        Property(Type::STRING, "prop1", description: "Property description", enum: BackedEnum::class),
        Property(Type::INT, "prop2", example: 1),
        Property(Type::BOOLEAN, "prop3"),
        Property(Type::REF, "prop4", ref: RefSchema::class)
        Response(ref: SchemaName::class, description: "Response description")
    ]
    public function get(#[Parameter("Parameter description")] int $id): JsonResponse {
        // ...
    }
}

enum BackedEnum: string
{
    case VAL1: "val1";
    case VAL2: "val2";
}

#[
    Schema,
    Property(Type::STRING, "Property 1"),
    Property(Type::INT, "Property 2"),
]
class RefSchema
{
    public string $property1;
    public int $property2;
}
```

Will generate

```
{
    "paths": {
        "/path/{id}": {
            "post": {
                "tags": [
                    "Tag1",
                    "Tag2"
                ],
                "summary": "Description of the method",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Parameter description",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "prop1": {
                                        "type": "string",
                                        "description": "Property description",
                                        "enum": [
                                            "val1",
                                            "val2"
                                        ]
                                    },
                                    "prop2": {
                                        "type": "integer",
                                        "description": ""
                                    },
                                    "prop3": {
                                        "type": "boolean",
                                        "description": ""
                                    },
                                    "prop4": {
                                        "$ref": "#/components/schemas/RefSchema"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Response description",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DummyComponent"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 71.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~70 days

Total

30

Last Release

784d ago

Major Versions

0.4.3 → 1.0.02022-01-12

1.8.4 → 2.0.02023-06-26

PHP version history (2 changes)0.1.0PHP &gt;=8.0

1.7.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/30d1720ab435668ae1a89d5d59235f752ae82fee5b9b3b7333a635a1144db892?d=identicon)[uderline](/maintainers/uderline)

---

Top Contributors

[![uderline](https://avatars.githubusercontent.com/u/10776690?v=4)](https://github.com/uderline "uderline (71 commits)")[![puggan](https://avatars.githubusercontent.com/u/866668?v=4)](https://github.com/puggan "puggan (17 commits)")[![edersoares](https://avatars.githubusercontent.com/u/957395?v=4)](https://github.com/edersoares "edersoares (3 commits)")[![AkioSarkiz](https://avatars.githubusercontent.com/u/42392852?v=4)](https://github.com/AkioSarkiz "AkioSarkiz (2 commits)")[![edineivaldameri](https://avatars.githubusercontent.com/u/99054215?v=4)](https://github.com/edineivaldameri "edineivaldameri (2 commits)")[![lampelk](https://avatars.githubusercontent.com/u/1291378?v=4)](https://github.com/lampelk "lampelk (1 commits)")[![DerpgonCz](https://avatars.githubusercontent.com/u/3275947?v=4)](https://github.com/DerpgonCz "DerpgonCz (1 commits)")[![boris-glumpler](https://avatars.githubusercontent.com/u/580004?v=4)](https://github.com/boris-glumpler "boris-glumpler (1 commits)")[![zaneevat](https://avatars.githubusercontent.com/u/67626444?v=4)](https://github.com/zaneevat "zaneevat (1 commits)")

---

Tags

apiapi-restattributesjsonjson-schemaopenapiopenapi3phpphp8rendererswaggerphpjsonapiopenapiattributesrendererphp8api-restopenapi3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uderline-openapi-php-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/uderline-openapi-php-attributes/health.svg)](https://phpackages.com/packages/uderline-openapi-php-attributes)
```

###  Alternatives

[mjaschen/collmex

Collmex PHP SDK

2080.7k](/packages/mjaschen-collmex)[harmbandstra/swagger-ui-bundle

Exposes swagger UI inside your Symfony project through a route (eg. /docs)

42867.3k](/packages/harmbandstra-swagger-ui-bundle)[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[wayofdev/laravel-symfony-serializer

📦 Laravel wrapper around Symfony Serializer.

2113.6k](/packages/wayofdev-laravel-symfony-serializer)[phplicengine/bitly

Bitly API v4

22277.3k](/packages/phplicengine-bitly)[facturama/facturama-php-sdk

Facturama PHP SDK

1194.9k1](/packages/facturama-facturama-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
