This package will add console command to lumen/laravel which will parse yml file, convert it into json and save to public path. Redoc UI is connected and Swagger UI are connected and can be accessed to view generated documentation. Also package adds route for raw json documentation output, so this package can be used in microservice architecture, where all your microservices expose list of available routes.
- Adds console command
php artisan opendox:transform
to transform OpenApi 3.0 specification yaml files to json, so it can be accessible for external services - Adds
/api/documentation
route where you can access Redoc UI interface of documentation - Adds
/api/console
route where you can access Swagger UI interface for API docs and interaction - Adds
/docs
route where RAW json can be accessed
- Install as composer package
$ composer require noitran/opendox
- Laravel uses provider auto discovery. Config file can be published using command
$ php artisan vendor:publish --provider="Noitran\Opendox\ServiceProvider"
- Open your bootstrap/app.php and register as service provider
$app->register(Noitran\Opendox\ServiceProvider::class);
- Config file should be loaded manually in bootstrap/app.php
$app->configure('opendox');
- In your application project
/src
folder createapi-docs.yml
file. Write your documentation using OpenAPI standard
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
- Transform and publish your configuration file using command
$ php artisan opendox:transform
- Now your documentation is accessible via specified routes:
/api/documentation - Redoc UI interface
/api/console - Swagger UI with ability to send example requests
/docs - Raw JSON documentation output, that can be used for external services