outcomer/symfony-json-schema-validation 问题修复 & 功能扩展

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

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

outcomer/symfony-json-schema-validation

最新稳定版本:v3.0.0

Composer 安装命令:

composer require outcomer/symfony-json-schema-validation

包简介

JSON Schema validation bundle for Symfony with OPIS integration

README 文档

README

A powerful and flexible JSON Schema validation solution for Symfony applications with automatic OpenAPI documentation generation.

GitHub Actions Latest Stable Version PHP Version Symfony Version License

📚 Why

Read the story behind this bundle on Hashnode

🚀 Features

  • Complete Request Validation: Validate request body, query parameters, path variables, and headers
  • Automatic OpenAPI Documentation: Generate API documentation with nelmio/api-doc-bundle integration
  • Priority-Based Validation: Control validation order with MapRequest priority system
  • Type-Safe Results: Strongly typed validated data with ValidatedDtoInterface support
  • Comprehensive Error Handling: Detailed validation errors with JSON Schema feedback
  • Modern Symfony Integration: Full support for Symfony 7.4+ and 8.0+ with attribute-based configuration

📖 Documentation

Complete Documentation - Visit our comprehensive documentation website

Quick Links

⚡ Quick Start

Installation

composer require outcomer/symfony-json-schema-validation

Basic Usage

use Outcomer\Bundle\SymfonyJsonSchemaValidation\Attribute\MapRequest;

class UserController
{
    #[Route('/api/users', methods: ['POST'])]
    public function create(
        #[MapRequest(
            schemaPath: 'schemas/user-create.json',
            validationGroups: ['create']
        )]
        UserCreateDto $user
    ): JsonResponse {
        // $user contains validated data from request body, query, path, and headers
        return new JsonResponse(['id' => $userService->create($user)]);
    }
}

JSON Schema Example

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "body": {
      "type": "object", 
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "email": {"type": "string", "format": "email"}
      },
      "required": ["name", "email"]
    },
    "query": {
      "type": "object",
      "properties": {
        "locale": {"type": "string", "enum": ["en", "de", "fr"]}
      }
    },
    "headers": {
      "type": "object",
      "properties": {
        "x-api-version": {"type": "string", "pattern": "^v[1-9]$"}
      }
    }
  }
}

🎯 Key Benefits

  • Developer Experience: Intuitive attribute-based validation with full IDE support
  • API Documentation: Automatic OpenAPI spec generation with zero configuration
  • Production Ready: Battle-tested with comprehensive error handling and logging
  • Flexible Schema: Support for complex validation scenarios across all request components
  • Modern PHP: Takes advantage of PHP 8.2+ features and Symfony 7.4+/8.0+ improvements

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Need Help?

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固