Skip to content

The documentation bundle manages the required routes and templates in order to show documentation both in OpenApi and AsyncApi formats.

License

Notifications You must be signed in to change notification settings

PcComponentes/documentation-bundle

Repository files navigation

Documentation Bundle

The documentation bundle manages the required routes and templates in order to show documentation both in OpenApi and AsyncApi formats.

Installation

Add the pccomponentes/documentation-bundle package to your require section in the composer.json file.

$ composer require pccomponentes/documentation-bundle

Add the DocumentationBundle to your application's kernel.

<?php
public function registerBundles()
{
    $bundles = [
        // ...
        new PcComponentes\DocumentationBundle\DocumentationBundle(),
        // ...
    ];
    ...
}

Depending on your installation, maybe you should add it to the bundles.php file instead.

<?php

return [
    // ...
    PcComponentes\DocumentationBundle\DocumentationBundle::class => ['all' => true],
    // ...
];

Usage

Configure the paths to your YAML files in your config.yml (Both keys are optional).

documentation:
    openapi: 'docs/openapi.yml'
    asyncapi: 'docs/asyncapi.yml'

Enable the paths in your routing.yml file.

documentation:
    resource: '@DocumentationBundle/Resources/config/routing.yaml'
    prefix: /docs

You can choose a prefix where the documentation will be published.

After this, you should be able to see the Swagger interface at /openapi (or /docs/openapi if you used the docs prefix), the AsyncApi at /asyncapi, and all of your event converters at /converters.

Also, you can customize the SwaggerUI options using the key swagger_options, and the AsyncApi ones using asyncapi_options, for example:

documentation:
    openapi: 'docs/openapi.yml'
    asyncapi: 'docs/asyncapi.yml'
    swagger_options:
        deepLinking: true
        displayOperationId: true
        displayRequestDuration: true
    asyncapi_options:
        schemaFetchOptions: '{"method":"GET","mode":"cors"}'
    

In addition, you can add your custom links to the homepage using the links key, here is an example:

documentation:
    links:
        - title: 'Google'
          description: 'You can add some notes for each link'
          url: 'https://www.google.com/'
        - title: 'Contact PcComponentes'
          url: 'https://www.pccomponentes.com/soporte/contactar-con-pccomponentes'

About

The documentation bundle manages the required routes and templates in order to show documentation both in OpenApi and AsyncApi formats.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •