ruwork/api-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Ruwork API Bundle

Installs: 7 181

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 5

Forks: 1

Type:symfony-bundle

0.13.5 2019-01-21 11:28 UTC

README

Routing

_api:
    resource: '@AppBundle/Controller/Api/'
    type:     annotation
    prefix:   /api
    defaults:
        _format: json
        # _ruwork_api attribute enables api listeners for this route
        _ruwork_api: true

Controller

<?php

namespace AppBundle\Controller\Api;

use Ruwork\ApiBundle\Annotations as Api;
use Ruwork\ApiBundle\Controller\AbstractApiController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * @Route("/test")
 */
class TestController extends AbstractApiController
{
    /**
     * @Method("GET")
     * @Route("")
     * @Api\Doc("Test method", requiresAuth=true, description="<p>Test method description.</p>",
     *     params={@Api\Param("id", required=true, format="int", description="<p>Description.</p>")},
     *     block="test", displayRoles={"ROLE_API_TEST"}
     * )
     */
    public function indexAction()
    {
        return ['test' => 1];
    }
}

Templating

twig:
    paths:
        "%kernel.project_dir%/vendor/ruwork/api-bundle/Resources/views": RuworkApiOriginal
{# app/Resources/RuworkApiBundle/views/docs.html.twig #}

{% extends '@RuworkApiOriginal/docs.html.twig' %}

{% block title 'Website API' %}

{% block test %}
    Override the whole method card
{% endblock %}

{% block test_description %}
    Override method description
{% endblock %}

{% block test_param_id_description %}
    Override parameter description
{% endblock %}