forked from loafle/openapi-generator-original
update php ze-ph samples
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTO;
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use Interop\Http\ServerMiddleware\MiddlewareInterface;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Zend\Stdlib\ErrorHandler;
|
||||
|
||||
class ErrorMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function process(Request $request, DelegateInterface $delegate)
|
||||
{
|
||||
$result = null;
|
||||
try {
|
||||
ErrorHandler::start();
|
||||
$result = $delegate->process($request);
|
||||
ErrorHandler::stop(true);
|
||||
if (!($result instanceof Response)) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Invalid response: expecting %s, got %s',
|
||||
Response::class,
|
||||
is_object($result)? get_class($result) : gettype($result)
|
||||
));
|
||||
}
|
||||
}
|
||||
catch (\Exception $error) {
|
||||
$result = (new \Zend\Diactoros\Response())->withStatus(500, 'Internal server error');
|
||||
error_log((string)$error);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class AnotherFakeDummy
|
||||
{
|
||||
/**
|
||||
* To test special tags
|
||||
* @PHA\Patch()
|
||||
* @PHA\handlePatch
|
||||
* 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":"bodyData"})
|
||||
|
||||
@@ -17,7 +17,7 @@ class Fake
|
||||
{
|
||||
/**
|
||||
* To test \"client\" model
|
||||
* @PHA\Patch()
|
||||
* @PHA\handlePatch
|
||||
* 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":"bodyData"})
|
||||
@@ -38,7 +38,7 @@ class Fake
|
||||
}
|
||||
/**
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
@@ -50,7 +50,7 @@ class Fake
|
||||
}
|
||||
/**
|
||||
* To test enum parameters
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
@@ -62,7 +62,7 @@ class Fake
|
||||
}
|
||||
/**
|
||||
* Fake endpoint to test group parameters (optional)
|
||||
* @PHA\Delete()
|
||||
* @PHA\handleDelete
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -16,7 +16,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
class FakeBodyWithFileSchema
|
||||
{
|
||||
/**
|
||||
* @PHA\Put()
|
||||
* @PHA\handlePut
|
||||
* 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\FileSchemaTestClass::class,"objectAttr":"bodyData"})
|
||||
|
||||
@@ -16,7 +16,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
class FakeBodyWithQueryParams
|
||||
{
|
||||
/**
|
||||
* @PHA\Put()
|
||||
* @PHA\handlePut
|
||||
* 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\User::class,"objectAttr":"bodyData"})
|
||||
|
||||
@@ -17,7 +17,7 @@ class FakeClassnameTest
|
||||
{
|
||||
/**
|
||||
* To test class name in snake case
|
||||
* @PHA\Patch()
|
||||
* @PHA\handlePatch
|
||||
* 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":"bodyData"})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
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;
|
||||
@@ -13,10 +13,11 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
/**
|
||||
* @PHA\Route(pattern="/fake/create_xml_item")
|
||||
*/
|
||||
class FakeCreateXmlItem implements Operation\PostInterface
|
||||
class FakeCreateXmlItem
|
||||
{
|
||||
/**
|
||||
* creates an XmlItem
|
||||
* @PHA\handlePost
|
||||
* 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/xml")
|
||||
* TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
@@ -32,13 +33,13 @@ class FakeCreateXmlItem implements Operation\PostInterface
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\XmlItem::class,"objectAttr":"bodyData"})
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 500 if the method is not implemented
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
*/
|
||||
public function handlePost(ServerRequestInterface $request)
|
||||
public function createXmlItem(ServerRequestInterface $request)
|
||||
{
|
||||
//TODO implement method
|
||||
/** @var \App\DTO\XmlItem $bodyData */
|
||||
$bodyData = $request->getAttribute("bodyData");
|
||||
throw new PHException\HttpCode(500, "Not implemented");
|
||||
throw new PHException\HttpCode(501, "Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class FakeInlineAdditionalProperties
|
||||
{
|
||||
/**
|
||||
* test inline additionalProperties
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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")
|
||||
* TODO check if attribute is valid and can handle your container type
|
||||
|
||||
@@ -17,7 +17,7 @@ class FakeJsonFormData
|
||||
{
|
||||
/**
|
||||
* test json serialization of form data
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -16,9 +16,9 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
class FakeOuterBoolean
|
||||
{
|
||||
/**
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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="n/a")
|
||||
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="*/*")
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -16,10 +16,10 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
class FakeOuterComposite
|
||||
{
|
||||
/**
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterComposite::class,"objectAttr":"bodyData"})
|
||||
* 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="n/a")
|
||||
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="*/*")
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -16,9 +16,9 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
class FakeOuterNumber
|
||||
{
|
||||
/**
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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="n/a")
|
||||
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="*/*")
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -16,9 +16,9 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
class FakeOuterString
|
||||
{
|
||||
/**
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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="n/a")
|
||||
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="*/*")
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -17,7 +17,7 @@ class FakePetIdUploadImageWithRequiredFile
|
||||
{
|
||||
/**
|
||||
* uploads an image (required)
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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
|
||||
|
||||
@@ -17,7 +17,7 @@ class Pet
|
||||
{
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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")
|
||||
* TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
@@ -36,7 +36,7 @@ class Pet
|
||||
}
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @PHA\Put()
|
||||
* @PHA\handlePut
|
||||
* 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")
|
||||
* TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
|
||||
@@ -17,7 +17,7 @@ class PetFindByStatus
|
||||
{
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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/xml")
|
||||
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
|
||||
@@ -17,7 +17,7 @@ class PetFindByTags
|
||||
{
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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/xml")
|
||||
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
|
||||
@@ -17,7 +17,7 @@ class PetPetId
|
||||
{
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @PHA\Delete()
|
||||
* @PHA\handleDelete
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
@@ -29,7 +29,7 @@ class PetPetId
|
||||
}
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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/xml")
|
||||
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
@@ -47,7 +47,7 @@ class PetPetId
|
||||
}
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -17,7 +17,7 @@ class PetPetIdUploadImage
|
||||
{
|
||||
/**
|
||||
* uploads an image
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* 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
|
||||
|
||||
@@ -17,7 +17,7 @@ class StoreInventory
|
||||
{
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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
|
||||
|
||||
@@ -17,7 +17,7 @@ class StoreOrder
|
||||
{
|
||||
/**
|
||||
* Place an order for a pet
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Order::class,"objectAttr":"bodyData"})
|
||||
* 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/xml")
|
||||
|
||||
@@ -17,7 +17,7 @@ class StoreOrderOrderId
|
||||
{
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* @PHA\Delete()
|
||||
* @PHA\handleDelete
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
@@ -29,7 +29,7 @@ class StoreOrderOrderId
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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/xml")
|
||||
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
|
||||
@@ -17,7 +17,7 @@ class User
|
||||
{
|
||||
/**
|
||||
* Create user
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"})
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserCreateWithArray
|
||||
{
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* TODO check if attribute is valid and can handle your container type
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"\App\DTO\User[]","objectAttr":"bodyData"})
|
||||
* @param ServerRequestInterface $request
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserCreateWithList
|
||||
{
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @PHA\Post()
|
||||
* @PHA\handlePost
|
||||
* TODO check if attribute is valid and can handle your container type
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"\App\DTO\User[]","objectAttr":"bodyData"})
|
||||
* @param ServerRequestInterface $request
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserLogin
|
||||
{
|
||||
/**
|
||||
* Logs user into the system
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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/xml")
|
||||
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserLogout
|
||||
{
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserUsername
|
||||
{
|
||||
/**
|
||||
* Delete user
|
||||
* @PHA\Delete()
|
||||
* @PHA\handleDelete
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
* @throws PHException\HttpCode 501 if the method is not implemented
|
||||
@@ -29,7 +29,7 @@ class UserUsername
|
||||
}
|
||||
/**
|
||||
* Get user by user name
|
||||
* @PHA\Get()
|
||||
* @PHA\handleGet
|
||||
* 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/xml")
|
||||
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
|
||||
@@ -47,7 +47,7 @@ class UserUsername
|
||||
}
|
||||
/**
|
||||
* Updated user
|
||||
* @PHA\Put()
|
||||
* @PHA\handlePut
|
||||
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"})
|
||||
* @param ServerRequestInterface $request
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user