Skip to content
forked from noitran/opendox

OpenApi(Swagger) 3.0 package for Lumen 5.5+ and Laravel 5.5+ with REDOC UI and SwaggerUI 3

License

Notifications You must be signed in to change notification settings

io-digital/opendox

 
 

Repository files navigation

Opendox - OpenAPI 3.0 (Swagger 3) package for Lumen and Laravel

Software License Latest Version Total Downloads

About

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.

Features

  • 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

  • Install as composer package
$ composer require io-digital/opendox

Laravel

  • Laravel uses provider auto discovery. Config file can be published using command
$ php artisan vendor:publish --provider="IoDigital\Opendox\ServiceProvider"

Lumen

  • Open your bootstrap/app.php and register as service provider
$app->register(IoDigital\Opendox\ServiceProvider::class);
  • Config file should be loaded manually in bootstrap/app.php
$app->configure('opendox');

Usage

  • In your application project /src folder create api-docs.yml file. Write your documentation using OpenAPI standard

Example

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

About

OpenApi(Swagger) 3.0 package for Lumen 5.5+ and Laravel 5.5+ with REDOC UI and SwaggerUI 3

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 82.2%
  • Blade 17.3%
  • Shell 0.5%