PHPackages                             finderly/openapi-php-lib - 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. finderly/openapi-php-lib

ActiveLibrary[API Development](/categories/api)

finderly/openapi-php-lib
========================

A PHP Library to assist in creation of OpenApi Specifications

v1.0.0(3y ago)0341[1 PRs](https://github.com/finderly/openapi-php-lib/pulls)MITPHPPHP &gt;=7.3

Since Jul 6Pushed 2y ago1 watchersCompare

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

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

openapi-php-lib
===============

[](#openapi-php-lib)

A PHP Library to assist in creation of OpenApi Specifications

Supported OpenApi Version
=========================

[](#supported-openapi-version)

[Version 3.1.0](https://spec.openapis.org/oas/v3.1.0.html).

Supported Output Formats
========================

[](#supported-output-formats)

Currently the library supports converting the OpenApi spec to an array which can easily be encoded as JSON in an endpoint or serialized for caching and later delivery as JSON.

[Support for YAML](https://spec.openapis.org/oas/v3.1.0.html#format) as per the spec is not yet directly supported.

Example Usage
=============

[](#example-usage)

Export Schema as JSON
---------------------

[](#export-schema-as-json)

```
// Class: MyDomainOpenApiGenerator.php

public class MyDomainOpenApiGenerator extends \Finderly\OpenapiPhpLib\OpenApiGenerator
{
    public function __construct(/* inject your dependencies here */) {}

    /**
     * your generation logic goes here, sample below
     * @return array
     */
    public function generateSpecification(): array
    {
        $mySchemas = $myPaths = [/* your domain logic here to populate these vars */];

        $openApi = new \Finderly\OpenapiPhpLib\Model\OpenApi(
            \Finderly\OpenapiPhpLib\Model\OpenApi::OPENAPI_VERSION,
            ['title' => 'My Spec\'s title', 'version' => 'My spec\'s version']
        );

        // add global schemas
        foreach ($mySchemas as $mySchema) {
            // $mySchema is your domain logic
            $openApi->getComponents()->addSchema(
                $mySchema->translateToOpenapiPhpLibSchemaName(),
                $mySchema->translateToOpenapiPhpLibSchema()
            );
        }

        foreach ($myPaths as $myPath) {
            // $myPath is your domain logic
            $pathItem = new \Finderly\OpenapiPhpLib\Model\Path\PathItem();
            $pathItem->setParameters(
                $myPath->translateToOpenapiPhpLibParameters()
            );

            foreach ($myPath->getSupportedHttpOperations() as $method) {
                $operation = $method->translateToOpenapiPhpLibOperation();
                $pathItem->setOperation(strtolower($method->getHttpMethod()), $operation);
            }

            $openApi->addPathItem($myPath->getHttpPath(), $pathItem);
        }

        return $openApi->toArray();
    }
}

// File: generation_command.php

$openApiGenerator = new MyDomainOpenApiGenerator();

$exporter = new \Finderly\OpenapiPhpLib\Exporter\OpenApiJsonExporter(
    $openApiGenerator
);

$exporter->exportFile('/path/to/file.json');
```

Contributing and Completeness
=============================

[](#contributing-and-completeness)

Supported OpenApi Objects
-------------------------

[](#supported-openapi-objects)

The following objects are currently supported:

- [body-object](https://spec.openapis.org/oas/v3.1.0.html#request-body-object)
- [components-object](https://spec.openapis.org/oas/v3.1.0.html#components-object)
- [item-object](https://spec.openapis.org/oas/v3.1.0.html#path-item-object)
- [license-object](https://spec.openapis.org/oas/v3.1.0.html#license-object)
- [openapi-object](https://spec.openapis.org/oas/v3.1.0.html#openapi-object)
- [operation-object](https://spec.openapis.org/oas/v3.1.0.html#operation-object)
- [parameter-object](https://spec.openapis.org/oas/v3.1.0.html#parameter-object)
- [paths-object](https://spec.openapis.org/oas/v3.1.0.html#paths-object)
- [reference-object](https://spec.openapis.org/oas/v3.1.0.html#reference-object)
- [response-object](https://spec.openapis.org/oas/v3.1.0.html#response-object)
- [schema-object](https://spec.openapis.org/oas/v3.1.0.html#schema-object)
- [server-object](https://spec.openapis.org/oas/v3.1.0.html#server-object)
- [type-object](https://spec.openapis.org/oas/v3.1.0.html#media-type-object)
- [variable-object](https://spec.openapis.org/oas/v3.1.0.html#server-variable-object)

If you do not see what you are looking for in this list, please contact us or contribute it!

Contributing
------------

[](#contributing)

New objects can be added relatively easily by mapping them using the following variables types.

### Variable Types

[](#variable-types)

#### Basic

[](#basic)

- `string`
- `array `
- `bool`
- `int`

When rendering the spec these variable types are treated as their standard variable type.

#### Objects

[](#objects)

- `object`
- `object[]`
- `object[k,v]`

When rendering the spec these variable types are recursed. An `object` is recursed. An `object[]` is a treated as a simple array of objects. The ["Paths"](https://spec.openapis.org/oas/v3.1.0.html#paths-object) and any "Map\[string, OpenApi Object Type" is handled as a `object[k,v]`.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

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

1412d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a111010b401c90f8f027427ae29842be7004dec37582fe7b35ba5cb358a96b08?d=identicon)[tdashton](/maintainers/tdashton)

---

Top Contributors

[![oestoer](https://avatars.githubusercontent.com/u/1198791?v=4)](https://github.com/oestoer "oestoer (5 commits)")[![tdashton](https://avatars.githubusercontent.com/u/820379?v=4)](https://github.com/tdashton "tdashton (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/finderly-openapi-php-lib/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

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

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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