specdocular/php-openapi
最新稳定版本:v0.1.0
Composer 安装命令:
composer require specdocular/php-openapi
包简介
Object-oriented OpenAPI implementation for PHP
README 文档
README
An object-oriented OpenAPI 3.1.x builder for PHP. Build complete API specifications with a fluent, chainable API that hides the complexity of the OpenAPI specification.
Installation
composer require specdocular/php-openapi
Usage
use Specdocular\OpenAPI\Schema\Objects\OpenAPI\OpenAPI; use Specdocular\OpenAPI\Schema\Objects\Info\Info; use Specdocular\OpenAPI\Schema\Objects\PathItem\PathItem; use Specdocular\OpenAPI\Schema\Objects\Operation\Operation; use Specdocular\OpenAPI\Schema\Objects\Schema\Schema; use Specdocular\JsonSchema\Draft202012\Keywords\Properties\Property; $openApi = OpenAPI::v311( Info::create('Pet Store', '1.0.0') ->description('A sample Pet Store API') ); // Define schemas $petSchema = Schema::object() ->properties( Property::create('id', Schema::string()->format('uuid')), Property::create('name', Schema::string()), ) ->required('id', 'name'); // Export as JSON $json = json_encode($openApi, JSON_PRETTY_PRINT);
Features
- Fluent, chainable API for all OpenAPI 3.1.x objects
- Full support for Paths, Operations, Schemas, Responses, Request Bodies, Parameters, Security Schemes, and more
- Automatic component reference collection and management
- Built on specdocular/php-json-schema for schema definitions
- Framework-agnostic — no dependencies on Laravel or any framework
Related Packages
| Package | Description |
|---|---|
| specdocular/php-json-schema | JSON Schema Draft 2020-12 builder (foundation) |
| specdocular/laravel-openapi | Laravel integration for OpenAPI generation (uses this package) |
| specdocular/laravel-rules-to-schema | Convert Laravel validation rules to JSON Schema |
License
MIT. See LICENSE for details.
统计信息
- 总下载量: 471
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-13