dandoetech/laravel-openapi-generator
Composer 安装命令:
composer require dandoetech/laravel-openapi-generator
包简介
Laravel bridge for DanDoeTech OpenAPI generator: artisan export command and wiring.
README 文档
README
Pre-release — Architecture by senior tech lead, implementation largely AI-assisted with human review. Not fully reviewed. Architecture may change before v1.0.0.
Laravel bridge for the DanDoeTech OpenAPI generator. Provides an Artisan command to export OpenAPI 3.1 specs from the Resource Registry.
Installation
composer require dandoetech/laravel-openapi-generator
The service provider is auto-discovered. Publish the config:
php artisan vendor:publish --tag=ddt-openapi-config
Requires dandoetech/laravel-resource-registry.
Quick Start
Export the spec:
php artisan openapi:export
This generates an OpenAPI 3.1 JSON file at storage/app/openapi.json (configurable).
Override title or version:
php artisan openapi:export --title="Catalog API" --oaversion="2.0.0" php artisan openapi:export --output="public/openapi.json"
What Gets Generated
Every registered resource produces:
GET /{resource}— list endpointPOST /{resource}— create endpointGET /{resource}/{id}— show endpoint- A component schema with all fields and computed fields
Example output (abbreviated):
{
"openapi": "3.1.0",
"info": { "title": "API", "version": "1.0.0" },
"servers": [{ "url": "http://localhost/api", "description": "Primary API" }],
"paths": {
"/product": {
"get": { "summary": "List Product" },
"post": { "summary": "Create Product" }
},
"/product/{id}": {
"get": { "summary": "Fetch Product" }
}
},
"components": {
"schemas": {
"Product": {
"type": "object",
"properties": {
"name": { "type": "string" },
"price": { "type": "number", "format": "double" },
"category_name": { "type": "string" }
},
"required": ["name", "price"]
},
"ProblemJson": { "..." : "..." }
}
}
}
Computed fields (like category_name) appear in schemas as regular properties. Error responses use the RFC 7807 ProblemJson schema.
Configuration
config/ddt_openapi.php:
return [ // OpenAPI info block 'title' => env('OPENAPI_TITLE', 'API'), 'version' => env('OPENAPI_VERSION', '1.0.0'), // Output path relative to storage_path() 'output' => env('OPENAPI_OUTPUT', 'app/openapi.json'), ];
The server URL is built from config('app.url') and the API prefix from config('ddt_api.prefix') (configured in laravel-generic-api).
Programmatic Use
Generate the spec in code:
use DanDoeTech\LaravelOpenApiGenerator\Services\OpenApiGenerator; $generator = app(OpenApiGenerator::class); $spec = $generator->create(); // array return response()->json($spec);
API Overview
| Class | Purpose |
|---|---|
OpenApiServiceProvider |
Registers config, artisan command |
OpenApiExportCommand |
openapi:export with --output, --title, --oaversion options |
OpenApiGenerator (service) |
Builds spec from Registry + config, returns array |
Testing
composer install composer test # PHPUnit (Orchestra Testbench) composer qa # cs:check + phpstan + test
License
MIT
dandoetech/laravel-openapi-generator 适用场景与选型建议
dandoetech/laravel-openapi-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「artisan」 「swagger」 「openapi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dandoetech/laravel-openapi-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dandoetech/laravel-openapi-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dandoetech/laravel-openapi-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Collection of handy Laravel artisan commands that most projects needs
Additional artisan commands for Laravel
Enterprise-Grade Modular Architecture for Laravel Applications - A powerful Laravel package that revolutionizes application development with robust Service Repository Pattern, Dynamic Module Management, and 50+ Artisan commands for scalable, maintainable applications.
Create views, including "resource" views, using console commands.
Generates Laravel Migrations from an existing database
Laravel Craftsman
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-15