2017 © Pedro Peláez
 

symfony-bundle nelmio-apidoc-yaml-bundle

This bundle provides an integration of NelmioApiDocBundle with yaml extractor

image

php-solution/nelmio-apidoc-yaml-bundle

This bundle provides an integration of NelmioApiDocBundle with yaml extractor

  • Friday, July 7, 2017
  • by olesav
  • Repository
  • 6 Watchers
  • 2 Stars
  • 213 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

NelmioApiDocYamlBundle

This bundle allows you to use NelmioApiDocBundle and store all apidocs on yml config files., (*1)

Bundle includes 2 new apidoc extractors: * Chain extractor * Yaml extractor., (*2)

Bundle change definition for standard api doc extractor and now @nelmio_api_doc.extractor.api_doc_extractor definition of PhpSolution\NelmioApiDocYamlBundle\Extractor\ChainApiDocExtractor., (*3)

You can use standard ApiDocExtractor with @nelmio_api_doc.extractor.api_doc_extractor.phpdoc service name., (*4)

Chain extractor use Yaml extractor and phpdoc extractor., (*5)

Yaml extractor check all @Bundle\Resources\config\api_doc.yml and create config for apidoc., (*6)

All configuration parameters you can find on https://github.com/nelmio/NelmioApiDocBundle documentation., (*7)

Using

Example of yml config:, (*8)

rest_api_security_login_check: # route name
    section: "Authorization"
    resource: false
    description: ""
    https: false
    deprecated: false
    tags: []
    filters: []
    output:
        class: PhpSolution\NelmioApiDocYamlBundle\Form\SimpleType
        options:
            fields:
                - {name: "token",  type: "text"}
                - {name: "expDate",  type: "integer", options: {description: "timestamp"}}
                - {name: "expDateOffset",  type: "integer", options: {description: "time offset"}}
    requirements:
        - { name: "username",  dataType: "string"}
        - { name: "password",  dataType: "string"}
    statusCodes: {"200": "Returned when successful", 401: "Returned when the user is not authorized"}
    views: []
    documentation: 'Get authorization token for access to api endpoints'
    authentication: true

If you want to define input options without creation new class for apidoc you can use like this:, (*9)

requirements:
    - { name: "username",  dataType: "string"}
    - { name: "password",  dataType: "string"}

If yo want to define output parameters without creation new class for apidoc you can use like this:, (*10)

output:
    class: PhpSolution\NelmioApiDocYamlBundle\Form\SimpleType
    options:
        fields:
            - {name: "token",  type: "text"}
            - {name: "expDate",  type: "integer", options: {description: "timestamp"}}
            - {name: "expDateOffset",  type: "integer", options: {description: "time offset"}}

Config

1) Add route to app/config/routing.yml, (*11)

NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /rest-api/doc 

2) If you want change default setting of bundle you can change it on app/config/config.yml:, (*12)

    ...
    nelmio_api_doc_yaml:
        metadata:
            file_path: api_doc.yml
            defaults: ~ #path to defaults
        cache:
            enabled: false
            file: %kernel.cache_dir%/api-doc-yml.cache

Installing

  1. Add to your composer.json
    "require": {
        ...
        "php-solution/nelmio-apidoc-yaml-bundle": "dev-master"
        ...
    }
  1. Add to AppKernel.php:
    public function registerBundles()
    {
        $bundles = array(
        ...
        new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
        new PhpSolution\NelmioApiDocYamlBundle\CiklumNelmioApiDocYamlBundle(),
        ...
  1. run:
    composer update php-solution/nelmio-apidoc-yaml-bundle

TODO

  • Coverage more than 80%

The Versions

07/07 2017

dev-master

9999999-dev

This bundle provides an integration of NelmioApiDocBundle with yaml extractor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oleksandr Savchenko

26/05 2017

v0.1

0.1.0.0

This bundle provides an integration of NelmioApiDocBundle with yaml extractor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oleksandr Savchenko