Zend Expressive fix and upgrade to version 2 (#6461)

* upgraded zend-expressive from version 1 to 2

* Changed error handler for compatibility with Zend Expressive 2

* generated newest sample files for Petstore ze-ph

* removed ErrorMiddleware because it is never been used anymore. Regenerated samples

* removed ErrorMiddleware Template from Codegen

* remove ErrorMiddleware from petstore sample

* Fixed some code styles

* regenerated ze-ph samples with corrected code styles

* added new line at the end of the file
This commit is contained in:
Brad Crumb 2017-09-23 09:31:20 +02:00 committed by wing328
parent ccc980e619
commit c5c639b62b
77 changed files with 274 additions and 163 deletions

View File

@ -55,7 +55,6 @@ public class ZendExpressivePathHandlerServerCodegen extends AbstractPhpCodegen {
supportingFiles.add(new SupportingFile("Date.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Strategy", "Date.php"));
supportingFiles.add(new SupportingFile("DateTime.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Strategy", "DateTime.php"));
supportingFiles.add(new SupportingFile("Type.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Validator", "Type.php"));
supportingFiles.add(new SupportingFile("ErrorMiddleware.php.mustache", packagePath + File.separator + srcBasePath, "ErrorMiddleware.php"));
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, "1.0.0");
}

View File

