NelmioApiDocBundle

Generate OpenAPI and Swagger documentation for your Symfony REST API from PHP attributes.

Library
Composer
vv5.11.1
2,363stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity84
Maintenance84
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality86
Innovation80
Learning Curve62

NelmioApiDocBundle is a Symfony bundle that produces OpenAPI (Swagger) documentation for your REST API automatically from your existing code. It reads PHP attributes, controller routes, form types, and serializer models to build an accurate API specification without maintaining a separate spec file by hand.

Bundling swagger-php under the hood, it exposes the generated spec as JSON/YAML and can render interactive Swagger UI and ReDoc interfaces, keeping your API documentation in sync with the implementation as your Symfony application evolves.

What You Get

  • Automatic OpenAPI 3 spec generation from Symfony routes, attributes, and models
  • Built-in Swagger UI and ReDoc rendering of the generated documentation
  • Model and form introspection using the Symfony PropertyInfo and serializer components
  • Export of the specification as JSON or YAML plus a console command to dump it

Common Use Cases

  • Documenting a Symfony REST API for internal and external consumers
  • Publishing interactive Swagger UI or ReDoc pages alongside an API
  • Generating an OpenAPI spec to feed client SDK generators or API gateways

Under The Hood

Architecture - The bundle centers on ApiDocGenerator.php, which orchestrates a pipeline of Describer and ModelDescriber classes to build an OpenAPI document. Route and attribute Describers enumerate endpoints, ModelDescribers introspect PHP classes via Symfony PropertyInfo, and the result is assembled with zircote/swagger-php’s model. Controllers and Symfony DependencyInjection wiring expose the spec and the Swagger UI/ReDoc templates.

Tech Stack - It is a PHP 8.2+ Symfony bundle (type symfony-bundle) depending on a broad set of Symfony 6.4/7/8 components (framework-bundle, routing, property-info, type-info, options-resolver) plus phpdocumentor reflection tooling and zircote/swagger-php for the OpenAPI model.

Code Quality - The project is mature and well-maintained, with a large PHPUnit test suite under tests/, PHPStan static analysis (phpstan.dist.neon with a baseline), Codecov coverage tracking, and documented upgrade guides across major versions.

API Design - Developers describe endpoints declaratively with OpenAPI attributes on controllers, and the bundle infers as much as possible from existing routes and models, minimizing hand-written spec. Configuration is done through standard Symfony bundle configuration, making adoption familiar to Symfony developers.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search