Search by

nickdnk / openapi-php

nickdnk

Tools for documenting PHP code in OpenAPI.

Package info

github.com/nickdnk/openapi-php

pkg:composer/nickdnk/openapi-php

Statistics

Installs: 6 720

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 1

0.8.0 2026-11-26 21:49 UTC

This package is auto-updated.

Last update: 2026-11-26 21:49:20 UTC


README

https://github.com/nickdnk/openapi-php/actions/workflows/test.yml

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 new CodeSample value object, emitted as the x-codeSamples extension (lang, optional label, 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() and Parameter::cookie() for in: header and in: cookie parameters. Header parameters named Accept, Content-Type or Authorization are ignored by the OpenAPI specification.
  • OpenAPI::addRequiredSecuritySchemes() now type-hints RequiredSecurityScheme|array; an invalid argument raises a TypeError instead of an InvalidArgumentException.
  • Typed class constants, readonly value-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.xml with Xdebug or PCOV for it.