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

ActiveLibrary[API Development](/categories/api)

dandoetech/openapi-generator
============================

Generate OpenAPI 3.1 from DanDoeTech Resource Registry with optional model metadata fallback.

v0.2.0(2d ago)002MITPHPPHP ^8.2CI passing

Since Mar 15Pushed 2d agoCompare

[ Source](https://github.com/dandoetech/openapi-generator)[ Packagist](https://packagist.org/packages/dandoetech/openapi-generator)[ Docs](https://github.com/dandoetech/openapi-generator)[ RSS](/packages/dandoetech-openapi-generator/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (3)Used By (2)

DanDoeTech OpenAPI Generator
============================

[](#dandoetech-openapi-generator)

> **Pre-release** — Architecture by senior tech lead, implementation largely AI-assisted with human review. Not fully reviewed. Architecture may change before v1.0.0.

Generate OpenAPI 3.1 specifications from a Resource Registry. Framework-agnostic — no Laravel required.

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

[](#installation)

```
composer require dandoetech/openapi-generator
```

Requires [`dandoetech/resource-registry`](https://github.com/dandoetech/resource-registry).

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

[](#quick-start)

```
use DanDoeTech\ResourceRegistry\Registry\{ArrayRegistryDriver, Registry};
use DanDoeTech\ResourceRegistry\Definition\{FieldDefinition, FieldType, ActionDefinition};
use DanDoeTech\OpenApiGenerator\OpenApiGenerator;
use DanDoeTech\OpenApiGenerator\Support\ResourceResolver;

// Build a registry (or use class-based resources via laravel-resource-registry)
$registry = new Registry(new ArrayRegistryDriver([
    'product' => [
        'label' => 'Product',
        'fields' => [
            new FieldDefinition('id', FieldType::Integer, nullable: false),
            new FieldDefinition('name', FieldType::String, nullable: false),
            new FieldDefinition('price', FieldType::Float, nullable: false),
        ],
        'actions' => [new ActionDefinition('create')],
    ],
]));

// Generate the spec
$generator = new OpenApiGenerator(
    resolver: new ResourceResolver(),
    title: 'My API',
    version: '1.0.0',
);
$doc = $generator->generate($registry);

echo $doc->toJson();
```

Output (abbreviated):

```
{
  "openapi": "3.1.0",
  "info": { "title": "My API", "version": "1.0.0" },
  "paths": {
    "/product": {
      "get": { "summary": "List Product", "..." : "..." },
      "post": { "summary": "Create Product", "..." : "..." }
    },
    "/product/{id}": {
      "get": { "summary": "Fetch Product", "..." : "..." }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "format": "int64" },
          "name": { "type": "string" },
          "price": { "type": "number", "format": "double" }
        },
        "required": ["id", "name", "price"]
      },
      "ProblemJson": { "..." : "..." }
    }
  }
}
```

> **Laravel users:** Use [`dandoetech/laravel-openapi-generator`](https://github.com/dandoetech/laravel-openapi-generator) for Artisan commands and automatic registry binding.

API Overview
------------

[](#api-overview)

ClassPurpose`OpenApiGenerator`Main entry point — `generate(Registry): OpenApiDocument``OpenApiDocument`Result container — `toArray()` and `toJson()``ResourceResolver`Resolves fields from resource definitions with optional fallback`PathsBuilder`Builds OpenAPI path items from resource definitions`ComponentsBuilder`Builds component schemas from resource fields`SchemaFactory`Maps fields and computed fields to JSON Schema properties`Types`Maps `FieldType` enum to OpenAPI type/format pairs### Contracts

[](#contracts)

InterfacePurpose`OpenApiGeneratorInterface``generate(Registry): OpenApiDocument``ModelMetaProviderInterface`Optional fallback for field metadata — `fieldsFor(string $key): array`### Type Mapping

[](#type-mapping)

FieldTypeOpenAPI`String``{ "type": "string" }``Integer``{ "type": "integer", "format": "int64" }``Float``{ "type": "number", "format": "double" }``Boolean``{ "type": "boolean" }``DateTime``{ "type": "string", "format": "date-time" }``Json``{ "type": "object" }``Date``{ "type": "string", "format": "date" }``Text``{ "type": "string" }``Email``{ "type": "string", "format": "email" }``Url``{ "type": "string", "format": "uri" }``Enum``{ "type": "string" }`Configuration
-------------

[](#configuration)

All configuration is via constructor arguments:

```
$generator = new OpenApiGenerator(
    resolver: new ResourceResolver($optionalFallbackProvider),
    title: 'My API',
    version: '2.0.0',
    servers: [['url' => 'https://api.example.com']],
);
```

### Field Fallback

[](#field-fallback)

If a resource has no fields defined, the generator can fall back to a `ModelMetaProviderInterface`:

```
use DanDoeTech\OpenApiGenerator\ModelMeta\ArrayModelMetaProvider;

$fallback = new ArrayModelMetaProvider([
    'product' => [
        new FieldDefinition('id', FieldType::Integer, nullable: false),
        new FieldDefinition('name', FieldType::String, nullable: false),
    ],
]);
$resolver = new ResourceResolver($fallback);
```

Testing
-------

[](#testing)

```
composer install
composer test        # PHPUnit
composer qa          # cs:check + phpstan + test
```

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance99

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity37

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

Every ~4 days

Total

2

Last Release

2d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7db403e7ef98a1eb428f771172dfa0edbd6f7c72d217fad0571992bee2cc089d?d=identicon)[dandoetech](/maintainers/dandoetech)

---

Top Contributors

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

---

Tags

phpapiswaggeropenapicode-generation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  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.7k44.1M87](/packages/swagger-api-swagger-ui)[jolicode/slack-php-api

An up to date PHP client for Slack's API

2534.3M12](/packages/jolicode-slack-php-api)[harmbandstra/swagger-ui-bundle

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

42860.5k](/packages/harmbandstra-swagger-ui-bundle)[dwolla/dwollaswagger

16431.9k](/packages/dwolla-dwollaswagger)[clever/clever-php

231.6k](/packages/clever-clever-php)

PHPackages © 2026

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