Update PHP ZE-PH server samples with OAS2, OAS3 (#259)

* update php ze-ph samples with oas2

* update zeph samples with oas3
This commit is contained in:
William Cheng 2018-04-28 21:48:50 +08:00 committed by GitHub
parent 490255025e
commit 2ce721d0b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 98 additions and 102 deletions

View File

@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/openapi-generator/src/main/resources/ze-ph -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l php-ze-ph -o samples/server/petstore/ze-ph"
java $JAVA_OPTS -jar $executable $ags

View File

@ -1 +1 @@
2.4.0-SNAPSHOT
3.0.0-SNAPSHOT

View File

@ -26,6 +26,7 @@ Articus\PathHandler\Router\FastRouteAnnotation:
handlers:
- App\Handler\AnotherFakeDummy
- App\Handler\Fake
- App\Handler\FakeBodyWithQueryParams
- App\Handler\FakeInlineAdditionalProperties
- App\Handler\FakeJsonFormData
- App\Handler\FakeOuterBoolean
@ -51,6 +52,7 @@ Articus\PathHandler\Router\FastRouteAnnotation:
Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory:
App\Handler\AnotherFakeDummy: []
App\Handler\Fake: []
App\Handler\FakeBodyWithQueryParams: []
App\Handler\FakeInlineAdditionalProperties: []
App\Handler\FakeJsonFormData: []
App\Handler\FakeOuterBoolean: []

View File

@ -14,6 +14,12 @@ class EnumTest
* @var string
*/
public $enum_string;
/**
* @DTA\Data(field="enum_string_required")
* @DTA\Validator(name="Type", options={"type":"string"})
* @var string
*/
public $enum_string_required;
/**
* @DTA\Data(field="enum_integer", nullable=true)
* @DTA\Validator(name="Type", options={"type":"int"})

View File

@ -70,8 +70,9 @@ class FormatTest
public $byte;
/**
* @DTA\Data(field="binary", nullable=true)
* @DTA\Validator(name="Type", options={"type":"string"})
* @var string
* @DTA\Strategy(name="Object", options={"type":\SplFileObject::class})
* @DTA\Validator(name="Dictionary", options={"type":\SplFileObject::class})
* @var \SplFileObject
*/
public $binary;
/**

View File

@ -10,23 +10,20 @@ class OuterComposite
{
/**
* @DTA\Data(field="my_number", nullable=true)
* @DTA\Strategy(name="Object", options={"type":\App\DTO\OuterNumber::class})
* @DTA\Validator(name="Dictionary", options={"type":\App\DTO\OuterNumber::class})
* @var \App\DTO\OuterNumber
* @DTA\Validator(name="Type", options={"type":"float"})
* @var float
*/
public $my_number;
/**
* @DTA\Data(field="my_string", nullable=true)
* @DTA\Strategy(name="Object", options={"type":\App\DTO\OuterString::class})
* @DTA\Validator(name="Dictionary", options={"type":\App\DTO\OuterString::class})
* @var \App\DTO\OuterString
* @DTA\Validator(name="Type", options={"type":"string"})
* @var string
*/
public $my_string;
/**
* @DTA\Data(field="my_boolean", nullable=true)
* @DTA\Strategy(name="Object", options={"type":\App\DTO\OuterBoolean::class})
* @DTA\Validator(name="Dictionary", options={"type":\App\DTO\OuterBoolean::class})
* @var \App\DTO\OuterBoolean
* @DTA\Validator(name="Type", options={"type":"bool"})
* @var bool
*/
public $my_boolean;
}

View File