@ -12,6 +12,10 @@ class Date extends DateTime
*/
protected function parseDateString($arrayValue)
{
return \DateTime::createFromFormat(static::DATE_TIME_FORMAT.' H:i:sP', $arrayValue.' 00:00:00+00:00', new \DateTimeZone('UTC'));
return \DateTime::createFromFormat(
static::DATE_TIME_FORMAT . ' H:i:sP',
$arrayValue . ' 00:00:00+00:00',
new \DateTimeZone('UTC')
);
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace {{invokerPackage}}\Strategy;
use Articus\DataTransfer\Strategy\StrategyInterface;
class DateTime implements StrategyInterface
{
const DATE_TIME_FORMAT = \DateTime::RFC3339;
/**
* @inheritDoc
*/

View File

@ -1,20 +0,0 @@
<?php
namespace {{invokerPackage}};
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Stratigility\ErrorMiddlewareInterface;
class ErrorMiddleware implements ErrorMiddlewareInterface
{
/**
* @inheritDoc
*/
public function __invoke($error, Request $request, Response $response, callable $out = null)
{
$response = $response->withStatus(500, 'Internal server error');
$response->getBody()->write((string)$error);
error_log((string) $error);
return ($out === null)? $response : $out($request, $response);
}
}

View File

@ -11,7 +11,6 @@ use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
{{#operations}}
{{#description}}
/**
* {{&description}}
@ -40,7 +39,11 @@ class {{classname}} implements {{interfacesToImplement}}
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="{{mediaType}}")
{{/produces}}
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
{{#returnType}}
*
* @return {{returnType}}
{{/returnType}}
*/

View File

@ -3,17 +3,24 @@ dependencies:
#Has to add this line because currently router is strict requirement for Zend\Expressive\Application even if only middleware_pipeline is used
Zend\Expressive\Router\RouterInterface: Zend\Expressive\Router\ZendRouter
Zend\Diactoros\Response\EmitterInterface: Zend\Diactoros\Response\SapiStreamEmitter
{{invokerPackage}}\ErrorMiddleware: {{invokerPackage}}\ErrorMiddleware
factories:
Zend\Expressive\Application: Zend\Expressive\Container\ApplicationFactory
Articus\PathHandler\Middleware: Articus\PathHandler\MiddlewareFactory
Articus\DataTransfer\Service: Articus\DataTransfer\ServiceFactory
Zend\Stratigility\Middleware\ErrorHandler: Zend\Expressive\Container\ErrorHandlerFactory
Zend\Expressive\Middleware\ErrorResponseGenerator: Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory
Zend\Expressive\Whoops: Zend\Expressive\Container\WhoopsFactory
Zend\Expressive\WhoopsPageHandler: Zend\Expressive\Container\WhoopsPageHandlerFactory
middleware_pipeline:
error:
middleware: Zend\Stratigility\Middleware\ErrorHandler
api:
middleware: Articus\PathHandler\Middleware
path: {{basePathWithoutHost}}
error:
middleware: {{invokerPackage}}\ErrorMiddleware
error: true
priority: -10000
whoops:
json_exceptions:
display: true
show_trace: true
ajax_only: true

View File

@ -7,12 +7,14 @@
"require": {
"php": "^5.6 || ^7.0",
"ext-yaml" : "^1.2 || ^2.0",
"zendframework/zend-expressive": "^1.0",
"zendframework/zend-expressive-router": "1.2.*",
"articus/path-handler": "0.1.*",
"zendframework/zend-expressive": "^2.0",
"zendframework/zend-expressive-router": "^2.1",
"zendframework/zend-expressive-zendrouter": "^2.0",
"articus/path-handler": "0.2.*",
"articus/data-transfer": "*",
"zendframework/zend-serializer": "*",
"zendframework/zend-config": "*"
"zendframework/zend-config": "*",
"filp/whoops": "^2.1.7"
},
"autoload": {
"psr-4": {

View File

@ -1,2 +1,3 @@
#App
cache_configuration: false
debug: true

View File

@ -127,5 +127,4 @@ class {{classname}}
*/
public ${{name}};
{{/vars}}
}
{{/model}}{{/models}}
}{{/model}}{{/models}}

View File

@ -1 +1 @@
2.2.3-SNAPSHOT
2.3.0-SNAPSHOT

View File

@ -1,2 +1,3 @@
#App
cache_configuration: false
debug: true

View File

@ -3,17 +3,24 @@ dependencies:
#Has to add this line because currently router is strict requirement for Zend\Expressive\Application even if only middleware_pipeline is used
Zend\Expressive\Router\RouterInterface: Zend\Expressive\Router\ZendRouter
Zend\Diactoros\Response\EmitterInterface: Zend\Diactoros\Response\SapiStreamEmitter
App\ErrorMiddleware: App\ErrorMiddleware
factories:
Zend\Expressive\Application: Zend\Expressive\Container\ApplicationFactory
Articus\PathHandler\Middleware: Articus\PathHandler\MiddlewareFactory
Articus\DataTransfer\Service: Articus\DataTransfer\ServiceFactory
Zend\Stratigility\Middleware\ErrorHandler: Zend\Expressive\Container\ErrorHandlerFactory
Zend\Expressive\Middleware\ErrorResponseGenerator: Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory
Zend\Expressive\Whoops: Zend\Expressive\Container\WhoopsFactory
Zend\Expressive\WhoopsPageHandler: Zend\Expressive\Container\WhoopsPageHandlerFactory
middleware_pipeline:
error:
middleware: Zend\Stratigility\Middleware\ErrorHandler
api:
middleware: Articus\PathHandler\Middleware
path: /v2
error:
middleware: App\ErrorMiddleware
error: true
priority: -10000
whoops:
json_exceptions:
display: true
show_trace: true
ajax_only: true

View File

@ -9,6 +9,12 @@ path_handler:
handler: Fake
may_terminate: true
child_routes:
'jsonFormData':
type: Literal
options:
route: /jsonFormData
defaults:
handler: FakeJsonFormData
'outer':
type: Literal
options:
@ -38,6 +44,12 @@ path_handler:
route: /string
defaults:
handler: FakeOuterString
'fake_classname_test':
type: Literal
options:
route: /fake_classname_test
defaults:
handler: FakeClassnameTest
'pet':
type: Literal
options:
@ -150,10 +162,12 @@ path_handler:
handlers:
invokables:
Fake: App\Handler\Fake
FakeJsonFormData: App\Handler\FakeJsonFormData
FakeOuterBoolean: App\Handler\FakeOuterBoolean
FakeOuterComposite: App\Handler\FakeOuterComposite
FakeOuterNumber: App\Handler\FakeOuterNumber
FakeOuterString: App\Handler\FakeOuterString
FakeClassnameTest: App\Handler\FakeClassnameTest
Pet: App\Handler\Pet
PetFindByStatus: App\Handler\PetFindByStatus
PetFindByTags: App\Handler\PetFindByTags

View File

@ -7,12 +7,14 @@
"require": {
"php": "^5.6 || ^7.0",
"ext-yaml" : "^1.2 || ^2.0",
"zendframework/zend-expressive": "^1.0",
"zendframework/zend-expressive-router": "1.2.*",
"articus/path-handler": "0.1.*",
"zendframework/zend-expressive": "^2.0",
"zendframework/zend-expressive-router": "^2.1",
"zendframework/zend-expressive-zendrouter": "^2.0",
"articus/path-handler": "0.2.*",
"articus/data-transfer": "*",
"zendframework/zend-serializer": "*",
"zendframework/zend-config": "*"
"zendframework/zend-config": "*",
"filp/whoops": "^2.1.7"
},
"autoload": {
"psr-4": {

View File

@ -21,4 +21,3 @@ class AdditionalPropertiesClass
*/
public $map_of_map_property;
}

View File

@ -21,4 +21,3 @@ class Animal
*/
public $color;
}

View File

@ -9,4 +9,3 @@ use Articus\DataTransfer\Annotation as DTA;
class AnimalFarm
{
}

View File

@ -27,4 +27,3 @@ class ApiResponse
*/
public $message;
}

View File

@ -18,4 +18,3 @@ class ArrayOfArrayOfNumberOnly
*/
public $array_array_number;
}

View File

@ -17,4 +17,3 @@ class ArrayOfNumberOnly
*/
public $array_number;
}

View File

@ -35,4 +35,3 @@ class ArrayTest
*/
public $array_array_of_model;
}

View File

@ -46,4 +46,3 @@ class Capitalization
*/
public $att_name;
}

View File

@ -27,4 +27,3 @@ class Cat
*/
public $declawed;
}

