Skip to content

Supported Events

The SwaggerBake.Operation.created is dispatched each time a new Operation is created. Simply listen for the event:

EventManager::instance()
    ->on('SwaggerBake.Operation.created', function (Event $event) {
        /** @var \SwaggerBake\Lib\OpenApi\Operation $operation */
        $operation = $event->getSubject();
    });

The SwaggerBake.Schema.created is dispatched each time a new Schema instance is created. Simply listen for the event:

EventManager::instance()
    ->on('SwaggerBake.Schema.created', function (Event $event) {
        /** @var \SwaggerBake\Lib\OpenApi\Schema $schema */
        $schema = $event->getSubject();
    });

The SwaggerBake.initialize is dispatched once, just before Swagger begins building OpenAPI from your routes, models, and annotations.

EventManager::instance()
    ->on('SwaggerBake.initialize', function (Event $event) {
        /** @var \SwaggerBake\Lib\Swagger $swagger */
        $swagger = $event->getSubject();
        $array = $swagger->getArray();
        $array['title'] = 'A new title';
        $swagger->setArray($array);
    });

The SwaggerBake.beforeRender is dispatched once, just before Swagger converts data to an OpenAPI array or json.

EventManager::instance()
    ->on('SwaggerBake.beforeRender', function (Event $event) {
        /** @var \SwaggerBake\Lib\Swagger $swagger */
        $swagger = $event->getSubject();
        $array = $swagger->getArray();
        $array['title'] = 'A new title';
        $swagger->setArray($array);
    });