承接 cortexphp/openapi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cortexphp/openapi

Composer 安装命令:

composer require cortexphp/openapi

包简介

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

README 文档

README

Latest Version GitHub License

A modern, fluent builder for OpenAPI 3.1 specs, built on top of 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

  • 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

  • PHP 8.3+

Installation

composer require cortexphp/openapi

For YAML output:

composer require symfony/yaml

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

📚 View Full Documentation →

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固