Search by

ak279642 / openapi-generator-laravel

Ak279642

Laravel package for automatic OpenAPI documentation generation from routes, controllers, Form Requests, and API resources, with Swagger UI and Scalar support.

Package info

github.com/Ak279642/openapi-generator-laravel

pkg:composer/ak279642/openapi-generator-laravel

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-09-11 05:58 UTC

This package is auto-updated.

Last update: 2026-09-11 05:59:59 UTC


README

Laravel package for automatic OpenAPI 3.1 documentation generation from application routes, controllers, Form Requests, and JSON Resources.

Requirements

  • PHP 8.2+
  • Laravel 10, 11, or 12

Installation

composer require ak279642/openapi-generator-laravel
php artisan vendor:publish --tag=openapi-generator-config
php artisan openapi:generate

Documentation UIs

  • Swagger UI: /docs/swagger
  • Scalar: /docs/scalar
  • JSON specification: /docs/openapi.json
  • YAML specification: /docs/openapi.yaml

The route prefix and middleware are configurable.

Generation

php artisan openapi:generate
php artisan openapi:generate --format=json
php artisan openapi:generate --format=yaml
php artisan openapi:generate --format=both
php artisan openapi:generate --check
php artisan openapi:generate --no-cache

--output may point to a file for a single format or to a directory for both.

Configuration

Publish config/openapi-generator.php and configure:

  • OpenAPI metadata and servers
  • API route prefixes and exclusions
  • security detection and bearer scheme
  • generated file locations
  • schema depth
  • Swagger/Scalar branding
  • documentation middleware

Application conventions

The generator is intentionally convention-light. It reads the Laravel route collection and uses reflection/AST inspection where possible. Form Requests can expose conditional or documentation-specific metadata through an openApiDocs() method when your application uses that convention.

JSON Resources are inspected to build reusable component schemas and nested resource references are protected against recursion.

Publishing views

php artisan vendor:publish --tag=openapi-generator-views

Published views live under resources/views/vendor/openapi-generator.

License

MIT