Skip to main content

Requirements

Before installing, ensure your environment meets these requirements:
The package requires illuminate/support, illuminate/console, and illuminate/routing packages, which are included in standard Laravel installations.

Install via Composer

1

Require the package

Install the package using Composer:
The service provider and facade are automatically discovered via Laravel’s package auto-discovery feature defined in composer.json.
2

Verify installation

Confirm the package is installed by checking the available Artisan commands:
You should see the openapi:generate command listed.

Publish Configuration Files

Publishing configuration files is highly recommended to customize API metadata, environments, and output settings.

Publish All Configuration Files

Run this command to publish all configuration files:
This creates four configuration files in your config/ directory:

Configuration File Purposes

openapi.php

Main configuration file for API metadata, servers, security schemes, API types, and output paths

openapi-docs.php

Custom endpoint documentation and resource-specific descriptions that override auto-generated content

openapi-tests.php

Settings for Postman test script generation including assertions and variable tracking

openapi-templates.php

Path configuration for custom JSON templates used to document specific endpoints

Publish Templates (Optional)

If you want to customize endpoint documentation using JSON templates, publish the template directory:
This creates the template directory structure:
Templates are optional. If not provided, the generator will automatically extract metadata from FormRequests and models.

Essential Configuration

After publishing, configure these essential settings in config/openapi.php:

1. API Information

Update the API metadata to match your application:
config/openapi.php

2. API Servers

Define the environments where your API is accessible:
config/openapi.php

3. API Types

Configure route prefixes for different API surfaces:
config/openapi.php

4. Security Schemes

Define authentication methods for your API:
config/openapi.php

5. Route Exclusions

Exclude internal or framework routes from documentation:
config/openapi.php

Enable HTTP Documentation Routes

To serve documentation via HTTP endpoints, ensure routes are enabled:
config/openapi.php
With this configuration, documentation is accessible at:
  • http://localhost:8000/documentation/openapi.json
  • http://localhost:8000/documentation/openapi.yaml
  • http://localhost:8000/documentation/postman
  • http://localhost:8000/documentation/insomnia
In production, protect documentation routes with authentication middleware to prevent public access to your API structure.

Environment Variables

For sensitive or environment-specific settings, use .env variables:
.env

Optional: Modular Architecture Support

If you use Nwidart Laravel Modules, configure the modules path:
config/openapi.php
The {module} placeholder is automatically replaced with actual module names during generation.

Verify Installation

Test the installation by generating documentation:
If successful, you’ll see output files in the configured output directory (default: storage/app/public/openapi/).

Next Steps

Quick Start Guide

Generate your first complete API documentation with a step-by-step tutorial