nickdnk / openapi-php
Tools for documenting PHP code in OpenAPI.
0.8.0
2026-11-26 21:49 UTC
Requires
- php: ^8.5
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^13.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
OpenAPI PHP
Tool used to generate OpenAPI swagger documentation specifications using PHP.
Requires PHP 8.5 or newer.
Changelog
0.8.0
- Added:
Endpoint::withCodeSamples()with the newCodeSamplevalue object, emitted as thex-codeSamplesextension (lang, optionallabel,source) that Redoc and other renderers show as a tab per sample. - Changed: an empty requirement passed to
Endpoint::withRequiredSecuritySchemes([])beside other requirements now serializes as the empty Security Requirement Object{}, which makes the others optional (e.g. HTTP Basic or no authentication:[{"Basic": []}, {}]). Alone it still removes security (security: []). Previously it was dropped, which made the other requirements mandatory.
0.7.0
- PHP 8.5 required.
- Fixed: a security requirement given as an array of
RequiredSecurityScheme(an AND-combination, e.g.[RequiredSecurityScheme::forOAuth('OAuth2', ['read']), RequiredSecurityScheme::forAny('ApiKey')]) wrapped the OAuth scopes in an extra array ({"OAuth2": [["read"]]}). Scopes are now emitted as a flat string array ({"OAuth2": ["read"], "ApiKey": []}), on both endpoints and the root document. - Added:
Parameter::header()andParameter::cookie()forin: headerandin: cookieparameters. Header parameters namedAccept,Content-TypeorAuthorizationare ignored by the OpenAPI specification. OpenAPI::addRequiredSecuritySchemes()now type-hintsRequiredSecurityScheme|array; an invalid argument raises aTypeErrorinstead of anInvalidArgumentException.- Typed class constants,
readonlyvalue-object properties and#[\Override]attributes throughout. - Tests run on PHPUnit 13, failing on any deprecation, notice or warning. Coverage is no longer configured by default:
run
php vendor/bin/phpunit --coverage-clover build/logs/clover.xmlwith Xdebug or PCOV for it.