diff --git a/src/Gatherer/Operation.php b/src/Gatherer/Operation.php index a2a9a11..1e18b36 100644 --- a/src/Gatherer/Operation.php +++ b/src/Gatherer/Operation.php @@ -156,6 +156,13 @@ public static function gather( ClassString::factory($baseNamespace, 'Operation\\' . Utils::fixKeyword($className)), ClassString::factory($baseNamespace, $classNameSanitized), ClassString::factory($baseNamespace, 'Operator\\' . Utils::fixKeyword($className)), + lcfirst( + str_replace( + ['\\'], + ['👷'], + ClassString::factory($baseNamespace, Utils::fixKeyword($className))->relative, + ), + ), $name, (new Convert($name))->toCamel(), $group, diff --git a/src/Generator/Client.php b/src/Generator/Client.php index 75a04ed..fc3e669 100644 --- a/src/Generator/Client.php +++ b/src/Generator/Client.php @@ -158,39 +158,46 @@ public static function generate(Configuration $configuration, string $pathPrefix new Node\Name('Operations'), [ new Arg( - new Node\Expr\Variable('browser'), - false, - false, - [], - new Node\Identifier('browser'), - ), - new Arg( - new Node\Expr\Variable('authentication'), - false, - false, - [], - new Node\Identifier('authentication'), - ), - new Arg( - new Node\Expr\Variable('requestSchemaValidator'), - false, - false, - [], - new Node\Identifier('requestSchemaValidator'), - ), - new Arg( - new Node\Expr\Variable('responseSchemaValidator'), - false, - false, - [], - new Node\Identifier('responseSchemaValidator'), - ), - new Arg( - new Node\Expr\Variable('hydrators'), - false, - false, - [], - new Node\Identifier('hydrators'), + new Node\Expr\New_( + new Node\Name('Operators'), + [ + new Arg( + new Node\Expr\Variable('browser'), + false, + false, + [], + new Node\Identifier('browser'), + ), + new Arg( + new Node\Expr\Variable('authentication'), + false, + false, + [], + new Node\Identifier('authentication'), + ), + new Arg( + new Node\Expr\Variable('requestSchemaValidator'), + false, + false, + [], + new Node\Identifier('requestSchemaValidator'), + ), + new Arg( + new Node\Expr\Variable('responseSchemaValidator'), + false, + false, + [], + new Node\Identifier('responseSchemaValidator'), + ), + new Arg( + new Node\Expr\Variable('hydrators'), + false, + false, + [], + new Node\Identifier('hydrators'), + ), + ], + ), ), ], ), @@ -206,14 +213,20 @@ public static function generate(Configuration $configuration, string $pathPrefix new Node\Expr\New_( new Node\Name('WebHooks'), [ - new Node\Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'requestSchemaValidator', - )), - new Node\Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'hydrators', - )), + new Arg( + new Node\Expr\Variable('requestSchemaValidator'), + false, + false, + [], + new Node\Identifier('requestSchemaValidator'), + ), + new Arg( + new Node\Expr\Variable('hydrators'), + false, + false, + [], + new Node\Identifier('hydrator'), + ), ], ), ), @@ -229,50 +242,35 @@ public static function generate(Configuration $configuration, string $pathPrefix new Node\Name('Routers'), [ new Arg( - new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'browser', - ), + new Node\Expr\Variable('browser'), false, false, [], new Node\Identifier('browser'), ), new Arg( - new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'authentication', - ), + new Node\Expr\Variable('authentication'), false, false, [], new Node\Identifier('authentication'), ), new Arg( - new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'requestSchemaValidator', - ), + new Node\Expr\Variable('requestSchemaValidator'), false, false, [], new Node\Identifier('requestSchemaValidator'), ), new Arg( - new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'responseSchemaValidator', - ), + new Node\Expr\Variable('responseSchemaValidator'), false, false, [], new Node\Identifier('responseSchemaValidator'), ), new Arg( - new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'hydrators', - ), + new Node\Expr\Variable('hydrators'), false, false, [], @@ -695,7 +693,11 @@ private static function traverseOperationPaths(array $operations, array &$operat return $operations; } - /** @param array $paths */ + /** + * @param array $paths + * + * @return iterable + */ private static function operationsInThisThree(array $paths, int $level, Routers $routers): iterable { foreach ($paths as $path) { diff --git a/src/Generator/Helper/Operation.php b/src/Generator/Helper/Operation.php index 23d5860..cd0de2c 100644 --- a/src/Generator/Helper/Operation.php +++ b/src/Generator/Helper/Operation.php @@ -5,7 +5,6 @@ namespace ApiClients\Tools\OpenApiClientGenerator\Generator\Helper; use ApiClients\Tools\OpenApiClientGenerator\Representation; -use ApiClients\Tools\OpenApiClientGenerator\Representation\Hydrator; use PhpParser\Builder; use PhpParser\Comment\Doc; use PhpParser\Node; @@ -27,7 +26,6 @@ use function is_string; use function str_replace; use function strpos; -use function ucfirst; use const PHP_EOL; @@ -54,107 +52,39 @@ public static function methodParams(Builder\Method $method, Representation\Opera public static function methodReturnType(Builder\Method $method, Representation\Operation $operation): Builder\Method { + $docComment = ReflectionTypes::copyDocBlock($operation->operatorClassName->fullyQualified->source, 'call'); + + if ($docComment !== null) { + $method = $method->setDocComment($docComment); + } + return $method->setReturnType( - new Node\UnionType( - Types::normalizeNodeName(...$operation->returnType), - ), + ReflectionTypes::copyReturnType($operation->operatorClassName->fullyQualified->source, 'call'), ); } - /** - * @param array $operationHydratorMap - * - * @return array - */ - public static function methodCallOperation(Representation\Operation $operation, array $operationHydratorMap): array + public static function methodCallOperation(Representation\Operation $operation): Node\Stmt\Return_ { - return [ - new Node\Stmt\If_( - new Node\Expr\BinaryOp\Equal( - new Node\Expr\FuncCall( - new Node\Name('\array_key_exists'), - [ - new Arg(new Node\Expr\ClassConstFetch( - new Node\Name($operation->operatorClassName->relative), - 'class', - )), - new Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'operator', - )), - ], + return new Node\Stmt\Return_( + new Expr\MethodCall( + new Expr\MethodCall( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + 'operators', ), - new Node\Expr\ConstFetch(new Node\Name('false')), + $operation->operatorLookUpMethod, ), + 'call', [ - 'stmts' => [ - new Node\Stmt\Expression( - new Node\Expr\Assign( - new Node\Expr\ArrayDimFetch(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'operator', - ), new Node\Expr\ClassConstFetch( - new Node\Name($operation->operatorClassName->relative), - 'class', - )), - new Node\Expr\New_( - new Node\Name($operation->operatorClassName->relative), - [ - new Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'browser', - )), - new Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'authentication', - )), - ...(count($operation->requestBody) > 0 ? [ - new Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'requestSchemaValidator', - )), - ] : []), - new Arg(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'responseSchemaValidator', - )), - new Arg( - new Expr\MethodCall( - new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'hydrators', - ), - 'getObjectMapper' . ucfirst($operationHydratorMap[$operation->operationId]->methodName), - ), - ), - ], - ), - ), - ), - ], + ...(static function (array $params): iterable { + foreach ($params as $param) { + yield new Arg(new Node\Expr\Variable($param->name)); + } + })($operation->parameters), + ...(count($operation->requestBody) > 0 ? [new Arg(new Node\Expr\Variable('params'))] : []), ], ), - new Node\Stmt\Return_( - new Expr\MethodCall( - new Node\Expr\ArrayDimFetch(new Node\Expr\PropertyFetch( - new Node\Expr\Variable('this'), - 'operator', - ), new Node\Expr\ClassConstFetch( - new Node\Name($operation->operatorClassName->relative), - 'class', - )), - 'call', - [ - ...(static function (array $params): iterable { - foreach ($params as $param) { - yield new Arg(new Node\Expr\Variable($param->name)); - } - })($operation->parameters), - ...(count($operation->requestBody) > 0 ? [new Arg(new Node\Expr\Variable('params'))] : []), - ], - ), - ), - ]; + ); } public static function getResultTypeFromOperation(Representation\Operation $operation): string diff --git a/src/Generator/Helper/ReflectionTypes.php b/src/Generator/Helper/ReflectionTypes.php new file mode 100644 index 0000000..27ba3cf --- /dev/null +++ b/src/Generator/Helper/ReflectionTypes.php @@ -0,0 +1,58 @@ +getMethod($method)->getReturnType(); + switch ($reflection::class) { + //ReflectionNamedType|ReflectionUnionType|ReflectionIntersectionType + case ReflectionNamedType::class: + return new Name( + (strpos((string) $reflection, '\\') !== false ? '\\' : '') . $reflection, + ); + + break; + case ReflectionUnionType::class: + return new Node\UnionType( + [ + ...(static function (ReflectionType ...$types): iterable { + foreach ($types as $type) { + yield new Name( + (strpos((string) $type, '\\') !== false ? '\\' : '') . $type, + ); + } + })(...$reflection->getTypes()), + ], + ); + + break; + default: + return ''; + } + } + + public static function copyDocBlock(string $class, string $method): Doc|null + { + $comment = (new ReflectionClass($class))->getMethod($method)->getDocComment(); + if ($comment !== null) { + return new Doc($comment); + } + + return null; + } +} diff --git a/src/Generator/Operation.php b/src/Generator/Operation.php index df2f082..dfc8fb1 100644 --- a/src/Generator/Operation.php +++ b/src/Generator/Operation.php @@ -324,7 +324,7 @@ public static function generate(string $pathPrefix, \ApiClients\Tools\OpenApiCli new Node\Stmt\Return_(new Node\Expr\MethodCall( new Node\Expr\PropertyFetch( new Node\Expr\Variable('this'), - 'hydrator', + 'hydrators', ), 'hydrateObject', [ diff --git a/src/Generator/Operations.php b/src/Generator/Operations.php index ddbc044..dd7cd2b 100644 --- a/src/Generator/Operations.php +++ b/src/Generator/Operations.php @@ -4,11 +4,9 @@ namespace ApiClients\Tools\OpenApiClientGenerator\Generator; -use ApiClients\Contracts\HTTP\Headers\AuthenticationInterface; use ApiClients\Tools\OpenApiClientGenerator\Configuration; use ApiClients\Tools\OpenApiClientGenerator\File; use ApiClients\Tools\OpenApiClientGenerator\PrivatePromotedPropertyAsParam; -use ApiClients\Tools\OpenApiClientGenerator\Representation\Hydrator; use ApiClients\Tools\OpenApiClientGenerator\Representation\Operation; use ApiClients\Tools\OpenApiClientGenerator\Representation\Path; use ApiClients\Tools\OpenApiClientGenerator\Utils; @@ -18,7 +16,6 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\Name; -use React\Http\Browser; final class Operations { @@ -37,52 +34,20 @@ public static function generate(Configuration $configuration, string $pathPrefix } } - $classReadonly = true; - $groups = []; + $groups = []; foreach ($operations as $operation) { $groups[$operation->group][] = $operation; - - if ($operation->group !== null) { - continue; - } - - $classReadonly = false; } $factory = new BuilderFactory(); $stmt = $factory->namespace($configuration->namespace->source); - $class = $factory->class('Operations')->makeFinal()->implement(new Name('OperationsInterface')); - if ($classReadonly) { - $class->makeReadonly(); - } else { - $class->addStmt( - $factory->property('operator')->setType('array')->setDefault([])->makePrivate(), - ); - } - - $params = []; - foreach ( - [ - 'browser' => '\\' . Browser::class, - 'authentication' => '\\' . AuthenticationInterface::class, - 'requestSchemaValidator' => '\League\OpenAPIValidation\Schema\SchemaValidator', - 'responseSchemaValidator' => '\League\OpenAPIValidation\Schema\SchemaValidator', - 'hydrators' => '\\' . $configuration->namespace->source . '\Hydrators', - ] as $name => $type - ) { - if ($classReadonly) { - $params[] = (new PrivatePromotedPropertyAsParam($name))->setType($type); - - continue; - } - - $params[] = (new PrivatePromotedPropertyAsParam($name))->setType($type); -// $params[] = (new PrivatePromotedPropertyAsParam($name))->setType($type)->makeReadonly(); - } + $class = $factory->class('Operations')->makeFinal()->implement(new Name('OperationsInterface'))->makeReadonly(); $class->addStmt( - $factory->method('__construct')->makePublic()->addParams($params), + $factory->method('__construct')->makePublic()->addParam( + (new PrivatePromotedPropertyAsParam('operators'))->setType('\\' . $configuration->namespace->source . '\Operators'), + ), ); foreach ($groups as $group => $groupsOperations) { @@ -92,7 +57,7 @@ public static function generate(Configuration $configuration, string $pathPrefix Helper\Operation::methodSignature( $factory->method((new Convert($groupsOperation->name))->toCamel())->makePublic(), $groupsOperation, - )->addStmts(Helper\Operation::methodCallOperation($groupsOperation, $operationHydratorMap)), + )->addStmt(Helper\Operation::methodCallOperation($groupsOperation)), ); } @@ -110,31 +75,7 @@ public static function generate(Configuration $configuration, string $pathPrefix new Arg( new Expr\PropertyFetch( new Expr\Variable('this'), - 'browser', - ), - ), - new Arg( - new Expr\PropertyFetch( - new Expr\Variable('this'), - 'authentication', - ), - ), - new Arg( - new Expr\PropertyFetch( - new Expr\Variable('this'), - 'requestSchemaValidator', - ), - ), - new Arg( - new Expr\PropertyFetch( - new Expr\Variable('this'), - 'responseSchemaValidator', - ), - ), - new Arg( - new Expr\PropertyFetch( - new Expr\Variable('this'), - 'hydrators', + 'operators', ), ), ], @@ -148,40 +89,28 @@ public static function generate(Configuration $configuration, string $pathPrefix $configuration->namespace, 'Operation\\' . $group, $groupsOperations, - $operationHydratorMap, $group, ); } + yield from Operators::generate($configuration, $pathPrefix, $operations, $operationHydratorMap); yield new File($pathPrefix, 'Operations', $stmt->addStmt($class)->getNode()); } /** - * @param array $operationHydratorMap * @param array $operations + * @param array $operationHydratorMap * * @return iterable */ - private static function generateOperationsGroup(string $pathPrefix, Configuration\Namespace_ $namespace, string $className, array $operations, array $operationHydratorMap, string $group): iterable + private static function generateOperationsGroup(string $pathPrefix, Configuration\Namespace_ $namespace, string $className, array $operations, string $group): iterable { $factory = new BuilderFactory(); $stmt = $factory->namespace(Utils::dirname($namespace->source . '\\' . $className)); $class = $factory->class(Utils::basename($className))->makeFinal()->addStmt( - $factory->property('operator')->setType('array')->setDefault([])->makePrivate(), - ); - - $class->addStmt( $factory->method('__construct')->makePublic()->addParam( - (new PrivatePromotedPropertyAsParam('browser'))->setType('\\' . Browser::class), - )->addParam( - (new PrivatePromotedPropertyAsParam('authentication'))->setType('\\' . AuthenticationInterface::class), - )->addParam( - (new PrivatePromotedPropertyAsParam('requestSchemaValidator'))->setType('\League\OpenAPIValidation\Schema\SchemaValidator'), - )->addParam( - (new PrivatePromotedPropertyAsParam('responseSchemaValidator'))->setType('\League\OpenAPIValidation\Schema\SchemaValidator'), - )->addParam( - (new PrivatePromotedPropertyAsParam('hydrators'))->setType('\\' . $namespace->source . '\Hydrators'), + (new PrivatePromotedPropertyAsParam('operators'))->setType('\\' . $namespace->source . '\Operators'), ), ); @@ -194,7 +123,7 @@ private static function generateOperationsGroup(string $pathPrefix, Configuratio Helper\Operation::methodSignature( $factory->method((new Convert($operation->name))->toCamel())->makePublic(), $operation, - )->addStmts(Helper\Operation::methodCallOperation($operation, $operationHydratorMap)), + )->addStmt(Helper\Operation::methodCallOperation($operation)), ); } diff --git a/src/Generator/Operator.php b/src/Generator/Operator.php index 30f6c21..54e6768 100644 --- a/src/Generator/Operator.php +++ b/src/Generator/Operator.php @@ -69,30 +69,6 @@ public static function generate(string $pathPrefix, Operation $operation, Repres ], Class_::MODIFIER_PUBLIC, ), - )->addStmt( - new Node\Stmt\ClassConst( - [ - new Node\Const_( - 'METHOD', - new Node\Scalar\String_( - $operation->method, - ), - ), - ], - Class_::MODIFIER_PRIVATE, - ), - )->addStmt( - new Node\Stmt\ClassConst( - [ - new Node\Const_( - 'PATH', - new Node\Scalar\String_( - $operation->path, // Deal with the query - ), - ), - ], - Class_::MODIFIER_PRIVATE, - ), ); $constructor = $factory->method('__construct')->makePublic(); diff --git a/src/Generator/Operators.php b/src/Generator/Operators.php new file mode 100644 index 0000000..164dcdc --- /dev/null +++ b/src/Generator/Operators.php @@ -0,0 +1,116 @@ + $operations + * @param array $operationHydratorMap + * + * @return iterable + */ + public static function generate(Configuration $configuration, string $pathPrefix, array $operations, array $operationHydratorMap): iterable + { + $factory = new BuilderFactory(); + $stmt = $factory->namespace(trim($configuration->namespace->source, '\\')); + + $class = $factory->class('Operators')->makeFinal()->addStmt( + $factory->method('__construct')->makePublic()->addParam( + (new PrivatePromotedPropertyAsParam('authentication'))->setType('\\' . AuthenticationInterface::class)->makeReadonly(), + )->addParam( + (new PrivatePromotedPropertyAsParam('browser'))->setType('\\' . Browser::class)->makeReadonly(), + )->addParam( + (new PrivatePromotedPropertyAsParam('requestSchemaValidator'))->setType('\League\OpenAPIValidation\Schema\SchemaValidator')->makeReadonly(), + )->addParam( + (new PrivatePromotedPropertyAsParam('responseSchemaValidator'))->setType('\League\OpenAPIValidation\Schema\SchemaValidator')->makeReadonly(), + )->addParam( + (new PrivatePromotedPropertyAsParam('hydrators'))->setType('Hydrators')->makeReadonly(), + ), + ); + + foreach ($operations as $operation) { + $class->addStmts([ + $factory->property($operation->operatorLookUpMethod)->setType('?' . $operation->operatorClassName->relative)->setDefault(null)->makePrivate(), + $factory->method($operation->operatorLookUpMethod)->setReturnType($operation->operatorClassName->relative)->makePublic()->addStmts([ + new Node\Stmt\If_( + new Node\Expr\BinaryOp\Identical( + new Node\Expr\Instanceof_( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + $operation->operatorLookUpMethod, + ), + new Node\Name($operation->operatorClassName->relative), + ), + new Node\Expr\ConstFetch(new Node\Name('false')), + ), + [ + 'stmts' => [ + new Node\Stmt\Expression( + new Node\Expr\Assign( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + $operation->operatorLookUpMethod, + ), + new Node\Expr\New_( + new Node\Name($operation->operatorClassName->relative), + [ + ...(static function (Operation $operation, array $operationHydratorMap): iterable { + foreach ((new ReflectionClass($operation->operatorClassName->fullyQualified->source))->getConstructor()->getParameters() as $parameter) { + if ($parameter->name === 'hydrator') { + yield new Arg( + new Node\Expr\MethodCall( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + 'hydrators', + ), + 'getObjectMapper' . ucfirst($operationHydratorMap[$operation->operationId]->methodName), + ), + ); + continue; + } + + yield new Arg( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + $parameter->name, + ), + ); + } + })($operation, $operationHydratorMap), + ], + ), + ), + ), + ], + ], + ), + new Node\Stmt\Return_( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + $operation->operatorLookUpMethod, + ), + ), + ]), + ]); + } + + yield new File($pathPrefix, 'Operators', $stmt->addStmt($class)->getNode()); + } +} diff --git a/src/Representation/Operation.php b/src/Representation/Operation.php index 82b5468..0e90c95 100644 --- a/src/Representation/Operation.php +++ b/src/Representation/Operation.php @@ -21,6 +21,7 @@ public function __construct( public ClassString $className, public ClassString $classNameSanitized, public ClassString $operatorClassName, + public string $operatorLookUpMethod, public string $name, public string $nameCamel, public string|null $group, diff --git a/tests/app/etc/openapi-client-generator.state b/tests/app/etc/openapi-client-generator.state index 65efc34..20e6ec5 100644 --- a/tests/app/etc/openapi-client-generator.state +++ b/tests/app/etc/openapi-client-generator.state @@ -4,11 +4,11 @@ "files": [ { "name": ".\/tests\/app\/src\/\/Operation\/Pets\/List_.php", - "hash": "1b52986d9a38fcc0651182fcbd11ffa9" + "hash": "dcd666d265d4c1356cfde3c55d31bedf" }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/List_.php", - "hash": "9af898ae1c57745103476d228faf3261" + "hash": "e1611a9cfaf37e7ac40cec7cadb35c5e" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/List_Test.php", @@ -16,11 +16,11 @@ }, { "name": ".\/tests\/app\/src\/\/Operation\/Pets\/ListListing.php", - "hash": "5f0b74e0153cbbcc42e609113df3ad5a" + "hash": "ed407ab7773eaf5abe25e343f7c85195" }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/ListListing.php", - "hash": "16970d4c645eadba4732fdd8934f25b4" + "hash": "ae49477fd471e5536416ae75000869e1" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/ListListingTest.php", @@ -32,7 +32,7 @@ }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/Create.php", - "hash": "3f866397b2738683e38ae39d6f717f47" + "hash": "3a6c48a8e9b709fd10fe1aefca00c10e" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/CreateTest.php", @@ -40,11 +40,11 @@ }, { "name": ".\/tests\/app\/src\/\/Operation\/Pets\/List_\/Gatos.php", - "hash": "9eb1793cc61df8d3e2be2a2779e986a2" + "hash": "4a8676068fec79375487c62dc39914fe" }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/List_\/Gatos.php", - "hash": "17afd48cbf5aeb2828985ec1ef1f0a63" + "hash": "0f9a02ab3c3127b534f87bd3169ac20a" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/List_\/GatosTest.php", @@ -52,11 +52,11 @@ }, { "name": ".\/tests\/app\/src\/\/Operation\/Pets\/List_\/GatosListing.php", - "hash": "ea926a83bcf00491d43f846d16990d12" + "hash": "b68daee5377f5f38ddfc1a583c872711" }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/List_\/GatosListing.php", - "hash": "84c5ee194ac9cfc0f1d2cac4fccfe97f" + "hash": "ceefc89a155ebc655acdae31d474b6bb" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/List_\/GatosListingTest.php", @@ -68,7 +68,7 @@ }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/Names.php", - "hash": "b42a70d3644f4b22f0c520a3219ff9a6" + "hash": "37d7f2830aba51fbf7492c6625fe5aaa" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/NamesTest.php", @@ -80,7 +80,7 @@ }, { "name": ".\/tests\/app\/src\/\/Operator\/Pets\/NamesListing.php", - "hash": "669429923285f44f2f62c058e27eafbb" + "hash": "ed2353e931e4134dac1325bd4511ce89" }, { "name": ".\/tests\/app\/tests\/\/Operation\/Pets\/NamesListingTest.php", @@ -88,11 +88,11 @@ }, { "name": ".\/tests\/app\/src\/\/Operation\/ShowPetById.php", - "hash": "7bf1df8e08fcf4bb8b340f0f15abd8d8" + "hash": "53b8909638c1af4dff6198ff9a9362d1" }, { "name": ".\/tests\/app\/src\/\/Operator\/ShowPetById.php", - "hash": "ddef8f6d81cac7c2bbe9ead2c7bd8104" + "hash": "b31f99b516cc79be873c05ec8c33c74f" }, { "name": ".\/tests\/app\/tests\/\/Operation\/ShowPetByIdTest.php", @@ -204,7 +204,7 @@ }, { "name": ".\/tests\/app\/src\/\/Client.php", - "hash": "811c28abdfeae2fa8b5c44e2f0e42a4c" + "hash": "7c3f6b9355d70255133db079142eac1a" }, { "name": ".\/tests\/app\/src\/\/Router\/Get\/Pets.php", @@ -256,19 +256,19 @@ }, { "name": ".\/tests\/app\/src\/\/OperationsInterface.php", - "hash": "e4ea2aaf111f619a3a7f42c59d5e755a" + "hash": "6a32a2f215c719877560625cf7177ef3" }, { "name": ".\/tests\/app\/src\/\/Operation\/Pets.php", - "hash": "31cc4b8df3a1effea19139d3863ffac4" + "hash": "df69fd3b28297d813b125b97036bbacf" }, { "name": ".\/tests\/app\/src\/\/Operation\/PetsList.php", - "hash": "4e4ef678bd6485e98380a3b60f9279ad" + "hash": "ee50f6c419779e5fcf372c99778e41dd" }, { "name": ".\/tests\/app\/src\/\/Operations.php", - "hash": "1fb22bae634b423443e062dd653d4904" + "hash": "a59c678e09e6b680223737a94d015793" }, { "name": ".\/tests\/app\/src\/\/Hydrator\/Operation\/Pets.php", @@ -289,6 +289,10 @@ { "name": ".\/tests\/app\/src\/\/Hydrators.php", "hash": "6dbea9f466671e1b304df02d18b5d627" + }, + { + "name": ".\/tests\/app\/src\/\/Operators.php", + "hash": "3c39f2158465dca6c75741e22ba40134" } ] }, diff --git a/tests/app/src/Client.php b/tests/app/src/Client.php index 33b3fb7..88358ac 100644 --- a/tests/app/src/Client.php +++ b/tests/app/src/Client.php @@ -24,8 +24,8 @@ public function __construct(\ApiClients\Contracts\HTTP\Headers\AuthenticationInt $requestSchemaValidator = new \League\OpenAPIValidation\Schema\SchemaValidator(\League\OpenAPIValidation\Schema\SchemaValidator::VALIDATE_AS_REQUEST); $responseSchemaValidator = new \League\OpenAPIValidation\Schema\SchemaValidator(\League\OpenAPIValidation\Schema\SchemaValidator::VALIDATE_AS_RESPONSE); $hydrators = new Hydrators(); - $this->operations = new Operations(browser: $browser, authentication: $authentication, requestSchemaValidator: $requestSchemaValidator, responseSchemaValidator: $responseSchemaValidator, hydrators: $hydrators); - $this->routers = new Routers(browser: $this->browser, authentication: $this->authentication, requestSchemaValidator: $this->requestSchemaValidator, responseSchemaValidator: $this->responseSchemaValidator, hydrators: $this->hydrators); + $this->operations = new Operations(new Operators(browser: $browser, authentication: $authentication, requestSchemaValidator: $requestSchemaValidator, responseSchemaValidator: $responseSchemaValidator, hydrators: $hydrators)); + $this->routers = new Routers(browser: $browser, authentication: $authentication, requestSchemaValidator: $requestSchemaValidator, responseSchemaValidator: $responseSchemaValidator, hydrators: $hydrators); } // phpcs:disable /** diff --git a/tests/app/src/Operation/Pets.php b/tests/app/src/Operation/Pets.php index 05e2966..7e8d546 100644 --- a/tests/app/src/Operation/Pets.php +++ b/tests/app/src/Operation/Pets.php @@ -15,43 +15,42 @@ use ApiClients\Contracts; final class Pets { - private array $operator = array(); - public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $requestSchemaValidator, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private \ApiClients\Client\PetStore\Hydrators $hydrators) + public function __construct(private \ApiClients\Client\PetStore\Operators $operators) { } - public function list(int $perPage, int $page) : Schema\Operations\Pets\List_\Response\ApplicationJson\Ok + /** + * @return iterable + */ + public function list(int $perPage, int $page) : iterable { - if (\array_key_exists(Operator\Pets\List_::class, $this->operator) == false) { - $this->operator[Operator\Pets\List_::class] = new Operator\Pets\List_($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets()); - } - return $this->operator[Operator\Pets\List_::class]->call($perPage, $page); + return $this->operators->pets👷List_()->call($perPage, $page); } - public function listListing(int $perPage, int $page) : Schema\Operations\Pets\List_\Response\ApplicationJson\Ok + /** + * @return iterable + */ + public function listListing(int $perPage, int $page) : iterable { - if (\array_key_exists(Operator\Pets\ListListing::class, $this->operator) == false) { - $this->operator[Operator\Pets\ListListing::class] = new Operator\Pets\ListListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets()); - } - return $this->operator[Operator\Pets\ListListing::class]->call($perPage, $page); + return $this->operators->pets👷ListListing()->call($perPage, $page); } - public function create(array $params) : \Psr\Http\Message\ResponseInterface + /** + * @return array{code:int} + */ + public function create(array $params) : array { - if (\array_key_exists(Operator\Pets\Create::class, $this->operator) == false) { - $this->operator[Operator\Pets\Create::class] = new Operator\Pets\Create($this->browser, $this->authentication, $this->requestSchemaValidator, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets()); - } - return $this->operator[Operator\Pets\Create::class]->call($params); + return $this->operators->pets👷Create()->call($params); } - public function names(int $perPage, int $page) : Schema\Operations\Pets\Names\Response\ApplicationJson\Ok + /** + * @return iterable + */ + public function names(int $perPage, int $page) : iterable { - if (\array_key_exists(Operator\Pets\Names::class, $this->operator) == false) { - $this->operator[Operator\Pets\Names::class] = new Operator\Pets\Names($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Names()); - } - return $this->operator[Operator\Pets\Names::class]->call($perPage, $page); + return $this->operators->pets👷Names()->call($perPage, $page); } - public function namesListing(int $perPage, int $page) : Schema\Operations\Pets\Names\Response\ApplicationJson\Ok + /** + * @return iterable + */ + public function namesListing(int $perPage, int $page) : iterable { - if (\array_key_exists(Operator\Pets\NamesListing::class, $this->operator) == false) { - $this->operator[Operator\Pets\NamesListing::class] = new Operator\Pets\NamesListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Names()); - } - return $this->operator[Operator\Pets\NamesListing::class]->call($perPage, $page); + return $this->operators->pets👷NamesListing()->call($perPage, $page); } } diff --git a/tests/app/src/Operation/Pets/ListListing.php b/tests/app/src/Operation/Pets/ListListing.php index 0e71337..58701a2 100644 --- a/tests/app/src/Operation/Pets/ListListing.php +++ b/tests/app/src/Operation/Pets/ListListing.php @@ -55,28 +55,28 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Cat::class, $body); + return $this->hydrators->hydrateObject(Schema\Cat::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaaa; } items_application_json_two_hundred_aaaaa: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Dog::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Dog::class, $body); + return $this->hydrators->hydrateObject(Schema\Dog::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaab; } items_application_json_two_hundred_aaaab: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Bird::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Bird::class, $body); + return $this->hydrators->hydrateObject(Schema\Bird::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaac; } items_application_json_two_hundred_aaaac: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Fish::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Fish::class, $body); + return $this->hydrators->hydrateObject(Schema\Fish::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaad; } diff --git a/tests/app/src/Operation/Pets/List_.php b/tests/app/src/Operation/Pets/List_.php index 3b2fe74..d443289 100644 --- a/tests/app/src/Operation/Pets/List_.php +++ b/tests/app/src/Operation/Pets/List_.php @@ -55,28 +55,28 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Cat::class, $body); + return $this->hydrators->hydrateObject(Schema\Cat::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaaa; } items_application_json_two_hundred_aaaaa: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Dog::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Dog::class, $body); + return $this->hydrators->hydrateObject(Schema\Dog::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaab; } items_application_json_two_hundred_aaaab: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Bird::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Bird::class, $body); + return $this->hydrators->hydrateObject(Schema\Bird::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaac; } items_application_json_two_hundred_aaaac: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Fish::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Fish::class, $body); + return $this->hydrators->hydrateObject(Schema\Fish::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaad; } diff --git a/tests/app/src/Operation/Pets/List_/Gatos.php b/tests/app/src/Operation/Pets/List_/Gatos.php index 73dc2d7..4fe543c 100644 --- a/tests/app/src/Operation/Pets/List_/Gatos.php +++ b/tests/app/src/Operation/Pets/List_/Gatos.php @@ -55,7 +55,7 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Cat::class, $body); + return $this->hydrators->hydrateObject(Schema\Cat::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaaa; } diff --git a/tests/app/src/Operation/Pets/List_/GatosListing.php b/tests/app/src/Operation/Pets/List_/GatosListing.php index e74cffe..47cde94 100644 --- a/tests/app/src/Operation/Pets/List_/GatosListing.php +++ b/tests/app/src/Operation/Pets/List_/GatosListing.php @@ -55,7 +55,7 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Cat::class, $body); + return $this->hydrators->hydrateObject(Schema\Cat::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaaa; } diff --git a/tests/app/src/Operation/PetsList.php b/tests/app/src/Operation/PetsList.php index b9a41e2..409a0f3 100644 --- a/tests/app/src/Operation/PetsList.php +++ b/tests/app/src/Operation/PetsList.php @@ -15,22 +15,21 @@ use ApiClients\Contracts; final class PetsList { - private array $operator = array(); - public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $requestSchemaValidator, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private \ApiClients\Client\PetStore\Hydrators $hydrators) + public function __construct(private \ApiClients\Client\PetStore\Operators $operators) { } - public function gatos(int $perPage, int $page) : Schema\Cat + /** + * @return iterable + */ + public function gatos(int $perPage, int $page) : iterable { - if (\array_key_exists(Operator\Pets\List_\Gatos::class, $this->operator) == false) { - $this->operator[Operator\Pets\List_\Gatos::class] = new Operator\Pets\List_\Gatos($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Gatos()); - } - return $this->operator[Operator\Pets\List_\Gatos::class]->call($perPage, $page); + return $this->operators->pets👷List_👷Gatos()->call($perPage, $page); } - public function gatosListing(int $perPage, int $page) : Schema\Cat + /** + * @return iterable + */ + public function gatosListing(int $perPage, int $page) : iterable { - if (\array_key_exists(Operator\Pets\List_\GatosListing::class, $this->operator) == false) { - $this->operator[Operator\Pets\List_\GatosListing::class] = new Operator\Pets\List_\GatosListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Gatos()); - } - return $this->operator[Operator\Pets\List_\GatosListing::class]->call($perPage, $page); + return $this->operators->pets👷List_👷GatosListing()->call($perPage, $page); } } diff --git a/tests/app/src/Operation/ShowPetById.php b/tests/app/src/Operation/ShowPetById.php index 9bf9fdb..4a096ea 100644 --- a/tests/app/src/Operation/ShowPetById.php +++ b/tests/app/src/Operation/ShowPetById.php @@ -48,28 +48,28 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Cat::class, $body); + return $this->hydrators->hydrateObject(Schema\Cat::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaaa; } items_application_json_two_hundred_aaaaa: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Dog::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Dog::class, $body); + return $this->hydrators->hydrateObject(Schema\Dog::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaab; } items_application_json_two_hundred_aaaab: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Bird::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Bird::class, $body); + return $this->hydrators->hydrateObject(Schema\Bird::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaac; } items_application_json_two_hundred_aaaac: try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Fish::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); - return $this->hydrator->hydrateObject(Schema\Fish::class, $body); + return $this->hydrators->hydrateObject(Schema\Fish::class, $body); } catch (\Throwable $error) { goto items_application_json_two_hundred_aaaad; } diff --git a/tests/app/src/Operations.php b/tests/app/src/Operations.php index 7caf452..f115061 100644 --- a/tests/app/src/Operations.php +++ b/tests/app/src/Operations.php @@ -13,25 +13,24 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final class Operations implements OperationsInterface +final readonly class Operations implements OperationsInterface { - private array $operator = array(); - public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $requestSchemaValidator, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private \ApiClients\Client\PetStore\Hydrators $hydrators) + public function __construct(private \ApiClients\Client\PetStore\Operators $operators) { } public function pets() : Operation\Pets { - return new Operation\Pets($this->browser, $this->authentication, $this->requestSchemaValidator, $this->responseSchemaValidator, $this->hydrators); + return new Operation\Pets($this->operators); } public function petsList() : Operation\PetsList { - return new Operation\PetsList($this->browser, $this->authentication, $this->requestSchemaValidator, $this->responseSchemaValidator, $this->hydrators); + return new Operation\PetsList($this->operators); } - public function showPetById() : Schema\Operations\ShowPetById\Response\ApplicationJson\Ok + /** + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + */ + public function showPetById() : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|array { - if (\array_key_exists(Operator\ShowPetById::class, $this->operator) == false) { - $this->operator[Operator\ShowPetById::class] = new Operator\ShowPetById($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀PetId()); - } - return $this->operator[Operator\ShowPetById::class]->call(); + return $this->operators->showPetById()->call(); } } diff --git a/tests/app/src/OperationsInterface.php b/tests/app/src/OperationsInterface.php index 887bb73..e68d75f 100644 --- a/tests/app/src/OperationsInterface.php +++ b/tests/app/src/OperationsInterface.php @@ -17,5 +17,8 @@ interface OperationsInterface { public function pets() : Operation\Pets; public function petsList() : Operation\PetsList; - public function showPetById() : Schema\Operations\ShowPetById\Response\ApplicationJson\Ok; + /** + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + */ + public function showPetById() : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|array; } diff --git a/tests/app/src/Operator/Pets/Create.php b/tests/app/src/Operator/Pets/Create.php index 4988f13..a32adf5 100644 --- a/tests/app/src/Operator/Pets/Create.php +++ b/tests/app/src/Operator/Pets/Create.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/create'; public const OPERATION_MATCH = 'POST /pets'; - private const METHOD = 'POST'; - private const PATH = '/pets'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $requestSchemaValidator, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets $hydrator) { } diff --git a/tests/app/src/Operator/Pets/ListListing.php b/tests/app/src/Operator/Pets/ListListing.php index 018186f..34d9f83 100644 --- a/tests/app/src/Operator/Pets/ListListing.php +++ b/tests/app/src/Operator/Pets/ListListing.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/list'; public const OPERATION_MATCH = 'LIST /pets'; - private const METHOD = 'GET'; - private const PATH = '/pets'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets $hydrator) { } diff --git a/tests/app/src/Operator/Pets/List_.php b/tests/app/src/Operator/Pets/List_.php index 6715bcb..79c220f 100644 --- a/tests/app/src/Operator/Pets/List_.php +++ b/tests/app/src/Operator/Pets/List_.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/list'; public const OPERATION_MATCH = 'GET /pets'; - private const METHOD = 'GET'; - private const PATH = '/pets'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets $hydrator) { } diff --git a/tests/app/src/Operator/Pets/List_/Gatos.php b/tests/app/src/Operator/Pets/List_/Gatos.php index 01444f8..40ba6d2 100644 --- a/tests/app/src/Operator/Pets/List_/Gatos.php +++ b/tests/app/src/Operator/Pets/List_/Gatos.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/list/gatos'; public const OPERATION_MATCH = 'GET /pets/gatos'; - private const METHOD = 'GET'; - private const PATH = '/pets/gatos'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets\Gatos $hydrator) { } diff --git a/tests/app/src/Operator/Pets/List_/GatosListing.php b/tests/app/src/Operator/Pets/List_/GatosListing.php index a6c391c..2b45ae7 100644 --- a/tests/app/src/Operator/Pets/List_/GatosListing.php +++ b/tests/app/src/Operator/Pets/List_/GatosListing.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/list/gatos'; public const OPERATION_MATCH = 'LIST /pets/gatos'; - private const METHOD = 'GET'; - private const PATH = '/pets/gatos'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets\Gatos $hydrator) { } diff --git a/tests/app/src/Operator/Pets/Names.php b/tests/app/src/Operator/Pets/Names.php index ebd1fbb..93086eb 100644 --- a/tests/app/src/Operator/Pets/Names.php +++ b/tests/app/src/Operator/Pets/Names.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/names'; public const OPERATION_MATCH = 'GET /pets/names'; - private const METHOD = 'GET'; - private const PATH = '/pets/names'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets\Names $hydrator) { } diff --git a/tests/app/src/Operator/Pets/NamesListing.php b/tests/app/src/Operator/Pets/NamesListing.php index 3f84c9c..69c01d2 100644 --- a/tests/app/src/Operator/Pets/NamesListing.php +++ b/tests/app/src/Operator/Pets/NamesListing.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'pets/names'; public const OPERATION_MATCH = 'LIST /pets/names'; - private const METHOD = 'GET'; - private const PATH = '/pets/names'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets\Names $hydrator) { } diff --git a/tests/app/src/Operator/ShowPetById.php b/tests/app/src/Operator/ShowPetById.php index aab8081..e699522 100644 --- a/tests/app/src/Operator/ShowPetById.php +++ b/tests/app/src/Operator/ShowPetById.php @@ -17,8 +17,6 @@ { public const OPERATION_ID = 'showPetById'; public const OPERATION_MATCH = 'GET /pets/{petId}'; - private const METHOD = 'GET'; - private const PATH = '/pets/{petId}'; public function __construct(private \React\Http\Browser $browser, private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Hydrator\Operation\Pets\PetId $hydrator) { } diff --git a/tests/app/src/Operators.php b/tests/app/src/Operators.php new file mode 100644 index 0000000..9d9b2b4 --- /dev/null +++ b/tests/app/src/Operators.php @@ -0,0 +1,85 @@ +pets👷List_ instanceof Operator\Pets\List_ === false) { + $this->pets👷List_ = new Operator\Pets\List_($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets()); + } + return $this->pets👷List_; + } + public function pets👷ListListing() : Operator\Pets\ListListing + { + if ($this->pets👷ListListing instanceof Operator\Pets\ListListing === false) { + $this->pets👷ListListing = new Operator\Pets\ListListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets()); + } + return $this->pets👷ListListing; + } + public function pets👷Create() : Operator\Pets\Create + { + if ($this->pets👷Create instanceof Operator\Pets\Create === false) { + $this->pets👷Create = new Operator\Pets\Create($this->browser, $this->authentication, $this->requestSchemaValidator, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets()); + } + return $this->pets👷Create; + } + public function pets👷List_👷Gatos() : Operator\Pets\List_\Gatos + { + if ($this->pets👷List_👷Gatos instanceof Operator\Pets\List_\Gatos === false) { + $this->pets👷List_👷Gatos = new Operator\Pets\List_\Gatos($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Gatos()); + } + return $this->pets👷List_👷Gatos; + } + public function pets👷List_👷GatosListing() : Operator\Pets\List_\GatosListing + { + if ($this->pets👷List_👷GatosListing instanceof Operator\Pets\List_\GatosListing === false) { + $this->pets👷List_👷GatosListing = new Operator\Pets\List_\GatosListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Gatos()); + } + return $this->pets👷List_👷GatosListing; + } + public function pets👷Names() : Operator\Pets\Names + { + if ($this->pets👷Names instanceof Operator\Pets\Names === false) { + $this->pets👷Names = new Operator\Pets\Names($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Names()); + } + return $this->pets👷Names; + } + public function pets👷NamesListing() : Operator\Pets\NamesListing + { + if ($this->pets👷NamesListing instanceof Operator\Pets\NamesListing === false) { + $this->pets👷NamesListing = new Operator\Pets\NamesListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Names()); + } + return $this->pets👷NamesListing; + } + public function showPetById() : Operator\ShowPetById + { + if ($this->showPetById instanceof Operator\ShowPetById === false) { + $this->showPetById = new Operator\ShowPetById($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀PetId()); + } + return $this->showPetById; + } +}