PHPackages                             ap-lib/openapi-plus - 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. ap-lib/openapi-plus

ActiveLibrary[API Development](/categories/api)

ap-lib/openapi-plus
===================

023PHP

Since Aug 17Pushed 8mo agoCompare

[ Source](https://github.com/ap-lib/openapi-plus)[ Packagist](https://packagist.org/packages/ap-lib/openapi-plus)[ RSS](/packages/ap-lib-openapi-plus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AP\\OpenAPIPlus
===============

[](#apopenapiplus)

[![MIT License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

A PHP specification system for generating OpenAPI 3.1-compatible schemas from PHP classes, enhanced with extra features and macros.

**Compatible with:** [OpenAPI 3.1 Specification](https://spec.openapis.org/oas/v3.1.0.html)

Highlights
----------

[](#highlights)

- Seamlessly integrates with PHP attributes and validators
- Supports schema generation from constructors or properties
- Allows macro extensions for enums and custom types

---

Installation
------------

[](#installation)

```
composer require ap-lib/openapi-plus
```

Requirements
------------

[](#requirements)

- PHP 8.3 or higher

---

Getting Started
---------------

[](#getting-started)

### 1. Initialize the OpenAPIPlus Loader

[](#1-initialize-the-openapiplus-loader)

Create a loader class to configure the system with your custom object definitions and enums:

```
class OpenAPI
{
    private static OpenAPIPlus $openAPIPlus;

    public static function get(): OpenAPIPlus
    {
        return self::$openAPIPlus ??= new OpenAPIPlus([
            new ImplementedObject(),
        ]);
    }
}
```

---

### 2. Use Traits to Generate Schemas

[](#2-use-traits-to-generate-schemas)

Choose between generating schemas from constructor arguments or class properties.

#### Constructor-Based Schema

[](#constructor-based-schema)

```
trait ByConstructorOpenAPI
{
    public static function openAPI(): array
    {
        return OpenAPI::get()->scheme(
            (new \ReflectionClass(static::class))
                ->getConstructor()
                ->getParameters()
        );
    }
}
```

#### Property-Based Schema

[](#property-based-schema)

```
trait PropertiesOpenAPI
{
    public static function openAPI(): array
    {
        return OpenAPI::get()->scheme(
            (new \ReflectionClass(static::class))
                ->getProperties()
        );
    }
}
```

---

### 3. Annotate and Generate

[](#3-annotate-and-generate)

Apply the trait to your class and use attribute-based validators (e.g. from [ap-lib/validator](https://github.com/ap-lib/validator)):

> Example how to implement OpenAPIModificator:

```
class SignUpBody
{
    use PropertiesOpenAPI;

    #[LabelCompany]
    public string $company_name;

    #[Email]
    public string $email;

    #[Password(min_length: 8)]
    public string $password;

    #[Timezone]
    public ?string $timezone = null;
}
```

Generate the OpenAPI schema:

```
echo json_encode(
    value: SignUpBody::openAPI(),
    flags: JSON_PRETTY_PRINT
);
```

---

### Example Output

[](#example-output)

```
{
  "type": "object",
  "properties": {
    "company_name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 32
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "password": {
      "type": "string",
      "format": "password"
    },
    "timezone": {
      "type": ["string", "null"],
      "default": null,
      "maxLength": 30
    }
  },
  "required": [
    "company_name",
    "email",
    "password"
  ]
}
```

---

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance42

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1215fe5ecc9ba0ab1c730d3c992125cf6ebf460562e66be71ebae127789d465a?d=identicon)[AntonPanfilov](/maintainers/AntonPanfilov)

---

Top Contributors

[![anton-panfilov](https://avatars.githubusercontent.com/u/1083546?v=4)](https://github.com/anton-panfilov "anton-panfilov (12 commits)")

### Embed Badge

![Health badge](/badges/ap-lib-openapi-plus/health.svg)

```
[![Health](https://phpackages.com/badges/ap-lib-openapi-plus/health.svg)](https://phpackages.com/packages/ap-lib-openapi-plus)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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