Commit c498d232 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

WIP API

parent 359e4c4f
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
<?php

use SygalApi\Validator\ValidatorAbstractFactory;

return [
    'validators' => [
        'abstract_factories' => [
            ValidatorAbstractFactory::class,
        ],
    ],
    'api-tools-versioning' => [
        'uri' => [
            0 => 'api.rest.ping',
+32 −19
Original line number Diff line number Diff line
<?php

return [
    'service_manager' => [
        'factories' => [
@@ -7,6 +8,17 @@ return [
            \SygalApi\V1\Rest\Inscription\InscriptionResource::class => \SygalApi\V1\Rest\Inscription\InscriptionResourceFactory::class,
        ],
    ],
    'validators' => [
        'aliases' => [
            'SygalApi\\V1\\Rest\\Inscription\\Validator' => \SygalApi\V1\Rest\Inscription\Validator\InscriptionResourceValidator::class,
        ],
    ],
    'resource_validators' => [
        \SygalApi\V1\Rest\Inscription\Validator\InscriptionResourceValidator::class => [
            'json_schema_file_path' => __DIR__ . '/inscription_schema.json',
            'json_schema_id' => "http://schema/inscription_schema.json",
        ]
    ],
    'router' => [
        'routes' => [
            'api.rest.ping' => [
@@ -45,13 +57,13 @@ return [
            'route_identifier_name' => 'ping_id',
            'collection_name' => 'ping',
            'entity_http_methods' => [
//                0 => 'GET',
                'GET' => 'GET', // astuce pour pouvoir "désactiver" la méthode si besoin
//                1 => 'PATCH',
//                2 => 'PUT',
//                3 => 'DELETE',
            ],
            'collection_http_methods' => [
                0 => 'GET',
//                0 => 'GET',
//                1 => 'POST',
            ],
            'collection_query_whitelist' => [],
@@ -115,17 +127,17 @@ return [
        'accept_whitelist' => [
            'SygalApi\\V1\\Rest\\Ping\\Controller' => [
                0 => 'application/vnd.api.v1+json',
                1 => 'application/hal+json',
                //1 => 'application/hal+json',
                2 => 'application/json',
            ],
            'SygalApi\\V1\\Rest\\Inscription\\Controller' => [
                0 => 'application/vnd.api.v1+json',
                1 => 'application/hal+json',
                //1 => 'application/hal+json',
                2 => 'application/json',
            ],
            'SygalApi\\V1\\Rest\\Diplomation\\Controller' => [
                0 => 'application/vnd.api.v1+json',
                1 => 'application/hal+json',
                //1 => 'application/hal+json',
                2 => 'application/json',
            ],
        ],
@@ -189,7 +201,8 @@ return [
            'input_filter' => 'SygalApi\\V1\\Rest\\Diplomation\\Validator',
        ],
        'SygalApi\\V1\\Rest\\Inscription\\Controller' => [
            'input_filter' => 'SygalApi\\V1\\Rest\\Inscription\\Validator',
//            'input_filter' => 'SygalApi\\V1\\Rest\\Inscription\\Validator',
            'validator' => 'SygalApi\\V1\\Rest\\Inscription\\Validator',
        ],
    ],
    'input_filter_specs' => [
@@ -202,22 +215,22 @@ return [
                'field_type' => 'string',
            ],
        ],
        'SygalApi\\V1\\Rest\\Inscription\\Validator' => [
            0 => [
                'required' => true,
                'validators' => [],
                'filters' => [],
                'name' => 'IdInstancePegase',
                'field_type' => 'string',
            ],
        ],
//        'SygalApi\\V1\\Rest\\Inscription\\Validator' => [
//            0 => [
//                'required' => true,
//                'validators' => [],
//                'filters' => [],
//                'name' => 'IdInstancePegase',
//                'field_type' => 'string',
//            ],
//        ],
    ],
    'api-tools-mvc-auth' => [
        'authorization' => [
            'SygalApi\\V1\\Rest\\Ping\\Controller' => [
                'collection' => [
                    'GET' => true,
                    'POST' => true,
                    'POST' => false,
                    'PUT' => false,
                    'PATCH' => false,
                    'DELETE' => false,
@@ -225,9 +238,9 @@ return [
                'entity' => [
                    'GET' => true,
                    'POST' => false,
                    'PUT' => true,
                    'PATCH' => true,
                    'DELETE' => true,
                    'PUT' => false,
                    'PATCH' => false,
                    'DELETE' => false,
                ],
            ],
            'SygalApi\\V1\\Rest\\Diplomation\\Controller' => [
+48 −0
Original line number Diff line number Diff line
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",

  "type": "object",

  "properties": {

    "routage": {
      "type": "object",
      "properties": {
        "IdInstancePegase": {
          "type": "string"
        }
      },
      "required": ["IdInstancePegase"],
      "additionalProperties": false
    },

    "periode": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "datedebut": {
          "type": "string",
          "format": "date"
        },
        "datefin": {
          "type": "string",
          "format": "date"
        },
        "anneeuniversitaire": {
          "type": "integer"
        }
      },
      "required": ["code", "datedebut", "datefin"],
      "additionalProperties": false
    }
  },

  "required": [
    "routage",
//    "periode"
  ],

  "additionalProperties": false
}
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ class Module implements ApiToolsProviderInterface

        return ArrayUtils::merge(
            include $configDir . '/module.config.php',
            include $configDir . '/versions/v1.config.php',
            include $configDir . '/v1/api.config.php',
        );
    }

@@ -21,7 +21,7 @@ class Module implements ApiToolsProviderInterface
        return [
            'Laminas\ApiTools\Autoloader' => [
                'namespaces' => [
                    __NAMESPACE__ => __DIR__ . '/../src',
                    __NAMESPACE__ => __DIR__,
                ],
            ],
        ];
+9 −0
Original line number Diff line number Diff line
@@ -4,9 +4,18 @@ namespace SygalApi\V1\Rest\Inscription;
use Laminas\ApiTools\ApiProblem\ApiProblem;
use Laminas\ApiTools\Rest\AbstractResourceListener;
use Laminas\Stdlib\Parameters;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;

class InscriptionResource extends AbstractResourceListener
{
    use LoggerAwareTrait;

    public function __construct()
    {
        $this->logger = new NullLogger();
    }

    /**
     * Create a resource
     *
Loading