View File

@ -21,4 +21,3 @@ class Category
*/
public $name;
}

View File

@ -16,4 +16,3 @@ class ClassModel
*/
public $_class;
}

View File

@ -15,4 +15,3 @@ class Client
*/
public $client;
}

View File

@ -27,4 +27,3 @@ class Dog
*/
public $breed;
}

View File

@ -23,4 +23,3 @@ class EnumArrays
*/
public $array_enum;
}

View File

@ -9,4 +9,3 @@ use Articus\DataTransfer\Annotation as DTA;
class EnumClass
{
}

View File

@ -34,4 +34,3 @@ class EnumTest
*/
public $outer_enum;
}

View File

@ -63,6 +63,8 @@ class FormatTest
public $string;
/**
* @DTA\Data(field="byte")
* @DTA\Validator(name="Type", options={"type":"string"})
* @DTA\Validator(name="Regex", options={"pattern":"/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/"})
* @var string
*/
public $byte;
@ -99,4 +101,3 @@ class FormatTest
*/
public $password;
}

View File

@ -21,4 +21,3 @@ class HasOnlyReadOnly
*/
public $foo;
}

View File

@ -21,4 +21,3 @@ class MapTest
*/
public $map_of_enum_string;
}

View File

@ -29,4 +29,3 @@ class MixedPropertiesAndAdditionalPropertiesClass
*/
public $map;
}

View File

@ -22,4 +22,3 @@ class Model200Response
*/
public $class;
}

View File

@ -16,4 +16,3 @@ class ModelReturn
*/
public $return;
}

View File

@ -34,4 +34,3 @@ class Name
*/
public $_123_number;
}

View File

@ -15,4 +15,3 @@ class NumberOnly
*/
public $just_number;
}

View File

@ -47,4 +47,3 @@ class Order
*/
public $complete;
}

View File

@ -9,4 +9,3 @@ use Articus\DataTransfer\Annotation as DTA;
class OuterBoolean
{
}

View File

@ -30,4 +30,3 @@ class OuterComposite
*/
public $my_boolean;
}

View File

@ -9,4 +9,3 @@ use Articus\DataTransfer\Annotation as DTA;
class OuterEnum
{
}

View File

@ -9,4 +9,3 @@ use Articus\DataTransfer\Annotation as DTA;
class OuterNumber
{
}

