diff --git a/composer.json b/composer.json index f35db3f..ab7d2e5 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "jawira/case-converter": "^3.5", "kwn/number-to-words": "^2.6", "league/openapi-psr7-validator": "^0.21", + "league/uri": "^6.8 || ^7.3", "nikic/php-parser": "^4.15", "nunomaduro/termwind": "^1.15", "ondram/ci-detector": "^4.1", @@ -55,10 +56,10 @@ ], "config": { "allow-plugins": { - "wyrihaximus/composer-update-bin-autoload-path": true, - "infection/extension-installer": true, "dealerdirect/phpcodesniffer-composer-installer": true, - "ergebnis/composer-normalize": true + "ergebnis/composer-normalize": true, + "infection/extension-installer": true, + "wyrihaximus/composer-update-bin-autoload-path": true }, "platform": { "php": "8.2.13" diff --git a/composer.lock b/composer.lock index 126021e..efc2bfc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7aaac3c8e01680bf30983bab9575e7bb", + "content-hash": "bd4ead13b5a208ede4245f561957c443", "packages": [ { "name": "amphp/amp", @@ -218,16 +218,17 @@ "source": { "type": "git", "url": "https://github.com/php-api-clients/github.git", - "reference": "334aa3eeb80e23c36f6e997df14e4377b56216b1" + "reference": "13c7dcad79a4d19f8caa9b68fb375f6722a3d76f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-api-clients/github/zipball/334aa3eeb80e23c36f6e997df14e4377b56216b1", - "reference": "334aa3eeb80e23c36f6e997df14e4377b56216b1", + "url": "https://api.github.com/repos/php-api-clients/github/zipball/13c7dcad79a4d19f8caa9b68fb375f6722a3d76f", + "reference": "13c7dcad79a4d19f8caa9b68fb375f6722a3d76f", "shasum": "" }, "require": { "api-clients/contracts": "^0.1", + "api-clients/openapi-client-utils": "dev-main", "devizzent/cebe-php-openapi": "^1.0.1", "eventsauce/object-hydrator": "^1.4.0", "league/openapi-psr7-validator": "^0.21", @@ -261,7 +262,7 @@ "issues": "https://github.com/php-api-clients/github/issues", "source": "https://github.com/php-api-clients/github/tree/v0.2.x" }, - "time": "2023-08-31T16:35:59+00:00" + "time": "2023-10-17T01:22:52+00:00" }, { "name": "api-clients/openapi-client-utils", @@ -269,12 +270,12 @@ "source": { "type": "git", "url": "https://github.com/php-api-clients/openapi-client-utils.git", - "reference": "ff61fcf268b3ca092d4a988963a2b02f2118a88d" + "reference": "e1c0db6cd3e2e94958cf9e99e8395a61d2354be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-api-clients/openapi-client-utils/zipball/ff61fcf268b3ca092d4a988963a2b02f2118a88d", - "reference": "ff61fcf268b3ca092d4a988963a2b02f2118a88d", + "url": "https://api.github.com/repos/php-api-clients/openapi-client-utils/zipball/e1c0db6cd3e2e94958cf9e99e8395a61d2354be5", + "reference": "e1c0db6cd3e2e94958cf9e99e8395a61d2354be5", "shasum": "" }, "require": { @@ -312,7 +313,7 @@ "type": "github" } ], - "time": "2023-09-05T06:06:58+00:00" + "time": "2023-09-27T07:38:48+00:00" }, { "name": "azjezz/psl", @@ -903,16 +904,16 @@ }, { "name": "composer/composer", - "version": "2.6.2", + "version": "2.6.5", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "623e5e1de055e65bc6c3c61b8348dc4662d75e2b" + "reference": "4b0fe89db9e65b1e64df633a992e70a7a215ab33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/623e5e1de055e65bc6c3c61b8348dc4662d75e2b", - "reference": "623e5e1de055e65bc6c3c61b8348dc4662d75e2b", + "url": "https://api.github.com/repos/composer/composer/zipball/4b0fe89db9e65b1e64df633a992e70a7a215ab33", + "reference": "4b0fe89db9e65b1e64df633a992e70a7a215ab33", "shasum": "" }, "require": { @@ -997,7 +998,7 @@ "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/composer/issues", "security": "https://github.com/composer/composer/security/policy", - "source": "https://github.com/composer/composer/tree/2.6.2" + "source": "https://github.com/composer/composer/tree/2.6.5" }, "funding": [ { @@ -1013,7 +1014,7 @@ "type": "tidelift" } ], - "time": "2023-09-03T12:09:15+00:00" + "time": "2023-10-06T08:11:52+00:00" }, { "name": "composer/metadata-minifier", @@ -1086,16 +1087,16 @@ }, { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -1137,7 +1138,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -1153,7 +1154,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/semver", @@ -1805,16 +1806,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -1846,9 +1847,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/instantiator", @@ -1998,38 +1999,38 @@ }, { "name": "ergebnis/composer-normalize", - "version": "2.36.0", + "version": "2.39.0", "source": { "type": "git", "url": "https://github.com/ergebnis/composer-normalize.git", - "reference": "a8ac2c507de9166652cd76f4c336e9c7c0dd1456" + "reference": "a878360bc8cb5cb440b9381f72b0aaa125f937c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/a8ac2c507de9166652cd76f4c336e9c7c0dd1456", - "reference": "a8ac2c507de9166652cd76f4c336e9c7c0dd1456", + "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/a878360bc8cb5cb440b9381f72b0aaa125f937c7", + "reference": "a878360bc8cb5cb440b9381f72b0aaa125f937c7", "shasum": "" }, "require": { "composer-plugin-api": "^2.0.0", - "ergebnis/json": "^1.0.1", - "ergebnis/json-normalizer": "^4.2.0", - "ergebnis/json-printer": "^3.3.0", + "ergebnis/json": "^1.1.0", + "ergebnis/json-normalizer": "^4.3.0", + "ergebnis/json-printer": "^3.4.0", "ext-json": "*", "justinrainbow/json-schema": "^5.2.12", "localheinz/diff": "^1.1.1", - "php": "~8.1.0 || ~8.2.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { - "composer/composer": "^2.6.2", - "ergebnis/license": "^2.1.0", - "ergebnis/php-cs-fixer-config": "^5.14.1", + "composer/composer": "^2.6.5", + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "~6.7.0", "ergebnis/phpunit-slow-test-detector": "^2.3.0", "fakerphp/faker": "^1.23.0", - "infection/infection": "~0.27.0", - "phpunit/phpunit": "^10.3.2", + "infection/infection": "~0.27.4", + "phpunit/phpunit": "^10.4.1", "psalm/plugin-phpunit": "~0.18.4", - "rector/rector": "~0.18.1", + "rector/rector": "~0.18.5", "symfony/filesystem": "^6.0.13", "vimeo/psalm": "^5.15.0" }, @@ -2054,7 +2055,8 @@ "authors": [ { "name": "Andreas Möller", - "email": "am@localheinz.com" + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" } ], "description": "Provides a composer plugin for normalizing composer.json.", @@ -2070,36 +2072,37 @@ "security": "https://github.com/ergebnis/composer-normalize/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/composer-normalize" }, - "time": "2023-09-04T10:00:36+00:00" + "time": "2023-10-10T15:43:27+00:00" }, { "name": "ergebnis/json", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/ergebnis/json.git", - "reference": "d66ea30060856d0729a4aa319a02752519ca63a0" + "reference": "9f2b9086c43b189d7044a5b6215a931fb6e9125d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/json/zipball/d66ea30060856d0729a4aa319a02752519ca63a0", - "reference": "d66ea30060856d0729a4aa319a02752519ca63a0", + "url": "https://api.github.com/repos/ergebnis/json/zipball/9f2b9086c43b189d7044a5b6215a931fb6e9125d", + "reference": "9f2b9086c43b189d7044a5b6215a931fb6e9125d", "shasum": "" }, "require": { - "php": "^8.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.29.0", - "ergebnis/data-provider": "^1.2.0", - "ergebnis/license": "^2.1.0", - "ergebnis/php-cs-fixer-config": "^5.0.0", - "ergebnis/phpstan-rules": "^1.0.0", - "fakerphp/faker": "^1.20.0", - "infection/infection": "~0.26.16", - "phpunit/phpunit": "^9.5.27", + "ergebnis/data-provider": "^3.0.0", + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "^6.6.0", + "ergebnis/phpunit-slow-test-detector": "^2.3.0", + "fakerphp/faker": "^1.23.0", + "infection/infection": "~0.27.4", + "phpunit/phpunit": "^10.4.1", "psalm/plugin-phpunit": "~0.18.4", - "vimeo/psalm": "^5.1.0" + "rector/rector": "~0.18.5", + "vimeo/psalm": "^5.15.0" }, "type": "library", "extra": { @@ -2120,7 +2123,8 @@ "authors": [ { "name": "Andreas Möller", - "email": "am@localheinz.com" + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" } ], "description": "Provides a Json value object for representing a valid JSON string.", @@ -2130,47 +2134,48 @@ ], "support": { "issues": "https://github.com/ergebnis/json/issues", + "security": "https://github.com/ergebnis/json/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/json" }, - "time": "2022-12-10T22:38:50+00:00" + "time": "2023-10-10T07:57:48+00:00" }, { "name": "ergebnis/json-normalizer", - "version": "4.2.0", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/ergebnis/json-normalizer.git", - "reference": "7d06355857dc5fad96e8b296996f26150dfab299" + "reference": "716fa0a5dcc75fbcb2c1c2e0542b2f56732460bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/json-normalizer/zipball/7d06355857dc5fad96e8b296996f26150dfab299", - "reference": "7d06355857dc5fad96e8b296996f26150dfab299", + "url": "https://api.github.com/repos/ergebnis/json-normalizer/zipball/716fa0a5dcc75fbcb2c1c2e0542b2f56732460bd", + "reference": "716fa0a5dcc75fbcb2c1c2e0542b2f56732460bd", "shasum": "" }, "require": { - "ergebnis/json": "^1.0.1", + "ergebnis/json": "^1.1.0", "ergebnis/json-pointer": "^3.2.0", - "ergebnis/json-printer": "^3.3.0", - "ergebnis/json-schema-validator": "^4.0.0", + "ergebnis/json-printer": "^3.4.0", + "ergebnis/json-schema-validator": "^4.1.0", "ext-json": "*", "justinrainbow/json-schema": "^5.2.12", - "php": "~8.1.0 || ~8.2.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { - "composer/semver": "^3.2.1", - "ergebnis/data-provider": "^2.0.0", - "ergebnis/license": "^2.1.0", - "ergebnis/php-cs-fixer-config": "^5.11.0", + "composer/semver": "^3.4.0", + "ergebnis/data-provider": "^3.0.0", + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "~6.7.0", "ergebnis/phpunit-slow-test-detector": "^2.3.0", "fakerphp/faker": "^1.23.0", - "infection/infection": "~0.27.0", - "phpunit/phpunit": "^10.2.3", + "infection/infection": "~0.27.4", + "phpunit/phpunit": "^10.4.1", "psalm/plugin-phpunit": "~0.18.4", - "rector/rector": "~0.17.2", + "rector/rector": "~0.18.5", "symfony/filesystem": "^6.3.1", - "symfony/finder": "^6.3.0", - "vimeo/psalm": "^5.13.1" + "symfony/finder": "^6.3.5", + "vimeo/psalm": "^5.15.0" }, "suggest": { "composer/semver": "If you want to use ComposerJsonNormalizer or VersionConstraintNormalizer" @@ -2188,7 +2193,8 @@ "authors": [ { "name": "Andreas Möller", - "email": "am@localheinz.com" + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" } ], "description": "Provides generic and vendor-specific normalizers for normalizing JSON documents.", @@ -2199,37 +2205,40 @@ ], "support": { "issues": "https://github.com/ergebnis/json-normalizer/issues", + "security": "https://github.com/ergebnis/json-normalizer/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/json-normalizer" }, - "time": "2023-07-09T16:22:57+00:00" + "time": "2023-10-10T15:15:03+00:00" }, { "name": "ergebnis/json-pointer", - "version": "3.2.0", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/ergebnis/json-pointer.git", - "reference": "861516ff5afa1aa8905fdf3361315909523a1bf8" + "reference": "8e517faefc06b7c761eaa041febef51a9375819a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/json-pointer/zipball/861516ff5afa1aa8905fdf3361315909523a1bf8", - "reference": "861516ff5afa1aa8905fdf3361315909523a1bf8", + "url": "https://api.github.com/repos/ergebnis/json-pointer/zipball/8e517faefc06b7c761eaa041febef51a9375819a", + "reference": "8e517faefc06b7c761eaa041febef51a9375819a", "shasum": "" }, "require": { - "php": "^8.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.28.3", - "ergebnis/data-provider": "^1.2.0", - "ergebnis/license": "^2.1.0", - "ergebnis/php-cs-fixer-config": "^5.0.0", - "fakerphp/faker": "^1.20.0", - "infection/infection": "~0.26.16", - "phpunit/phpunit": "^9.5.26", - "psalm/plugin-phpunit": "~0.18.3", - "vimeo/psalm": "^4.30" + "ergebnis/composer-normalize": "^2.29.0", + "ergebnis/data-provider": "^3.0.0", + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "~6.7.0", + "ergebnis/phpunit-slow-test-detector": "^2.3.0", + "fakerphp/faker": "^1.23.0", + "infection/infection": "~0.27.4", + "phpunit/phpunit": "^10.4.1", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.18.5", + "vimeo/psalm": "^5.15.0" }, "type": "library", "extra": { @@ -2250,7 +2259,8 @@ "authors": [ { "name": "Andreas Möller", - "email": "am@localheinz.com" + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" } ], "description": "Provides JSON pointer as a value object.", @@ -2262,37 +2272,40 @@ ], "support": { "issues": "https://github.com/ergebnis/json-pointer/issues", + "security": "https://github.com/ergebnis/json-pointer/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/json-pointer" }, - "time": "2022-11-28T17:03:31+00:00" + "time": "2023-10-10T14:41:06+00:00" }, { "name": "ergebnis/json-printer", - "version": "3.3.0", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/ergebnis/json-printer.git", - "reference": "18920367473b099633f644f0ca6dc8794345148f" + "reference": "05841593d72499de4f7ce4034a237c77e470558f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/json-printer/zipball/18920367473b099633f644f0ca6dc8794345148f", - "reference": "18920367473b099633f644f0ca6dc8794345148f", + "url": "https://api.github.com/repos/ergebnis/json-printer/zipball/05841593d72499de4f7ce4034a237c77e470558f", + "reference": "05841593d72499de4f7ce4034a237c77e470558f", "shasum": "" }, "require": { "ext-json": "*", "ext-mbstring": "*", - "php": "^8.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { - "ergebnis/license": "^2.0.0", - "ergebnis/php-cs-fixer-config": "^4.11.0", - "fakerphp/faker": "^1.20.0", - "infection/infection": "~0.26.6", - "phpunit/phpunit": "^9.5.26", - "psalm/plugin-phpunit": "~0.18.3", - "vimeo/psalm": "^4.30.0" + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "^6.6.0", + "ergebnis/phpunit-slow-test-detector": "^2.3.0", + "fakerphp/faker": "^1.23.0", + "infection/infection": "~0.27.3", + "phpunit/phpunit": "^10.4.1", + "psalm/plugin-phpunit": "~0.18.4", + "rector/rector": "~0.18.5", + "vimeo/psalm": "^5.15.0" }, "type": "library", "autoload": { @@ -2307,7 +2320,8 @@ "authors": [ { "name": "Andreas Möller", - "email": "am@localheinz.com" + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" } ], "description": "Provides a JSON printer, allowing for flexible indentation.", @@ -2319,41 +2333,44 @@ ], "support": { "issues": "https://github.com/ergebnis/json-printer/issues", + "security": "https://github.com/ergebnis/json-printer/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/json-printer" }, - "time": "2022-11-28T10:27:43+00:00" + "time": "2023-10-10T07:42:48+00:00" }, { "name": "ergebnis/json-schema-validator", - "version": "4.0.0", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/ergebnis/json-schema-validator.git", - "reference": "a6166272ac5691a9bc791f185841e5f92a6d4723" + "reference": "d568ed85d1cdc2e49d650c2fc234dc2516f3f25b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/json-schema-validator/zipball/a6166272ac5691a9bc791f185841e5f92a6d4723", - "reference": "a6166272ac5691a9bc791f185841e5f92a6d4723", + "url": "https://api.github.com/repos/ergebnis/json-schema-validator/zipball/d568ed85d1cdc2e49d650c2fc234dc2516f3f25b", + "reference": "d568ed85d1cdc2e49d650c2fc234dc2516f3f25b", "shasum": "" }, "require": { - "ergebnis/json": "^1.0.0", + "ergebnis/json": "^1.0.1", "ergebnis/json-pointer": "^3.2.0", "ext-json": "*", "justinrainbow/json-schema": "^5.2.12", - "php": "^8.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.21.0", - "ergebnis/data-provider": "^1.2.0", - "ergebnis/license": "^2.1.0", - "ergebnis/php-cs-fixer-config": "~5.0.0", - "fakerphp/faker": "^1.20.0", - "infection/infection": "~0.26.16", - "phpunit/phpunit": "~9.5.27", + "ergebnis/data-provider": "^3.0.0", + "ergebnis/license": "^2.2.0", + "ergebnis/php-cs-fixer-config": "~6.6.0", + "ergebnis/phpunit-slow-test-detector": "^2.3.0", + "fakerphp/faker": "^1.23.0", + "infection/infection": "~0.27.4", + "phpunit/phpunit": "^10.4.1", "psalm/plugin-phpunit": "~0.18.4", - "vimeo/psalm": "^5.1.0" + "rector/rector": "~0.18.5", + "vimeo/psalm": "^5.15.0" }, "type": "library", "extra": { @@ -2374,7 +2391,8 @@ "authors": [ { "name": "Andreas Möller", - "email": "am@localheinz.com" + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" } ], "description": "Provides a JSON schema validator, building on top of justinrainbow/json-schema.", @@ -2386,9 +2404,10 @@ ], "support": { "issues": "https://github.com/ergebnis/json-schema-validator/issues", + "security": "https://github.com/ergebnis/json-schema-validator/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/json-schema-validator" }, - "time": "2022-12-10T14:50:15+00:00" + "time": "2023-10-10T14:16:57+00:00" }, { "name": "ergebnis/phpstan-rules", @@ -3815,16 +3834,16 @@ }, { "name": "justinrainbow/json-schema", - "version": "5.2.12", + "version": "v5.2.13", "source": { "type": "git", "url": "https://github.com/justinrainbow/json-schema.git", - "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60" + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", - "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", "shasum": "" }, "require": { @@ -3879,22 +3898,22 @@ ], "support": { "issues": "https://github.com/justinrainbow/json-schema/issues", - "source": "https://github.com/justinrainbow/json-schema/tree/5.2.12" + "source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13" }, - "time": "2022-04-13T08:02:27+00:00" + "time": "2023-09-26T02:20:38+00:00" }, { "name": "kwn/number-to-words", - "version": "2.6.4", + "version": "2.7.2", "source": { "type": "git", "url": "https://github.com/kwn/number-to-words.git", - "reference": "c4c14c84374baaeef35c47373c500ec7aa28b1b5" + "reference": "6821e1f6c2195ceff1595cfba9ecb13c9b121579" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kwn/number-to-words/zipball/c4c14c84374baaeef35c47373c500ec7aa28b1b5", - "reference": "c4c14c84374baaeef35c47373c500ec7aa28b1b5", + "url": "https://api.github.com/repos/kwn/number-to-words/zipball/6821e1f6c2195ceff1595cfba9ecb13c9b121579", + "reference": "6821e1f6c2195ceff1595cfba9ecb13c9b121579", "shasum": "" }, "require": { @@ -3932,9 +3951,9 @@ ], "support": { "issues": "https://github.com/kwn/number-to-words/issues", - "source": "https://github.com/kwn/number-to-words/tree/2.6.4" + "source": "https://github.com/kwn/number-to-words/tree/2.7.2" }, - "time": "2023-05-03T17:11:50+00:00" + "time": "2023-09-16T15:30:18+00:00" }, { "name": "league/openapi-psr7-validator", @@ -4231,36 +4250,36 @@ }, { "name": "maglnet/composer-require-checker", - "version": "4.6.0", + "version": "4.7.1", "source": { "type": "git", "url": "https://github.com/maglnet/ComposerRequireChecker.git", - "reference": "a5d4951d0839b57fb5dce1d6d0a6e36f23b2823f" + "reference": "e49c58b18fef21e37941a642c1a70d3962e86f28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maglnet/ComposerRequireChecker/zipball/a5d4951d0839b57fb5dce1d6d0a6e36f23b2823f", - "reference": "a5d4951d0839b57fb5dce1d6d0a6e36f23b2823f", + "url": "https://api.github.com/repos/maglnet/ComposerRequireChecker/zipball/e49c58b18fef21e37941a642c1a70d3962e86f28", + "reference": "e49c58b18fef21e37941a642c1a70d3962e86f28", "shasum": "" }, "require": { "composer-runtime-api": "^2.0.0", "ext-phar": "*", - "nikic/php-parser": "^4.15.2", - "php": "~8.1.0 || ~8.2.0", - "symfony/console": "^6.2.3", + "nikic/php-parser": "^4.17.1", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "symfony/console": "^6.3.4", "webmozart/assert": "^1.11.0", "webmozart/glob": "^4.6.0" }, "require-dev": { - "doctrine/coding-standard": "^11.0.0", + "doctrine/coding-standard": "^12.0.0", "ext-zend-opcache": "*", "mikey179/vfsstream": "^1.6.11", "phing/phing": "^2.17.4", - "phpstan/phpstan": "^1.9.4", - "phpunit/phpunit": "^9.5.27", - "roave/infection-static-analysis-plugin": "^1.27.0", - "vimeo/psalm": "^5.4.0" + "phpstan/phpstan": "^1.10.34", + "phpunit/phpunit": "^10.3.4", + "roave/infection-static-analysis-plugin": "^1.33", + "vimeo/psalm": "^5.15" }, "bin": [ "bin/composer-require-checker" @@ -4305,9 +4324,9 @@ ], "support": { "issues": "https://github.com/maglnet/ComposerRequireChecker/issues", - "source": "https://github.com/maglnet/ComposerRequireChecker/tree/4.6.0" + "source": "https://github.com/maglnet/ComposerRequireChecker/tree/4.7.1" }, - "time": "2023-04-21T21:13:53+00:00" + "time": "2023-09-27T14:57:19+00:00" }, { "name": "myclabs/deep-copy", @@ -4538,37 +4557,40 @@ }, { "name": "nunomaduro/collision", - "version": "v7.8.1", + "version": "v7.10.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "61553ad3260845d7e3e49121b7074619233d361b" + "reference": "49ec67fa7b002712da8526678abd651c09f375b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/61553ad3260845d7e3e49121b7074619233d361b", - "reference": "61553ad3260845d7e3e49121b7074619233d361b", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/49ec67fa7b002712da8526678abd651c09f375b2", + "reference": "49ec67fa7b002712da8526678abd651c09f375b2", "shasum": "" }, "require": { "filp/whoops": "^2.15.3", "nunomaduro/termwind": "^1.15.1", "php": "^8.1.0", - "symfony/console": "^6.3.2" + "symfony/console": "^6.3.4" + }, + "conflict": { + "laravel/framework": ">=11.0.0" }, "require-dev": { - "brianium/paratest": "^7.2.4", - "laravel/framework": "^10.17.1", - "laravel/pint": "^1.10.5", - "laravel/sail": "^1.23.1", - "laravel/sanctum": "^3.2.5", - "laravel/tinker": "^2.8.1", + "brianium/paratest": "^7.3.0", + "laravel/framework": "^10.28.0", + "laravel/pint": "^1.13.3", + "laravel/sail": "^1.25.0", + "laravel/sanctum": "^3.3.1", + "laravel/tinker": "^2.8.2", "nunomaduro/larastan": "^2.6.4", - "orchestra/testbench-core": "^8.5.9", - "pestphp/pest": "^2.12.1", - "phpunit/phpunit": "^10.3.1", + "orchestra/testbench-core": "^8.13.0", + "pestphp/pest": "^2.23.2", + "phpunit/phpunit": "^10.4.1", "sebastian/environment": "^6.0.1", - "spatie/laravel-ignition": "^2.2.0" + "spatie/laravel-ignition": "^2.3.1" }, "type": "library", "extra": { @@ -4627,7 +4649,7 @@ "type": "patreon" } ], - "time": "2023-08-07T08:03:21+00:00" + "time": "2023-10-11T15:45:01+00:00" }, { "name": "nunomaduro/termwind", @@ -4717,32 +4739,32 @@ }, { "name": "ocramius/package-versions", - "version": "2.7.0", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "065921ed7cb2a6861443d91138d0a4378316af8d" + "reference": "7b5821f854cf1e6753c4ed7ceb3b11ae83bbad4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/065921ed7cb2a6861443d91138d0a4378316af8d", - "reference": "065921ed7cb2a6861443d91138d0a4378316af8d", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/7b5821f854cf1e6753c4ed7ceb3b11ae83bbad4e", + "reference": "7b5821f854cf1e6753c4ed7ceb3b11ae83bbad4e", "shasum": "" }, "require": { "composer-runtime-api": "^2.2.0", - "php": "~8.1.0 || ~8.2.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, "replace": { "composer/package-versions-deprecated": "*" }, "require-dev": { - "composer/composer": "^2.4.4", - "doctrine/coding-standard": "^10.0.0", + "composer/composer": "^2.6.3", + "doctrine/coding-standard": "^12.0.0", "ext-zip": "^1.15.0", - "phpunit/phpunit": "^9.5.26", - "roave/infection-static-analysis-plugin": "^1.25.0", - "vimeo/psalm": "^4.29.0" + "phpunit/phpunit": "^9.6.12", + "roave/infection-static-analysis-plugin": "^1.33", + "vimeo/psalm": "^5.15.0" }, "type": "library", "autoload": { @@ -4763,7 +4785,7 @@ "description": "Provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/Ocramius/PackageVersions/issues", - "source": "https://github.com/Ocramius/PackageVersions/tree/2.7.0" + "source": "https://github.com/Ocramius/PackageVersions/tree/2.8.0" }, "funding": [ { @@ -4775,7 +4797,7 @@ "type": "tidelift" } ], - "time": "2022-10-31T12:51:46+00:00" + "time": "2023-09-15T11:02:59+00:00" }, { "name": "ondram/ci-detector", @@ -5662,16 +5684,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.0", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { @@ -5703,22 +5725,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-09-07T20:46:32+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.33", + "version": "1.10.39", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1" + "reference": "d9dedb0413f678b4d03cbc2279a48f91592c97c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", - "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d9dedb0413f678b4d03cbc2279a48f91592c97c4", + "reference": "d9dedb0413f678b4d03cbc2279a48f91592c97c4", "shasum": "" }, "require": { @@ -5767,7 +5789,7 @@ "type": "tidelift" } ], - "time": "2023-09-04T12:20:53+00:00" + "time": "2023-10-17T15:46:26+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -5817,6 +5839,56 @@ }, "time": "2023-08-05T09:02:04+00:00" }, + { + "name": "phpstan/phpstan-mockery", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-mockery.git", + "reference": "6aa86bd8e9c9a1be97baf0558d4a2ed1374736a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/6aa86bd8e9c9a1be97baf0558d4a2ed1374736a6", + "reference": "6aa86bd8e9c9a1be97baf0558d4a2ed1374736a6", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "mockery/mockery": "^1.2.4", + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan Mockery extension", + "support": { + "issues": "https://github.com/phpstan/phpstan-mockery/issues", + "source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.1" + }, + "time": "2023-02-18T13:54:03+00:00" + }, { "name": "phpstan/phpstan-php-parser", "version": "1.1.0", @@ -5866,20 +5938,21 @@ "issues": "https://github.com/phpstan/phpstan-php-parser/issues", "source": "https://github.com/phpstan/phpstan-php-parser/tree/1.1.0" }, + "abandoned": true, "time": "2021-12-16T19:43:32+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.3.14", + "version": "1.3.15", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "614acc10c522e319639bf38b0698a4a566665f04" + "reference": "70ecacc64fe8090d8d2a33db5a51fe8e88acd93a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/614acc10c522e319639bf38b0698a4a566665f04", - "reference": "614acc10c522e319639bf38b0698a4a566665f04", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/70ecacc64fe8090d8d2a33db5a51fe8e88acd93a", + "reference": "70ecacc64fe8090d8d2a33db5a51fe8e88acd93a", "shasum": "" }, "require": { @@ -5916,9 +5989,9 @@ "description": "PHPUnit extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.14" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.15" }, - "time": "2023-08-25T09:46:39+00:00" + "time": "2023-10-09T18:58:39+00:00" }, { "name": "phpstan/phpstan-strict-rules", @@ -5971,16 +6044,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -6037,7 +6110,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" }, "funding": [ { @@ -6045,7 +6118,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6290,16 +6363,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.11", + "version": "9.6.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", "shasum": "" }, "require": { @@ -6314,7 +6387,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -6373,7 +6446,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" }, "funding": [ { @@ -6389,7 +6462,7 @@ "type": "tidelift" } ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2023-09-19T05:39:22+00:00" }, { "name": "pointybeard/reverse-regex", @@ -6620,16 +6693,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -6666,9 +6739,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -8051,16 +8124,16 @@ }, { "name": "roave/better-reflection", - "version": "6.13.0", + "version": "6.15.0", "source": { "type": "git", "url": "https://github.com/Roave/BetterReflection.git", - "reference": "89087a62547d5509b3a0329d8b67218448c7d1d7" + "reference": "19b15d504ca61c5b5f10f5aafb329234c8eeaed2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/BetterReflection/zipball/89087a62547d5509b3a0329d8b67218448c7d1d7", - "reference": "89087a62547d5509b3a0329d8b67218448c7d1d7", + "url": "https://api.github.com/repos/Roave/BetterReflection/zipball/19b15d504ca61c5b5f10f5aafb329234c8eeaed2", + "reference": "19b15d504ca61c5b5f10f5aafb329234c8eeaed2", "shasum": "" }, "require": { @@ -8075,10 +8148,10 @@ }, "require-dev": { "doctrine/coding-standard": "^12.0.0", - "phpstan/phpstan": "^1.10.32", + "phpstan/phpstan": "^1.10.37", "phpstan/phpstan-phpunit": "^1.3.14", - "phpunit/phpunit": "^10.3.2", - "roave/infection-static-analysis-plugin": "^1.32.0", + "phpunit/phpunit": "^10.4.0", + "roave/infection-static-analysis-plugin": "^1.33.0", "vimeo/psalm": "5.15.0" }, "suggest": { @@ -8119,34 +8192,34 @@ "description": "Better Reflection - an improved code reflection API", "support": { "issues": "https://github.com/Roave/BetterReflection/issues", - "source": "https://github.com/Roave/BetterReflection/tree/6.13.0" + "source": "https://github.com/Roave/BetterReflection/tree/6.15.0" }, - "time": "2023-08-29T19:55:40+00:00" + "time": "2023-10-06T14:31:35+00:00" }, { "name": "roave/infection-static-analysis-plugin", - "version": "1.32.0", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/Roave/infection-static-analysis-plugin.git", - "reference": "885d4f82458e48a87a6b4b81cbb7e35e35234c8d" + "reference": "3dd4ea3d5c4b380bb426c8b943328796a5664587" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/infection-static-analysis-plugin/zipball/885d4f82458e48a87a6b4b81cbb7e35e35234c8d", - "reference": "885d4f82458e48a87a6b4b81cbb7e35e35234c8d", + "url": "https://api.github.com/repos/Roave/infection-static-analysis-plugin/zipball/3dd4ea3d5c4b380bb426c8b943328796a5664587", + "reference": "3dd4ea3d5c4b380bb426c8b943328796a5664587", "shasum": "" }, "require": { + "composer-runtime-api": "^2.2", "infection/infection": "0.27.0", - "ocramius/package-versions": "^2.7.0", - "php": "~8.1.0 || ~8.2.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "sanmai/later": "^0.1.2", - "vimeo/psalm": "^4.30.0 || ^5.0.0" + "vimeo/psalm": "^4.30.0 || ^5.15" }, "require-dev": { "doctrine/coding-standard": "^12.0.0", - "phpunit/phpunit": "^10.1.3" + "phpunit/phpunit": "^10.3.4" }, "bin": [ "bin/roave-infection-static-analysis-plugin" @@ -8170,9 +8243,9 @@ "description": "Static analysis on top of mutation testing - prevents escaped mutants from being invalid according to static analysis", "support": { "issues": "https://github.com/Roave/infection-static-analysis-plugin/issues", - "source": "https://github.com/Roave/infection-static-analysis-plugin/tree/1.32.0" + "source": "https://github.com/Roave/infection-static-analysis-plugin/tree/1.33.0" }, - "time": "2023-05-21T01:01:51+00:00" + "time": "2023-09-15T10:43:53+00:00" }, { "name": "roave/signature", @@ -8274,16 +8347,16 @@ }, { "name": "sanmai/pipeline", - "version": "v6.8.1", + "version": "v6.9", "source": { "type": "git", "url": "https://github.com/sanmai/pipeline.git", - "reference": "2e88e466dd49f20c10a15330b3953d4d49c326e3" + "reference": "c48f45c22c3ce4140d071f7658fb151df1cc08ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sanmai/pipeline/zipball/2e88e466dd49f20c10a15330b3953d4d49c326e3", - "reference": "2e88e466dd49f20c10a15330b3953d4d49c326e3", + "url": "https://api.github.com/repos/sanmai/pipeline/zipball/c48f45c22c3ce4140d071f7658fb151df1cc08ea", + "reference": "c48f45c22c3ce4140d071f7658fb151df1cc08ea", "shasum": "" }, "require": { @@ -8327,7 +8400,7 @@ "description": "General-purpose collections pipeline", "support": { "issues": "https://github.com/sanmai/pipeline/issues", - "source": "https://github.com/sanmai/pipeline/tree/v6.8.1" + "source": "https://github.com/sanmai/pipeline/tree/v6.9" }, "funding": [ { @@ -8335,7 +8408,7 @@ "type": "github" } ], - "time": "2023-06-15T09:14:47+00:00" + "time": "2023-10-08T11:56:54+00:00" }, { "name": "sebastian/cli-parser", @@ -9476,32 +9549,32 @@ }, { "name": "slevomat/coding-standard", - "version": "8.13.4", + "version": "8.14.1", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322" + "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/4b2af2fb17773656d02fbfb5d18024ebd19fe322", - "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/fea1fd6f137cc84f9cba0ae30d549615dbc6a926", + "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.23.0", + "phpstan/phpdoc-parser": "^1.23.1", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.26", - "phpstan/phpstan-deprecation-rules": "1.1.3", - "phpstan/phpstan-phpunit": "1.3.13", + "phpstan/phpstan": "1.10.37", + "phpstan/phpstan-deprecation-rules": "1.1.4", + "phpstan/phpstan-phpunit": "1.3.14", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.6" + "phpunit/phpunit": "8.5.21|9.6.8|10.3.5" }, "type": "phpcodesniffer-standard", "extra": { @@ -9525,7 +9598,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.13.4" + "source": "https://github.com/slevomat/coding-standard/tree/8.14.1" }, "funding": [ { @@ -9537,7 +9610,7 @@ "type": "tidelift" } ], - "time": "2023-07-25T10:28:55+00:00" + "time": "2023-10-08T07:28:08+00:00" }, { "name": "spatie/array-to-xml", @@ -9826,16 +9899,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v6.3.4", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "68a5a9570806a087982f383f6109c5e925892a49" + "reference": "2ed62b3bf98346e1f45529a7b6be2196739bb993" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/68a5a9570806a087982f383f6109c5e925892a49", - "reference": "68a5a9570806a087982f383f6109c5e925892a49", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/2ed62b3bf98346e1f45529a7b6be2196739bb993", + "reference": "2ed62b3bf98346e1f45529a7b6be2196739bb993", "shasum": "" }, "require": { @@ -9887,7 +9960,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v6.3.4" + "source": "https://github.com/symfony/dependency-injection/tree/v6.3.5" }, "funding": [ { @@ -9903,7 +9976,7 @@ "type": "tidelift" } ], - "time": "2023-08-16T17:55:17+00:00" + "time": "2023-09-25T16:46:40+00:00" }, { "name": "symfony/deprecation-contracts", @@ -10037,16 +10110,16 @@ }, { "name": "symfony/finder", - "version": "v6.3.3", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e" + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e", - "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", "shasum": "" }, "require": { @@ -10081,7 +10154,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.3.3" + "source": "https://github.com/symfony/finder/tree/v6.3.5" }, "funding": [ { @@ -10097,7 +10170,7 @@ "type": "tidelift" } ], - "time": "2023-07-31T08:31:44+00:00" + "time": "2023-09-26T12:56:25+00:00" }, { "name": "symfony/polyfill-ctype", @@ -10893,16 +10966,16 @@ }, { "name": "symfony/serializer", - "version": "v6.3.4", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/serializer.git", - "reference": "96d28a58d5a128bf77c54534b380eb7c92c8f846" + "reference": "855fc058c8bdbb69f53834f2fdb3876c9bc0ab7c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/serializer/zipball/96d28a58d5a128bf77c54534b380eb7c92c8f846", - "reference": "96d28a58d5a128bf77c54534b380eb7c92c8f846", + "url": "https://api.github.com/repos/symfony/serializer/zipball/855fc058c8bdbb69f53834f2fdb3876c9bc0ab7c", + "reference": "855fc058c8bdbb69f53834f2fdb3876c9bc0ab7c", "shasum": "" }, "require": { @@ -10967,7 +11040,7 @@ "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/serializer/tree/v6.3.4" + "source": "https://github.com/symfony/serializer/tree/v6.3.5" }, "funding": [ { @@ -10983,7 +11056,7 @@ "type": "tidelift" } ], - "time": "2023-08-24T14:35:28+00:00" + "time": "2023-09-29T16:18:53+00:00" }, { "name": "symfony/service-contracts", @@ -11131,16 +11204,16 @@ }, { "name": "symfony/string", - "version": "v6.3.2", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "53d1a83225002635bca3482fcbf963001313fb68" + "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68", - "reference": "53d1a83225002635bca3482fcbf963001313fb68", + "url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339", + "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339", "shasum": "" }, "require": { @@ -11197,7 +11270,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.2" + "source": "https://github.com/symfony/string/tree/v6.3.5" }, "funding": [ { @@ -11213,7 +11286,7 @@ "type": "tidelift" } ], - "time": "2023-07-05T08:41:27+00:00" + "time": "2023-09-18T10:38:32+00:00" }, { "name": "symfony/var-exporter", @@ -12098,26 +12171,27 @@ }, { "name": "wyrihaximus/phpstan-rules-wrapper", - "version": "3.0.0", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/WyriHaximus/php-phpstan-rules-wrapper.git", - "reference": "16bcf692411eaae54953fe6a946b385e254fd47d" + "reference": "8e65ee7749a3e10100f0abec58b7e53ee540c43d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WyriHaximus/php-phpstan-rules-wrapper/zipball/16bcf692411eaae54953fe6a946b385e254fd47d", - "reference": "16bcf692411eaae54953fe6a946b385e254fd47d", + "url": "https://api.github.com/repos/WyriHaximus/php-phpstan-rules-wrapper/zipball/8e65ee7749a3e10100f0abec58b7e53ee540c43d", + "reference": "8e65ee7749a3e10100f0abec58b7e53ee540c43d", "shasum": "" }, "require": { - "ergebnis/phpstan-rules": "^2.0", + "ergebnis/phpstan-rules": "^2.1.0", "jangregor/phpstan-prophecy": "^1.0", "pepakriz/phpstan-exception-rules": "^0.12.0", "php": "^8.2", - "phpstan/phpstan-deprecation-rules": "^1.1.3", + "phpstan/phpstan-deprecation-rules": "^1.1.4", + "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-php-parser": "^1.1", - "phpstan/phpstan-phpunit": "^1.3.13", + "phpstan/phpstan-phpunit": "^1.3.14", "phpstan/phpstan-strict-rules": "^1.5.1", "thecodingmachine/phpstan-safe-rule": "^1.2", "thecodingmachine/phpstan-strict-rules": "^1.0" @@ -12136,7 +12210,7 @@ "description": "🌯 PHPStan rules wrapper", "support": { "issues": "https://github.com/WyriHaximus/php-phpstan-rules-wrapper/issues", - "source": "https://github.com/WyriHaximus/php-phpstan-rules-wrapper/tree/3.0.0" + "source": "https://github.com/WyriHaximus/php-phpstan-rules-wrapper/tree/3.3.0" }, "funding": [ { @@ -12144,7 +12218,7 @@ "type": "github" } ], - "time": "2023-07-22T03:17:18+00:00" + "time": "2023-09-26T09:07:47+00:00" }, { "name": "wyrihaximus/react-awaitable-observable", @@ -12260,12 +12334,12 @@ "source": { "type": "git", "url": "https://github.com/WyriHaximus/php-subsplit-tools.git", - "reference": "163f80a0aa833ac7b6100a5978e43ad5c2f72b8b" + "reference": "22db9bbeced36051af9eb13f8cc4d5d6ec8c4765" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WyriHaximus/php-subsplit-tools/zipball/163f80a0aa833ac7b6100a5978e43ad5c2f72b8b", - "reference": "163f80a0aa833ac7b6100a5978e43ad5c2f72b8b", + "url": "https://api.github.com/repos/WyriHaximus/php-subsplit-tools/zipball/22db9bbeced36051af9eb13f8cc4d5d6ec8c4765", + "reference": "22db9bbeced36051af9eb13f8cc4d5d6ec8c4765", "shasum": "" }, "require": { @@ -12307,7 +12381,7 @@ "type": "github" } ], - "time": "2023-07-28T08:17:10+00:00" + "time": "2023-10-05T10:18:29+00:00" }, { "name": "wyrihaximus/test-utilities", @@ -12422,5 +12496,5 @@ "platform-overrides": { "php": "8.2.13" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/example/templates/composer.json b/example/templates/composer.json index e11cd01..2efacd3 100644 --- a/example/templates/composer.json +++ b/example/templates/composer.json @@ -20,6 +20,7 @@ "devizzent/cebe-php-openapi": "^1", "eventsauce/object-hydrator": "^1.1", "league/openapi-psr7-validator": "^0.21", + "league/uri": "^7.3 || ^6.8", "psr/http-message": "^1.0", "react/http": "^1.8", "react/async": "^4.0", diff --git a/src/Gatherer/ExampleData.php b/src/Gatherer/ExampleData.php index e6a3fe1..f4aeb89 100644 --- a/src/Gatherer/ExampleData.php +++ b/src/Gatherer/ExampleData.php @@ -14,18 +14,20 @@ use ReverseRegex\Lexer; use ReverseRegex\Parser; +use function explode; use function gettype; use function is_array; use function is_string; use function Safe\date; use function Safe\json_encode; use function strlen; +use function strpos; final class ExampleData { public static function gather(mixed $exampleData, PropertyType $type, string $propertyName): Representation\ExampleData { - if ($type->type === 'array') { + if ($type->type === 'array' || $type->type === 'union') { if ($type->payload instanceof Schema) { $exampleData = ArrayMerger::doMerge( $type->payload->example, @@ -34,6 +36,11 @@ public static function gather(mixed $exampleData, PropertyType $type, string $pr ); } elseif ($type->payload instanceof PropertyType) { return self::gather($exampleData, $type->payload, $propertyName); + +// } elseif (is_array($type->payload)) { +// $exampleData = [ +// self::gather($exampleData, $type->payload[0], $propertyName), +// ]; } return new Representation\ExampleData($exampleData, $exampleData instanceof Node\Expr ? $exampleData : self::turnArrayIntoNode((array) $exampleData)); @@ -90,6 +97,12 @@ public static function determiteType(mixed $exampleData): Representation\Example /** @phpstan-ignore-next-line */ public static function scalarData(int $seed, string $type, string|null $format, string|null $pattern = null): Representation\ExampleData { + if (strpos($type, '|') !== false) { + [$firstType] = explode('|', $type); + + return self::scalarData($seed, $firstType, $format, $pattern); + } + if ($type === 'int' || $type === '?int') { return new Representation\ExampleData($seed, new Node\Scalar\LNumber($seed)); } @@ -149,6 +162,23 @@ public static function scalarData(int $seed, string $type, string|null $format, return new Representation\ExampleData('generated', new Node\Scalar\String_('generated')); } + if ($type === 'array' || $type === '?array') { + $string = self::scalarData($seed, 'string', $format, $pattern); + + return new Representation\ExampleData( + [ + $string->raw, + ], + new Node\Expr\Array_( + [ + new Node\Expr\ArrayItem( + $string->node, + ), + ], + ), + ); + } + return new Representation\ExampleData( null, new Node\Expr\ConstFetch( diff --git a/src/Gatherer/Operation.php b/src/Gatherer/Operation.php index c987f2a..d56ee23 100644 --- a/src/Gatherer/Operation.php +++ b/src/Gatherer/Operation.php @@ -6,6 +6,7 @@ use ApiClients\Tools\OpenApiClientGenerator\ClassString; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\ThrowableSchema; use ApiClients\Tools\OpenApiClientGenerator\Representation\Header; @@ -45,11 +46,20 @@ public static function gather( openAPIOperation $operation, ThrowableSchema $throwableSchemaRegistry, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): \ApiClients\Tools\OpenApiClientGenerator\Representation\Operation { $returnType = []; $parameters = []; $empties = []; foreach ($operation->parameters as $parameter) { + $types = is_array($parameter->schema->type) ? $parameter->schema->type : [$parameter->schema->type]; + if (count($parameter->schema->oneOf ?? []) > 0) { + $types = []; + foreach ($parameter->schema->oneOf as $oneOfSchema) { + $types[] = $oneOfSchema->type; + } + } + $parameterType = str_replace([ 'integer', 'any', @@ -58,7 +68,7 @@ public static function gather( 'int', 'string|object', 'bool', - ], implode('|', is_array($parameter->schema->type) ? $parameter->schema->type : [$parameter->schema->type])); + ], implode('|', $types)); $parameters[] = new Parameter( (new Convert($parameter->name))->toCamel(), @@ -82,7 +92,7 @@ public static function gather( ); $requestBody[] = new OperationRequestBody( $contentType, - Schema::gather($baseNamespace, $requestBodyClassname, $requestBodyDetails->schema, $schemaRegistry), + Schema::gather($baseNamespace, $requestBodyClassname, $requestBodyDetails->schema, $schemaRegistry, $contractRegistry), ); } } @@ -115,6 +125,7 @@ public static function gather( $contentTypeMediaType->schema, true, $schemaRegistry, + $contractRegistry, ), ); if ($isError) { @@ -139,6 +150,7 @@ public static function gather( ), $headerSpec->schema, $schemaRegistry, + $contractRegistry, ), ExampleData::determiteType($headerSpec->example)); } diff --git a/src/Gatherer/Path.php b/src/Gatherer/Path.php index c080119..f2e7ace 100644 --- a/src/Gatherer/Path.php +++ b/src/Gatherer/Path.php @@ -7,6 +7,7 @@ use ApiClients\Tools\OpenApiClientGenerator\ClassString; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Voter; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\ThrowableSchema; use ApiClients\Tools\OpenApiClientGenerator\Utils; @@ -23,6 +24,7 @@ public static function gather( string $path, PathItem $pathItem, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ThrowableSchema $throwableSchemaRegistry, Voter|null $voters, ): \ApiClients\Tools\OpenApiClientGenerator\Representation\Path { @@ -45,6 +47,7 @@ public static function gather( $operation, $throwableSchemaRegistry, $schemaRegistry, + $contractRegistry, ); if ($voters !== null && is_array($voters->listOperation)) { @@ -75,6 +78,7 @@ public static function gather( $operation, $throwableSchemaRegistry, $schemaRegistry, + $contractRegistry, ); } } @@ -105,6 +109,7 @@ public static function gather( $operation, $throwableSchemaRegistry, $schemaRegistry, + $contractRegistry, ); } diff --git a/src/Gatherer/Property.php b/src/Gatherer/Property.php index 356915a..3d5ea9e 100644 --- a/src/Gatherer/Property.php +++ b/src/Gatherer/Property.php @@ -5,6 +5,7 @@ namespace ApiClients\Tools\OpenApiClientGenerator\Gatherer; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Representation; use cebe\openapi\spec\Schema as baseSchema; @@ -13,6 +14,7 @@ use PhpParser\Node; use function array_filter; +use function array_key_exists; use function array_values; use function count; use function is_array; @@ -30,6 +32,7 @@ public static function gather( bool $required, baseSchema $property, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): Representation\Property { $enum = []; $exampleData = null; @@ -80,6 +83,7 @@ static function ($matches) { $property, $required, $schemaRegistry, + $contractRegistry, ); if ($property->type === 'array' && is_array($type->payload)) { @@ -87,7 +91,11 @@ static function ($matches) { $arrayItemsNode = []; foreach ($type->payload as $index => $arrayItem) { - $arrayItemExampleData = ExampleData::gather($exampleData, $arrayItem, $propertyName . str_pad('', $index + 1, '_')); + $arrayItemExampleData = ExampleData::gather( + $exampleData, + $arrayItem->type === 'union' ? $arrayItem->payload[(array_key_exists($index, $arrayItem->payload) ? $index : 0)] : $arrayItem, + $propertyName . str_pad('', $index + 1, '_'), + ); $arrayItemsRaw[] = $arrayItemExampleData->raw; $arrayItemsNode[] = new Node\Expr\ArrayItem($arrayItemExampleData->node); } diff --git a/src/Gatherer/Schema.php b/src/Gatherer/Schema.php index 1e7fe95..1de3fbe 100644 --- a/src/Gatherer/Schema.php +++ b/src/Gatherer/Schema.php @@ -6,6 +6,7 @@ use ApiClients\Tools\OpenApiClientGenerator\ClassString; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Utils; use cebe\openapi\spec\Schema as baseSchema; @@ -22,6 +23,7 @@ public static function gather( string $className, baseSchema $schema, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): \ApiClients\Tools\OpenApiClientGenerator\Representation\Schema { $className = Utils::className($className); $isArray = $schema->type === 'array'; @@ -38,12 +40,13 @@ public static function gather( $className, (string) $propertyName, in_array( - $propertyName, + (string) $propertyName, $schema->required ?? [], false, ), $property, $schemaRegistry, + $contractRegistry, ); $properties[] = $gatheredProperty; @@ -60,10 +63,16 @@ public static function gather( } $example[$gatheredProperty->sourceName] = $gatheredProperty->example->raw; + + foreach ($property->enum ?? [] as $value) { + $example[$gatheredProperty->sourceName] = $value; + break; + } } return new \ApiClients\Tools\OpenApiClientGenerator\Representation\Schema( ClassString::factory($baseNamespace, 'Schema\\' . $className), + ClassString::factory($baseNamespace, 'Contract\\' . $className), ClassString::factory($baseNamespace, 'Error\\' . $className), ClassString::factory($baseNamespace, 'ErrorSchemas\\' . $className), $schema->title ?? '', diff --git a/src/Gatherer/Type.php b/src/Gatherer/Type.php index b2a0758..936a32b 100644 --- a/src/Gatherer/Type.php +++ b/src/Gatherer/Type.php @@ -5,6 +5,7 @@ namespace ApiClients\Tools\OpenApiClientGenerator\Gatherer; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Representation\PropertyType; use ApiClients\Tools\OpenApiClientGenerator\Utils; @@ -29,18 +30,50 @@ public static function gather( baseSchema $property, bool $required, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): PropertyType { $type = $property->type; $nullable = ! $required; if (is_array($property->allOf) && count($property->allOf) > 0) { - return self::gather( - $baseNamespace, - $className, - $propertyName, - $property->allOf[0], - $required, - $schemaRegistry, + return new PropertyType( + 'intersection', + null, + null, + [ + ...(static function ( + Namespace_ $baseNamespace, + string $className, + string $propertyName, + array $properties, + bool $required, + SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, + ): iterable { + foreach ($properties as $index => $property) { + $type = self::gather( + $baseNamespace, + $className, + $propertyName . '\\' . NumberToWords::transformNumber('en', $index), + $property, + $required, + $schemaRegistry, + $contractRegistry, + ); + yield $type; + // $contractRegistry-> + } + })( + $baseNamespace, + $className, + $propertyName, + $property->allOf, + $required, + $schemaRegistry, + $contractRegistry, + ), + ], + $nullable, ); } @@ -48,15 +81,16 @@ public static function gather( // Check if nullable if ( count($property->oneOf) === 2 && - count(array_filter($property->oneOf, static fn (\cebe\openapi\spec\Schema $schema): bool => $schema->type === 'null')) === 1 + count(array_filter($property->oneOf, static fn (BaseSchema $schema): bool => $schema->type === 'null')) === 1 ) { return self::gather( $baseNamespace, $className, $propertyName, - current(array_filter($property->oneOf, static fn (\cebe\openapi\spec\Schema $schema): bool => $schema->type !== 'null')), + current(array_filter($property->oneOf, static fn (BaseSchema $schema): bool => $schema->type !== 'null')), false, $schemaRegistry, + $contractRegistry, ); } @@ -72,6 +106,7 @@ public static function gather( array $properties, bool $required, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): iterable { foreach ($properties as $index => $property) { yield self::gather( @@ -81,6 +116,7 @@ public static function gather( $property, $required, $schemaRegistry, + $contractRegistry, ); } })( @@ -90,6 +126,7 @@ public static function gather( $property->oneOf, $required, $schemaRegistry, + $contractRegistry, ), ], $nullable, @@ -100,15 +137,16 @@ public static function gather( // Check if nullable if ( count($property->anyOf) === 2 && - count(array_filter($property->anyOf, static fn (\cebe\openapi\spec\Schema $schema): bool => $schema->type === 'null')) === 1 + count(array_filter($property->anyOf, static fn (BaseSchema $schema): bool => $schema->type === 'null')) === 1 ) { return self::gather( $baseNamespace, $className, $propertyName, - current(array_filter($property->anyOf, static fn (\cebe\openapi\spec\Schema $schema): bool => $schema->type !== 'null')), + current(array_filter($property->anyOf, static fn (BaseSchema $schema): bool => $schema->type !== 'null')), false, $schemaRegistry, + $contractRegistry, ); } @@ -124,6 +162,7 @@ public static function gather( array $properties, bool $required, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): iterable { foreach ($properties as $index => $property) { yield self::gather( @@ -133,6 +172,7 @@ public static function gather( $property, $required, $schemaRegistry, + $contractRegistry, ); } })( @@ -142,6 +182,7 @@ public static function gather( $property->anyOf, $required, $schemaRegistry, + $contractRegistry, ), ], $nullable, @@ -178,6 +219,7 @@ public static function gather( $property->items, $required, $schemaRegistry, + $contractRegistry, ); } @@ -231,6 +273,7 @@ public static function gather( ), $property, $schemaRegistry, + $contractRegistry, ), $nullable, ); diff --git a/src/Gatherer/WebHook.php b/src/Gatherer/WebHook.php index ec44691..2ef6ffd 100644 --- a/src/Gatherer/WebHook.php +++ b/src/Gatherer/WebHook.php @@ -5,6 +5,7 @@ namespace ApiClients\Tools\OpenApiClientGenerator\Gatherer; use ApiClients\Tools\OpenApiClientGenerator\Configuration\Namespace_; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Representation\Header; use cebe\openapi\spec\PathItem; @@ -23,6 +24,7 @@ public static function gather( Namespace_ $baseNamespace, PathItem $webhook, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ): \ApiClients\Tools\OpenApiClientGenerator\Representation\WebHook { if ($webhook->post?->requestBody === null && ! property_exists($webhook->post->requestBody, 'content')) { throw new RuntimeException('Missing request body content to deal with'); @@ -44,6 +46,7 @@ public static function gather( ), $header->schema, $schemaRegistry, + $contractRegistry, ), ExampleData::determiteType($header->example)); } @@ -54,16 +57,17 @@ public static function gather( $webhook->post->operationId, $webhook->post->externalDocs->url ?? '', $headers, - iterator_to_array((static function (array $content, SchemaRegistry $schemaRegistry, Namespace_ $baseNamespace): iterable { + iterator_to_array((static function (array $content, SchemaRegistry $schemaRegistry, ContractRegistry $contractRegistry, Namespace_ $baseNamespace): iterable { foreach ($content as $type => $schema) { yield $type => Schema::gather( $baseNamespace, $schemaRegistry->get($schema->schema, 'T' . time()), $schema->schema, $schemaRegistry, + $contractRegistry, ); } - })($webhook->post->requestBody->content, $schemaRegistry, $baseNamespace)), + })($webhook->post->requestBody->content, $schemaRegistry, $contractRegistry, $baseNamespace)), ); } } diff --git a/src/Generator.php b/src/Generator.php index 3168bde..0681c5b 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -22,6 +22,7 @@ use ApiClients\Tools\OpenApiClientGenerator\Generator\WebHook; use ApiClients\Tools\OpenApiClientGenerator\Generator\WebHooks; use ApiClients\Tools\OpenApiClientGenerator\Output\Status\Step; +use ApiClients\Tools\OpenApiClientGenerator\Registry\Contract as ContractRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\Schema as SchemaRegistry; use ApiClients\Tools\OpenApiClientGenerator\Registry\ThrowableSchema; use ApiClients\Tools\OpenApiClientGenerator\Representation\Path; @@ -210,6 +211,7 @@ public function generate(string $namespace, string $namespaceTest, string $confi ]); } })([ + ltrim($namespace, '\\') . 'Contract' => null, ltrim($namespace, '\\') . 'Error' => 'ErrorSchemas', ltrim($namespace, '\\') . 'Internal' => null, ltrim($namespace, '\\') . 'Operation' => null, @@ -299,6 +301,11 @@ private function all(string $configurationLocation): iterable $this->configuration->schemas->allowDuplication ?? false, $this->configuration->schemas->useAliasesForDuplication ?? false, ); + $contractRegistry = new ContractRegistry( + $this->configuration->namespace, + $this->configuration->schemas->allowDuplication ?? false, + $this->configuration->schemas->useAliasesForDuplication ?? false, + ); $schemas = []; $throwableSchemaRegistry = new ThrowableSchema(); if (count($this->spec->components->schemas ?? []) > 0) { @@ -322,7 +329,7 @@ private function all(string $configurationLocation): iterable */ foreach ($this->spec->components->schemas as $name => $schema) { assert($schema instanceof \cebe\openapi\spec\Schema); - $schemas[] = Gatherer\Schema::gather($this->configuration->namespace, Utils::className($name), $schema, $schemaRegistry); + $schemas[] = Gatherer\Schema::gather($this->configuration->namespace, Utils::className($name), $schema, $schemaRegistry, $contractRegistry); $this->statusOutput->advanceStep('gathering_schemas'); } } @@ -335,7 +342,7 @@ private function all(string $configurationLocation): iterable $this->statusOutput->itemForStep('gathering_webhooks', count($this->spec->webhooks)); foreach ($this->spec->webhooks as $webHook) { try { - $webHookje = Gatherer\WebHook::gather($this->configuration->namespace, $webHook, $schemaRegistry); + $webHookje = Gatherer\WebHook::gather($this->configuration->namespace, $webHook, $schemaRegistry, $contractRegistry); if (! array_key_exists($webHookje->event, $webHooks)) { $webHooks[$webHookje->event] = []; } @@ -372,6 +379,7 @@ private function all(string $configurationLocation): iterable $path, $pathItem, $schemaRegistry, + $contractRegistry, $throwableSchemaRegistry, $this->configuration->voter, ); @@ -393,7 +401,7 @@ private function all(string $configurationLocation): iterable $this->statusOutput->markStepBusy('client_single'); /** @phpstan-ignore-next-line */ - yield from $this->oneClient($configurationLocation, $schemaRegistry, $throwableSchemaRegistry, $schemas, $paths, $webHooks); + yield from $this->oneClient($configurationLocation, $schemaRegistry, $contractRegistry, $throwableSchemaRegistry, $schemas, $paths, $webHooks); $this->statusOutput->markStepDone('client_single'); } else { @@ -405,7 +413,7 @@ private function all(string $configurationLocation): iterable $this->statusOutput->markStepBusy('client_subsplit'); /** @phpstan-ignore-next-line */ - yield from $this->subSplitClient($configurationLocation, $schemaRegistry, $throwableSchemaRegistry, $schemas, $paths, $webHooks); + yield from $this->subSplitClient($configurationLocation, $schemaRegistry, $contractRegistry, $throwableSchemaRegistry, $schemas, $paths, $webHooks); $this->statusOutput->markStepDone('client_subsplit'); } @@ -421,6 +429,7 @@ private function all(string $configurationLocation): iterable private function oneClient( string $configurationLocation, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ThrowableSchema $throwableSchemaRegistry, array $schemas, array $paths, @@ -469,7 +478,7 @@ private function oneClient( $unknownSchemaCount += count($unknownSchemas); $this->statusOutput->itemForStep('gathering_unknown_schemas', $unknownSchemaCount); foreach ($unknownSchemas as $schema) { - $schemas[] = Gatherer\Schema::gather($this->configuration->namespace, $schema->className, $schema->schema, $schemaRegistry); + $schemas[] = Gatherer\Schema::gather($this->configuration->namespace, $schema->className, $schema->schema, $schemaRegistry, $contractRegistry); $this->statusOutput->advanceStep('gathering_unknown_schemas'); } } @@ -629,6 +638,7 @@ private function oneClient( private function subSplitClient( string $configurationLocation, SchemaRegistry $schemaRegistry, + ContractRegistry $contractRegistry, ThrowableSchema $throwableSchemaRegistry, array $schemas, array $paths, @@ -718,7 +728,7 @@ private function subSplitClient( $unknownSchemaCount += count($unknownSchemas); $this->statusOutput->itemForStep('gathering_unknown_schemas', $unknownSchemaCount); foreach ($unknownSchemas as $schema) { - $schemas[] = Gatherer\Schema::gather($this->configuration->namespace, $schema->className, $schema->schema, $schemaRegistry); + $schemas[] = Gatherer\Schema::gather($this->configuration->namespace, $schema->className, $schema->schema, $schemaRegistry, $contractRegistry); $this->statusOutput->advanceStep('gathering_unknown_schemas'); } } diff --git a/src/Generator/Client/PHPStan/ClientCallReturnTypesTest.php b/src/Generator/Client/PHPStan/ClientCallReturnTypesTest.php index 47cedef..c283f30 100644 --- a/src/Generator/Client/PHPStan/ClientCallReturnTypesTest.php +++ b/src/Generator/Client/PHPStan/ClientCallReturnTypesTest.php @@ -15,6 +15,7 @@ use PhpParser\Node\Expr; use React\Http\Browser; +use function str_replace; use function trim; final class ClientCallReturnTypesTest @@ -87,7 +88,7 @@ public static function generate(Configuration $configuration, string $pathPrefix [ new Arg( new Node\Scalar\String_( - Operation::getDocBlockResultTypeFromOperation($operation), + str_replace(',', ', ', Operation::getDocBlockResultTypeFromOperation($operation)), ), ), new Arg( diff --git a/src/Generator/Operation.php b/src/Generator/Operation.php index b3502c9..97c13cd 100644 --- a/src/Generator/Operation.php +++ b/src/Generator/Operation.php @@ -15,6 +15,7 @@ use cebe\openapi\Reader; use cebe\openapi\spec\Schema; use Jawira\CaseConverter\Convert; +use League\Uri\UriTemplate; use NumberToWords\NumberToWords; use PhpParser\Builder\Param; use PhpParser\BuilderFactory; @@ -34,7 +35,6 @@ use Rx\Subject\Subject; use Throwable; -use function array_keys; use function array_map; use function array_unique; use function array_values; @@ -43,7 +43,7 @@ use function is_array; use function is_int; use function is_string; -use function rtrim; +use function ksort; use function strlen; use function strpos; use function strtolower; @@ -140,36 +140,66 @@ public static function generate(string $pathPrefix, \ApiClients\Tools\OpenApiCli ), ); if ($parameter->location === 'path' || $parameter->location === 'query') { - $requestReplaces['{' . $parameter->targetName . '}'] = new Node\Expr\PropertyFetch( + $propertyFetch = new Node\Expr\PropertyFetch( new Node\Expr\Variable('this'), $parameter->name, ); + $requestReplaces[$parameter->targetName] = $propertyFetch; } if ($parameter->location !== 'query') { continue; } - $query[] = $parameter->targetName . '={' . $parameter->targetName . '}'; + $query[$parameter->targetName] = $parameter->targetName . ($parameter->type === 'array' ? '*' : ''); } + ksort($query); + ksort($requestReplaces); + $requestParameters = [ - new Node\Arg(new Node\Scalar\String_($operation->method)), - new Node\Arg(new Node\Expr\FuncCall( - new Node\Name('\str_replace'), - [ - new Node\Arg(new Node\Expr\Array_(array_map(static fn (string $key): Node\Expr\ArrayItem => new Node\Expr\ArrayItem(new Node\Scalar\String_($key)), array_keys($requestReplaces)))), - new Node\Arg(new Node\Expr\Array_(array_map(static fn (Node\Expr\PropertyFetch $pf): Node\Expr\ArrayItem => new Node\Expr\ArrayItem($pf), array_values($requestReplaces)))), - new Node\Arg(count($query) > 0 ? new Node\Expr\BinaryOp\Concat( - new Node\Scalar\String_( - $operation->path, // Deal with the query + new Node\Arg( + new Node\Scalar\String_($operation->method), + ), + new Node\Arg( + new Node\Expr\Cast\String_( + new Node\Expr\MethodCall( + new Node\Expr\New_( + new Node\Name( + '\\' . UriTemplate::class, + ), + [ + new Node\Arg( + count($query) > 0 ? new Node\Scalar\String_( + $operation->path . '{?' . implode(',', $query) . '}', + ) : new Node\Scalar\String_( + $operation->path, // Deal with the query + ), + ), + ], ), - new Node\Scalar\String_(rtrim('?' . implode('&', $query), '?')), - ) : new Node\Scalar\String_( - $operation->path, // Deal with the query - )), - ], - )), + new Node\Name( + 'expand', + ), + [ + new Arg( + new Node\Expr\Array_( + [ + ...(static function (array $requestReplaces): iterable { + foreach ($requestReplaces as $key => $valueRetreival) { + yield new Node\Expr\ArrayItem( + $valueRetreival, + new Node\Scalar\String_($key), + ); + } + })($requestReplaces), + ], + ), + ), + ], + ), + ), + ), ]; $createRequestMethod = $factory->method('createRequest')->setReturnType('\\' . RequestInterface::class)->makePublic(); diff --git a/src/Generator/OperationTest.php b/src/Generator/OperationTest.php index 41523ce..9393c52 100644 --- a/src/Generator/OperationTest.php +++ b/src/Generator/OperationTest.php @@ -25,12 +25,16 @@ use WyriHaximus\AsyncTestUtilities\AsyncTestCase; use function count; +use function current; use function implode; use function is_array; +use function is_bool; use function is_string; +use function ksort; use function Safe\preg_replace; use function str_replace; use function strtolower; +use function urlencode; use const PHP_EOL; @@ -784,7 +788,7 @@ private static function testSetUp(Node\Expr $responseSchemaFetch, Representation continue; } - $items[] = $parameter->example->raw; + $items[] = is_bool($parameter->example->raw) ? (int) $parameter->example->raw : $parameter->example->raw; } return $items; @@ -797,9 +801,26 @@ private static function testSetUp(Node\Expr $responseSchemaFetch, Representation continue; } - $items[] = $parameter->targetName . '=' . $parameter->example->raw; + if (is_bool($parameter->example->raw)) { + $items[$parameter->targetName] = $parameter->targetName . '=' . (int) $parameter->example->raw; + continue; + } + + if ($parameter->type === 'array') { + $items[$parameter->targetName] = $parameter->targetName . '=' . urlencode(current($parameter->example->raw)); + continue; + } + + if (is_string($parameter->example->raw)) { + $items[$parameter->targetName] = $parameter->targetName . '=' . urlencode($parameter->example->raw); + continue; + } + + $items[$parameter->targetName] = $parameter->targetName . '=' . $parameter->example->raw; } + ksort($items); + return count($items) > 0 ? '?' . implode('&', $items) : ''; })($operation->parameters), ), diff --git a/src/Generator/Schema.php b/src/Generator/Schema.php index 34ac25c..dcef889 100644 --- a/src/Generator/Schema.php +++ b/src/Generator/Schema.php @@ -6,7 +6,8 @@ use ApiClients\Tools\OpenApiClientGenerator\ClassString; use ApiClients\Tools\OpenApiClientGenerator\File; -use ApiClients\Tools\OpenApiClientGenerator\Generator\Schema\CastUnionToType; +use ApiClients\Tools\OpenApiClientGenerator\Generator\Schema\MultipleCastUnionToType; +use ApiClients\Tools\OpenApiClientGenerator\Generator\Schema\SingleCastUnionToType; use ApiClients\Tools\OpenApiClientGenerator\PromotedPropertyAsParam; use ApiClients\Tools\OpenApiClientGenerator\Representation; use ApiClients\Tools\OpenApiClientGenerator\Utils; @@ -17,6 +18,7 @@ use PhpParser\Node\Stmt\Class_; use function array_filter; +use function array_key_exists; use function array_unique; use function count; use function explode; @@ -54,7 +56,6 @@ public static function generate(string $pathPrefix, Representation\Schema $schem } $factory = new BuilderFactory(); - $stmt = $factory->namespace($className->namespace->source); $schemaJson = new Node\Stmt\ClassConst( [ @@ -68,7 +69,8 @@ public static function generate(string $pathPrefix, Representation\Schema $schem Class_::MODIFIER_PUBLIC, ); - $class = $factory->class($className->className)->makeReadonly(); + $contract = $factory->interface($schema->contractClassName->className); + $class = $factory->class($className->className)->makeReadonly()->implement($schema->contractClassName->relative); if (count($aliases) === 0) { $class = $class->makeFinal(); @@ -114,8 +116,9 @@ public static function generate(string $pathPrefix, Representation\Schema $schem ), ); - $constructor = (new BuilderFactory())->method('__construct')->makePublic(); - $constructDocBlock = []; + $constructor = (new BuilderFactory())->method('__construct')->makePublic(); + $constructDocBlock = []; + $contractProperties = []; foreach ($schema->properties as $property) { if (strlen($property->description) > 0) { $constructDocBlock[] = $property->name . ': ' . $property->description; @@ -139,9 +142,9 @@ public static function generate(string $pathPrefix, Representation\Schema $schem $schemaClasses = [...self::getUnionTypeSchemas($property->type)]; if (count($schemaClasses) > 0) { - $castToUnionToType = ClassString::factory($schema->className->baseNamespaces, Utils::className('Internal\\Attribute\\CastUnionToType\\' . $schema->className->relative . '\\' . $property->name)); + $castToUnionToType = ClassString::factory($schema->className->baseNamespaces, Utils::className('Internal\\Attribute\\CastUnionToType\\Single\\' . $schema->className->relative . '\\' . $property->name)); - yield from CastUnionToType::generate($pathPrefix, $castToUnionToType, ...$schemaClasses); + yield from SingleCastUnionToType::generate($pathPrefix, $castToUnionToType, ...$schemaClasses); $constructorParam->addAttribute( new Node\Attribute( @@ -164,9 +167,9 @@ public static function generate(string $pathPrefix, Representation\Schema $schem $iterableType = self::buildUnionType($iterableType); if (count($schemaClasses) > 0) { - $castToUnionToType = ClassString::factory($schema->className->baseNamespaces, Utils::className('Internal\\Attribute\\CastUnionToType\\' . $schema->className->relative . '\\' . $property->name)); + $castToUnionToType = ClassString::factory($schema->className->baseNamespaces, Utils::className('Internal\\Attribute\\CastUnionToType\\Single\\' . $schema->className->relative . '\\' . $property->name)); - yield from CastUnionToType::generate($pathPrefix, $castToUnionToType, ...$schemaClasses); + yield from SingleCastUnionToType::generate($pathPrefix, $castToUnionToType, ...$schemaClasses); $constructorParam->addAttribute( new Node\Attribute( @@ -180,7 +183,9 @@ public static function generate(string $pathPrefix, Representation\Schema $schem $iterableType = $iterableType->payload; } - $constructDocBlock[] = '@param ' . ($property->nullable ? '?' : '') . 'array<' . $iterableType . '> $' . $property->name; + $compiledTYpe = ($property->nullable ? '?' : '') . 'array<' . $iterableType . '>'; + $contractProperties[$property->name] = '@property ' . $compiledTYpe . ' $' . $property->name; + $constructDocBlock[] = '@param ' . $compiledTYpe . ' $' . $property->name; } if ($property->type->payload->payload instanceof Representation\Schema) { @@ -196,6 +201,35 @@ public static function generate(string $pathPrefix, Representation\Schema $schem ), ); } + } elseif (is_array($property->type->payload)) { + $schemaClasses = []; + foreach ($property->type->payload as $payloadType) { + $schemaClasses = [...$schemaClasses, ...self::getUnionTypeSchemas($payloadType)]; + } + + if (count($schemaClasses) > 0) { + $castToUnionToType = ClassString::factory($schema->className->baseNamespaces, Utils::className('Internal\\Attribute\\CastUnionToType\\Single\\' . $schema->className->relative . '\\' . $property->name)); + $arrayCastToUnionToType = ClassString::factory($schema->className->baseNamespaces, Utils::className('Internal\\Attribute\\CastUnionToType\\Multiple\\' . $schema->className->relative . '\\' . $property->name)); + + yield from SingleCastUnionToType::generate($pathPrefix, $castToUnionToType, ...$schemaClasses); + yield from MultipleCastUnionToType::generate($pathPrefix, $arrayCastToUnionToType, $castToUnionToType, ...$schemaClasses); + + $constructorParam->addAttribute( + new Node\Attribute( + new Node\Name($arrayCastToUnionToType->fullyQualified->source), + ), + ); + + $compiledTYpe = ($property->nullable ? '?' : '') . 'array<' . implode('|', array_unique([ + ...(static function (Representation\Schema ...$schemas): iterable { + foreach ($schemas as $schema) { + yield $schema->className->fullyQualified->source; + } + })(...$schemaClasses), + ])) . '>'; + $contractProperties[$property->name] = '@property ' . $compiledTYpe . ' $' . $property->name; + $constructDocBlock[] = '@param ' . $compiledTYpe . ' $' . $property->name; + } } $types[] = 'array'; @@ -214,6 +248,13 @@ public static function generate(string $pathPrefix, Representation\Schema $schem if (count($types) > 0) { $constructorParam->setType($nullable . implode('|', $types)); + if (! array_key_exists($property->name, $contractProperties)) { + $contractProperties[$property->name] = '@property ' . $nullable . implode('|', $types) . ' $' . $property->name; + } + } else { + if (! array_key_exists($property->name, $contractProperties)) { + $contractProperties[$property->name] = '@property $' . $property->name; + } } $constructor->addParam($constructorParam); @@ -223,9 +264,14 @@ public static function generate(string $pathPrefix, Representation\Schema $schem $constructor->setDocComment('/**' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', str_replace(['/**', '*/'], '', $constructDocBlock)) . PHP_EOL . ' */'); } + if (count($contractProperties) > 0) { + $contract->setDocComment('/**' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', $contractProperties) . PHP_EOL . ' */'); + } + $class->addStmt($constructor); - yield new File($pathPrefix, $className->relative, $stmt->addStmt($class)->getNode()); + yield new File($pathPrefix, $schema->contractClassName->relative, $factory->namespace($schema->contractClassName->namespace->source)->addStmt($contract)->getNode()); + yield new File($pathPrefix, $className->relative, $factory->namespace($className->namespace->source)->addStmt($class)->getNode()); foreach ($aliases as $alias) { $aliasTms = $factory->namespace($alias->namespace->source); diff --git a/src/Generator/Schema/MultipleCastUnionToType.php b/src/Generator/Schema/MultipleCastUnionToType.php new file mode 100644 index 0000000..866730e --- /dev/null +++ b/src/Generator/Schema/MultipleCastUnionToType.php @@ -0,0 +1,140 @@ + */ + public static function generate(string $pathPrefix, ClassString $classString, ClassString $wrappingClassString, Schema ...$schemas): iterable + { + $factory = new BuilderFactory(); + $stmt = $factory->namespace($classString->namespace->source); + + $class = $factory->class($classString->className)->makeFinal()->makeReadonly()->addAttribute( + new Node\Attribute( + new Node\Name('\\' . Attribute::class), + [ + new Node\Arg( + new Node\Expr\ClassConstFetch( + new Node\Name('\\' . Attribute::class), + 'TARGET_PARAMETER', + ), + ), + ], + ), + )->implement('\\' . PropertyCaster::class)->addStmt( + $factory->property('wrappedCaster')->makePrivate()->setType($wrappingClassString->fullyQualified->source), + )->addStmt( + $factory->method('__construct')->makePublic()->addStmts([ + new Node\Stmt\Expression( + new Node\Expr\Assign( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable( + new Node\Name('this'), + ), + new Node\Name('wrappedCaster'), + ), + new Node\Expr\New_( + new Node\Name( + $wrappingClassString->fullyQualified->source, + ), + ), + ), + ), + ]), + )->addStmt( + $factory->method('cast')->makePublic()->addParams([ + (new Param('value'))->setType('mixed'), + (new Param('hydrator'))->setType('\\' . ObjectMapper::class), + ])->setReturnType('mixed')->addStmts([ + new Node\Stmt\Expression( + new Node\Expr\Assign( + new Node\Expr\Variable( + new Node\Name('data'), + ), + new Node\Expr\Array_(), + ), + ), + new Node\Stmt\Expression( + new Node\Expr\Assign( + new Node\Expr\Variable( + new Node\Name('values'), + ), + new Node\Expr\Variable( + new Node\Name('value'), + ), + ), + ), + new Node\Expr\FuncCall( + new Node\Name('unset'), + [ + new Node\Arg( + new Node\Expr\Variable( + new Node\Name('value'), + ), + ), + ], + ), + new Node\Stmt\Foreach_( + new Node\Expr\Variable( + new Node\Name('values'), + ), + new Node\Expr\Variable( + new Node\Name('value'), + ), + [ + 'stmts' => [ + new Node\Stmt\Expression( + new Node\Expr\Assign( + new Node\Expr\ArrayDimFetch( + new Node\Expr\Variable( + new Node\Name('values'), + ), + ), + new Node\Expr\MethodCall( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable( + new Node\Name('this'), + ), + new Node\Name('wrappedCaster'), + ), + new Node\Name('cast'), + [ + new Node\Arg( + new Node\Expr\Variable( + new Node\Name('value'), + ), + ), + new Node\Arg( + new Node\Expr\Variable( + new Node\Name('hydrator'), + ), + ), + ], + ), + ), + ), + ], + ], + ), + new Node\Stmt\Return_( + new Node\Expr\Variable('data'), + ), + ]), + ); + + yield new File($pathPrefix, $classString->relative, $stmt->addStmt($class)->getNode()); + } +} diff --git a/src/Generator/Schema/CastUnionToType.php b/src/Generator/Schema/SingleCastUnionToType.php similarity index 99% rename from src/Generator/Schema/CastUnionToType.php rename to src/Generator/Schema/SingleCastUnionToType.php index b418a76..e840e97 100644 --- a/src/Generator/Schema/CastUnionToType.php +++ b/src/Generator/Schema/SingleCastUnionToType.php @@ -21,7 +21,7 @@ use function implode; use function sort; -final class CastUnionToType +final class SingleCastUnionToType { /** @return iterable */ public static function generate(string $pathPrefix, ClassString $classString, Schema ...$schemas): iterable diff --git a/src/Registry/Contract.php b/src/Registry/Contract.php new file mode 100644 index 0000000..e1f0bb0 --- /dev/null +++ b/src/Registry/Contract.php @@ -0,0 +1,116 @@ + */ + private array $splHash = []; + /** @var array */ + private array $json = []; + + /** @var array */ + private array $unknownSchemas = []; + + /** @var array */ + private array $unknownSchemasJson = []; + /** @var array> */ + private array $aliasses = []; + + public function __construct( + private readonly Namespace_ $baseNamespaces, + private readonly bool $allowDuplicatedSchemas, + private readonly bool $useAliasesForDuplication, + ) { + } + + /** @throws JsonException */ + public function get(openAPISchema $schema, string $fallbackName): string + { + if ($schema->type === 'array') { + $schema = $schema->items; + } + + if (! $schema instanceof openAPISchema) { + throw new RuntimeException('Schemas has to be instance of: ' . openAPISchema::class); + } + + $hash = spl_object_hash($schema); + if (array_key_exists($hash, $this->splHash)) { + return $this->splHash[$hash]; + } + + $json = json_encode($schema->getSerializableData()); + if (! $this->allowDuplicatedSchemas && array_key_exists($json, $this->json)) { + return $this->json[$json]; + } + + if (! $this->allowDuplicatedSchemas && array_key_exists($json, $this->unknownSchemasJson)) { + return $this->unknownSchemasJson[$json]; + } + + $className = Utils::fixKeyword($fallbackName); + + if ($this->allowDuplicatedSchemas && $this->useAliasesForDuplication && array_key_exists($json, $this->json)) { + $this->aliasses['Schema\\' . $this->json[$json]][] = ClassString::factory($this->baseNamespaces, 'Schema\\' . $className); + + return $className; + } + + if ($this->allowDuplicatedSchemas && $this->useAliasesForDuplication && array_key_exists($json, $this->unknownSchemasJson)) { + $this->aliasses['Schema\\' . $this->unknownSchemasJson[$json]][] = ClassString::factory($this->baseNamespaces, 'Schema\\' . $className); + + return $className; + } + + $suffix = 'a'; + while (array_key_exists($className, $this->unknownSchemas)) { + $className = Utils::fixKeyword($fallbackName . strtoupper($suffix++)); + } + + $this->splHash[spl_object_hash($schema)] = $className; + $this->unknownSchemasJson[$json] = $className; + $this->unknownSchemas[$className] = new UnknownSchema($fallbackName, $className, $schema); + + return $className; + } + + public function hasUnknownSchemas(): bool + { + return count($this->unknownSchemas) > 0; + } + + /** @return iterable */ + public function unknownSchemas(): iterable + { + $unknownSchemas = $this->unknownSchemas; + $this->unknownSchemas = []; + + yield from $unknownSchemas; + } + + /** @return iterable */ + public function aliasesForClassName(string $classname): iterable + { + if (! array_key_exists($classname, $this->aliasses)) { + return; + } + + yield from $this->aliasses[$classname]; + } +} diff --git a/src/Representation/Schema.php b/src/Representation/Schema.php index 4689eb9..eddfb82 100644 --- a/src/Representation/Schema.php +++ b/src/Representation/Schema.php @@ -16,6 +16,7 @@ final class Schema */ public function __construct( public readonly ClassString $className, + public readonly ClassString $contractClassName, public readonly ClassString $errorClassName, public readonly ClassString $errorClassNameAliased, public readonly string $title, diff --git a/tests/app-templates/composer.json b/tests/app-templates/composer.json index e11cd01..5e32df4 100644 --- a/tests/app-templates/composer.json +++ b/tests/app-templates/composer.json @@ -20,6 +20,7 @@ "devizzent/cebe-php-openapi": "^1", "eventsauce/object-hydrator": "^1.1", "league/openapi-psr7-validator": "^0.21", + "league/uri": "^7.3", "psr/http-message": "^1.0", "react/http": "^1.8", "react/async": "^4.0", diff --git a/tests/app/composer.json b/tests/app/composer.json index d88d0c9..5bea2c1 100644 --- a/tests/app/composer.json +++ b/tests/app/composer.json @@ -15,6 +15,7 @@ "devizzent/cebe-php-openapi": "^1", "eventsauce/object-hydrator": "^1.1", "league/openapi-psr7-validator": "^0.21", + "league/uri": "^7.3", "psr/http-message": "^1.0", "react/http": "^1.8", "react/async": "^4.0", diff --git a/tests/app/etc/openapi-client-generator.state b/tests/app/etc/openapi-client-generator.state index 4228851..d60da1c 100644 --- a/tests/app/etc/openapi-client-generator.state +++ b/tests/app/etc/openapi-client-generator.state @@ -1,266 +1,314 @@ { - "specHash": "b34763a4d9c5c8f8174783e23496f785", + "specHash": "a2c50b99009eeb8489aadcdbced647bb", "generatedFiles": { "files": [ { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/List_.php", - "hash": "3335d838b36c19fa3df3a5611de1327b" + "hash": "b233171a1a49e4f27e4877e36628625e" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/List_.php", - "hash": "4ebf25c09b352c6bf1cb90ba82dc4cd6" + "hash": "56590ead78bddef1b5ce2f694670a886" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/List_Test.php", - "hash": "118a4b865946b20525ec5e294d4142f0" + "hash": "a55edea63c07b47db2b06f8a4552419b" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/ListListing.php", - "hash": "0d9967a302ca7fb3d6caac3c64053973" + "hash": "4b40ee7ba719298034c1ac143af935eb" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/ListListing.php", - "hash": "c11b29843d4a000f2707d1c8fadcffef" + "hash": "8324e40bba567bb1fe904e08ea4bca90" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/ListListingTest.php", - "hash": "55aa65fc342c80607681971ff8d3b8a7" + "hash": "a565e061be5406b21e98798aa1124632" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/Create.php", - "hash": "7c8734f0d61928c3f40976535c41da3f" + "hash": "10ca455872aa8e50dc50e6ccc4be9ee8" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/Create.php", - "hash": "7558d10cb6b365376dbd1bd4772644bc" + "hash": "1894602e2383fc07d45f10c15a959e5f" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/CreateTest.php", - "hash": "955f6464b777eca7d93966ff896a5914" + "hash": "c7f1b5aa62146ad64081177d26e9c994" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/List_\/Gatos.php", - "hash": "5f881cdd1eb2f8375929f7abfbd33c7d" + "hash": "f4b232e914937297d5a892754f63c172" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/List_\/Gatos.php", - "hash": "9a0e8b8f7719fccb70e7cc4e0832d268" + "hash": "3b21fa465f28a528bafd38fed238d7d5" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/List_\/GatosTest.php", - "hash": "55ca3ebb3ceb17a9ac82eec51b12122d" + "hash": "ba271b6f0c919ad74870903c49358487" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/List_\/GatosListing.php", - "hash": "eafb9b140f372014143fd7d1b3e271f7" + "hash": "3a785d5c18a38ad282fcf7c05a533cca" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/List_\/GatosListing.php", - "hash": "ebd439f04cc01b4059112f4f08f6cd6c" + "hash": "464515feabb30b925ca80dec3b3200b7" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/List_\/GatosListingTest.php", - "hash": "49401e5bcd114a3e8f07ff378c9f86db" + "hash": "b390b45049613024209e795a63428b17" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/Kinds\/Walking.php", + "hash": "e7d984f51b6314b9edb29939a48eedcd" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/Kinds\/Walking.php", + "hash": "f6eea567a7759bdb0f8391eb82a010f9" + }, + { + "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/Kinds\/WalkingTest.php", + "hash": "cdc490680bc8bc8bc01699bcd16afb7c" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/Kinds\/WalkingListing.php", + "hash": "50e8e5c567a1b3eba53b4f77d29ebc11" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/Kinds\/WalkingListing.php", + "hash": "58dfd773dc75abb7d5fe6b32e154793f" + }, + { + "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/Kinds\/WalkingListingTest.php", + "hash": "c44cc667c3c4a7536ed9e65c1577c236" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/Grouped\/By\/Type.php", + "hash": "9d26f1af1b900ea85a2b2c60f3e2411f" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/Grouped\/By\/Type.php", + "hash": "2514d2139048da39f8734a87a34a4787" + }, + { + "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/Grouped\/By\/TypeTest.php", + "hash": "b59cfc90a1cf6a8448bbda0227f202c8" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/Names.php", - "hash": "b84ca3b1cab00b4be051ad86b73cbdd1" + "hash": "6597d53081735f442af07731f67048cd" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/Names.php", - "hash": "1337e618e38f0a989814088eb4f9d09a" + "hash": "66b7cac30b2f07748737b97e9a0e8056" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/NamesTest.php", - "hash": "0ff49128895f3379bb6a131ec383d25b" + "hash": "9c861d7eda455fdb2d97464e4f52ebe1" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/Pets\/NamesListing.php", - "hash": "c0b8d49169aae176984d12a0030ecd13" + "hash": "c108707e8fff08989852ca98bf4f1043" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/Pets\/NamesListing.php", - "hash": "d9969b99380a63a7708871e4d87a040d" + "hash": "fa24eee87e05c9b3d7b373cde1511ddb" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/Pets\/NamesListingTest.php", - "hash": "be68bd2eadf35c2f3434bddd89778ed9" + "hash": "2bd6f5a5c8d809760ade5ebb0c1ff3d9" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operation\/ShowPetById.php", - "hash": "99cae2c0f875cde1a0f93475618a9c76" + "hash": "c27f58ea100588a410786c5274652f59" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operator\/ShowPetById.php", - "hash": "abfb82c3aeca91bf33f6058ffdbe3eca" + "hash": "f106fffb57aa50c3916b664e55eb4b33" }, { "name": ".\/tests\/app\/tests\/\/Internal\/Operation\/ShowPetByIdTest.php", - "hash": "5041b34e5e62b902025c1964333f2f2e" - }, - { - "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Schema\/Cat\/Eyes.php", - "hash": "f06fab9ea8735b70e17e215014038b5c" + "hash": "56a07d4a2fff947aa1a91312eb6d5f42" }, { "name": ".\/tests\/app\/src\/\/Schema\/Cat.php", - "hash": "371cfd85bfe07286fb95ad7a7d29187c" - }, - { - "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Schema\/Dog\/Eyes.php", - "hash": "87e2777a1e85044306e01a7cc941320e" + "hash": "dc3cedbcc32d05359ae5495e4f4c5f1f" }, { "name": ".\/tests\/app\/src\/\/Schema\/Dog.php", - "hash": "232a56bd647746d61a6e9e54f562dde3" + "hash": "86b4c886cd415de1469aadb6054a9724" }, { - "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Schema\/Bird\/Eyes.php", - "hash": "1fcc98776dcbc8580b7f4faec5353f05" + "name": ".\/tests\/app\/src\/\/Schema\/Spider.php", + "hash": "b62cbaa7b139273053a41c930f921733" }, { "name": ".\/tests\/app\/src\/\/Schema\/Bird.php", - "hash": "e42c62ba366a1199b3d4ffeeb1f84763" - }, - { - "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Schema\/Fish\/Eyes.php", - "hash": "a1ce37c0cf57e738f62aa66231a77a97" + "hash": "17fbd2d954f2f0ed8a00e6ab6062022e" }, { "name": ".\/tests\/app\/src\/\/Schema\/Fish.php", - "hash": "70708fa5d240484343fc3d2d192d01e6" + "hash": "849607b8b13ddd6c1169271b8f403aee" }, { "name": ".\/tests\/app\/src\/\/Schema\/Error.php", - "hash": "527bda2504b2d138fa10bd3549cd45a2" + "hash": "f80f769c7a4c8c68aea934d6ab348753" }, { "name": ".\/tests\/app\/src\/\/Error\/Error.php", - "hash": "bf0d8ec4540bd74558b5c107f132fe9d" + "hash": "feb248b9aaa268d799d22ce3a0d32d82" }, { "name": ".\/tests\/app\/src\/\/Schema\/Legs.php", - "hash": "7283a6b13ff4266cf6a00362a400bd65" + "hash": "b67532b7c8ac986f616080402baac75d" }, { "name": ".\/tests\/app\/src\/\/Schema\/Tails.php", - "hash": "f65ba3cbdf98c04d55db7c91c4d98b40" + "hash": "b014236ffacd12123d41632522be3a0d" }, { "name": ".\/tests\/app\/src\/\/Schema\/Fins.php", - "hash": "cdf5aef72f39100b0ac9415fe8674a9c" + "hash": "81b9d536290a1ae0be0b6044de7dcf85" }, { "name": ".\/tests\/app\/src\/\/Schema\/Wings.php", - "hash": "831c8c0cc46f017c449ad605c426787e" + "hash": "338b33430ecb97c1344c8bc9e8723bba" }, { "name": ".\/tests\/app\/src\/\/Schema\/RedEyes.php", - "hash": "68aceac83f2c6b628241ab6331bb4fe6" + "hash": "4e83e7e8550cebb9cd5295c444cbc97b" }, { "name": ".\/tests\/app\/src\/\/Schema\/GreenEyes.php", - "hash": "07bb8870dedd7fa113608f4a66e8ca98" + "hash": "4a74d6a7d6c2e5e6dc664ef559092127" }, { "name": ".\/tests\/app\/src\/\/Schema\/YellowEyes.php", - "hash": "137b7ae0b43f4a427d7387e56968febb" + "hash": "906c2067a33469c829d8b7ebfce513d1" }, { "name": ".\/tests\/app\/src\/\/Schema\/BlackEyes.php", - "hash": "dd3386a44db052e697f98b526599755a" + "hash": "3ceafa5ee4635806c15fd3aeff58d860" }, { "name": ".\/tests\/app\/src\/\/Schema\/BlueEyes.php", - "hash": "9bcd4cd1f1c9920d1c6555adf2aec13d" + "hash": "17adf4d334500e864b4d0c94de3abb66" }, { "name": ".\/tests\/app\/src\/\/Schema\/Cat\/Features.php", - "hash": "59574049775dec2023502d515171268b" + "hash": "42309d9c833e24d88590ae6dd14a228a" }, { "name": ".\/tests\/app\/src\/\/Schema\/Operations\/Pets\/List_\/Response\/ApplicationJson\/Ok.php", - "hash": "9670a027bb35bf227e29e3ab05f40b36" - }, - { - "name": ".\/tests\/app\/src\/\/Schema\/AliasAbstract\/Tiet3079EDA6\/TietC8A57480\/TietAA436E3B\/Tiet0E7D3D03.php", - "hash": "e35aecc048cbf5c34a25ac110554ed76" + "hash": "3b0900cfd97292182073223fb1ed3ff4" }, { "name": ".\/tests\/app\/src\/\/Schema\/Operations\/ShowPetById\/Response\/ApplicationJson\/Ok.php", - "hash": "067b93703a593299d4bb98e1c8f0fce1" + "hash": "3b2d563da05fa861761294467a24b299" }, { "name": ".\/tests\/app\/src\/\/Schema\/Pets\/Create\/Request\/ApplicationJson.php", - "hash": "3df1a4826468190561c97c29dfffd99d" + "hash": "61826bce135ced0358b8b06de9558f0a" + }, + { + "name": ".\/tests\/app\/src\/\/Schema\/Operations\/Pets\/Kinds\/Walking\/Response\/ApplicationJson\/Ok.php", + "hash": "0efa19921e865f4c1f02c59328276f7c" + }, + { + "name": ".\/tests\/app\/src\/\/Schema\/Operations\/Pets\/Grouped\/By\/Type\/Response\/ApplicationJson\/Ok.php", + "hash": "8dfaf61b4d2e18290489f694600d9d01" }, { "name": ".\/tests\/app\/src\/\/Schema\/Operations\/Pets\/Names\/Response\/ApplicationJson\/Ok.php", - "hash": "16a9b50aa1d445c11a53a1e3b1b537a1" + "hash": "4a301cd45b2aa9e0c3bb4e27b59b145b" }, { "name": ".\/tests\/app\/src\/\/ClientInterface.php", - "hash": "9b32fe8d0561625aaca2585bfbb27529" + "hash": "3c95cda80a5d5a0035ffd8d0b1978b3e" }, { "name": ".\/tests\/app\/src\/\/Client.php", - "hash": "3d378f18ff2470116a67981cf84dc721" + "hash": "50273a0e8ee86c0f309aa5a1bc78c304" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/Pets.php", - "hash": "c23546b09a87ba3a455be95bc5c2ce36" + "hash": "50246c7c69b80454f65b98fb78a765fe" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/PetsList.php", - "hash": "409c03c5e43887620f5f47c9177643c0" + "hash": "d28ed757714675cce217d3c3280c0573" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/PetsGroupedBy.php", + "hash": "fd3134b03ec0d40e4dc21785efa3da75" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get.php", - "hash": "68edf375bba9f6578afb8274e2b97de7" + "hash": "c3cd1fe34e19e7d0c2377b4b9bce4939" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/PetsKinds.php", + "hash": "29d04f3035cc25fb43f53e09864f853d" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/List\/Pets.php", - "hash": "b32884ea78f685b86aa1f5c464fc0aaf" + "hash": "e85caf8484493a1b84fb49bd0d1d3989" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/List\/PetsList.php", - "hash": "153e3322116d7b671682061f90f29487" + "hash": "430159a271abdf64c6848458b8309969" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Router\/List\/PetsKinds.php", + "hash": "caadcd3461dddf544af955d4140cbeec" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Post\/Pets.php", - "hash": "8ef945a4100cffc65825a02375b3f04f" + "hash": "6a2b6ef8dc6fe4e7f0cfcc03a14ef916" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/Two.php", - "hash": "7b7d4b9a968f14f380a92ae6313ce8f4" + "hash": "5e0d50c4bd2b43893f8b4a798af51949" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/Three.php", - "hash": "cfd9ac40faf59d186ef864c659a058dc" + "hash": "b87dabf60f65b189e3ad0ea673cb5b0f" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Router\/Get\/Four.php", + "hash": "4514c03ee094549e47db4f8f9fe162de" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/List\/Two.php", - "hash": "38ce5494202d78c11ec1d99a3cd50121" + "hash": "d5eb024f2c36f80b005f001d3db99e70" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/List\/Three.php", - "hash": "ea20389356bf4f898364bb2d942559cb" + "hash": "5c677ce26874a1d04eced0390b5b6582" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Router\/List\/Four.php", + "hash": "7f96cefeb63fe87dd1d906d6565b5628" }, { "name": ".\/tests\/app\/src\/\/Internal\/Router\/Post\/Two.php", - "hash": "bb74e1a2fe9780b2919d28071ff187cb" + "hash": "259311d4ce584913ad28482b216ccb1f" }, { "name": ".\/tests\/app\/src\/\/Internal\/Routers.php", - "hash": "27ae653029f6d54ef26c6b156366e3a3" + "hash": "8204cdc19452a95d8556cd3baf5b02a6" }, { "name": ".\/tests\/app\/src\/\/PHPStan\/ClientCallReturnTypes.php", - "hash": "7df241311848c7ffaa377eb789cebb58" + "hash": "0719ff7741d28cc2d45b9d3e62a1c749" }, { "name": ".\/tests\/app\/tests\/\/Types\/ClientCallReturnTypes.php", - "hash": "f614aa6d327b69a2edd47d21ffbe163d" + "hash": "392fb0bb57534d1c0631a9e92b23073f" }, { "name": ".\/tests\/app\/src\/\/..\/etc\/phpstan-extension.neon", @@ -268,23 +316,31 @@ }, { "name": ".\/tests\/app\/src\/\/OperationsInterface.php", - "hash": "54d7fd0cc8f652ba8c5ca0f490e462a5" + "hash": "59dc8c9c8649087bf7c3e7ee2866bed9" }, { "name": ".\/tests\/app\/src\/\/Operation\/Pets.php", - "hash": "928ce9f3f462bf874afa055342d8f165" + "hash": "666cc04c0ab09379a9a4b6f0f0063a24" }, { "name": ".\/tests\/app\/src\/\/Operation\/PetsList.php", - "hash": "cbe84bf2d290017ccd0946101d58a7da" + "hash": "5dad30f80783e68cefd11f401b170d2d" + }, + { + "name": ".\/tests\/app\/src\/\/Operation\/PetsKinds.php", + "hash": "8b5bf4724380253e389d61ff31ae5dc9" + }, + { + "name": ".\/tests\/app\/src\/\/Operation\/PetsGroupedBy.php", + "hash": "116f94a4bf54b3186780de4c793c589d" }, { "name": ".\/tests\/app\/src\/\/Internal\/Operators.php", - "hash": "067d783201e09465d9bc4185fa23953b" + "hash": "9a327b2c58687e0ed2261c341c4e3422" }, { "name": ".\/tests\/app\/src\/\/Operations.php", - "hash": "91f162958d7ac8ac63feaccbb534eb45" + "hash": "65089bd8b715ff442449eb7d7ed9b147" }, { "name": ".\/tests\/app\/src\/\/Internal\/Hydrator\/Operation\/Pets.php", @@ -294,6 +350,14 @@ "name": ".\/tests\/app\/src\/\/Internal\/Hydrator\/Operation\/Pets\/Gatos.php", "hash": "fc5f76f6986c1c96eb7a4f9c98fb718e" }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Hydrator\/Operation\/Pets\/Kinds\/Walking.php", + "hash": "90eb300e4cb8d0abe7a5159f53c0d9c7" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Hydrator\/Operation\/Pets\/GroupedByType.php", + "hash": "da2f224be43cb2cc7903f47638c196e1" + }, { "name": ".\/tests\/app\/src\/\/Internal\/Hydrator\/Operation\/Pets\/Names.php", "hash": "763360da3f82b554e30cd9c53a2c4c69" @@ -304,7 +368,135 @@ }, { "name": ".\/tests\/app\/src\/\/Internal\/Hydrators.php", - "hash": "1672b758f3f1c7b7a0710f08a843b4b5" + "hash": "fbb023471a07a315d08b4a3c8a1a797c" + }, + { + "name": ".\/tests\/app\/src\/\/Schema\/AliasAbstract\/Tiet771CDE1E\/Tiet4BA1D187\/Tiet5DDDC8AF\/TietA6F4E1BB.php", + "hash": "824753deddf42f2d2d939907c7f1f450" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Multiple\/Schema\/Cat\/Eyes.php", + "hash": "503c33760dfe73b24a02bd20bfe4998d" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Multiple\/Schema\/Dog\/Eyes.php", + "hash": "a21475e3742fbd1cc55f1f14ab21bc33" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Multiple\/Schema\/Spider\/Eyes.php", + "hash": "7f117477922ccc957817fcc47b83177f" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Single\/Schema\/Bird\/Eyes.php", + "hash": "18bdd1915bbd9a5152e5dc5f98af70dd" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Single\/Schema\/Fish\/Eyes.php", + "hash": "f9572ac57d6b2ff7cc69e64c64fdac03" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Multiple\/Schema\/Operations\/Pets\/Grouped\/By\/Type\/Response\/ApplicationJson\/Ok\/Pets.php", + "hash": "ce24c150645696a7ce97483ecbc9f314" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Single\/Schema\/Cat\/Eyes.php", + "hash": "cddfbcb1e600bdd28629759fe4b9889a" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Single\/Schema\/Dog\/Eyes.php", + "hash": "4fb880d277bb77b8ab11e2358dd40575" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Single\/Schema\/Spider\/Eyes.php", + "hash": "6d7ff273e85dd03a767677eff11631ce" + }, + { + "name": ".\/tests\/app\/src\/\/Internal\/Attribute\/CastUnionToType\/Single\/Schema\/Operations\/Pets\/Grouped\/By\/Type\/Response\/ApplicationJson\/Ok\/Pets.php", + "hash": "627ca6bbb27fe48b37691ac80ed36d95" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Cat.php", + "hash": "efca710704a4f207f9e8ff3a93b322a3" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Dog.php", + "hash": "1a29f16092f85b51cc855c1aa94883a6" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Spider.php", + "hash": "1809aed6800d4225a0464f4d18e5c852" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Bird.php", + "hash": "79ba0d355707b46d7f6822150e2649ac" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Fish.php", + "hash": "1eb6eb8d2bfeb0518d9804dae2ab9e7e" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Error.php", + "hash": "888aac4e2dfd815ae61650be7c9a030c" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Legs.php", + "hash": "a92256f12b2c73f6570dfe6c5f1c73e4" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Tails.php", + "hash": "66fa727e0d2d200b697fa4c551690703" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Fins.php", + "hash": "5015c047ef897ed7158b61dccf0eecc6" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Wings.php", + "hash": "e9570bc1c4d2f81bd585bf5460846d16" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/RedEyes.php", + "hash": "833330c924747a27e982e6a778051ce6" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/GreenEyes.php", + "hash": "9ea4e67be717aeaa917577d09d94e951" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/YellowEyes.php", + "hash": "8ba3be68dd394a4579ccd2f66fa00415" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/BlackEyes.php", + "hash": "ba7dc750473a4fc8caef228933de78b7" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/BlueEyes.php", + "hash": "d583ccd34c5dd526f16bee0d74ccc1fe" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Cat\/Features.php", + "hash": "12e61b11807152ba3c71ef854c2d0ba7" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Operations\/Pets\/List_\/Response\/ApplicationJson\/Ok.php", + "hash": "3af7854e4196f13457cdd01aeffeb30c" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Pets\/Create\/Request\/ApplicationJson.php", + "hash": "23c8c398cc7e8483fd9f89fc39ed7fbd" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Operations\/Pets\/Kinds\/Walking\/Response\/ApplicationJson\/Ok.php", + "hash": "5021e52be7c2b44ce04df206dda33b53" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Operations\/Pets\/Grouped\/By\/Type\/Response\/ApplicationJson\/Ok.php", + "hash": "4d813ea056806b13790cb64e809f93b4" + }, + { + "name": ".\/tests\/app\/src\/\/Contract\/Operations\/Pets\/Names\/Response\/ApplicationJson\/Ok.php", + "hash": "43c07e4ce6bde480632b657eaa44558f" } ] }, @@ -312,7 +504,7 @@ "files": [ { "name": "composer.json", - "hash": "b5d01de7c1f443ef8e07eb69633cea43" + "hash": "5f3a1e7681873ef9a8226a2a404267a9" }, { "name": "composer.lock", diff --git a/tests/app/src/Client.php b/tests/app/src/Client.php index d29c9cb..83783ea 100644 --- a/tests/app/src/Client.php +++ b/tests/app/src/Client.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -28,7 +29,7 @@ public function __construct(\ApiClients\Contracts\HTTP\Headers\AuthenticationInt /** */ // phpcs:enable - public function call(string $call, array $params = array()) : iterable|\ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody|\ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish + public function call(string $call, array $params = array()) : iterable|\ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody|\ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok|\ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|\ApiClients\Client\PetStore\Schema\Spider { [$method, $path] = explode(' ', $call); $pathChunks = explode('/', $path); @@ -44,6 +45,11 @@ public function call(string $call, array $params = array()) : iterable|\ApiClien $this->router[Internal\Router\Get\Three::class] = new Internal\Router\Get\Three(routers: $this->routers); } return $this->router[Internal\Router\Get\Three::class]->call($call, $params, $pathChunks); + } elseif ($pathChunksCount === 4) { + if (\array_key_exists(Internal\Router\Get\Four::class, $this->router) == false) { + $this->router[Internal\Router\Get\Four::class] = new Internal\Router\Get\Four(routers: $this->routers); + } + return $this->router[Internal\Router\Get\Four::class]->call($call, $params, $pathChunks); } } elseif ($method === 'LIST') { if ($pathChunksCount === 2) { @@ -56,6 +62,11 @@ public function call(string $call, array $params = array()) : iterable|\ApiClien $this->router[Internal\Router\List\Three::class] = new Internal\Router\List\Three(routers: $this->routers); } return $this->router[Internal\Router\List\Three::class]->call($call, $params, $pathChunks); + } elseif ($pathChunksCount === 4) { + if (\array_key_exists(Internal\Router\List\Four::class, $this->router) == false) { + $this->router[Internal\Router\List\Four::class] = new Internal\Router\List\Four(routers: $this->routers); + } + return $this->router[Internal\Router\List\Four::class]->call($call, $params, $pathChunks); } } elseif ($method === 'POST') { if ($pathChunksCount === 2) { diff --git a/tests/app/src/ClientInterface.php b/tests/app/src/ClientInterface.php index 3772630..6512832 100644 --- a/tests/app/src/ClientInterface.php +++ b/tests/app/src/ClientInterface.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,6 +17,6 @@ interface ClientInterface /** */ // phpcs:enabled - public function call(string $call, array $params = array()) : iterable|\ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody|\ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish; + public function call(string $call, array $params = array()) : iterable|\ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody|\ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok|\ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|\ApiClients\Client\PetStore\Schema\Spider; public function operations() : OperationsInterface; } diff --git a/tests/app/src/Contract/Bird.php b/tests/app/src/Contract/Bird.php new file mode 100644 index 0000000..e440d9d --- /dev/null +++ b/tests/app/src/Contract/Bird.php @@ -0,0 +1,22 @@ + $eyes + */ +interface Cat +{ +} diff --git a/tests/app/src/Contract/Cat/Features.php b/tests/app/src/Contract/Cat/Features.php new file mode 100644 index 0000000..eb1a625 --- /dev/null +++ b/tests/app/src/Contract/Cat/Features.php @@ -0,0 +1,16 @@ + $eyes + */ +interface Dog +{ +} diff --git a/tests/app/src/Contract/Error.php b/tests/app/src/Contract/Error.php new file mode 100644 index 0000000..97d2d7f --- /dev/null +++ b/tests/app/src/Contract/Error.php @@ -0,0 +1,20 @@ + $pets + */ +interface Ok +{ +} diff --git a/tests/app/src/Contract/Operations/Pets/Kinds/Walking/Response/ApplicationJson/Ok.php b/tests/app/src/Contract/Operations/Pets/Kinds/Walking/Response/ApplicationJson/Ok.php new file mode 100644 index 0000000..bfa4e11 --- /dev/null +++ b/tests/app/src/Contract/Operations/Pets/Kinds/Walking/Response/ApplicationJson/Ok.php @@ -0,0 +1,16 @@ + $eyes + */ +interface Spider +{ +} diff --git a/tests/app/src/Contract/Tails.php b/tests/app/src/Contract/Tails.php new file mode 100644 index 0000000..c1162a5 --- /dev/null +++ b/tests/app/src/Contract/Tails.php @@ -0,0 +1,19 @@ +wrappedCaster = new \ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Single\Schema\Cat\Eyes(); + } + public function cast(mixed $value, \EventSauce\ObjectHydrator\ObjectMapper $hydrator) : mixed + { + $data = array(); + $values = $value; + unset($value); + foreach ($values as $value) { + $values[] = $this->wrappedCaster->cast($value, $hydrator); + } + return $data; + } +} diff --git a/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Dog/Eyes.php b/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Dog/Eyes.php new file mode 100644 index 0000000..f6ecd72 --- /dev/null +++ b/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Dog/Eyes.php @@ -0,0 +1,32 @@ +wrappedCaster = new \ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Single\Schema\Dog\Eyes(); + } + public function cast(mixed $value, \EventSauce\ObjectHydrator\ObjectMapper $hydrator) : mixed + { + $data = array(); + $values = $value; + unset($value); + foreach ($values as $value) { + $values[] = $this->wrappedCaster->cast($value, $hydrator); + } + return $data; + } +} diff --git a/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Operations/Pets/Grouped/By/Type/Response/ApplicationJson/Ok/Pets.php b/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Operations/Pets/Grouped/By/Type/Response/ApplicationJson/Ok/Pets.php new file mode 100644 index 0000000..c02b8a4 --- /dev/null +++ b/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Operations/Pets/Grouped/By/Type/Response/ApplicationJson/Ok/Pets.php @@ -0,0 +1,32 @@ +wrappedCaster = new \ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Single\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok\Pets(); + } + public function cast(mixed $value, \EventSauce\ObjectHydrator\ObjectMapper $hydrator) : mixed + { + $data = array(); + $values = $value; + unset($value); + foreach ($values as $value) { + $values[] = $this->wrappedCaster->cast($value, $hydrator); + } + return $data; + } +} diff --git a/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Spider/Eyes.php b/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Spider/Eyes.php new file mode 100644 index 0000000..8df1c15 --- /dev/null +++ b/tests/app/src/Internal/Attribute/CastUnionToType/Multiple/Schema/Spider/Eyes.php @@ -0,0 +1,32 @@ +wrappedCaster = new \ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Single\Schema\Spider\Eyes(); + } + public function cast(mixed $value, \EventSauce\ObjectHydrator\ObjectMapper $hydrator) : mixed + { + $data = array(); + $values = $value; + unset($value); + foreach ($values as $value) { + $values[] = $this->wrappedCaster->cast($value, $hydrator); + } + return $data; + } +} diff --git a/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Cat/Eyes.php b/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Cat/Eyes.php deleted file mode 100644 index 466500a..0000000 --- a/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Cat/Eyes.php +++ /dev/null @@ -1,55 +0,0 @@ -hydrateObject(Schema\RedEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && ($value['type'] === 'sky' || $value['type'] === 'boobies')) { - try { - return $hydrator->hydrateObject(Schema\BlueEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && ($value['type'] === 'hulk' || $value['type'] === 'forest' || $value['type'] === 'feral')) { - try { - return $hydrator->hydrateObject(Schema\GreenEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && $value['type'] === 'snake') { - try { - return $hydrator->hydrateObject(Schema\YellowEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && $value['type'] === 'rage') { - try { - return $hydrator->hydrateObject(Schema\BlackEyes::class, $value); - } catch (\Throwable) { - } - } - } - return $value; - } -} diff --git a/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Dog/Eyes.php b/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Dog/Eyes.php deleted file mode 100644 index a9a991d..0000000 --- a/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Dog/Eyes.php +++ /dev/null @@ -1,55 +0,0 @@ -hydrateObject(Schema\RedEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && ($value['type'] === 'sky' || $value['type'] === 'boobies')) { - try { - return $hydrator->hydrateObject(Schema\BlueEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && ($value['type'] === 'hulk' || $value['type'] === 'forest' || $value['type'] === 'feral')) { - try { - return $hydrator->hydrateObject(Schema\GreenEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && $value['type'] === 'snake') { - try { - return $hydrator->hydrateObject(Schema\YellowEyes::class, $value); - } catch (\Throwable) { - } - } - if ($signature === 'count|type' && $value['type'] === 'rage') { - try { - return $hydrator->hydrateObject(Schema\BlackEyes::class, $value); - } catch (\Throwable) { - } - } - } - return $value; - } -} diff --git a/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Fish/Eyes.php b/tests/app/src/Internal/Attribute/CastUnionToType/Single/Schema/Bird/Eyes.php similarity index 97% rename from tests/app/src/Internal/Attribute/CastUnionToType/Schema/Fish/Eyes.php rename to tests/app/src/Internal/Attribute/CastUnionToType/Single/Schema/Bird/Eyes.php index bff3d8b..2b1612f 100644 --- a/tests/app/src/Internal/Attribute/CastUnionToType/Schema/Fish/Eyes.php +++ b/tests/app/src/Internal/Attribute/CastUnionToType/Single/Schema/Bird/Eyes.php @@ -1,8 +1,9 @@ $className + * @return T + */ + public function hydrateObject(string $className, array $payload): object + { + return match($className) { + 'ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok' => $this->hydrateApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Operations⚡️Pets⚡️Grouped⚡️By⚡️Type⚡️Response⚡️ApplicationJson⚡️Ok($payload), + 'ApiClients\Client\PetStore\Schema\Error' => $this->hydrateApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error($payload), + default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack), + }; + } + + + private function hydrateApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Operations⚡️Pets⚡️Grouped⚡️By⚡️Type⚡️Response⚡️ApplicationJson⚡️Ok(array $payload): \ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok + { + $properties = []; + $missingFields = []; + try { + $value = $payload['pets'] ?? null; + + if ($value === null) { + $missingFields[] = 'pets'; + goto after_pets; + } + + static $petsCaster1; + + if ($petsCaster1 === null) { + $petsCaster1 = new \ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Multiple\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok\Pets(...array ( +)); + } + + $value = $petsCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'pets'; + goto after_pets; + } + + $properties['pets'] = $value; + + after_pets: + + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError('ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok', $exception, stack: $this->hydrationStack); + } + + if (count($missingFields) > 0) { + throw UnableToHydrateObject::dueToMissingFields(\ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok::class, $missingFields, stack: $this->hydrationStack); + } + + try { + return new \ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok(...$properties); + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError('ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok', $exception, stack: $this->hydrationStack); + } + } + + + private function hydrateApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error(array $payload): \ApiClients\Client\PetStore\Schema\Error + { + $properties = []; + $missingFields = []; + try { + $value = $payload['code'] ?? null; + + if ($value === null) { + $missingFields[] = 'code'; + goto after_code; + } + + $properties['code'] = $value; + + after_code: + + $value = $payload['message'] ?? null; + + if ($value === null) { + $missingFields[] = 'message'; + goto after_message; + } + + $properties['message'] = $value; + + after_message: + + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError('ApiClients\Client\PetStore\Schema\Error', $exception, stack: $this->hydrationStack); + } + + if (count($missingFields) > 0) { + throw UnableToHydrateObject::dueToMissingFields(\ApiClients\Client\PetStore\Schema\Error::class, $missingFields, stack: $this->hydrationStack); + } + + try { + return new \ApiClients\Client\PetStore\Schema\Error(...$properties); + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError('ApiClients\Client\PetStore\Schema\Error', $exception, stack: $this->hydrationStack); + } + } + + private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array + { + foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) { + if (is_a($object, $valueType)) { + return [$accessor => $payloadType] + $this->{$method}($object); + } + } + + throw new \LogicException('No type mapped for object of class: ' . get_class($object)); + } + + public function serializeObject(object $object): mixed + { + return $this->serializeObjectOfType($object, get_class($object)); + } + + /** + * @template T + * + * @param T $object + * @param class-string $className + */ + public function serializeObjectOfType(object $object, string $className): mixed + { + try { + return match($className) { + 'array' => $this->serializeValuearray($object), + 'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object), + 'DateTime' => $this->serializeValueDateTime($object), + 'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object), + 'DateTimeInterface' => $this->serializeValueDateTimeInterface($object), + 'ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok' => $this->serializeObjectApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Operations⚡️Pets⚡️Grouped⚡️By⚡️Type⚡️Response⚡️ApplicationJson⚡️Ok($object), + 'ApiClients\Client\PetStore\Schema\Error' => $this->serializeObjectApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error($object), + default => throw new \LogicException('No serialization defined for $className'), + }; + } catch (\Throwable $exception) { + throw UnableToSerializeObject::dueToError($className, $exception); + } + } + + + private function serializeValuearray(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueDateTime(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueDateTimeImmutable(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueDateTimeInterface(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeObjectApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Operations⚡️Pets⚡️Grouped⚡️By⚡️Type⚡️Response⚡️ApplicationJson⚡️Ok(mixed $object): mixed + { + \assert($object instanceof \ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok); + $result = []; + + $pets = $object->pets; + static $petsSerializer0; + + if ($petsSerializer0 === null) { + $petsSerializer0 = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array ( +)); + } + + $pets = $petsSerializer0->serialize($pets, $this); + after_pets: $result['pets'] = $pets; + + + return $result; + } + + + private function serializeObjectApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error(mixed $object): mixed + { + \assert($object instanceof \ApiClients\Client\PetStore\Schema\Error); + $result = []; + + $code = $object->code; + after_code: $result['code'] = $code; + + + $message = $object->message; + after_message: $result['message'] = $message; + + + return $result; + } + + + + /** + * @template T + * + * @param class-string $className + * @param iterable $payloads; + * + * @return IterableList + * + * @throws UnableToHydrateObject + */ + public function hydrateObjects(string $className, iterable $payloads): IterableList + { + return new IterableList($this->doHydrateObjects($className, $payloads)); + } + + private function doHydrateObjects(string $className, iterable $payloads): Generator + { + foreach ($payloads as $index => $payload) { + yield $index => $this->hydrateObject($className, $payload); + } + } + + /** + * @template T + * + * @param class-string $className + * @param iterable $payloads; + * + * @return IterableList + * + * @throws UnableToSerializeObject + */ + public function serializeObjects(iterable $payloads): IterableList + { + return new IterableList($this->doSerializeObjects($payloads)); + } + + private function doSerializeObjects(iterable $objects): Generator + { + foreach ($objects as $index => $object) { + yield $index => $this->serializeObject($object); + } + } +} diff --git a/tests/app/src/Internal/Hydrator/Operation/Pets/Kinds/Walking.php b/tests/app/src/Internal/Hydrator/Operation/Pets/Kinds/Walking.php new file mode 100644 index 0000000..67fde76 --- /dev/null +++ b/tests/app/src/Internal/Hydrator/Operation/Pets/Kinds/Walking.php @@ -0,0 +1,240 @@ + $className + * @return T + */ + public function hydrateObject(string $className, array $payload): object + { + return match($className) { + 'ApiClients\Client\PetStore\Schema\Error' => $this->hydrateApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error($payload), + default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack), + }; + } + + + private function hydrateApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error(array $payload): \ApiClients\Client\PetStore\Schema\Error + { + $properties = []; + $missingFields = []; + try { + $value = $payload['code'] ?? null; + + if ($value === null) { + $missingFields[] = 'code'; + goto after_code; + } + + $properties['code'] = $value; + + after_code: + + $value = $payload['message'] ?? null; + + if ($value === null) { + $missingFields[] = 'message'; + goto after_message; + } + + $properties['message'] = $value; + + after_message: + + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError('ApiClients\Client\PetStore\Schema\Error', $exception, stack: $this->hydrationStack); + } + + if (count($missingFields) > 0) { + throw UnableToHydrateObject::dueToMissingFields(\ApiClients\Client\PetStore\Schema\Error::class, $missingFields, stack: $this->hydrationStack); + } + + try { + return new \ApiClients\Client\PetStore\Schema\Error(...$properties); + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError('ApiClients\Client\PetStore\Schema\Error', $exception, stack: $this->hydrationStack); + } + } + + private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array + { + foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) { + if (is_a($object, $valueType)) { + return [$accessor => $payloadType] + $this->{$method}($object); + } + } + + throw new \LogicException('No type mapped for object of class: ' . get_class($object)); + } + + public function serializeObject(object $object): mixed + { + return $this->serializeObjectOfType($object, get_class($object)); + } + + /** + * @template T + * + * @param T $object + * @param class-string $className + */ + public function serializeObjectOfType(object $object, string $className): mixed + { + try { + return match($className) { + 'array' => $this->serializeValuearray($object), + 'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object), + 'DateTime' => $this->serializeValueDateTime($object), + 'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object), + 'DateTimeInterface' => $this->serializeValueDateTimeInterface($object), + 'ApiClients\Client\PetStore\Schema\Error' => $this->serializeObjectApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error($object), + default => throw new \LogicException('No serialization defined for $className'), + }; + } catch (\Throwable $exception) { + throw UnableToSerializeObject::dueToError($className, $exception); + } + } + + + private function serializeValuearray(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueDateTime(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueDateTimeImmutable(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeValueDateTimeInterface(mixed $value): mixed + { + static $serializer; + + if ($serializer === null) { + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array ( +)); + } + + return $serializer->serialize($value, $this); + } + + + private function serializeObjectApiClients⚡️Client⚡️PetStore⚡️Schema⚡️Error(mixed $object): mixed + { + \assert($object instanceof \ApiClients\Client\PetStore\Schema\Error); + $result = []; + + $code = $object->code; + after_code: $result['code'] = $code; + + + $message = $object->message; + after_message: $result['message'] = $message; + + + return $result; + } + + + + /** + * @template T + * + * @param class-string $className + * @param iterable $payloads; + * + * @return IterableList + * + * @throws UnableToHydrateObject + */ + public function hydrateObjects(string $className, iterable $payloads): IterableList + { + return new IterableList($this->doHydrateObjects($className, $payloads)); + } + + private function doHydrateObjects(string $className, iterable $payloads): Generator + { + foreach ($payloads as $index => $payload) { + yield $index => $this->hydrateObject($className, $payload); + } + } + + /** + * @template T + * + * @param class-string $className + * @param iterable $payloads; + * + * @return IterableList + * + * @throws UnableToSerializeObject + */ + public function serializeObjects(iterable $payloads): IterableList + { + return new IterableList($this->doSerializeObjects($payloads)); + } + + private function doSerializeObjects(iterable $objects): Generator + { + foreach ($objects as $index => $object) { + yield $index => $this->serializeObject($object); + } + } +} diff --git a/tests/app/src/Internal/Hydrators.php b/tests/app/src/Internal/Hydrators.php index 909f7ec..aebc236 100644 --- a/tests/app/src/Internal/Hydrators.php +++ b/tests/app/src/Internal/Hydrators.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -14,12 +15,15 @@ final class Hydrators implements \EventSauce\ObjectHydrator\ObjectMapper { private ?Internal\Hydrator\Operation\Pets $operation🌀Pets = null; private ?Internal\Hydrator\Operation\Pets\Gatos $operation🌀Pets🌀Gatos = null; + private ?Internal\Hydrator\Operation\Pets\Kinds\Walking $operation🌀Pets🌀Kinds🌀Walking = null; + private ?Internal\Hydrator\Operation\Pets\GroupedByType $operation🌀Pets🌀GroupedByType = null; private ?Internal\Hydrator\Operation\Pets\Names $operation🌀Pets🌀Names = null; private ?Internal\Hydrator\Operation\Pets\PetId $operation🌀Pets🌀PetId = null; public function hydrateObject(string $className, array $payload) : object { return match ($className) { '\\ApiClients\\Client\\PetStore\\Schema\\Error' => $this->getObjectMapperOperation🌀Pets()->hydrateObject($className, $payload), + '\\ApiClients\\Client\\PetStore\\Schema\\Operations\\Pets\\Grouped\\By\\Type\\Response\\ApplicationJson\\Ok' => $this->getObjectMapperOperation🌀Pets🌀GroupedByType()->hydrateObject($className, $payload), }; } public function hydrateObjects(string $className, iterable $payloads) : \EventSauce\ObjectHydrator\IterableList @@ -40,6 +44,7 @@ public function serializeObjectOfType(object $object, string $className) : mixed { return match ($className) { '\\ApiClients\\Client\\PetStore\\Schema\\Error' => $this->getObjectMapperOperation🌀Pets()->serializeObject($object), + '\\ApiClients\\Client\\PetStore\\Schema\\Operations\\Pets\\Grouped\\By\\Type\\Response\\ApplicationJson\\Ok' => $this->getObjectMapperOperation🌀Pets🌀GroupedByType()->serializeObject($object), }; } public function serializeObjects(iterable $payloads) : \EventSauce\ObjectHydrator\IterableList @@ -66,6 +71,20 @@ public function getObjectMapperOperation🌀Pets🌀Gatos() : Internal\Hydrator\ } return $this->operation🌀Pets🌀Gatos; } + public function getObjectMapperOperation🌀Pets🌀Kinds🌀Walking() : Internal\Hydrator\Operation\Pets\Kinds\Walking + { + if ($this->operation🌀Pets🌀Kinds🌀Walking instanceof Internal\Hydrator\Operation\Pets\Kinds\Walking === false) { + $this->operation🌀Pets🌀Kinds🌀Walking = new Internal\Hydrator\Operation\Pets\Kinds\Walking(); + } + return $this->operation🌀Pets🌀Kinds🌀Walking; + } + public function getObjectMapperOperation🌀Pets🌀GroupedByType() : Internal\Hydrator\Operation\Pets\GroupedByType + { + if ($this->operation🌀Pets🌀GroupedByType instanceof Internal\Hydrator\Operation\Pets\GroupedByType === false) { + $this->operation🌀Pets🌀GroupedByType = new Internal\Hydrator\Operation\Pets\GroupedByType(); + } + return $this->operation🌀Pets🌀GroupedByType; + } public function getObjectMapperOperation🌀Pets🌀Names() : Internal\Hydrator\Operation\Pets\Names { if ($this->operation🌀Pets🌀Names instanceof Internal\Hydrator\Operation\Pets\Names === false) { diff --git a/tests/app/src/Internal/Operation/Pets/Create.php b/tests/app/src/Internal/Operation/Pets/Create.php index 5c024e1..84b1ade 100644 --- a/tests/app/src/Internal/Operation/Pets/Create.php +++ b/tests/app/src/Internal/Operation/Pets/Create.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re public function createRequest(array $data) : \Psr\Http\Message\RequestInterface { $this->requestSchemaValidator->validate($data, \cebe\openapi\Reader::readFromJson(Schema\Pets\Create\Request\ApplicationJson::SCHEMA_JSON, \cebe\openapi\spec\Schema::class)); - return new \RingCentral\Psr7\Request('POST', \str_replace(array(), array(), '/pets'), array('Content-Type' => 'application/json'), json_encode($data)); + return new \RingCentral\Psr7\Request('POST', (string) (new \League\Uri\UriTemplate('/pets'))->expand(array()), array('Content-Type' => 'application/json'), json_encode($data)); } /** * @return \ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody diff --git a/tests/app/src/Internal/Operation/Pets/Grouped/By/Type.php b/tests/app/src/Internal/Operation/Pets/Grouped/By/Type.php new file mode 100644 index 0000000..9fe8eca --- /dev/null +++ b/tests/app/src/Internal/Operation/Pets/Grouped/By/Type.php @@ -0,0 +1,63 @@ +perPage = $perPage; + $this->page = $page; + $this->responseSchemaValidator = $responseSchemaValidator; + $this->hydrator = $hydrator; + } + public function createRequest() : \Psr\Http\Message\RequestInterface + { + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/groupedByType{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); + } + /** + * @return Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok + */ + public function createResponse(\Psr\Http\Message\ResponseInterface $response) : Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok + { + $code = $response->getStatusCode(); + [$contentType] = explode(';', $response->getHeaderLine('Content-Type')); + switch ($contentType) { + case 'application/json': + $body = json_decode($response->getBody()->getContents(), true); + switch ($code) { + /** + * A shitty design choice to test a specific situation in the generator + **/ + case 200: + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok::SCHEMA_JSON, \cebe\openapi\spec\Schema::class)); + return $this->hydrator->hydrateObject(Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok::class, $body); + /** + * unexpected error + **/ + default: + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Error::SCHEMA_JSON, \cebe\openapi\spec\Schema::class)); + throw new ErrorSchemas\Error($code, $this->hydrator->hydrateObject(Schema\Error::class, $body)); + } + break; + } + throw new \RuntimeException('Unable to find matching response code and content type'); + } +} diff --git a/tests/app/src/Internal/Operation/Pets/Kinds/Walking.php b/tests/app/src/Internal/Operation/Pets/Kinds/Walking.php new file mode 100644 index 0000000..77db70c --- /dev/null +++ b/tests/app/src/Internal/Operation/Pets/Kinds/Walking.php @@ -0,0 +1,79 @@ +perPage = $perPage; + $this->page = $page; + $this->responseSchemaValidator = $responseSchemaValidator; + $this->hydrator = $hydrator; + } + public function createRequest() : \Psr\Http\Message\RequestInterface + { + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/kinds/walking{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); + } + /** + * @return \Rx\Observable + */ + public function createResponse(\Psr\Http\Message\ResponseInterface $response) : \Rx\Observable + { + $code = $response->getStatusCode(); + [$contentType] = explode(';', $response->getHeaderLine('Content-Type')); + switch ($contentType) { + case 'application/json': + $body = json_decode($response->getBody()->getContents(), true); + switch ($code) { + /** + * A paged array of cats + **/ + case 200: + return \Rx\Observable::fromArray($body, new \Rx\Scheduler\ImmediateScheduler())->map(function (array $body) : Schema\Cat|Schema\Dog { + $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); + } 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); + } catch (\Throwable $error) { + goto items_application_json_two_hundred_aaaab; + } + items_application_json_two_hundred_aaaab: + throw $error; + }); + /** + * unexpected error + **/ + default: + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Error::SCHEMA_JSON, \cebe\openapi\spec\Schema::class)); + throw new ErrorSchemas\Error($code, $this->hydrator->hydrateObject(Schema\Error::class, $body)); + } + break; + } + throw new \RuntimeException('Unable to find matching response code and content type'); + } +} diff --git a/tests/app/src/Internal/Operation/Pets/Kinds/WalkingListing.php b/tests/app/src/Internal/Operation/Pets/Kinds/WalkingListing.php new file mode 100644 index 0000000..7083423 --- /dev/null +++ b/tests/app/src/Internal/Operation/Pets/Kinds/WalkingListing.php @@ -0,0 +1,79 @@ +perPage = $perPage; + $this->page = $page; + $this->responseSchemaValidator = $responseSchemaValidator; + $this->hydrator = $hydrator; + } + public function createRequest() : \Psr\Http\Message\RequestInterface + { + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/kinds/walking{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); + } + /** + * @return \Rx\Observable + */ + public function createResponse(\Psr\Http\Message\ResponseInterface $response) : \Rx\Observable + { + $code = $response->getStatusCode(); + [$contentType] = explode(';', $response->getHeaderLine('Content-Type')); + switch ($contentType) { + case 'application/json': + $body = json_decode($response->getBody()->getContents(), true); + switch ($code) { + /** + * A paged array of cats + **/ + case 200: + return \Rx\Observable::fromArray($body, new \Rx\Scheduler\ImmediateScheduler())->map(function (array $body) : Schema\Cat|Schema\Dog { + $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); + } 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); + } catch (\Throwable $error) { + goto items_application_json_two_hundred_aaaab; + } + items_application_json_two_hundred_aaaab: + throw $error; + }); + /** + * unexpected error + **/ + default: + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Error::SCHEMA_JSON, \cebe\openapi\spec\Schema::class)); + throw new ErrorSchemas\Error($code, $this->hydrator->hydrateObject(Schema\Error::class, $body)); + } + break; + } + throw new \RuntimeException('Unable to find matching response code and content type'); + } +} diff --git a/tests/app/src/Internal/Operation/Pets/ListListing.php b/tests/app/src/Internal/Operation/Pets/ListListing.php index 8edb254..125df60 100644 --- a/tests/app/src/Internal/Operation/Pets/ListListing.php +++ b/tests/app/src/Internal/Operation/Pets/ListListing.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -29,10 +30,10 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array('{per_page}', '{page}'), array($this->perPage, $this->page), '/pets' . '?per_page={per_page}&page={page}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); } /** - * @return \Rx\Observable + * @return \Rx\Observable */ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : \Rx\Observable { @@ -46,7 +47,7 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : * A paged array of pets **/ case 200: - return \Rx\Observable::fromArray($body, new \Rx\Scheduler\ImmediateScheduler())->map(function (array $body) : Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish { + return \Rx\Observable::fromArray($body, new \Rx\Scheduler\ImmediateScheduler())->map(function (array $body) : Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider { $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); @@ -76,6 +77,13 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : goto items_application_json_two_hundred_aaaad; } items_application_json_two_hundred_aaaad: + try { + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Spider::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); + return $this->hydrator->hydrateObject(Schema\Spider::class, $body); + } catch (\Throwable $error) { + goto items_application_json_two_hundred_aaaae; + } + items_application_json_two_hundred_aaaae: throw $error; }); /** diff --git a/tests/app/src/Internal/Operation/Pets/List_.php b/tests/app/src/Internal/Operation/Pets/List_.php index f5b9375..398ddaf 100644 --- a/tests/app/src/Internal/Operation/Pets/List_.php +++ b/tests/app/src/Internal/Operation/Pets/List_.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -29,10 +30,10 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array('{per_page}', '{page}'), array($this->perPage, $this->page), '/pets' . '?per_page={per_page}&page={page}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); } /** - * @return \Rx\Observable + * @return \Rx\Observable */ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : \Rx\Observable { @@ -46,7 +47,7 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : * A paged array of pets **/ case 200: - return \Rx\Observable::fromArray($body, new \Rx\Scheduler\ImmediateScheduler())->map(function (array $body) : Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish { + return \Rx\Observable::fromArray($body, new \Rx\Scheduler\ImmediateScheduler())->map(function (array $body) : Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider { $error = new \RuntimeException(); try { $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Cat::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); @@ -76,6 +77,13 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : goto items_application_json_two_hundred_aaaad; } items_application_json_two_hundred_aaaad: + try { + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Spider::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); + return $this->hydrator->hydrateObject(Schema\Spider::class, $body); + } catch (\Throwable $error) { + goto items_application_json_two_hundred_aaaae; + } + items_application_json_two_hundred_aaaae: throw $error; }); /** diff --git a/tests/app/src/Internal/Operation/Pets/List_/Gatos.php b/tests/app/src/Internal/Operation/Pets/List_/Gatos.php index db912ff..b734bbb 100644 --- a/tests/app/src/Internal/Operation/Pets/List_/Gatos.php +++ b/tests/app/src/Internal/Operation/Pets/List_/Gatos.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets\List_; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -29,7 +30,7 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array('{per_page}', '{page}'), array($this->perPage, $this->page), '/pets/gatos' . '?per_page={per_page}&page={page}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/gatos{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); } /** * @return \Rx\Observable diff --git a/tests/app/src/Internal/Operation/Pets/List_/GatosListing.php b/tests/app/src/Internal/Operation/Pets/List_/GatosListing.php index ac47a15..5414868 100644 --- a/tests/app/src/Internal/Operation/Pets/List_/GatosListing.php +++ b/tests/app/src/Internal/Operation/Pets/List_/GatosListing.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets\List_; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -29,7 +30,7 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array('{per_page}', '{page}'), array($this->perPage, $this->page), '/pets/gatos' . '?per_page={per_page}&page={page}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/gatos{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); } /** * @return \Rx\Observable diff --git a/tests/app/src/Internal/Operation/Pets/Names.php b/tests/app/src/Internal/Operation/Pets/Names.php index 16c0716..f7a31d7 100644 --- a/tests/app/src/Internal/Operation/Pets/Names.php +++ b/tests/app/src/Internal/Operation/Pets/Names.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -29,7 +30,7 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array('{per_page}', '{page}'), array($this->perPage, $this->page), '/pets/names' . '?per_page={per_page}&page={page}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/names{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); } /** * @return \Rx\Observable diff --git a/tests/app/src/Internal/Operation/Pets/NamesListing.php b/tests/app/src/Internal/Operation/Pets/NamesListing.php index f95d2fa..a5fc250 100644 --- a/tests/app/src/Internal/Operation/Pets/NamesListing.php +++ b/tests/app/src/Internal/Operation/Pets/NamesListing.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -29,7 +30,7 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array('{per_page}', '{page}'), array($this->perPage, $this->page), '/pets/names' . '?per_page={per_page}&page={page}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/names{?page,per_page}'))->expand(array('page' => $this->page, 'per_page' => $this->perPage))); } /** * @return \Rx\Observable diff --git a/tests/app/src/Internal/Operation/ShowPetById.php b/tests/app/src/Internal/Operation/ShowPetById.php index 00ceb0c..4bfd760 100644 --- a/tests/app/src/Internal/Operation/ShowPetById.php +++ b/tests/app/src/Internal/Operation/ShowPetById.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operation; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -23,12 +24,12 @@ public function __construct(\League\OpenAPIValidation\Schema\SchemaValidator $re } public function createRequest() : \Psr\Http\Message\RequestInterface { - return new \RingCentral\Psr7\Request('GET', \str_replace(array(), array(), '/pets/{petId}')); + return new \RingCentral\Psr7\Request('GET', (string) (new \League\Uri\UriTemplate('/pets/{petId}'))->expand(array())); } /** - * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider */ - public function createResponse(\Psr\Http\Message\ResponseInterface $response) : Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + public function createResponse(\Psr\Http\Message\ResponseInterface $response) : Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider { $code = $response->getStatusCode(); [$contentType] = explode(';', $response->getHeaderLine('Content-Type')); @@ -69,6 +70,13 @@ public function createResponse(\Psr\Http\Message\ResponseInterface $response) : goto items_application_json_two_hundred_aaaad; } items_application_json_two_hundred_aaaad: + try { + $this->responseSchemaValidator->validate($body, \cebe\openapi\Reader::readFromJson(Schema\Spider::SCHEMA_JSON, '\\cebe\\openapi\\spec\\Schema')); + return $this->hydrator->hydrateObject(Schema\Spider::class, $body); + } catch (\Throwable $error) { + goto items_application_json_two_hundred_aaaae; + } + items_application_json_two_hundred_aaaae: throw $error; /** * unexpected error diff --git a/tests/app/src/Internal/Operator/Pets/Create.php b/tests/app/src/Internal/Operator/Pets/Create.php index f151119..2c1e048 100644 --- a/tests/app/src/Internal/Operator/Pets/Create.php +++ b/tests/app/src/Internal/Operator/Pets/Create.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Operator/Pets/Grouped/By/Type.php b/tests/app/src/Internal/Operator/Pets/Grouped/By/Type.php new file mode 100644 index 0000000..7427038 --- /dev/null +++ b/tests/app/src/Internal/Operator/Pets/Grouped/By/Type.php @@ -0,0 +1,36 @@ +responseSchemaValidator, $this->hydrator, $perPage, $page); + $request = $operation->createRequest(); + $result = \React\Async\await($this->browser->request($request->getMethod(), (string) $request->getUri(), $request->withHeader('Authorization', $this->authentication->authHeader())->getHeaders(), (string) $request->getBody())->then(function (\Psr\Http\Message\ResponseInterface $response) use($operation) : \ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok { + return $operation->createResponse($response); + })); + if ($result instanceof \Rx\Observable) { + $result = \WyriHaximus\React\awaitObservable($result); + } + return $result; + } +} diff --git a/tests/app/src/Internal/Operator/Pets/Kinds/Walking.php b/tests/app/src/Internal/Operator/Pets/Kinds/Walking.php new file mode 100644 index 0000000..c83f45e --- /dev/null +++ b/tests/app/src/Internal/Operator/Pets/Kinds/Walking.php @@ -0,0 +1,36 @@ + + */ + public function call(int $perPage = 30, int $page = 1) : iterable + { + $operation = new \ApiClients\Client\PetStore\Internal\Operation\Pets\Kinds\Walking($this->responseSchemaValidator, $this->hydrator, $perPage, $page); + $request = $operation->createRequest(); + $result = \React\Async\await($this->browser->request($request->getMethod(), (string) $request->getUri(), $request->withHeader('Authorization', $this->authentication->authHeader())->getHeaders(), (string) $request->getBody())->then(function (\Psr\Http\Message\ResponseInterface $response) use($operation) : \Rx\Observable { + return $operation->createResponse($response); + })); + if ($result instanceof \Rx\Observable) { + $result = \WyriHaximus\React\awaitObservable($result); + } + return $result; + } +} diff --git a/tests/app/src/Internal/Operator/Pets/Kinds/WalkingListing.php b/tests/app/src/Internal/Operator/Pets/Kinds/WalkingListing.php new file mode 100644 index 0000000..d60f6e7 --- /dev/null +++ b/tests/app/src/Internal/Operator/Pets/Kinds/WalkingListing.php @@ -0,0 +1,36 @@ + + */ + public function call(int $perPage = 30, int $page = 1) : iterable + { + $operation = new \ApiClients\Client\PetStore\Internal\Operation\Pets\Kinds\WalkingListing($this->responseSchemaValidator, $this->hydrator, $perPage, $page); + $request = $operation->createRequest(); + $result = \React\Async\await($this->browser->request($request->getMethod(), (string) $request->getUri(), $request->withHeader('Authorization', $this->authentication->authHeader())->getHeaders(), (string) $request->getBody())->then(function (\Psr\Http\Message\ResponseInterface $response) use($operation) : \Rx\Observable { + return $operation->createResponse($response); + })); + if ($result instanceof \Rx\Observable) { + $result = \WyriHaximus\React\awaitObservable($result); + } + return $result; + } +} diff --git a/tests/app/src/Internal/Operator/Pets/ListListing.php b/tests/app/src/Internal/Operator/Pets/ListListing.php index 26cfa31..7890841 100644 --- a/tests/app/src/Internal/Operator/Pets/ListListing.php +++ b/tests/app/src/Internal/Operator/Pets/ListListing.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -18,7 +19,7 @@ public function __construct(private \React\Http\Browser $browser, private \ApiCl { } /** - * @return iterable + * @return iterable */ public function call(int $perPage = 30, int $page = 1) : iterable { diff --git a/tests/app/src/Internal/Operator/Pets/List_.php b/tests/app/src/Internal/Operator/Pets/List_.php index 9e4cb2c..61100f9 100644 --- a/tests/app/src/Internal/Operator/Pets/List_.php +++ b/tests/app/src/Internal/Operator/Pets/List_.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -18,7 +19,7 @@ public function __construct(private \React\Http\Browser $browser, private \ApiCl { } /** - * @return iterable + * @return iterable */ public function call(int $perPage = 30, int $page = 1) : iterable { diff --git a/tests/app/src/Internal/Operator/Pets/List_/Gatos.php b/tests/app/src/Internal/Operator/Pets/List_/Gatos.php index a29a055..d0b00ad 100644 --- a/tests/app/src/Internal/Operator/Pets/List_/Gatos.php +++ b/tests/app/src/Internal/Operator/Pets/List_/Gatos.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets\List_; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Operator/Pets/List_/GatosListing.php b/tests/app/src/Internal/Operator/Pets/List_/GatosListing.php index de81575..3595e7a 100644 --- a/tests/app/src/Internal/Operator/Pets/List_/GatosListing.php +++ b/tests/app/src/Internal/Operator/Pets/List_/GatosListing.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets\List_; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Operator/Pets/Names.php b/tests/app/src/Internal/Operator/Pets/Names.php index 45ca604..9769957 100644 --- a/tests/app/src/Internal/Operator/Pets/Names.php +++ b/tests/app/src/Internal/Operator/Pets/Names.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Operator/Pets/NamesListing.php b/tests/app/src/Internal/Operator/Pets/NamesListing.php index 5c4f3d7..55f7874 100644 --- a/tests/app/src/Internal/Operator/Pets/NamesListing.php +++ b/tests/app/src/Internal/Operator/Pets/NamesListing.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Operator/ShowPetById.php b/tests/app/src/Internal/Operator/ShowPetById.php index 944d30e..5a963cb 100644 --- a/tests/app/src/Internal/Operator/ShowPetById.php +++ b/tests/app/src/Internal/Operator/ShowPetById.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Operator; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -18,13 +19,13 @@ public function __construct(private \React\Http\Browser $browser, private \ApiCl { } /** - * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider */ - public function call() : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish + public function call() : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|\ApiClients\Client\PetStore\Schema\Spider { $operation = new \ApiClients\Client\PetStore\Internal\Operation\ShowPetById($this->responseSchemaValidator, $this->hydrator); $request = $operation->createRequest(); - $result = \React\Async\await($this->browser->request($request->getMethod(), (string) $request->getUri(), $request->withHeader('Authorization', $this->authentication->authHeader())->getHeaders(), (string) $request->getBody())->then(function (\Psr\Http\Message\ResponseInterface $response) use($operation) : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish { + $result = \React\Async\await($this->browser->request($request->getMethod(), (string) $request->getUri(), $request->withHeader('Authorization', $this->authentication->authHeader())->getHeaders(), (string) $request->getBody())->then(function (\Psr\Http\Message\ResponseInterface $response) use($operation) : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|\ApiClients\Client\PetStore\Schema\Spider { return $operation->createResponse($response); })); if ($result instanceof \Rx\Observable) { diff --git a/tests/app/src/Internal/Operators.php b/tests/app/src/Internal/Operators.php index 19d2e31..02d04b7 100644 --- a/tests/app/src/Internal/Operators.php +++ b/tests/app/src/Internal/Operators.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -17,6 +18,9 @@ final class Operators private ?Internal\Operator\Pets\Create $pets👷Create = null; private ?Internal\Operator\Pets\List_\Gatos $pets👷List_👷Gatos = null; private ?Internal\Operator\Pets\List_\GatosListing $pets👷List_👷GatosListing = null; + private ?Internal\Operator\Pets\Kinds\Walking $pets👷Kinds👷Walking = null; + private ?Internal\Operator\Pets\Kinds\WalkingListing $pets👷Kinds👷WalkingListing = null; + private ?Internal\Operator\Pets\Grouped\By\Type $pets👷Grouped👷By👷Type = null; private ?Internal\Operator\Pets\Names $pets👷Names = null; private ?Internal\Operator\Pets\NamesListing $pets👷NamesListing = null; private ?Internal\Operator\ShowPetById $showPetById = null; @@ -58,6 +62,27 @@ public function pets👷List_👷GatosListing() : Internal\Operator\Pets\List_\G } return $this->pets👷List_👷GatosListing; } + public function pets👷Kinds👷Walking() : Internal\Operator\Pets\Kinds\Walking + { + if ($this->pets👷Kinds👷Walking instanceof Internal\Operator\Pets\Kinds\Walking === false) { + $this->pets👷Kinds👷Walking = new Internal\Operator\Pets\Kinds\Walking($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Kinds🌀Walking()); + } + return $this->pets👷Kinds👷Walking; + } + public function pets👷Kinds👷WalkingListing() : Internal\Operator\Pets\Kinds\WalkingListing + { + if ($this->pets👷Kinds👷WalkingListing instanceof Internal\Operator\Pets\Kinds\WalkingListing === false) { + $this->pets👷Kinds👷WalkingListing = new Internal\Operator\Pets\Kinds\WalkingListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Kinds🌀Walking()); + } + return $this->pets👷Kinds👷WalkingListing; + } + public function pets👷Grouped👷By👷Type() : Internal\Operator\Pets\Grouped\By\Type + { + if ($this->pets👷Grouped👷By👷Type instanceof Internal\Operator\Pets\Grouped\By\Type === false) { + $this->pets👷Grouped👷By👷Type = new Internal\Operator\Pets\Grouped\By\Type($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀GroupedByType()); + } + return $this->pets👷Grouped👷By👷Type; + } public function pets👷Names() : Internal\Operator\Pets\Names { if ($this->pets👷Names instanceof Internal\Operator\Pets\Names === false) { diff --git a/tests/app/src/Internal/Router/Get.php b/tests/app/src/Internal/Router/Get.php index 9d166fa..ccdeacb 100644 --- a/tests/app/src/Internal/Router/Get.php +++ b/tests/app/src/Internal/Router/Get.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,9 +17,9 @@ public function __construct(private \League\OpenAPIValidation\Schema\SchemaValid { } /** - * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider */ - public function showPetById(array $params) : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish + public function showPetById(array $params) : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|\ApiClients\Client\PetStore\Schema\Spider { $operator = new Internal\Operator\ShowPetById($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀PetId()); return $operator->call(); diff --git a/tests/app/src/Internal/Router/Get/Four.php b/tests/app/src/Internal/Router/Get/Four.php new file mode 100644 index 0000000..f6b044a --- /dev/null +++ b/tests/app/src/Internal/Router/Get/Four.php @@ -0,0 +1,37 @@ + + */ + public function call(string $call, array $params, array $pathChunks) : iterable + { + if ($pathChunks[0] == '') { + if ($pathChunks[1] == 'pets') { + if ($pathChunks[2] == 'kinds') { + if ($pathChunks[3] == 'walking') { + if ($call == 'GET /pets/kinds/walking') { + return $this->routers->internal🔀Router🔀Get🔀PetsKinds()->walking($params); + } + } + } + } + } + throw new \InvalidArgumentException(); + } +} diff --git a/tests/app/src/Internal/Router/Get/Pets.php b/tests/app/src/Internal/Router/Get/Pets.php index dbd4a54..5d99f9f 100644 --- a/tests/app/src/Internal/Router/Get/Pets.php +++ b/tests/app/src/Internal/Router/Get/Pets.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\Get; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,7 +17,7 @@ public function __construct(private \League\OpenAPIValidation\Schema\SchemaValid { } /** - * @return iterable + * @return iterable */ public function list(array $params) : iterable { diff --git a/tests/app/src/Internal/Router/Get/PetsGroupedBy.php b/tests/app/src/Internal/Router/Get/PetsGroupedBy.php new file mode 100644 index 0000000..b143825 --- /dev/null +++ b/tests/app/src/Internal/Router/Get/PetsGroupedBy.php @@ -0,0 +1,38 @@ +browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀GroupedByType()); + return $operator->call($arguments['per_page'], $arguments['page']); + } +} diff --git a/tests/app/src/Internal/Router/Get/PetsKinds.php b/tests/app/src/Internal/Router/Get/PetsKinds.php new file mode 100644 index 0000000..f5acdda --- /dev/null +++ b/tests/app/src/Internal/Router/Get/PetsKinds.php @@ -0,0 +1,38 @@ + + */ + public function walking(array $params) : iterable + { + $arguments = array(); + if (array_key_exists('per_page', $params) === false) { + throw new \InvalidArgumentException('Missing mandatory field: per_page'); + } + $arguments['per_page'] = $params['per_page']; + unset($params['per_page']); + if (array_key_exists('page', $params) === false) { + throw new \InvalidArgumentException('Missing mandatory field: page'); + } + $arguments['page'] = $params['page']; + unset($params['page']); + $operator = new Internal\Operator\Pets\Kinds\Walking($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Kinds🌀Walking()); + return $operator->call($arguments['per_page'], $arguments['page']); + } +} diff --git a/tests/app/src/Internal/Router/Get/PetsList.php b/tests/app/src/Internal/Router/Get/PetsList.php index b3ef8fd..41767a0 100644 --- a/tests/app/src/Internal/Router/Get/PetsList.php +++ b/tests/app/src/Internal/Router/Get/PetsList.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\Get; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Router/Get/Three.php b/tests/app/src/Internal/Router/Get/Three.php index 6ddedcc..e5ed37d 100644 --- a/tests/app/src/Internal/Router/Get/Three.php +++ b/tests/app/src/Internal/Router/Get/Three.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\Get; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,9 +17,9 @@ public function __construct(private \ApiClients\Client\PetStore\Internal\Routers { } /** - * @return iterable|iterable|Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + * @return iterable|Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok|iterable|Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider */ - public function call(string $call, array $params, array $pathChunks) : iterable|\ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish + public function call(string $call, array $params, array $pathChunks) : iterable|\ApiClients\Client\PetStore\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok|\ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\Schema\Fish|\ApiClients\Client\PetStore\Schema\Spider { if ($pathChunks[0] == '') { if ($pathChunks[1] == 'pets') { @@ -26,6 +27,10 @@ public function call(string $call, array $params, array $pathChunks) : iterable| if ($call == 'GET /pets/gatos') { return $this->routers->internal🔀Router🔀Get🔀PetsList()->gatos($params); } + } elseif ($pathChunks[2] == 'groupedByType') { + if ($call == 'GET /pets/groupedByType') { + return $this->routers->internal🔀Router🔀Get🔀PetsGroupedBy()->type($params); + } } elseif ($pathChunks[2] == 'names') { if ($call == 'GET /pets/names') { return $this->routers->internal🔀Router🔀Get🔀Pets()->names($params); diff --git a/tests/app/src/Internal/Router/Get/Two.php b/tests/app/src/Internal/Router/Get/Two.php index 678d83b..099ecd4 100644 --- a/tests/app/src/Internal/Router/Get/Two.php +++ b/tests/app/src/Internal/Router/Get/Two.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\Get; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,7 +17,7 @@ public function __construct(private \ApiClients\Client\PetStore\Internal\Routers { } /** - * @return iterable + * @return iterable */ public function call(string $call, array $params, array $pathChunks) : iterable { diff --git a/tests/app/src/Internal/Router/List/Four.php b/tests/app/src/Internal/Router/List/Four.php new file mode 100644 index 0000000..b3ac4ea --- /dev/null +++ b/tests/app/src/Internal/Router/List/Four.php @@ -0,0 +1,37 @@ + + */ + public function call(string $call, array $params, array $pathChunks) : iterable + { + if ($pathChunks[0] == '') { + if ($pathChunks[1] == 'pets') { + if ($pathChunks[2] == 'kinds') { + if ($pathChunks[3] == 'walking') { + if ($call == 'LIST /pets/kinds/walking') { + return $this->routers->internal🔀Router🔀List🔀PetsKinds()->walkingListing($params); + } + } + } + } + } + throw new \InvalidArgumentException(); + } +} diff --git a/tests/app/src/Internal/Router/List/Pets.php b/tests/app/src/Internal/Router/List/Pets.php index f469cdb..77d4e5f 100644 --- a/tests/app/src/Internal/Router/List/Pets.php +++ b/tests/app/src/Internal/Router/List/Pets.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\List; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,7 +17,7 @@ public function __construct(private \League\OpenAPIValidation\Schema\SchemaValid { } /** - * @return iterable + * @return iterable */ public function listListing(array $params) : iterable { diff --git a/tests/app/src/Internal/Router/List/PetsKinds.php b/tests/app/src/Internal/Router/List/PetsKinds.php new file mode 100644 index 0000000..968b9b7 --- /dev/null +++ b/tests/app/src/Internal/Router/List/PetsKinds.php @@ -0,0 +1,43 @@ + + */ + public function walkingListing(array $params) : iterable + { + $arguments = array(); + if (array_key_exists('per_page', $params) === false) { + throw new \InvalidArgumentException('Missing mandatory field: per_page'); + } + $arguments['per_page'] = $params['per_page']; + unset($params['per_page']); + if (array_key_exists('page', $params) === false) { + throw new \InvalidArgumentException('Missing mandatory field: page'); + } + $arguments['page'] = $params['page']; + unset($params['page']); + $arguments['page'] = 1; + do { + $operator = new Internal\Operator\Pets\Kinds\WalkingListing($this->browser, $this->authentication, $this->responseSchemaValidator, $this->hydrators->getObjectMapperOperation🌀Pets🌀Kinds🌀Walking()); + $items = [...$operator->call($arguments['per_page'], $arguments['page'])]; + yield from $items; + $arguments['page']++; + } while (count($items) > 0); + } +} diff --git a/tests/app/src/Internal/Router/List/PetsList.php b/tests/app/src/Internal/Router/List/PetsList.php index d2bcff0..fb3f9a4 100644 --- a/tests/app/src/Internal/Router/List/PetsList.php +++ b/tests/app/src/Internal/Router/List/PetsList.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\List; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Router/List/Three.php b/tests/app/src/Internal/Router/List/Three.php index ef917a3..05beb59 100644 --- a/tests/app/src/Internal/Router/List/Three.php +++ b/tests/app/src/Internal/Router/List/Three.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\List; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Router/List/Two.php b/tests/app/src/Internal/Router/List/Two.php index fc01877..1333b02 100644 --- a/tests/app/src/Internal/Router/List/Two.php +++ b/tests/app/src/Internal/Router/List/Two.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\List; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,7 +17,7 @@ public function __construct(private \ApiClients\Client\PetStore\Internal\Routers { } /** - * @return iterable + * @return iterable */ public function call(string $call, array $params, array $pathChunks) : iterable { diff --git a/tests/app/src/Internal/Router/Post/Pets.php b/tests/app/src/Internal/Router/Post/Pets.php index 9489a61..6e80294 100644 --- a/tests/app/src/Internal/Router/Post/Pets.php +++ b/tests/app/src/Internal/Router/Post/Pets.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\Post; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Router/Post/Two.php b/tests/app/src/Internal/Router/Post/Two.php index 0b8d8fc..dba200b 100644 --- a/tests/app/src/Internal/Router/Post/Two.php +++ b/tests/app/src/Internal/Router/Post/Two.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal\Router\Post; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Internal/Routers.php b/tests/app/src/Internal/Routers.php index b8ee5a2..83b01c4 100644 --- a/tests/app/src/Internal/Routers.php +++ b/tests/app/src/Internal/Routers.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Internal; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -14,9 +15,12 @@ final class Routers { private ?Internal\Router\Get\Pets $internal🔀Router🔀Get🔀Pets = null; private ?Internal\Router\Get\PetsList $internal🔀Router🔀Get🔀PetsList = null; + private ?Internal\Router\Get\PetsGroupedBy $internal🔀Router🔀Get🔀PetsGroupedBy = null; private ?Internal\Router\Get $internal🔀Router🔀Get = null; + private ?Internal\Router\Get\PetsKinds $internal🔀Router🔀Get🔀PetsKinds = null; private ?Internal\Router\List\Pets $internal🔀Router🔀List🔀Pets = null; private ?Internal\Router\List\PetsList $internal🔀Router🔀List🔀PetsList = null; + private ?Internal\Router\List\PetsKinds $internal🔀Router🔀List🔀PetsKinds = null; private ?Internal\Router\Post\Pets $internal🔀Router🔀Post🔀Pets = null; public function __construct(private \ApiClients\Contracts\HTTP\Headers\AuthenticationInterface $authentication, private \React\Http\Browser $browser, private \League\OpenAPIValidation\Schema\SchemaValidator $requestSchemaValidator, private \League\OpenAPIValidation\Schema\SchemaValidator $responseSchemaValidator, private Internal\Hydrators $hydrators) { @@ -35,6 +39,13 @@ public function internal🔀Router🔀Get🔀PetsList() : Internal\Router\Get\Pe } return $this->internal🔀Router🔀Get🔀PetsList; } + public function internal🔀Router🔀Get🔀PetsGroupedBy() : Internal\Router\Get\PetsGroupedBy + { + if ($this->internal🔀Router🔀Get🔀PetsGroupedBy instanceof Internal\Router\Get\PetsGroupedBy === false) { + $this->internal🔀Router🔀Get🔀PetsGroupedBy = new Internal\Router\Get\PetsGroupedBy(browser: $this->browser, authentication: $this->authentication, requestSchemaValidator: $this->requestSchemaValidator, responseSchemaValidator: $this->responseSchemaValidator, hydrators: $this->hydrators); + } + return $this->internal🔀Router🔀Get🔀PetsGroupedBy; + } public function internal🔀Router🔀Get() : Internal\Router\Get { if ($this->internal🔀Router🔀Get instanceof Internal\Router\Get === false) { @@ -42,6 +53,13 @@ public function internal🔀Router🔀Get() : Internal\Router\Get } return $this->internal🔀Router🔀Get; } + public function internal🔀Router🔀Get🔀PetsKinds() : Internal\Router\Get\PetsKinds + { + if ($this->internal🔀Router🔀Get🔀PetsKinds instanceof Internal\Router\Get\PetsKinds === false) { + $this->internal🔀Router🔀Get🔀PetsKinds = new Internal\Router\Get\PetsKinds(browser: $this->browser, authentication: $this->authentication, requestSchemaValidator: $this->requestSchemaValidator, responseSchemaValidator: $this->responseSchemaValidator, hydrators: $this->hydrators); + } + return $this->internal🔀Router🔀Get🔀PetsKinds; + } public function internal🔀Router🔀List🔀Pets() : Internal\Router\List\Pets { if ($this->internal🔀Router🔀List🔀Pets instanceof Internal\Router\List\Pets === false) { @@ -56,6 +74,13 @@ public function internal🔀Router🔀List🔀PetsList() : Internal\Router\List\ } return $this->internal🔀Router🔀List🔀PetsList; } + public function internal🔀Router🔀List🔀PetsKinds() : Internal\Router\List\PetsKinds + { + if ($this->internal🔀Router🔀List🔀PetsKinds instanceof Internal\Router\List\PetsKinds === false) { + $this->internal🔀Router🔀List🔀PetsKinds = new Internal\Router\List\PetsKinds(browser: $this->browser, authentication: $this->authentication, requestSchemaValidator: $this->requestSchemaValidator, responseSchemaValidator: $this->responseSchemaValidator, hydrators: $this->hydrators); + } + return $this->internal🔀Router🔀List🔀PetsKinds; + } public function internal🔀Router🔀Post🔀Pets() : Internal\Router\Post\Pets { if ($this->internal🔀Router🔀Post🔀Pets instanceof Internal\Router\Post\Pets === false) { diff --git a/tests/app/src/Operation/Pets.php b/tests/app/src/Operation/Pets.php index c7e16ea..3188c6f 100644 --- a/tests/app/src/Operation/Pets.php +++ b/tests/app/src/Operation/Pets.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Operation; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -16,14 +17,14 @@ public function __construct(private Internal\Operators $operators) { } /** - * @return iterable + * @return iterable */ public function list(int $perPage, int $page) : iterable { return $this->operators->pets👷List_()->call($perPage, $page); } /** - * @return iterable + * @return iterable */ public function listListing(int $perPage, int $page) : iterable { diff --git a/tests/app/src/Operation/PetsGroupedBy.php b/tests/app/src/Operation/PetsGroupedBy.php new file mode 100644 index 0000000..a03c06e --- /dev/null +++ b/tests/app/src/Operation/PetsGroupedBy.php @@ -0,0 +1,26 @@ +operators->pets👷Grouped👷By👷Type()->call($perPage, $page); + } +} diff --git a/tests/app/src/Operation/PetsKinds.php b/tests/app/src/Operation/PetsKinds.php new file mode 100644 index 0000000..409b8d3 --- /dev/null +++ b/tests/app/src/Operation/PetsKinds.php @@ -0,0 +1,33 @@ + + */ + public function walking(int $perPage, int $page) : iterable + { + return $this->operators->pets👷Kinds👷Walking()->call($perPage, $page); + } + /** + * @return iterable + */ + public function walkingListing(int $perPage, int $page) : iterable + { + return $this->operators->pets👷Kinds👷WalkingListing()->call($perPage, $page); + } +} diff --git a/tests/app/src/Operation/PetsList.php b/tests/app/src/Operation/PetsList.php index b56af45..2094acc 100644 --- a/tests/app/src/Operation/PetsList.php +++ b/tests/app/src/Operation/PetsList.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Operation; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/src/Operations.php b/tests/app/src/Operations.php index 8f0f820..6be9f6f 100644 --- a/tests/app/src/Operations.php +++ b/tests/app/src/Operations.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -23,10 +24,18 @@ public function petsList() : Operation\PetsList { return new Operation\PetsList($this->operators); } + public function petsKinds() : Operation\PetsKinds + { + return new Operation\PetsKinds($this->operators); + } + public function petsGroupedBy() : Operation\PetsGroupedBy + { + return new Operation\PetsGroupedBy($this->operators); + } /** - * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider */ - public function showPetById() : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\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|\ApiClients\Client\PetStore\Schema\Spider { return $this->operators->showPetById()->call(); } diff --git a/tests/app/src/OperationsInterface.php b/tests/app/src/OperationsInterface.php index 1edc617..569628f 100644 --- a/tests/app/src/OperationsInterface.php +++ b/tests/app/src/OperationsInterface.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -14,8 +15,10 @@ interface OperationsInterface { public function pets() : Operation\Pets; public function petsList() : Operation\PetsList; + public function petsKinds() : Operation\PetsKinds; + public function petsGroupedBy() : Operation\PetsGroupedBy; /** - * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish + * @return Schema\Cat|Schema\Dog|Schema\Bird|Schema\Fish|Schema\Spider */ - public function showPetById() : \ApiClients\Client\PetStore\Schema\Cat|\ApiClients\Client\PetStore\Schema\Dog|\ApiClients\Client\PetStore\Schema\Bird|\ApiClients\Client\PetStore\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|\ApiClients\Client\PetStore\Schema\Spider; } diff --git a/tests/app/src/PHPStan/ClientCallReturnTypes.php b/tests/app/src/PHPStan/ClientCallReturnTypes.php index 85d62e2..84a7702 100644 --- a/tests/app/src/PHPStan/ClientCallReturnTypes.php +++ b/tests/app/src/PHPStan/ClientCallReturnTypes.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\PHPStan; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -33,10 +34,10 @@ public function getTypeFromMethodCall(\PHPStan\Reflection\MethodReflection $meth } $call = substr($this->printer->prettyPrintExpr($args[0]->value), 1, -1); if ($call === 'GET /pets') { - return $this->typeResolver->resolve('iterable'); + return $this->typeResolver->resolve('iterable'); } if ($call === 'LIST /pets') { - return $this->typeResolver->resolve('iterable'); + return $this->typeResolver->resolve('iterable'); } if ($call === 'POST /pets') { return $this->typeResolver->resolve('\\ApiClients\\Tools\\OpenApiClient\\Utils\\Response\\WithoutBody'); @@ -47,6 +48,15 @@ public function getTypeFromMethodCall(\PHPStan\Reflection\MethodReflection $meth if ($call === 'LIST /pets/gatos') { return $this->typeResolver->resolve('iterable'); } + if ($call === 'GET /pets/kinds/walking') { + return $this->typeResolver->resolve('iterable'); + } + if ($call === 'LIST /pets/kinds/walking') { + return $this->typeResolver->resolve('iterable'); + } + if ($call === 'GET /pets/groupedByType') { + return $this->typeResolver->resolve('Schema\\Operations\\Pets\\Grouped\\By\\Type\\Response\\ApplicationJson\\Ok'); + } if ($call === 'GET /pets/names') { return $this->typeResolver->resolve('iterable'); } @@ -54,7 +64,7 @@ public function getTypeFromMethodCall(\PHPStan\Reflection\MethodReflection $meth return $this->typeResolver->resolve('iterable'); } if ($call === 'GET /pets/{petId}') { - return $this->typeResolver->resolve('Schema\\Cat|Schema\\Dog|Schema\\Bird|Schema\\Fish'); + return $this->typeResolver->resolve('Schema\\Cat|Schema\\Dog|Schema\\Bird|Schema\\Fish|Schema\\Spider'); } return null; } diff --git a/tests/app/src/Schema/AliasAbstract/Tiet3079EDA6/TietC8A57480/TietAA436E3B/Tiet0E7D3D03.php b/tests/app/src/Schema/AliasAbstract/Tiet3079EDA6/TietC8A57480/TietAA436E3B/Tiet0E7D3D03.php deleted file mode 100644 index 93dc9d9..0000000 --- a/tests/app/src/Schema/AliasAbstract/Tiet3079EDA6/TietC8A57480/TietAA436E3B/Tiet0E7D3D03.php +++ /dev/null @@ -1,508 +0,0 @@ - $eyes + */ + public function __construct(public int $id, public string $name, public bool $indoor, public Schema\Cat\Features $features, #[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Multiple\Schema\Cat\Eyes] public array $eyes) { } } diff --git a/tests/app/src/Schema/Cat/Features.php b/tests/app/src/Schema/Cat/Features.php index 3c0a930..f4599db 100644 --- a/tests/app/src/Schema/Cat/Features.php +++ b/tests/app/src/Schema/Cat/Features.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema\Cat; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Features +final readonly class Features implements Contract\Cat\Features { public const SCHEMA_JSON = '{ "type": "object" diff --git a/tests/app/src/Schema/Dog.php b/tests/app/src/Schema/Dog.php index 836bdf5..362b96b 100644 --- a/tests/app/src/Schema/Dog.php +++ b/tests/app/src/Schema/Dog.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,12 +11,13 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Dog +final readonly class Dog implements Contract\Dog { public const SCHEMA_JSON = '{ "required": [ "id", "name", + "good-boy", "eyes" ], "type": "object", @@ -31,104 +33,109 @@ "type": "bool" }, "eyes": { - "type": "object", - "oneOf": [ - { - "required": [ - "count", - "type" - ], - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "type": { - "enum": [ - "blood", - "wine", - "stale" - ], - "type": "string" + "maxItems": 2, + "minItems": 2, + "type": "array", + "items": { + "type": "object", + "oneOf": [ + { + "required": [ + "count", + "type" + ], + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "type": { + "enum": [ + "blood", + "wine", + "stale" + ], + "type": "string" + } } - } - }, - { - "required": [ - "count", - "type" - ], - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "type": { - "enum": [ - "sky", - "boobies" - ], - "type": "string" + }, + { + "required": [ + "count", + "type" + ], + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "type": { + "enum": [ + "sky", + "boobies" + ], + "type": "string" + } } - } - }, - { - "required": [ - "count", - "type" - ], - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "type": { - "enum": [ - "hulk", - "forest", - "feral" - ], - "type": "string" + }, + { + "required": [ + "count", + "type" + ], + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "type": { + "enum": [ + "hulk", + "forest", + "feral" + ], + "type": "string" + } } - } - }, - { - "required": [ - "count", - "type" - ], - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "type": { - "enum": [ - "snake" - ], - "type": "string" + }, + { + "required": [ + "count", + "type" + ], + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "type": { + "enum": [ + "snake" + ], + "type": "string" + } } - } - }, - { - "required": [ - "count", - "type" - ], - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "type": { - "enum": [ - "rage" - ], - "type": "string" + }, + { + "required": [ + "count", + "type" + ], + "type": "object", + "properties": { + "count": { + "type": "integer" + }, + "type": { + "enum": [ + "rage" + ], + "type": "string" + } } } - } - ] + ] + } } } }'; @@ -138,9 +145,21 @@ "id": 2, "name": "generated", "good-boy": false, - "eyes": null + "eyes": [ + { + "count": 5, + "type": "blood" + }, + { + "count": 5, + "type": "sky" + } + ] }'; - public function __construct(public int $id, public string $name, #[\EventSauce\ObjectHydrator\MapFrom('good-boy')] public ?bool $goodMinBoy, #[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Schema\Dog\Eyes] public Schema\RedEyes|Schema\BlueEyes|Schema\GreenEyes|Schema\YellowEyes|Schema\BlackEyes $eyes) + /** + * @param array<\ApiClients\Client\PetStore\Schema\RedEyes|\ApiClients\Client\PetStore\Schema\BlueEyes|\ApiClients\Client\PetStore\Schema\GreenEyes|\ApiClients\Client\PetStore\Schema\YellowEyes|\ApiClients\Client\PetStore\Schema\BlackEyes> $eyes + */ + public function __construct(public int $id, public string $name, #[\EventSauce\ObjectHydrator\MapFrom('good-boy')] public bool $goodMinBoy, #[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Multiple\Schema\Dog\Eyes] public array $eyes) { } } diff --git a/tests/app/src/Schema/Error.php b/tests/app/src/Schema/Error.php index 0518472..25f47fc 100644 --- a/tests/app/src/Schema/Error.php +++ b/tests/app/src/Schema/Error.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Error +final readonly class Error implements Contract\Error { public const SCHEMA_JSON = '{ "required": [ diff --git a/tests/app/src/Schema/Fins.php b/tests/app/src/Schema/Fins.php index 9b54eb7..1a21389 100644 --- a/tests/app/src/Schema/Fins.php +++ b/tests/app/src/Schema/Fins.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Fins +final readonly class Fins implements Contract\Fins { public const SCHEMA_JSON = '{ "required": [ diff --git a/tests/app/src/Schema/Fish.php b/tests/app/src/Schema/Fish.php index 85880c0..9c44343 100644 --- a/tests/app/src/Schema/Fish.php +++ b/tests/app/src/Schema/Fish.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,12 +11,14 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Fish +final readonly class Fish implements Contract\Fish { public const SCHEMA_JSON = '{ "required": [ "id", "name", + "flat", + "flies", "eyes" ], "type": "object", @@ -30,6 +33,9 @@ "flat": { "type": "bool" }, + "flies": { + "type": "bool" + }, "eyes": { "type": "object", "oneOf": [ @@ -138,9 +144,10 @@ "id": 2, "name": "generated", "flat": false, + "flies": false, "eyes": null }'; - public function __construct(public int $id, public string $name, public ?bool $flat, #[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Schema\Fish\Eyes] public Schema\RedEyes|Schema\BlueEyes|Schema\GreenEyes|Schema\YellowEyes|Schema\BlackEyes $eyes) + public function __construct(public int $id, public string $name, public bool $flat, public bool $flies, #[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Single\Schema\Fish\Eyes] public Schema\RedEyes|Schema\BlueEyes|Schema\GreenEyes|Schema\YellowEyes|Schema\BlackEyes $eyes) { } } diff --git a/tests/app/src/Schema/GreenEyes.php b/tests/app/src/Schema/GreenEyes.php index 04bbdf8..74a52dc 100644 --- a/tests/app/src/Schema/GreenEyes.php +++ b/tests/app/src/Schema/GreenEyes.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class GreenEyes +final readonly class GreenEyes implements Contract\GreenEyes { public const SCHEMA_JSON = '{ "required": [ @@ -36,7 +37,7 @@ public const SCHEMA_DESCRIPTION = ''; public const SCHEMA_EXAMPLE_DATA = '{ "count": 5, - "type": "feral" + "type": "hulk" }'; public function __construct(public int $count, public string $type) { diff --git a/tests/app/src/Schema/Legs.php b/tests/app/src/Schema/Legs.php index a855747..1e1b324 100644 --- a/tests/app/src/Schema/Legs.php +++ b/tests/app/src/Schema/Legs.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Legs +final readonly class Legs implements Contract\Legs { public const SCHEMA_JSON = '{ "required": [ diff --git a/tests/app/src/Schema/Operations/Pets/Grouped/By/Type/Response/ApplicationJson/Ok.php b/tests/app/src/Schema/Operations/Pets/Grouped/By/Type/Response/ApplicationJson/Ok.php new file mode 100644 index 0000000..6eef153 --- /dev/null +++ b/tests/app/src/Schema/Operations/Pets/Grouped/By/Type/Response/ApplicationJson/Ok.php @@ -0,0 +1,331 @@ + $pets + */ + public function __construct(#[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Multiple\Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok\Pets] public array $pets) + { + } +} diff --git a/tests/app/src/Schema/Operations/Pets/Kinds/Walking/Response/ApplicationJson/Ok.php b/tests/app/src/Schema/Operations/Pets/Kinds/Walking/Response/ApplicationJson/Ok.php new file mode 100644 index 0000000..676632f --- /dev/null +++ b/tests/app/src/Schema/Operations/Pets/Kinds/Walking/Response/ApplicationJson/Ok.php @@ -0,0 +1,283 @@ + $eyes + */ + public function __construct(public int $id, public string $name, public array $legs, #[\ApiClients\Client\PetStore\Internal\Attribute\CastUnionToType\Multiple\Schema\Spider\Eyes] public array $eyes) + { + } +} diff --git a/tests/app/src/Schema/Tails.php b/tests/app/src/Schema/Tails.php index 1bd4f78..459318c 100644 --- a/tests/app/src/Schema/Tails.php +++ b/tests/app/src/Schema/Tails.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Tails +final readonly class Tails implements Contract\Tails { public const SCHEMA_JSON = '{ "required": [ diff --git a/tests/app/src/Schema/Wings.php b/tests/app/src/Schema/Wings.php index 433928a..ad9af16 100644 --- a/tests/app/src/Schema/Wings.php +++ b/tests/app/src/Schema/Wings.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class Wings +final readonly class Wings implements Contract\Wings { public const SCHEMA_JSON = '{ "required": [ diff --git a/tests/app/src/Schema/YellowEyes.php b/tests/app/src/Schema/YellowEyes.php index d7445ed..d3c5356 100644 --- a/tests/app/src/Schema/YellowEyes.php +++ b/tests/app/src/Schema/YellowEyes.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Client\PetStore\Schema; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -10,7 +11,7 @@ use League\OpenAPIValidation; use React\Http; use ApiClients\Contracts; -final readonly class YellowEyes +final readonly class YellowEyes implements Contract\YellowEyes { public const SCHEMA_JSON = '{ "required": [ diff --git a/tests/app/tests/Internal/Operation/Pets/CreateTest.php b/tests/app/tests/Internal/Operation/Pets/CreateTest.php index b79cbbb..cfac119 100644 --- a/tests/app/tests/Internal/Operation/Pets/CreateTest.php +++ b/tests/app/tests/Internal/Operation/Pets/CreateTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/tests/Internal/Operation/Pets/Grouped/By/TypeTest.php b/tests/app/tests/Internal/Operation/Pets/Grouped/By/TypeTest.php new file mode 100644 index 0000000..bc013ee --- /dev/null +++ b/tests/app/tests/Internal/Operation/Pets/Grouped/By/TypeTest.php @@ -0,0 +1,87 @@ + 'application/json'), json_encode(json_decode(Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/groupedByType?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->call(Internal\Operation\Pets\Grouped\By\Type::OPERATION_MATCH, (static function (array $data) : array { + $data['per_page'] = 8; + $data['page'] = 1; + return $data; + })(array())); + } + /** + * @test + */ + public function operations_httpCode_200_responseContentType_application_json_zero() + { + $response = new \React\Http\Message\Response(200, array('Content-Type' => 'application/json'), json_encode(json_decode(Schema\Operations\Pets\Grouped\By\Type\Response\ApplicationJson\Ok::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/groupedByType?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->operations()->petsGroupedBy()->type(8, 1); + } + /** + * @test + */ + public function call_httpCode_default_responseContentType_application_json_zero() + { + $response = new \React\Http\Message\Response(999, array('Content-Type' => 'application/json'), json_encode(json_decode(Schema\Error::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/groupedByType?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->call(Internal\Operation\Pets\Grouped\By\Type::OPERATION_MATCH, (static function (array $data) : array { + $data['per_page'] = 8; + $data['page'] = 1; + return $data; + })(array())); + } + /** + * @test + */ + public function operations_httpCode_default_responseContentType_application_json_zero() + { + $response = new \React\Http\Message\Response(999, array('Content-Type' => 'application/json'), json_encode(json_decode(Schema\Error::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/groupedByType?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->operations()->petsGroupedBy()->type(8, 1); + } +} diff --git a/tests/app/tests/Internal/Operation/Pets/Kinds/WalkingListingTest.php b/tests/app/tests/Internal/Operation/Pets/Kinds/WalkingListingTest.php new file mode 100644 index 0000000..e43ab64 --- /dev/null +++ b/tests/app/tests/Internal/Operation/Pets/Kinds/WalkingListingTest.php @@ -0,0 +1,57 @@ + 'application/json'), json_encode(json_decode(Schema\Error::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/kinds/walking?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->call(Internal\Operation\Pets\Kinds\WalkingListing::OPERATION_MATCH, (static function (array $data) : array { + $data['per_page'] = 8; + $data['page'] = 1; + return $data; + })(array())); + foreach ($result as $item) { + } + } + /** + * @test + */ + public function operations_httpCode_default_responseContentType_application_json_zero() + { + $response = new \React\Http\Message\Response(999, array('Content-Type' => 'application/json'), json_encode(json_decode(Schema\Error::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/kinds/walking?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->operations()->petsKinds()->walkingListing(8, 1); + foreach ($result as $item) { + } + } +} diff --git a/tests/app/tests/Internal/Operation/Pets/Kinds/WalkingTest.php b/tests/app/tests/Internal/Operation/Pets/Kinds/WalkingTest.php new file mode 100644 index 0000000..54a7dce --- /dev/null +++ b/tests/app/tests/Internal/Operation/Pets/Kinds/WalkingTest.php @@ -0,0 +1,53 @@ + 'application/json'), json_encode(json_decode(Schema\Error::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/kinds/walking?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->call(Internal\Operation\Pets\Kinds\Walking::OPERATION_MATCH, (static function (array $data) : array { + $data['per_page'] = 8; + $data['page'] = 1; + return $data; + })(array())); + } + /** + * @test + */ + public function operations_httpCode_default_responseContentType_application_json_zero() + { + $response = new \React\Http\Message\Response(999, array('Content-Type' => 'application/json'), json_encode(json_decode(Schema\Error::SCHEMA_EXAMPLE_DATA, true))); + $auth = $this->prophesize(\ApiClients\Contracts\HTTP\Headers\AuthenticationInterface::class); + $auth->authHeader(\Prophecy\Argument::any())->willReturn('Bearer beer')->shouldBeCalled(); + $browser = $this->prophesize(\React\Http\Browser::class); + $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); + $browser->request('GET', '/pets/kinds/walking?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); + $result = $client->operations()->petsKinds()->walking(8, 1); + } +} diff --git a/tests/app/tests/Internal/Operation/Pets/ListListingTest.php b/tests/app/tests/Internal/Operation/Pets/ListListingTest.php index ab5d3f3..22eeed4 100644 --- a/tests/app/tests/Internal/Operation/Pets/ListListingTest.php +++ b/tests/app/tests/Internal/Operation/Pets/ListListingTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function call_httpCode_default_responseContentType_application_json_zero( $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->call(Internal\Operation\Pets\ListListing::OPERATION_MATCH, (static function (array $data) : array { $data['per_page'] = 8; @@ -47,7 +48,7 @@ public function operations_httpCode_default_responseContentType_application_json $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->operations()->pets()->listListing(8, 1); foreach ($result as $item) { diff --git a/tests/app/tests/Internal/Operation/Pets/List_/GatosListingTest.php b/tests/app/tests/Internal/Operation/Pets/List_/GatosListingTest.php index 596f0f9..a100ada 100644 --- a/tests/app/tests/Internal/Operation/Pets/List_/GatosListingTest.php +++ b/tests/app/tests/Internal/Operation/Pets/List_/GatosListingTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets\List_; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function call_httpCode_default_responseContentType_application_json_zero( $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/gatos?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/gatos?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->call(Internal\Operation\Pets\List_\GatosListing::OPERATION_MATCH, (static function (array $data) : array { $data['per_page'] = 8; @@ -47,7 +48,7 @@ public function operations_httpCode_default_responseContentType_application_json $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/gatos?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/gatos?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->operations()->petsList()->gatosListing(8, 1); foreach ($result as $item) { diff --git a/tests/app/tests/Internal/Operation/Pets/List_/GatosTest.php b/tests/app/tests/Internal/Operation/Pets/List_/GatosTest.php index d4474ac..ff4d3a5 100644 --- a/tests/app/tests/Internal/Operation/Pets/List_/GatosTest.php +++ b/tests/app/tests/Internal/Operation/Pets/List_/GatosTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets\List_; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function call_httpCode_default_responseContentType_application_json_zero( $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/gatos?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/gatos?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->call(Internal\Operation\Pets\List_\Gatos::OPERATION_MATCH, (static function (array $data) : array { $data['per_page'] = 8; @@ -45,7 +46,7 @@ public function operations_httpCode_default_responseContentType_application_json $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/gatos?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/gatos?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->operations()->petsList()->gatos(8, 1); } diff --git a/tests/app/tests/Internal/Operation/Pets/List_Test.php b/tests/app/tests/Internal/Operation/Pets/List_Test.php index 3096e09..03ebd92 100644 --- a/tests/app/tests/Internal/Operation/Pets/List_Test.php +++ b/tests/app/tests/Internal/Operation/Pets/List_Test.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function call_httpCode_default_responseContentType_application_json_zero( $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->call(Internal\Operation\Pets\List_::OPERATION_MATCH, (static function (array $data) : array { $data['per_page'] = 8; @@ -45,7 +46,7 @@ public function operations_httpCode_default_responseContentType_application_json $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->operations()->pets()->list(8, 1); } diff --git a/tests/app/tests/Internal/Operation/Pets/NamesListingTest.php b/tests/app/tests/Internal/Operation/Pets/NamesListingTest.php index c866f1b..ad41249 100644 --- a/tests/app/tests/Internal/Operation/Pets/NamesListingTest.php +++ b/tests/app/tests/Internal/Operation/Pets/NamesListingTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function call_httpCode_default_responseContentType_application_json_zero( $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/names?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/names?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->call(Internal\Operation\Pets\NamesListing::OPERATION_MATCH, (static function (array $data) : array { $data['per_page'] = 8; @@ -47,7 +48,7 @@ public function operations_httpCode_default_responseContentType_application_json $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/names?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/names?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->operations()->pets()->namesListing(8, 1); foreach ($result as $item) { diff --git a/tests/app/tests/Internal/Operation/Pets/NamesTest.php b/tests/app/tests/Internal/Operation/Pets/NamesTest.php index f775ed3..97ad505 100644 --- a/tests/app/tests/Internal/Operation/Pets/NamesTest.php +++ b/tests/app/tests/Internal/Operation/Pets/NamesTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation\Pets; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -26,7 +27,7 @@ public function call_httpCode_default_responseContentType_application_json_zero( $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/names?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/names?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->call(Internal\Operation\Pets\Names::OPERATION_MATCH, (static function (array $data) : array { $data['per_page'] = 8; @@ -45,7 +46,7 @@ public function operations_httpCode_default_responseContentType_application_json $browser = $this->prophesize(\React\Http\Browser::class); $browser->withBase(\Prophecy\Argument::any())->willReturn($browser->reveal()); $browser->withFollowRedirects(\Prophecy\Argument::any())->willReturn($browser->reveal()); - $browser->request('GET', '/pets/names?per_page=8&page=1', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); + $browser->request('GET', '/pets/names?page=1&per_page=8', \Prophecy\Argument::type('array'), \Prophecy\Argument::any())->willReturn(\React\Promise\resolve($response))->shouldBeCalled(); $client = new \ApiClients\Client\PetStore\Client($auth->reveal(), $browser->reveal()); $result = $client->operations()->pets()->names(8, 1); } diff --git a/tests/app/tests/Internal/Operation/ShowPetByIdTest.php b/tests/app/tests/Internal/Operation/ShowPetByIdTest.php index d3c4b09..8b0424d 100644 --- a/tests/app/tests/Internal/Operation/ShowPetByIdTest.php +++ b/tests/app/tests/Internal/Operation/ShowPetByIdTest.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Internal\Operation; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; diff --git a/tests/app/tests/Types/ClientCallReturnTypes.php b/tests/app/tests/Types/ClientCallReturnTypes.php index de23e7f..42123a0 100644 --- a/tests/app/tests/Types/ClientCallReturnTypes.php +++ b/tests/app/tests/Types/ClientCallReturnTypes.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace ApiClients\Tests\Client\PetStore\Types; +use ApiClients\Client\PetStore\Contract; use ApiClients\Client\PetStore\Error as ErrorSchemas; use ApiClients\Client\PetStore\Internal; use ApiClients\Client\PetStore\Operation; @@ -17,11 +18,14 @@ function authHeader() : string return 'Saturn V'; } }, new \React\Http\Browser()); -\PHPStan\Testing\assertType('iterable', $client->call('GET /pets')); -\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets')); +\PHPStan\Testing\assertType('iterable', $client->call('GET /pets')); +\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets')); \PHPStan\Testing\assertType('\\ApiClients\\Tools\\OpenApiClient\\Utils\\Response\\WithoutBody', $client->call('POST /pets')); -\PHPStan\Testing\assertType('iterable', $client->call('GET /pets/gatos')); -\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets/gatos')); -\PHPStan\Testing\assertType('iterable', $client->call('GET /pets/names')); -\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets/names')); -\PHPStan\Testing\assertType('Schema\\Cat|Schema\\Dog|Schema\\Bird|Schema\\Fish', $client->call('GET /pets/{petId}')); +\PHPStan\Testing\assertType('iterable', $client->call('GET /pets/gatos')); +\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets/gatos')); +\PHPStan\Testing\assertType('iterable', $client->call('GET /pets/kinds/walking')); +\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets/kinds/walking')); +\PHPStan\Testing\assertType('Schema\\Operations\\Pets\\Grouped\\By\\Type\\Response\\ApplicationJson\\Ok', $client->call('GET /pets/groupedByType')); +\PHPStan\Testing\assertType('iterable', $client->call('GET /pets/names')); +\PHPStan\Testing\assertType('iterable', $client->call('LIST /pets/names')); +\PHPStan\Testing\assertType('Schema\\Cat|Schema\\Dog|Schema\\Bird|Schema\\Fish|Schema\\Spider', $client->call('GET /pets/{petId}')); diff --git a/tests/petstore.yaml b/tests/petstore.yaml index 19faf9e..15ff563 100644 --- a/tests/petstore.yaml +++ b/tests/petstore.yaml @@ -34,6 +34,7 @@ paths: - $ref: "#/components/schemas/Dog" - $ref: "#/components/schemas/Bird" - $ref: "#/components/schemas/Fish" + - $ref: "#/components/schemas/Spider" default: description: unexpected error content: @@ -55,6 +56,7 @@ paths: - $ref: "#/components/schemas/Dog" - $ref: "#/components/schemas/Bird" - $ref: "#/components/schemas/Fish" + - $ref: "#/components/schemas/Spider" responses: 201: description: Null response @@ -93,6 +95,76 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" + /pets/kinds/walking: + get: + summary: List all cats + operationId: pets/kinds/walking + tags: + - cats + parameters: + - "$ref": "#/components/parameters/per-page" + - "$ref": "#/components/parameters/page" + responses: + 200: + description: A paged array of cats + headers: + x-next: + description: A link to the next page of cats + schema: + type: string + content: + application/json: + schema: + type: array + items: + type: object + oneOf: + - $ref: "#/components/schemas/Cat" + - $ref: "#/components/schemas/Dog" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/groupedByType: + get: + summary: List all pets + operationId: pets/grouped/by/type + tags: + - cats + - dogs + parameters: + - "$ref": "#/components/parameters/per-page" + - "$ref": "#/components/parameters/page" + responses: + 200: + description: A shitty design choice to test a specific situation in the generator + headers: + x-next: + description: A link to the next page of cats + schema: + type: string + content: + application/json: + schema: + type: object + required: + - pets + properties: + pets: + type: array + items: + type: object + oneOf: + - $ref: "#/components/schemas/Cat" + - $ref: "#/components/schemas/Dog" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /pets/names: get: summary: List all pet names @@ -139,6 +211,7 @@ paths: - $ref: "#/components/schemas/Dog" - $ref: "#/components/schemas/Bird" - $ref: "#/components/schemas/Fish" + - $ref: "#/components/schemas/Spider" default: description: unexpected error content: @@ -152,6 +225,8 @@ components: required: - id - name + - indoor + - features - eyes properties: id: @@ -164,18 +239,23 @@ components: features: type: object eyes: - type: object - oneOf: - - $ref: "#/components/schemas/RedEyes" - - $ref: "#/components/schemas/BlueEyes" - - $ref: "#/components/schemas/GreenEyes" - - $ref: "#/components/schemas/YellowEyes" - - $ref: "#/components/schemas/BlackEyes" + type: array + minItems: 2 + maxItems: 2 + items: + type: object + anyOf: + - $ref: "#/components/schemas/RedEyes" + - $ref: "#/components/schemas/BlueEyes" + - $ref: "#/components/schemas/GreenEyes" + - $ref: "#/components/schemas/YellowEyes" + - $ref: "#/components/schemas/BlackEyes" Dog: type: object required: - id - name + - good-boy - eyes properties: id: @@ -186,18 +266,54 @@ components: good-boy: type: bool eyes: - type: object - oneOf: - - $ref: "#/components/schemas/RedEyes" - - $ref: "#/components/schemas/BlueEyes" - - $ref: "#/components/schemas/GreenEyes" - - $ref: "#/components/schemas/YellowEyes" - - $ref: "#/components/schemas/BlackEyes" + type: array + minItems: 2 + maxItems: 2 + items: + type: object + oneOf: + - $ref: "#/components/schemas/RedEyes" + - $ref: "#/components/schemas/BlueEyes" + - $ref: "#/components/schemas/GreenEyes" + - $ref: "#/components/schemas/YellowEyes" + - $ref: "#/components/schemas/BlackEyes" + Spider: + type: object + required: + - id + - name + - eyes + - legs + properties: + id: + type: integer + format: int64 + name: + type: string + legs: + type: array + minItems: 8 + maxItems: 8 + items: + type: string + eyes: + type: array + minItems: 8 + maxItems: 8 + items: + type: object + oneOf: + - $ref: "#/components/schemas/RedEyes" + - $ref: "#/components/schemas/BlueEyes" + - $ref: "#/components/schemas/GreenEyes" + - $ref: "#/components/schemas/YellowEyes" + - $ref: "#/components/schemas/BlackEyes" Bird: type: object required: - id - name + - flies - eyes properties: id: @@ -220,6 +336,8 @@ components: required: - id - name + - flat + - flies - eyes properties: id: @@ -229,6 +347,8 @@ components: type: string flat: type: bool + flies: + type: bool eyes: type: object oneOf: