定制 dawen/api-doc-property-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dawen/api-doc-property-bundle

Composer 安装命令:

composer require dawen/api-doc-property-bundle

包简介

A extension for nelmio api doc bundle to expose properties

README 文档

README

Build Status

This bundle allows you to expose properties for api documentation that are not handled by json, jms or validator parsers

Installation

Require the dawen/api-doc-property-bundle package in your composer.json and update your dependencies.

    $ composer require dawen/api-doc-property-bundle
    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new Dawen\Bundle\ApiDocPropertyBundle\ApiDocPropertyBundle(),
        );
    }

Register the bundle in app/AppKernel.php:

Usage And Examples

For defining a property you can add a new annotation to your property

    @ApiDocProperty(type="string")

Available properties for setting your informations:

name

Type: string
Description: Name of the property. If this is not set, then the name of the class property will be taken

description

Type: string
Description: This will be set as description for the property

type

Types: all php types, full qualified class name, array<full qualified class name>
Description: The type property has no strict limitation. you can write whatever you want. But keep in mind, 
that it appears in the api documentation. There is only some magic for classes and array of objects. This will be parsed recursively

Example for a simple class:

    namespace Dawen\Bundle\ApiDocPropertyBundle;
    
    use Dawen\Bundle\ApiDocPropertyBundle\Component\Annotation\ApiDocProperty;
    
    class Dummy
    {
        /**
         * @ApiDocProperty(type="string")
         * @var string
         */
        private $firstName;
    
        /**
         * @ApiDocProperty(type="string")
         * @var string 
         */
        private $lastName;
    
        /**
         * @ApiDocProperty(type="int")
         * @var int
         */
        private $age = 0;
    
        /**
         * @ApiDocProperty(type="Dawen\Bundle\ApiDocPropertyBundle\Address")
         * @var Dawen\Bundle\ApiDocPropertyBundle\Address
         */
        private $address;
    
        /**
         * @ApiDocProperty(type="array<Dawen\Bundle\ApiDocPropertyBundle\Key>")
         * @var array
         */
        private $keys = [];
    
        /**
         * @return string
         */
        public function getFirstName()
        {
            return $this->firstName;
        }
    
        /**
         * @param string $firstName
         */
        public function setFirstName($firstName)
        {
            $this->firstName = $firstName;
        }
    
        /**
         * @return string
         */
        public function getLastName()
        {
            return $this->lastName;
        }
    
        /**
         * @param string $lastName
         */
        public function setLastName($lastName)
        {
            $this->lastName = $lastName;
        }
    
        /**
         * @return int
         */
        public function getAge()
        {
            return $this->age;
        }
    
        /**
         * @param int $age
         */
        public function setAge($age)
        {
            $this->age = $age;
        }
    
        /**
         * @return Dawen\Bundle\ApiDocPropertyBundle\Address
         */
        public function getAddress()
        {
            return $this->address;
        }
    
        /**
         * @param Dawen\Bundle\ApiDocPropertyBundle\Address $address
         */
        public function setAddress($address)
        {
            $this->address = $address;
        }
    
        /**
         * @return array
         */
        public function getKeys()
        {
            return $this->keys;
        }
    
        /**
         * @param array $keys
         */
        public function setKeys($keys)
        {
            $this->keys = $keys;
        }
        
    }

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固