@ -37,10 +37,6 @@ class Fake implements Operation\PatchInterface, Operation\PostInterface, Operati
}
/**
* Fake endpoint for testing various 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="application/xml; charset=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=utf-8")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
@ -52,13 +48,6 @@ class Fake implements Operation\PatchInterface, Operation\PostInterface, Operati
}
/**
* To test enum parameters
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={
* "type":\App\DTO\TestEnumParametersQueryData::class,
* "objectAttr":"queryData",
* "source": PHAttribute\Transfer::SOURCE_GET
* })
* 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
@ -66,8 +55,6 @@ class Fake implements Operation\PatchInterface, Operation\PostInterface, Operati
public function handleGet(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\TestEnumParametersQueryData $queryData */
$queryData = $request->getAttribute("queryData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -0,0 +1,33 @@
<?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;
/**
* @PHA\Route(pattern="/fake/body-with-query-params")
*/
class FakeBodyWithQueryParams implements Operation\PutInterface
{
/**
* 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"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*/
public function handlePut(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\User $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -19,6 +19,8 @@ class FakeInlineAdditionalProperties implements Operation\PostInterface
* test inline additionalProperties
* 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
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":string::class,"objectAttr":"bodyData"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
@ -26,6 +28,8 @@ class FakeInlineAdditionalProperties implements Operation\PostInterface
public function handlePost(ServerRequestInterface $request)
{
//TODO implement method
/** @var string $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -16,18 +16,17 @@ use Psr\Http\Message\ServerRequestInterface;
class FakeOuterBoolean implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterBoolean::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="*/*")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterBoolean
* @return bool
*/
public function handlePost(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\OuterBoolean $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -17,6 +17,8 @@ class FakeOuterComposite implements Operation\PostInterface
{
/**
* @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="*/*")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented

View File

@ -16,18 +16,17 @@ use Psr\Http\Message\ServerRequestInterface;
class FakeOuterNumber implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterNumber::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="*/*")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterNumber
* @return float
*/
public function handlePost(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\OuterNumber $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -16,18 +16,17 @@ use Psr\Http\Message\ServerRequestInterface;
class FakeOuterString implements Operation\PostInterface
{
/**
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\OuterString::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="*/*")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
*
* @return \App\DTO\OuterString
* @return string
*/
public function handlePost(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\OuterString $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -22,10 +22,6 @@ class Pet implements Operation\PostInterface, Operation\PutInterface
* 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")
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Pet::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")
* 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
@ -44,10 +40,6 @@ class Pet implements Operation\PostInterface, Operation\PutInterface
* 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")
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Pet::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")
* 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

View File

@ -17,11 +17,6 @@ class PetFindByStatus implements Operation\GetInterface
{
/**
* Finds Pets by status
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={
* "type":\App\DTO\FindPetsByStatusQueryData::class,
* "objectAttr":"queryData",
* "source": PHAttribute\Transfer::SOURCE_GET
* })
* 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
@ -35,8 +30,6 @@ class PetFindByStatus implements Operation\GetInterface
public function handleGet(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\FindPetsByStatusQueryData $queryData */
$queryData = $request->getAttribute("queryData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -17,11 +17,6 @@ class PetFindByTags implements Operation\GetInterface
{
/**
* Finds Pets by tags
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={
* "type":\App\DTO\FindPetsByTagsQueryData::class,
* "objectAttr":"queryData",
* "source": PHAttribute\Transfer::SOURCE_GET
* })
* 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
@ -35,8 +30,6 @@ class PetFindByTags implements Operation\GetInterface
public function handleGet(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\FindPetsByTagsQueryData $queryData */
$queryData = $request->getAttribute("queryData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -17,10 +17,6 @@ class PetPetId implements Operation\DeleteInterface, Operation\GetInterface, Ope
{
/**
* Deletes a pet
* 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
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
@ -49,10 +45,6 @@ class PetPetId implements Operation\DeleteInterface, Operation\GetInterface, Ope
}
/**
* Updates a pet in the store with form data
* 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
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented

View File

@ -17,10 +17,6 @@ class StoreOrderOrderId implements Operation\DeleteInterface, Operation\GetInter
{
/**
* Delete purchase order by ID
* 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
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented

View File

@ -18,10 +18,6 @@ class User implements Operation\PostInterface
/**
* Create user
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::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")
* 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

View File

@ -19,10 +19,6 @@ class UserCreateWithArray implements Operation\PostInterface
* Creates list of users with given input array
* TODO check if attribute is valid and can handle your container type
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User[]::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")
* 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

View File

@ -19,10 +19,6 @@ class UserCreateWithList implements Operation\PostInterface
* Creates list of users with given input array
* TODO check if attribute is valid and can handle your container type
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User[]::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")
* 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

View File

@ -17,11 +17,6 @@ class UserLogin implements Operation\GetInterface
{
/**
* Logs user into the system
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={
* "type":\App\DTO\LoginUserQueryData::class,
* "objectAttr":"queryData",
* "source": PHAttribute\Transfer::SOURCE_GET
* })
* 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
@ -35,8 +30,6 @@ class UserLogin implements Operation\GetInterface
public function handleGet(ServerRequestInterface $request)
{
//TODO implement method
/** @var \App\DTO\LoginUserQueryData $queryData */
$queryData = $request->getAttribute("queryData");
throw new PHException\HttpCode(500, "Not implemented");
}
}

View File

@ -17,10 +17,6 @@ class UserLogout implements Operation\GetInterface
{
/**
* Logs out current logged in user session
* 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
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented

View File

@ -17,10 +17,6 @@ class UserUsername implements Operation\DeleteInterface, Operation\GetInterface,
{
/**
* Delete user
* 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
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/json")
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 500 if the method is not implemented
@ -50,10 +46,6 @@ class UserUsername implements Operation\DeleteInterface, Operation\GetInterface,
/**
* Updated user
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::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")
* 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