View File

@ -9,4 +9,3 @@ use Articus\DataTransfer\Annotation as DTA;
class OuterString
{
}

View File

@ -52,4 +52,3 @@ class Pet
*/
public $status;
}

View File

@ -21,4 +21,3 @@ class ReadOnlyFirst
*/
public $baz;
}

View File

@ -15,4 +15,3 @@ class SpecialModelName
*/
public $special_property_name;
}

View File

@ -21,4 +21,3 @@ class Tag
*/
public $name;
}

View File

@ -58,4 +58,3 @@ class User
*/
public $user_status;
}

View File

@ -1,20 +0,0 @@
<?php
namespace App;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Stratigility\ErrorMiddlewareInterface;
class ErrorMiddleware implements ErrorMiddlewareInterface
{
/**
* @inheritDoc
*/
public function __invoke($error, Request $request, Response $response, callable $out = null)
{
$response = $response->withStatus(500, 'Internal server error');
$response->getBody()->write((string)$error);
error_log((string) $error);
return ($out === null)? $response : $out($request, $response);
}
}

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class Fake implements Operation\PatchInterface, Operation\PostInterface, Operation\GetInterface
{
/**
@ -20,6 +19,10 @@ class Fake implements Operation\PatchInterface, Operation\PostInterface, Operati
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Client::class,"objectAttr":"body"})
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Client
*/
public function handlePatch(ServerRequestInterface $request)
@ -35,6 +38,9 @@ class Fake implements Operation\PatchInterface, Operation\PostInterface, Operati
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml; charset&#x3D;utf-8")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json; charset&#x3D;utf-8")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePost(ServerRequestInterface $request)
{
@ -45,6 +51,9 @@ class Fake implements Operation\PatchInterface, Operation\PostInterface, Operati
* To test enum parameters
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="*/*")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handleGet(ServerRequestInterface $request)
{

View File

@ -0,0 +1,35 @@
<?php
namespace App\Handler;
use Articus\PathHandler\Operation;
use Articus\PathHandler\Annotation as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class FakeClassnameTest implements Operation\PatchInterface
{
/**
* To test class name in snake case
* TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json")
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Client::class,"objectAttr":"body"})
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Client
*/
public function handlePatch(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\Client $body */
$body = $request->getAttribute("body");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Handler;
use Articus\PathHandler\Operation;
use Articus\PathHandler\Annotation as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class FakeJsonFormData implements Operation\GetInterface
{
/**
* test json serialization of form data
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handleGet(ServerRequestInterface $request)
{
//TODO implement method
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -10,11 +10,14 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class FakeOuterBoolean implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterBoolean::class,"objectAttr":"body"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterBoolean
*/
public function handlePost(ServerRequestInterface $request)

View File

@ -10,11 +10,14 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class FakeOuterComposite implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterComposite::class,"objectAttr":"body"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterComposite
*/
public function handlePost(ServerRequestInterface $request)

View File

@ -10,11 +10,14 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class FakeOuterNumber implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterNumber::class,"objectAttr":"body"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterNumber
*/
public function handlePost(ServerRequestInterface $request)

View File

@ -10,11 +10,14 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class FakeOuterString implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterString::class,"objectAttr":"body"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterString
*/
public function handlePost(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class Pet implements Operation\PostInterface, Operation\PutInterface
{
/**
@ -24,6 +23,9 @@ class Pet implements Operation\PostInterface, Operation\PutInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePost(ServerRequestInterface $request)
{
@ -43,6 +45,9 @@ class Pet implements Operation\PostInterface, Operation\PutInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePut(ServerRequestInterface $request)
{

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class PetFindByStatus implements Operation\GetInterface
{
/**
@ -19,6 +18,10 @@ class PetFindByStatus implements Operation\GetInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Pet[]
*/
public function handleGet(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class PetFindByTags implements Operation\GetInterface
{
/**
@ -19,6 +18,10 @@ class PetFindByTags implements Operation\GetInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Pet[]
*/
public function handleGet(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class PetPetId implements Operation\DeleteInterface, Operation\GetInterface, Operation\PostInterface
{
/**
@ -19,6 +18,9 @@ class PetPetId implements Operation\DeleteInterface, Operation\GetInterface, Ope
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handleDelete(ServerRequestInterface $request)
{
@ -31,6 +33,10 @@ class PetPetId implements Operation\DeleteInterface, Operation\GetInterface, Ope
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Pet
*/
public function handleGet(ServerRequestInterface $request)
@ -44,6 +50,9 @@ class PetPetId implements Operation\DeleteInterface, Operation\GetInterface, Ope
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePost(ServerRequestInterface $request)
{

View File

@ -10,13 +10,16 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class PetPetIdUploadImage implements Operation\PostInterface
{
/**
* uploads an image
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\ApiResponse
*/
public function handlePost(ServerRequestInterface $request)

View File

@ -10,13 +10,16 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class StoreInventory implements Operation\GetInterface
{
/**
* Returns pet inventories by status
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return map[string,int]
*/
public function handleGet(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class StoreOrder implements Operation\PostInterface
{
/**
@ -20,6 +19,10 @@ class StoreOrder implements Operation\PostInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Order
*/
public function handlePost(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class StoreOrderOrderId implements Operation\DeleteInterface, Operation\GetInterface
{
/**
@ -19,6 +18,9 @@ class StoreOrderOrderId implements Operation\DeleteInterface, Operation\GetInter
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handleDelete(ServerRequestInterface $request)
{
@ -31,6 +33,10 @@ class StoreOrderOrderId implements Operation\DeleteInterface, Operation\GetInter
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\Order
*/
public function handleGet(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class User implements Operation\PostInterface
{
/**
@ -20,6 +19,9 @@ class User implements Operation\PostInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePost(ServerRequestInterface $request)
{

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class UserCreateWithArray implements Operation\PostInterface
{
/**
@ -20,6 +19,9 @@ class UserCreateWithArray implements Operation\PostInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePost(ServerRequestInterface $request)
{

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class UserCreateWithList implements Operation\PostInterface
{
/**
@ -20,6 +19,9 @@ class UserCreateWithList implements Operation\PostInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePost(ServerRequestInterface $request)
{

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class UserLogin implements Operation\GetInterface
{
/**
@ -19,6 +18,10 @@ class UserLogin implements Operation\GetInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return string
*/
public function handleGet(ServerRequestInterface $request)

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class UserLogout implements Operation\GetInterface
{
/**
@ -19,6 +18,9 @@ class UserLogout implements Operation\GetInterface
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handleGet(ServerRequestInterface $request)
{

View File

@ -10,7 +10,6 @@ use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
class UserUsername implements Operation\DeleteInterface, Operation\GetInterface, Operation\PutInterface
{
/**
@ -19,6 +18,9 @@ class UserUsername implements Operation\DeleteInterface, Operation\GetInterface,
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handleDelete(ServerRequestInterface $request)
{
@ -31,6 +33,10 @@ class UserUsername implements Operation\DeleteInterface, Operation\GetInterface,
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\User
*/
public function handleGet(ServerRequestInterface $request)
@ -45,6 +51,9 @@ class UserUsername implements Operation\DeleteInterface, Operation\GetInterface,
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml")
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePut(ServerRequestInterface $request)
{

View File

@ -12,6 +12,10 @@ class Date extends DateTime
*/
protected function parseDateString($arrayValue)
{
return \DateTime::createFromFormat(static::DATE_TIME_FORMAT.' H:i:sP', $arrayValue.' 00:00:00+00:00', new \DateTimeZone('UTC'));
return \DateTime::createFromFormat(
static::DATE_TIME_FORMAT . ' H:i:sP',
$arrayValue . ' 00:00:00+00:00',
new \DateTimeZone('UTC')
);
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace App\Strategy;
use Articus\DataTransfer\Strategy\StrategyInterface;
class DateTime implements StrategyInterface
{
const DATE_TIME_FORMAT = \DateTime::RFC3339;
/**
* @inheritDoc
*/