bcastellano/json-schema-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bcastellano/json-schema-bundle

Composer 安装命令:

composer require bcastellano/json-schema-bundle

包简介

Symfony bundle to validate json api request and responses with json-schema

README 文档

README

Build Status Coverage Status SensioLabsInsight License

Json-Schema Bundle

Symfony bundle to validate json api requests and responses based on JSON Schema specification.

It auto validates Requests and Responses for an API with json-schema files that can be auto generated from json body.

JSON Schema is described in its specification as:

JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

Features

  • Json Schema service for validate jsons
  • Listener to auto validate request and responses
  • Json Schema file generation from json body (request and responses content)

Installation

Composer:

composer require bcastellano/json-schema-bundle

Load the bundle:

<?php
// app/AppKernel.php

use Bcastellano\JsonSchemaBundle\JsonSchemaBundle;

public function registerBundles()
{
    $bundles = array(
        // ...
        new JsonSchemaBundle(),
    );
}

Configuration

This is a complete example of configuration parameters:

json_schema:
    # Validator
    validator:
        # Class to use in validation. Is an enum
        class: Bcastellano\JsonSchemaBundle\Validator\JsonSchemaValidator
        # To auto register request and response events to auto validate jsons 
        use_listener: true
    
    # Locator
    locator:
        # Class to locate schema files
        class: Bcastellano\JsonSchemaBundle\Locator\ControllerSchemaFileLocator
        # Directory for json schema files (also to save new ones)
        resources_dir: '%kernel.root_dir%/Resources/Schemas'
    
    # Configuration for schema generator
    generator:
        enabled: false
        # NOTE: these two configurations are incompatible, you can't configure both
        # this use any external command to generate schema from json
        command: '/path/to/command {{source_file}} --output {{target_file}}'
        # this use any custom service to generate schema from json
        service: 'some.custom.service'

License

This bundle is under the MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固