PHP code example of ptyhard / json-schema-bundle

1. Go to this page and download the library: Download ptyhard/json-schema-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ptyhard / json-schema-bundle example snippets




return [
...



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



// src/JsonSchema/User.php

namespace App\JsonSchema;

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

/**
* @SchemaClass(g
     */
    private $name;
}




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();
    }

}