This guide shows you how to build your first REST API endpoint (/api/users/{id}) in Symfony 7.2, document it with OpenAPI YAML, and integrate Swagger UI for interactive testing. Using nelmio/api-doc-bundle and a hybrid approach, we’ll keep code clean, generate openapi.yaml, and set up docs with minimal effort. Follow these steps from scratch to create a fully documented API!
Prerequisites
- PHP 8.2+
- MySQL 8.0.42
- Composer
- Symfony CLI
- Node.js and npm (for Swagger UI)