PHPackages                             cortexphp/openapi - 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. cortexphp/openapi

ActiveLibrary[API Development](/categories/api)

cortexphp/openapi
=================

A fluent OpenAPI 3.1 builder for PHP, built on top of cortexphp/json-schema

0.1.0(4w ago)21[1 PRs](https://github.com/cortexphp/openapi/pulls)MITPHPPHP ^8.3CI passing

Since May 11Pushed 1w agoCompare

[ Source](https://github.com/cortexphp/openapi)[ Packagist](https://packagist.org/packages/cortexphp/openapi)[ Docs](https://github.com/cortexphp/openapi)[ RSS](/packages/cortexphp-openapi/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

Fluently build OpenAPI 3.1 specs
================================

[](#fluently-build-openapi-31-specs)

[![Latest Version](https://camo.githubusercontent.com/9c6d145f2d8fb1bd8ac2892a103c270bc567589181552ef4032fc4cb5a4b7743/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f727465787068702f6f70656e6170692e7376673f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572)](https://packagist.org/packages/cortexphp/openapi)[![GitHub License](https://camo.githubusercontent.com/22e3d709c1be944385fcfbe6961e3aab61db2ee6753aaae710e8ddc29e4375cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f727465787068702f6f70656e6170693f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://camo.githubusercontent.com/22e3d709c1be944385fcfbe6961e3aab61db2ee6753aaae710e8ddc29e4375cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f727465787068702f6f70656e6170693f7374796c653d666c61742d737175617265266c6f676f3d676974687562)

A modern, fluent builder for [OpenAPI 3.1](https://spec.openapis.org/oas/v3.1.0) specs, built on top of [`cortexphp/json-schema`](https://github.com/cortexphp/json-schema) so that schemas are first-class JSON Schema 2020-12 and everything plays nicely with the rest of the Cortex ecosystem.

Features
--------

[](#features)

- Full OpenAPI 3.1 object graph (paths, webhooks, callbacks, components, security, tags)
- Schemas via `cortexphp/json-schema` — no parallel schema DSL to learn
- Vendor extensions (`x-*`) and `$ref` on every object
- JSON and YAML output (YAML via optional `symfony/yaml`)
- Meta-schema validation proxied through the existing `cortex/json-schema` pipeline

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

[](#requirements)

- PHP 8.3+

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

[](#installation)

```
composer require cortexphp/openapi
```

For YAML output:

```
composer require symfony/yaml
```

Quick Start
-----------

[](#quick-start)

```
use Cortex\JsonSchema\Schema;
use Cortex\JsonSchema\Enums\SchemaFormat;
use Cortex\OpenApi\OpenApi;
use Cortex\OpenApi\Objects\{Info, Tag, PathItem, Operation, Response, MediaType, Parameter, Components, Reference};

$userSchema = Schema::object('User')->properties(
    Schema::string('id')->format(SchemaFormat::Uuid)->required(),
    Schema::string('name')->required(),
    Schema::integer('age')->minimum(0),
);

$openApi = OpenApi::create()
    ->info(Info::create()->title('Example API')->version('1.0.0'))
    ->tags(Tag::create('Users')->description('User endpoints'))
    ->components(Components::create()->schema('User', $userSchema))
    ->paths(
        PathItem::create('/users/{id}')
            ->parameters(Parameter::path('id', Schema::string()->format(SchemaFormat::Uuid)))
            ->operations(
                Operation::get()
                    ->operationId('users.show')
                    ->tags('Users')
                    ->responses(
                        Response::ok()->content(MediaType::json(Reference::schema('User'))),
                        Response::notFound(),
                    ),
            ),
    );

echo $openApi->toJson(JSON_PRETTY_PRINT);
```

Documentation
-------------

[](#documentation)

📚 **[View Full Documentation →](https://docs.cortexphp.com/openapi)**

Credits
-------

[](#credits)

- [Sean Tymon](https://github.com/tymondesigns)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance96

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2730d341811c79252a25178ab52ee3a83a857cf66b409e9691ecd3e89b6307e0?d=identicon)[tymondesigns](/maintainers/tymondesigns)

---

Top Contributors

[![tymondesigns](https://avatars.githubusercontent.com/u/1801923?v=4)](https://github.com/tymondesigns "tymondesigns (24 commits)")

---

Tags

openapiopenapi3swaggerjson-schemaswaggeropenapioascortexopenapi-3.1

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cortexphp-openapi/health.svg)

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

###  Alternatives

[swagger-api/swagger-ui

 Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

28.8k48.1M111](/packages/swagger-api-swagger-ui)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k36.4M124](/packages/darkaonline-l5-swagger)[goldspecdigital/oooas

An object oriented approach to generating OpenAPI specs, implemented in PHP.

2312.9M26](/packages/goldspecdigital-oooas)[jolicode/slack-php-api

An up to date PHP client for Slack's API

2564.6M12](/packages/jolicode-slack-php-api)[darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

3362.4M3](/packages/darkaonline-swagger-lume)[wotz/laravel-swagger-ui

Add Swagger UI to a Laravel application.

279385.0k](/packages/wotz-laravel-swagger-ui)

PHPackages © 2026

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