From e8267c912890cd993be7d9b70a462e967366df48 Mon Sep 17 00:00:00 2001 From: TZK- <7808125+TZK-@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:09:23 +0100 Subject: [PATCH 1/7] fix: RequestValidateFacade Variable could not be converted to string (#925) Co-authored-by: Thibault GRANADA --- .../ValidationRulesFinders/RequestValidateFacade.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Extracting/Shared/ValidationRulesFinders/RequestValidateFacade.php b/src/Extracting/Shared/ValidationRulesFinders/RequestValidateFacade.php index 07aaeb7e..80b199da 100644 --- a/src/Extracting/Shared/ValidationRulesFinders/RequestValidateFacade.php +++ b/src/Extracting/Shared/ValidationRulesFinders/RequestValidateFacade.php @@ -25,13 +25,14 @@ public static function find(Node $node) if ( $expr instanceof Node\Expr\StaticCall - && in_array((string) $expr->class, ['Request', \Illuminate\Support\Facades\Request::class]) + && $expr->class instanceof Node\Name + && in_array($expr->class->name, ['Request', \Illuminate\Support\Facades\Request::class]) ) { - if ($expr->name->name == "validate") { + if ($expr->name->name === "validate") { return $expr->args[0]->value; } - if ($expr->name->name == "validateWithBag") { + if ($expr->name->name === "validateWithBag") { return $expr->args[1]->value; } } From f00f6bffa72fb48a1fca861102e1e805a0f05eb1 Mon Sep 17 00:00:00 2001 From: Majid Alaeinia <11965368+majidalaeinia@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:12:51 +0330 Subject: [PATCH 2/7] Update scribe.php (#928) --- config/scribe.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/scribe.php b/config/scribe.php index 66dbb831..b2e0c036 100644 --- a/config/scribe.php +++ b/config/scribe.php @@ -106,7 +106,7 @@ // Options: query, body, basic, bearer, header (for custom header) 'in' => 'bearer', - // The name of the auth parameter (eg token, key, apiKey) or header (eg Authorization, Api-Key). + // The name of the auth parameter (e.g. token, key, apiKey) or header (e.g. Authorization, Api-Key). 'name' => 'key', // The value of the parameter to be used by Scribe to authenticate response calls. @@ -189,7 +189,7 @@ 'last_updated' => 'Last updated: {date:F j, Y}', 'examples' => [ - // Set this to any number (eg. 1234) to generate the same example values for parameters on each run, + // Set this to any number (e.g. 1234) to generate the same example values for parameters on each run, 'faker_seed' => null, // With API resources and transformers, Scribe tries to generate example models to use in your API responses. From fcc0f5ce84cccccb84b488306670eeee86f56de9 Mon Sep 17 00:00:00 2001 From: Mark Walet Date: Mon, 30 Dec 2024 17:46:31 +0100 Subject: [PATCH 3/7] Resolve PHP 8.4 deprecations (#929) --- src/Config/Extracting.php | 8 ++++---- src/Config/Output.php | 6 +++--- src/Extracting/ApiDetails.php | 2 +- src/Extracting/Extractor.php | 2 +- src/Extracting/ParamHelpers.php | 2 +- src/Extracting/Shared/UrlParamsNormalizer.php | 2 +- src/Extracting/Strategies/Metadata/GetFromDocBlocks.php | 2 +- .../Strategies/UrlParameters/GetFromLaravelAPI.php | 2 +- src/Tools/BladeMarkdownEngine.php | 2 +- src/Tools/PathConfig.php | 4 ++-- src/Writing/HtmlWriter.php | 2 +- src/Writing/OpenAPISpecWriter.php | 6 +++--- src/Writing/PostmanCollectionWriter.php | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Config/Extracting.php b/src/Config/Extracting.php index f291e9d7..c34551ae 100644 --- a/src/Config/Extracting.php +++ b/src/Config/Extracting.php @@ -23,7 +23,7 @@ public static function auth( bool $default = false, string $in = 'bearer', string $name = 'key', - string $useValue = null, + ?string $useValue = null, string $placeholder = '{YOUR_AUTH_KEY}', string $extraInfo = '' ): array @@ -48,10 +48,10 @@ public static function with( Routes $routes, string $defaultGroup = 'Endpoints', array $databaseConnectionsToTransact = [], - int $fakerSeedForExamples = null, + ?int $fakerSeedForExamples = null, array $dataSourcesForExampleModels = ['factoryCreate', 'factoryMake', 'databaseFirst'], - string $routeMatcher = null, - string $fractalSerializer = null, + ?string $routeMatcher = null, + ?string $fractalSerializer = null, array $auth = [], array $strategies = [], ): Extracting diff --git a/src/Config/Output.php b/src/Config/Output.php index e90b53b1..2b6b08bc 100644 --- a/src/Config/Output.php +++ b/src/Config/Output.php @@ -6,7 +6,7 @@ class Output { public static function with( string $theme = 'default', - string $title = null, + ?string $title = null, string $description = '', array $baseUrls = [], array $exampleLanguages = ['bash', 'javascript'], @@ -45,7 +45,7 @@ public function __construct( public static function laravelType( bool $addRoutes = true, string $docsUrl = '/docs', - string $assetsDirectory = null, + ?string $assetsDirectory = null, array $middleware = [], ): array { @@ -93,7 +93,7 @@ public static function openApi( public static function tryItOut( bool $enabled = true, - string $baseUrl = null, + ?string $baseUrl = null, bool $useCsrf = false, string $csrfUrl = '/sanctum/csrf-cookie', ): array diff --git a/src/Extracting/ApiDetails.php b/src/Extracting/ApiDetails.php index 52055f38..95a03291 100644 --- a/src/Extracting/ApiDetails.php +++ b/src/Extracting/ApiDetails.php @@ -26,7 +26,7 @@ class ApiDetails public function __construct( PathConfig $paths, - DocumentationConfig $config = null, + ?DocumentationConfig $config = null, bool $preserveUserChanges = true ) { $this->markdownOutputPath = $paths->intermediateOutputPath(); //.scribe by default diff --git a/src/Extracting/Extractor.php b/src/Extracting/Extractor.php index fd56d469..79cc4ee1 100644 --- a/src/Extracting/Extractor.php +++ b/src/Extracting/Extractor.php @@ -25,7 +25,7 @@ class Extractor private static ?Route $routeBeingProcessed = null; - public function __construct(DocumentationConfig $config = null) + public function __construct(?DocumentationConfig $config = null) { // If no config is injected, pull from global $this->config = $config ?: new DocumentationConfig(config('scribe')); diff --git a/src/Extracting/ParamHelpers.php b/src/Extracting/ParamHelpers.php index 9f76adbc..377847cd 100644 --- a/src/Extracting/ParamHelpers.php +++ b/src/Extracting/ParamHelpers.php @@ -103,7 +103,7 @@ protected function getDummyValueGenerator(string $type, array $hints = []): \Clo return $fakeFactoriesByType[$baseType] ?? $fakeFactoriesByType['string']; } - private function getDummyDataGeneratorBetween(string $type, $min, $max = 90, string $fieldName = null): \Closure + private function getDummyDataGeneratorBetween(string $type, $min, $max = 90, ?string $fieldName = null): \Closure { $hints = [ 'name' => $fieldName, diff --git a/src/Extracting/Shared/UrlParamsNormalizer.php b/src/Extracting/Shared/UrlParamsNormalizer.php index bfb21b0d..332b969d 100644 --- a/src/Extracting/Shared/UrlParamsNormalizer.php +++ b/src/Extracting/Shared/UrlParamsNormalizer.php @@ -145,7 +145,7 @@ public static function getTypeHintedEnums(ReflectionFunctionAbstract $method): a * @return string|null */ protected static function getRouteKeyForUrlParam( - Route $route, string $paramName, array $typeHintedEloquentModels = [], string $default = null + Route $route, string $paramName, array $typeHintedEloquentModels = [], ?string $default = null ): ?string { if ($binding = self::getInlineRouteKey($route, $paramName)) { diff --git a/src/Extracting/Strategies/Metadata/GetFromDocBlocks.php b/src/Extracting/Strategies/Metadata/GetFromDocBlocks.php index 67a85b10..2641d6b1 100644 --- a/src/Extracting/Strategies/Metadata/GetFromDocBlocks.php +++ b/src/Extracting/Strategies/Metadata/GetFromDocBlocks.php @@ -36,7 +36,7 @@ public function getMetadataFromDocBlock(DocBlock $methodDocBlock, DocBlock $clas return $metadata; } - protected function getAuthStatusFromDocBlock(DocBlock $methodDocBlock, DocBlock $classDocBlock = null): ?bool + protected function getAuthStatusFromDocBlock(DocBlock $methodDocBlock, ?DocBlock $classDocBlock = null): ?bool { foreach ($methodDocBlock->getTags() as $tag) { if (strtolower($tag->getName()) === 'authenticated') { diff --git a/src/Extracting/Strategies/UrlParameters/GetFromLaravelAPI.php b/src/Extracting/Strategies/UrlParameters/GetFromLaravelAPI.php index 7a40ed6e..3e33a4b4 100644 --- a/src/Extracting/Strategies/UrlParameters/GetFromLaravelAPI.php +++ b/src/Extracting/Strategies/UrlParameters/GetFromLaravelAPI.php @@ -186,7 +186,7 @@ protected function setTypesAndExamplesForOthers(array $parameters, ExtractedEndp * * @return string|null */ - protected function getNameOfUrlThing(string $url, string $paramName, string $alternateParamName = null): ?string + protected function getNameOfUrlThing(string $url, string $paramName, ?string $alternateParamName = null): ?string { $parts = explode("/", $url); if (count($parts) === 1) return null; // URL was "/{thing}" diff --git a/src/Tools/BladeMarkdownEngine.php b/src/Tools/BladeMarkdownEngine.php index f3263f64..0ccdac8a 100644 --- a/src/Tools/BladeMarkdownEngine.php +++ b/src/Tools/BladeMarkdownEngine.php @@ -12,7 +12,7 @@ class BladeMarkdownEngine extends CompilerEngine { private Parsedown $markdown; - public function __construct(CompilerInterface $compiler, Filesystem $files = null) + public function __construct(CompilerInterface $compiler, ?Filesystem $files = null) { parent::__construct($compiler, $files ?: new Filesystem); $this->markdown = Parsedown::instance(); diff --git a/src/Tools/PathConfig.php b/src/Tools/PathConfig.php index a1161104..aeff4350 100644 --- a/src/Tools/PathConfig.php +++ b/src/Tools/PathConfig.php @@ -19,7 +19,7 @@ public function __construct( } } - public function outputPath(string $resolvePath = null, string $separator = '/'): string + public function outputPath(?string $resolvePath = null, string $separator = '/'): string { if (is_null($resolvePath)) { return $this->configName; @@ -36,7 +36,7 @@ public function configFileName(): string /** * The directory where Scribe writes its intermediate output (default is . ie .scribe) */ - public function intermediateOutputPath(string $resolvePath = null, string $separator = '/'): string + public function intermediateOutputPath(?string $resolvePath = null, string $separator = '/'): string { if (is_null($resolvePath)) { return $this->scribeDir; diff --git a/src/Writing/HtmlWriter.php b/src/Writing/HtmlWriter.php index 78fa4c82..6d9ba53f 100644 --- a/src/Writing/HtmlWriter.php +++ b/src/Writing/HtmlWriter.php @@ -22,7 +22,7 @@ class HtmlWriter protected string $assetPathPrefix; protected MarkdownParser $markdownParser; - public function __construct(DocumentationConfig $config = null) + public function __construct(?DocumentationConfig $config = null) { $this->config = $config ?: new DocumentationConfig(config('scribe', [])); $this->markdownParser = new MarkdownParser(); diff --git a/src/Writing/OpenAPISpecWriter.php b/src/Writing/OpenAPISpecWriter.php index 41e1fb46..31dc2ea3 100644 --- a/src/Writing/OpenAPISpecWriter.php +++ b/src/Writing/OpenAPISpecWriter.php @@ -22,7 +22,7 @@ class OpenAPISpecWriter private DocumentationConfig $config; - public function __construct(DocumentationConfig $config = null) + public function __construct(?DocumentationConfig $config = null) { $this->config = $config ?: new DocumentationConfig(config('scribe', [])); } @@ -400,7 +400,7 @@ protected function generateResponseContentSpec(?string $responseContent, OutputE ], 'example' => $decoded, ], - ], + ], ]; case 'object': @@ -661,7 +661,7 @@ public function filterRequiredFields(OutputEndpointData $endpoint, array $proper return $required; } - + /* * Set the description for the schema. If the field has a description, it is set in the schema. */ diff --git a/src/Writing/PostmanCollectionWriter.php b/src/Writing/PostmanCollectionWriter.php index 29be7765..cf748d38 100644 --- a/src/Writing/PostmanCollectionWriter.php +++ b/src/Writing/PostmanCollectionWriter.php @@ -21,7 +21,7 @@ class PostmanCollectionWriter protected string $baseUrl; - public function __construct(DocumentationConfig $config = null) + public function __construct(?DocumentationConfig $config = null) { $this->config = $config ?: new DocumentationConfig(config('scribe', [])); $this->baseUrl = $this->config->get('base_url') ?: config('app.url'); From 38a0b631d16c64069e5ed6012f67588b8f574561 Mon Sep 17 00:00:00 2001 From: KriKrus <115444441+KriKrus@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:00:40 +0100 Subject: [PATCH 4/7] fix: Collection with formdata malformed for API (#926) --- src/Writing/PostmanCollectionWriter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Writing/PostmanCollectionWriter.php b/src/Writing/PostmanCollectionWriter.php index cf748d38..d6ac612f 100644 --- a/src/Writing/PostmanCollectionWriter.php +++ b/src/Writing/PostmanCollectionWriter.php @@ -222,7 +222,7 @@ protected function getFormDataParams(array $paramsKeyValue, ?string $key = null, if (!is_array($value)) { $body[] = [ 'key' => $index, - 'value' => $value, + 'value' => (string) $value, 'type' => 'text', 'description' => $paramsFullDetails[$index]->description ?? '', ]; From cb4c2e552fdae4fd2306e12bba60d5de38a9e4ad Mon Sep 17 00:00:00 2001 From: Shalvah Date: Tue, 31 Dec 2024 15:13:50 +0100 Subject: [PATCH 5/7] 4.39.0 --- CHANGELOG.md | 14 ++++++++++++++ src/Scribe.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83da7e6f..2e75081c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Removed +# 4.39.0 (31 December 2024) +## Added +- Correctly list required fields for nested objects in OpenAPI spec [#905](https://github.com/knuckleswtf/scribe/pull/905) +- Cursor pagination support in API responses (`cursorPaginate`/`paginate=cursor`) [#917](https://github.com/knuckleswtf/scribe/pull/917) + +## Fixed +- Fixed type error when attempting to parse Request::validate [#925](https://github.com/knuckleswtf/scribe/pull/925) +- Don't render empty responses as string "null" in OpenAPI spec [#911](https://github.com/knuckleswtf/scribe/pull/911) +- Correctly replace `apiDescriptionUrl`for `external_laravel` (Eelements theme) [#906](https://github.com/knuckleswtf/scribe/pull/906) +- Cast form data values to strings in Postman collection [#926](https://github.com/knuckleswtf/scribe/pull/926) + +## Modified +- Resolve PHP 8.4 deprecations [#929](https://github.com/knuckleswtf/scribe/pull/929) + # 4.38.0 (18 October 2024) ## Fixed - Elements theme: Fix display of boolean examples [#887](https://github.com/knuckleswtf/scribe/pull/887) diff --git a/src/Scribe.php b/src/Scribe.php index a0e5f839..80259669 100644 --- a/src/Scribe.php +++ b/src/Scribe.php @@ -9,7 +9,7 @@ class Scribe { - public const VERSION = '4.38.0'; + public const VERSION = '4.39.0'; /** * Specify a callback that will be executed just before a response call is made From c5a3d957e918ffcb6a26f86e27a6a2a7a16ca4bb Mon Sep 17 00:00:00 2001 From: Shalvah Date: Sat, 18 Jan 2025 19:57:04 +0100 Subject: [PATCH 6/7] Drop PHP 8.0 --- .github/workflows/lint.yml | 4 ++-- .github/workflows/run-tests.yml | 7 ++++--- composer.json | 2 +- composer.lowest.json | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fb700a61..513aeb3d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,7 @@ name: Lint on: push: - branches: [master] + branches: [master, vNext] pull_request: jobs: @@ -11,7 +11,7 @@ jobs: strategy: matrix: php: - - 8.1 + - 8.3 name: Lint code (PHP ${{ matrix.php }}) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index af680832..936d4915 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -2,7 +2,7 @@ name: Tests on: push: - branches: [master, v4] + branches: [master, vNext] pull_request: jobs: @@ -11,13 +11,14 @@ jobs: strategy: matrix: php: + - '8.4' + - '8.3' - '8.2' - '8.1' - - '8.0' deps: - highest include: - - {php: '8.0', deps: lowest} + - {php: '8.1', deps: lowest} - {php: '8.1', deps: dingo} name: Tests (PHP ${{ matrix.php }} - ${{ matrix.deps }}) diff --git a/composer.json b/composer.json index 82526415..28be4671 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "ext-fileinfo": "*", "ext-json": "*", "ext-pdo": "*", diff --git a/composer.lowest.json b/composer.lowest.json index e54e31b2..d6b7b56f 100644 --- a/composer.lowest.json +++ b/composer.lowest.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "ext-fileinfo": "*", "ext-json": "*", "ext-pdo": "*", From d5e61ebbe70700a59ecabdd85883718bdd072350 Mon Sep 17 00:00:00 2001 From: Shalvah Date: Sat, 18 Jan 2025 21:16:34 +0100 Subject: [PATCH 7/7] Drop PHP 8.0 --- src/Attributes/GenericParam.php | 6 ++--- src/Extracting/ParsesValidationRules.php | 4 ++-- .../Strategies/GetFromInlineValidatorBase.php | 3 +-- tests/Fixtures/TestController.php | 5 ---- tests/Fixtures/collection.json | 18 +++++++------- tests/Fixtures/openapi.yaml | 24 +++++++++---------- tests/GenerateDocumentation/OutputTest.php | 12 ++++++++++ .../Strategies/GetFromInlineValidatorTest.php | 4 ---- .../UrlParameters/GetFromLaravelAPITest.php | 9 ++++--- tests/Unit/ValidationRuleParsingTest.php | 8 ++----- 10 files changed, 44 insertions(+), 49 deletions(-) diff --git a/src/Attributes/GenericParam.php b/src/Attributes/GenericParam.php index 21dd83a1..5adfcee1 100644 --- a/src/Attributes/GenericParam.php +++ b/src/Attributes/GenericParam.php @@ -41,12 +41,10 @@ protected function getEnumValues(): array return $this->enum; } - if (function_exists('enum_exists') && enum_exists($this->enum) - && method_exists($this->enum, 'tryFrom') - ) { + if (enum_exists($this->enum) && method_exists($this->enum, 'tryFrom')) { return array_map( // $case->value only exists on BackedEnums, not UnitEnums - // method_exists($enum, 'tryFrom') implies $enum instanceof BackedEnum + // method_exists($enum, 'tryFrom') implies the enum is a BackedEnum // @phpstan-ignore-next-line fn ($case) => $case->value, $this->enum::cases() diff --git a/src/Extracting/ParsesValidationRules.php b/src/Extracting/ParsesValidationRules.php index 58a2c9ad..80d49dcd 100644 --- a/src/Extracting/ParsesValidationRules.php +++ b/src/Extracting/ParsesValidationRules.php @@ -205,7 +205,7 @@ protected function parseRule($rule, array &$parameterData, bool $independentOnly return true; } - if (function_exists('enum_exists') && $rule instanceof \Illuminate\Validation\Rules\Enum) { + if ($rule instanceof \Illuminate\Validation\Rules\Enum) { $reflection = new \ReflectionClass($rule); $property = $reflection->getProperty('type'); $property->setAccessible(true); @@ -213,7 +213,7 @@ protected function parseRule($rule, array &$parameterData, bool $independentOnly if (enum_exists($type) && method_exists($type, 'tryFrom')) { // $case->value only exists on BackedEnums, not UnitEnums - // method_exists($enum, 'tryFrom') implies $enum instanceof BackedEnum + // method_exists($enum, 'tryFrom') implies the enum is a BackedEnum // @phpstan-ignore-next-line $cases = array_map(fn ($case) => $case->value, $type::cases()); $parameterData['type'] = gettype($cases[0]); diff --git a/src/Extracting/Strategies/GetFromInlineValidatorBase.php b/src/Extracting/Strategies/GetFromInlineValidatorBase.php index 6995a15c..108637bf 100644 --- a/src/Extracting/Strategies/GetFromInlineValidatorBase.php +++ b/src/Extracting/Strategies/GetFromInlineValidatorBase.php @@ -84,12 +84,11 @@ public function lookForInlineValidationRules(ClassMethod $methodAst): array } // Try to extract Enum rule else if ( - function_exists('enum_exists') && ($enum = $this->extractEnumClassFromArrayItem($arrayItem)) && enum_exists($enum) && method_exists($enum, 'tryFrom') ) { // $case->value only exists on BackedEnums, not UnitEnums - // method_exists($enum, 'tryFrom') implies $enum instanceof BackedEnum + // method_exists($enum, 'tryFrom') implies the enum is a BackedEnum // @phpstan-ignore-next-line $rulesList[] = 'in:' . implode(',', array_map(fn ($case) => $case->value, $enum::cases())); } diff --git a/tests/Fixtures/TestController.php b/tests/Fixtures/TestController.php index ac40b28c..68b95089 100644 --- a/tests/Fixtures/TestController.php +++ b/tests/Fixtures/TestController.php @@ -704,19 +704,14 @@ public function withEnumRule(Request $request) ]); } - /** - * Can only run on PHP 8.1 public function withInjectedEnumAndModel(Category $category, TestUser $user) { return null; } - */ } -/** enum Category: string { case Fruits = 'fruits'; case People = 'people'; } -*/ diff --git a/tests/Fixtures/collection.json b/tests/Fixtures/collection.json index ccf3d58d..ba25c929 100644 --- a/tests/Fixtures/collection.json +++ b/tests/Fixtures/collection.json @@ -128,7 +128,7 @@ ], "body": { "mode": "raw", - "raw": "{\"user_id\":9,\"room_id\":\"consequatur\",\"forever\":false,\"another_one\":11613.31890586,\"yet_another_param\":{\"name\":\"consequatur\"},\"even_more_param\":[11613.31890586],\"book\":{\"name\":\"consequatur\",\"author_id\":17,\"pages_count\":17},\"ids\":[17],\"users\":[{\"first_name\":\"John\",\"last_name\":\"Doe\"}]}" + "raw": "{\"user_id\":9,\"room_id\":\"architecto\",\"forever\":false,\"another_one\":4326.41688,\"yet_another_param\":{\"name\":\"architecto\"},\"even_more_param\":[4326.41688],\"book\":{\"name\":\"architecto\",\"author_id\":16,\"pages_count\":16},\"ids\":[16],\"users\":[{\"first_name\":\"John\",\"last_name\":\"Doe\"}]}" }, "description": "", "auth": { @@ -146,7 +146,7 @@ "query": [ { "key": "location_id", - "value": "consequatur", + "value": "architecto", "description": "The id of the location.", "disabled": false }, @@ -164,7 +164,7 @@ }, { "key": "filters", - "value": "consequatur", + "value": "architecto", "description": "The filters.", "disabled": false }, @@ -175,7 +175,7 @@ "disabled": false } ], - "raw": "{{baseUrl}}/api/withQueryParameters?location_id=consequatur&user_id=me&page=4&filters=consequatur&url_encoded=%2B+%5B%5D%26%3D" + "raw": "{{baseUrl}}/api/withQueryParameters?location_id=architecto&user_id=me&page=4&filters=architecto&url_encoded=%2B+%5B%5D%26%3D" }, "method": "GET", "header": [ @@ -268,12 +268,12 @@ "query": [ { "key": "something", - "value": "consequatur", + "value": "architecto", "description": "", "disabled": false } ], - "raw": "{{baseUrl}}/api/echoesUrlParameters/:param/:param2/:param3/:param4?something=consequatur", + "raw": "{{baseUrl}}/api/echoesUrlParameters/:param/:param2/:param3/:param4?something=architecto", "variable": [ { "id": "param", @@ -284,13 +284,13 @@ { "id": "param2", "key": "param2", - "value": "consequatur", + "value": "architecto", "description": "" }, { "id": "param3", "key": "param3", - "value": "consequatur", + "value": "architecto", "description": "" }, { @@ -331,7 +331,7 @@ } ], "code": 200, - "body": "{\"param\":\"4\",\"param2\":\"consequatur\",\"param3\":\"consequatur\",\"param4\":null}", + "body": "{\"param\":\"4\",\"param2\":\"architecto\",\"param3\":\"architecto\",\"param4\":null}", "name": null } ] diff --git a/tests/Fixtures/openapi.yaml b/tests/Fixtures/openapi.yaml index 97e8b4ca..3505556f 100644 --- a/tests/Fixtures/openapi.yaml +++ b/tests/Fixtures/openapi.yaml @@ -91,12 +91,12 @@ paths: in: query name: location_id description: 'The id of the location.' - example: consequatur + example: architecto required: true schema: type: string description: 'The id of the location.' - example: consequatur + example: architecto nullable: false - in: query @@ -124,12 +124,12 @@ paths: in: query name: filters description: 'The filters.' - example: consequatur + example: architecto required: false schema: type: string description: 'The filters.' - example: consequatur + example: architecto nullable: false - in: query @@ -193,12 +193,12 @@ paths: in: query name: something description: '' - example: consequatur + example: architecto required: false schema: type: string description: '' - example: consequatur + example: architecto nullable: false - in: header @@ -216,13 +216,13 @@ paths: type: object example: param: '4' - param2: consequatur - param3: consequatur + param2: architecto + param3: architecto param4: null properties: param: { type: string, example: '4' } - param2: { type: string, example: consequatur } - param3: { type: string, example: consequatur } + param2: { type: string, example: architecto } + param3: { type: string, example: architecto } param4: { type: string, example: null } tags: - Other😎 @@ -243,7 +243,7 @@ paths: required: true schema: type: string - example: consequatur + example: architecto - in: path name: param3 @@ -257,7 +257,7 @@ paths: value: '' present: summary: 'When the value is present' - value: consequatur + value: architecto - in: path name: param4 diff --git a/tests/GenerateDocumentation/OutputTest.php b/tests/GenerateDocumentation/OutputTest.php index 448bf8a5..08ee5ccf 100644 --- a/tests/GenerateDocumentation/OutputTest.php +++ b/tests/GenerateDocumentation/OutputTest.php @@ -171,6 +171,12 @@ private function generate_with_paths($configName, $intermediateOutputDirectory = /** @test */ public function generated_postman_collection_file_is_correct() { + if (phpversion() < 8.3) { + // See https://github.com/FakerPHP/Faker/issues/694 + $this->markTestSkipped('Faker seeding changed in PHP 8.3'); + return; + } + RouteFacade::post('/api/withBodyParametersAsArray', [TestController::class, 'withBodyParametersAsArray']); RouteFacade::post('/api/withFormDataParams', [TestController::class, 'withFormDataParams']); RouteFacade::post('/api/withBodyParameters', [TestController::class, 'withBodyParameters']); @@ -205,6 +211,12 @@ public function generated_postman_collection_file_is_correct() /** @test */ public function generated_openapi_spec_file_is_correct() { + if (phpversion() < 8.3) { + // See https://github.com/FakerPHP/Faker/issues/694 + $this->markTestSkipped('Faker seeding changed in PHP 8.3'); + return; + } + RouteFacade::post('/api/withBodyParametersAsArray', [TestController::class, 'withBodyParametersAsArray']); RouteFacade::post('/api/withFormDataParams', [TestController::class, 'withFormDataParams']); RouteFacade::get('/api/withResponseTag', [TestController::class, 'withResponseTag']); diff --git a/tests/Strategies/GetFromInlineValidatorTest.php b/tests/Strategies/GetFromInlineValidatorTest.php index 16a23910..972a1a07 100644 --- a/tests/Strategies/GetFromInlineValidatorTest.php +++ b/tests/Strategies/GetFromInlineValidatorTest.php @@ -232,10 +232,6 @@ public function respects_query_params_comment() /** @test */ public function can_fetch_inline_enum_rules() { - if (phpversion() < 8.1) { - $this->markTestSkipped('Enums are only supported in PHP 8.1 or later'); - } - $endpoint = $this->endpoint(function (ExtractedEndpointData $e) { $e->method = new \ReflectionMethod(TestController::class, 'withEnumRule'); }); diff --git a/tests/Strategies/UrlParameters/GetFromLaravelAPITest.php b/tests/Strategies/UrlParameters/GetFromLaravelAPITest.php index a80b1012..62329342 100644 --- a/tests/Strategies/UrlParameters/GetFromLaravelAPITest.php +++ b/tests/Strategies/UrlParameters/GetFromLaravelAPITest.php @@ -22,9 +22,8 @@ class GetFromLaravelAPITest extends BaseLaravelTest /** @test */ public function can_infer_type_from_model_binding() { - $endpoint = $this->endpointForRoute("users/{id}", TestController::class, 'withInjectedModel'); - // Can only run on PHP 8.1 - // $endpoint = $this->endpointForRoute("categories/{category}/users/{id}/", TestController::class, 'withInjectedEnumAndModel'); + // $endpoint = $this->endpointForRoute("users/{id}", TestController::class, 'withInjectedModel'); + $endpoint = $this->endpointForRoute("categories/{category}/users/{id}/", TestController::class, 'withInjectedEnumAndModel'); $results = $this->fetch($endpoint); $this->assertArraySubset([ @@ -32,14 +31,14 @@ public function can_infer_type_from_model_binding() "description" => "The ID of the user.", "required" => true, "type" => "integer", - ], $results['id']);/* + ], $results['id']); $this->assertArraySubset([ "name" => "category", "description" => "The category.", "required" => true, "type" => "string", "example" => \Knuckles\Scribe\Tests\Fixtures\Category::cases()[0]->value, - ], $results['category']);*/ + ], $results['category']); $this->assertIsInt($results['id']['example']); } diff --git a/tests/Unit/ValidationRuleParsingTest.php b/tests/Unit/ValidationRuleParsingTest.php index 0bfda300..aa46d9be 100644 --- a/tests/Unit/ValidationRuleParsingTest.php +++ b/tests/Unit/ValidationRuleParsingTest.php @@ -45,7 +45,7 @@ public function can_parse_supported_rules(array $ruleset, array $customInfo, arr Schema::create('users', function ($table) { $table->id(); }); - + $results = $this->strategy->parse($ruleset, $customInfo); $parameterName = array_keys($ruleset)[0]; @@ -57,7 +57,7 @@ public function can_parse_supported_rules(array $ruleset, array $customInfo, arr // Validate that the generated values actually pass validation (for rules where we can generate some data) if (is_string($ruleset[$parameterName]) && str_contains($ruleset[$parameterName], "exists")) return; - + $exampleData = [$parameterName => $results[$parameterName]['example']]; $validator = Validator::make($exampleData, $ruleset); try { @@ -552,10 +552,6 @@ public function can_parse_custom_rule_classes() /** @test */ public function can_parse_enum_rules() { - if (phpversion() < 8.1) { - $this->markTestSkipped('Enums are only supported in PHP 8.1 or later'); - } - $results = $this->strategy->parse([ 'enum' => [ 'required',