open-solid/api
最新稳定版本:v0.1.4
Composer 安装命令:
composer require open-solid/api
包简介
An OpenApi Bridge for Symfony
README 文档
README
A Symfony bundle that automatically generates OpenAPI specifications from your controller classes using swagger-php.
Define your API endpoints with PHP attributes, and the bundle takes care of generating a complete OpenAPI spec — including operations, request bodies, query parameters, path parameters, response schemas, and pagination.
Features
- Route-driven spec generation — OpenAPI operations are derived from custom routing attributes (
#[Get],#[Post], etc.), eliminating duplicate annotations - Automatic request body inference — Detects
#[MapRequestPayload]parameters and generates request body schemas - Query parameter expansion — Expands
#[MapQueryString]DTOs into individual query parameters - Response type inference — Infers response schemas from controller return types
- Pagination support — Built-in
Paginatorinterface with standardized paginated response format - GetOrCreate pattern — Dual 200/201 responses for upsert endpoints
- Custom path parameter resolvers — Extensible resolution of value object path parameters (e.g.
ProductIdto UUID) - JSON streaming — Responses are streamed via Symfony's JsonStreamer for memory efficiency
- Serve & export — Serve the spec at
/docs.jsonor export it withphp bin/console openapi:generate
Installation
composer require open-solid/api
Quick Start
#[Get(
path: '/products/{id}',
name: 'api_find_product',
description: 'Find a Product',
summary: 'Retrieves a single product by its unique identifier.',
tags: ['Product'],
)]
final readonly class FindProductController
{
public function __invoke(#[PathParameter] ProductId $id): ProductView
{
// ...
}
}
This single class generates a complete OpenAPI operation with path parameters, response schema, and status codes — no extra annotations needed.
Documentation
- Getting Started
- Routing Attributes
- Request & Response Handling
- Pagination
- OpenAPI Generation
- Path Parameter Resolvers
- Configuration Reference
License
MIT
open-solid/api 适用场景与选型建议
open-solid/api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 775 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 open-solid/api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 open-solid/api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 775
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-01