承接 php-solution/nelmio-apidoc-yaml-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-solution/nelmio-apidoc-yaml-bundle

Composer 安装命令:

composer require php-solution/nelmio-apidoc-yaml-bundle

包简介

This bundle provides an integration of NelmioApiDocBundle with yaml extractor

README 文档

README

This bundle allows you to use NelmioApiDocBundle and store all apidocs on yml config files.

Bundle includes 2 new apidoc extractors:

  • Chain extractor
  • Yaml extractor.

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

You can use standard ApiDocExtractor with @nelmio_api_doc.extractor.api_doc_extractor.phpdoc service name.

Chain extractor use Yaml extractor and phpdoc extractor.

Yaml extractor check all @Bundle\Resources\config\api_doc.yml and create config for apidoc.

All configuration parameters you can find on https://github.com/nelmio/NelmioApiDocBundle documentation.

Using

Example of yml config:

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:

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:

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
NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /rest-api/doc 
  1. If you want change default setting of bundle you can change it on app/config/config.yml:
    ...
    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%

统计信息

  • 总下载量: 261
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固