承接 ptyhard/json-schema-bundle 相关项目开发

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

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

ptyhard/json-schema-bundle

Composer 安装命令:

composer require ptyhard/json-schema-bundle

包简介

this bundles is json schema validation support.

README 文档

README

CI

JsonSchema Validate For Symfony Bundle.

Installation

$ composer req ptyhard/json-schema-bundle "dev-master"

Add config/bundles.php

<?php

return [
...



    Ptyhard\JsonSchemaBundle\JsonSchemaBundle::class => ['all' => true]
];

Introduce bundle configuration to your config file

# config/packages/ptyhard_json_schema.yml

ptyhard_json_schema: ~
    use_jms_serializer: true # default true
    json_file_directory: ~ # default null
    json_write_directory: # default null
    

Usage

Create Schema php class.

<?php
// src/JsonSchema/User.php

namespace App\JsonSchema;

use Ptyhard\JsonSchemaBundle\Annotations\SchemaClass;
use Ptyhard\JsonSchemaBundle\Annotations\Property;

/**
* @SchemaClass(required={"id","name"})
 */
class User 
{
    /**
     * @Property\NumberProperty("id")
     *
     * @var int
     */
    private $id;

    /**
     * @Property\StringProperty("name")
     *
     * @var string
     */
    private $name;
}

Create controller class.

<?php

namespace App\Controller;


use App\JsonSchema\User;
use Polidog\SimpleApiBundle\Annotations\Api;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/")
 */
class TopController
{
    /**
     * @Route("/request/check",methods={"POST"}) 
     * @Api(statusCode=200)
     *
     * @param User $user
     * @return User
     */
    public function requestCheck(User $user) :User
    {
        return  [];
    }

    /**
     * @Route("/response/check",methods={"GET"}) 
     * @Api(statusCode=200)
     *
     * @return User
     */
    public function responseCheck() :User
    {
        return new User();
    }

}

Generate object to json schema file.

If you need json schema file, can use generate command.

$ bin/console json-schema:generate:file

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固