Skip to content

Commit

Permalink
Merge branch 'vNext' into openapi-generators
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah authored Jan 18, 2025
2 parents 9e4dcf6 + 9e20117 commit 7fd97db
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 854 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- highest
include:
- {php: '8.1', deps: lowest}
- {php: '8.1', deps: dingo}

name: Tests (PHP ${{ matrix.php }} - ${{ matrix.deps }})

Expand All @@ -36,23 +35,15 @@ jobs:
if: ${{ matrix.deps == 'highest' }}
run: composer update

- name: Install dependencies (Dingo)
if: ${{ matrix.deps == 'dingo' }}
run: COMPOSER=composer.dingo.json composer update --prefer-stable

- name: Install dependencies (lowest)
if: ${{ matrix.deps == 'lowest' }}
run: COMPOSER=composer.lowest.json composer update --prefer-stable


- name: Execute tests (Laravel/Lumen)
- name: Execute tests (Laravel)
run: composer test-ci
if: ${{ matrix.deps == 'highest' }}

- name: Execute tests (Lowest)
run: COMPOSER=composer.lowest.json composer test-ci
if: ${{ matrix.deps == 'lowest' }}

- name: Execute tests (Dingo)
run: COMPOSER=composer.dingo.json composer test-ci
if: ${{ matrix.deps == 'dingo' }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.DS_Store
composer.lock
composer.dingo.lock
.php_cs.cache
/vendor/
public/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

> [v4 is out now](https://scribe.knuckles.wtf/blog/laravel-v4)! Featuring subgroups, easier sorting, and an automated upgrade command.
Scribe helps you generate API documentation for humans from your Laravel/Lumen/[Dingo](https://github.com/dingo/api) codebase. See a live example at [demo.scribe.knuckles.wtf](https://demo.scribe.knuckles.wtf).
Scribe helps you generate API documentation for humans from your Laravel codebase. See a live example at [demo.scribe.knuckles.wtf](https://demo.scribe.knuckles.wtf).

## Features
- Useful output:
Expand Down
98 changes: 0 additions & 98 deletions composer.dingo.json

This file was deleted.

12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"keywords": [
"API",
"documentation",
"laravel",
"dingo"
"laravel"
],
"homepage": "http://github.com/knuckleswtf/scribe",
"authors": [
Expand Down Expand Up @@ -39,7 +38,6 @@
"brianium/paratest": "^6.0",
"dms/phpunit-arraysubset-asserts": "^0.4",
"laravel/legacy-factories": "^1.3.0",
"laravel/lumen-framework": "^8.0|^9.0|^10.0",
"league/fractal": "^0.20",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^6.0|^7.0|^8.0",
Expand All @@ -62,10 +60,10 @@
},
"scripts": {
"lint": "phpstan analyse -c ./phpstan.neon src camel --memory-limit 1G",
"test": "pest --stop-on-failure --exclude-group dingo --colors",
"test-ci": "pest --exclude-group dingo --coverage --min=80",
"test-parallel": "paratest -p16 --stop-on-failure --exclude-group dingo",
"test-parallel-ci": "paratest -p16 --exclude-group dingo"
"test": "pest --stop-on-failure --colors",
"test-ci": "pest --coverage --min=80",
"test-parallel": "paratest -p16 --stop-on-failure",
"test-parallel-ci": "paratest -p16"
},
"extra": {
"laravel": {
Expand Down
12 changes: 5 additions & 7 deletions composer.lowest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"keywords": [
"API",
"documentation",
"laravel",
"dingo"
"laravel"
],
"homepage": "http://github.com/knuckleswtf/scribe",
"authors": [
Expand Down Expand Up @@ -40,7 +39,6 @@
"brianium/paratest": "^6.0",
"dms/phpunit-arraysubset-asserts": "^0.2.0",
"laravel/legacy-factories": "^1.3.0",
"laravel/lumen-framework": "^8.0",
"league/fractal": "^0.19.0",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^6.0|^7.0",
Expand All @@ -63,10 +61,10 @@
},
"scripts": {
"lint": "phpstan analyse -c ./phpstan.neon src camel --memory-limit 1G",
"test": "phpunit --stop-on-failure --exclude-group dingo",
"test-ci": "pest --exclude-group dingo --coverage --min=80",
"test-parallel": "paratest -p16 --stop-on-failure --exclude-group dingo",
"test-parallel-ci": "paratest -p16 --exclude-group dingo"
"test": "phpunit --stop-on-failure",
"test-ci": "pest --coverage --min=80",
"test-parallel": "paratest -p16 --stop-on-failure",
"test-parallel-ci": "paratest -p16"
},
"extra": {
"laravel": {
Expand Down
3 changes: 0 additions & 3 deletions config/scribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

// Match only routes whose domains match this pattern (use * as a wildcard to match any characters). Example: 'api.*'.
'domains' => ['*'],

// [Dingo router only] Match only routes registered under this version. Wildcards are NOT supported.
'versions' => ['v1'],
],

// Include these routes even if they did not match the rules above.
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ parameters:
reportUnmatchedIgnoredErrors: true
inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
- '#Call to an undefined method Illuminate\\Routing\\Route::versions\(\).#'
- '#Call to an undefined method ReflectionType::getName\(\).#'
- '#.+Dingo.+#'
- '#Call to an undefined method Illuminate\\Contracts\\Filesystem\\Filesystem::path\(\)#'
- '#Call to an undefined method Illuminate\\Contracts\\Foundation\\Application::forgetInstance\(\)#'
- '#Access to an undefined property Illuminate\\Support\\HigherOrderCollectionProxy#'
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GenerateDocumentation extends Command
{--scribe-dir= : Specify the directory where Scribe stores its intermediate output and cache. Defaults to `.<config_file>`}
";

protected $description = 'Generate API documentation from your Laravel/Dingo routes.';
protected $description = 'Generate API documentation from your Laravel routes.';

protected DocumentationConfig $docConfig;

Expand Down
1 change: 0 additions & 1 deletion src/Config/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static function urlParametersStrategies(): StrategyListWrapper
{
return new StrategyListWrapper([
Strategies\UrlParameters\GetFromLaravelAPI::class,
Strategies\UrlParameters\GetFromLumenAPI::class,
Strategies\UrlParameters\GetFromUrlParamAttribute::class,
Strategies\UrlParameters\GetFromUrlParamTag::class,
]);
Expand Down
2 changes: 0 additions & 2 deletions src/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Routes
public static function match(
array $prefixes = ['api/*'],
array $domains = ['*'],
array $dingoVersions = ['v1'],
array $alwaysInclude = [],
array $alwaysExclude = [],
): static
Expand All @@ -18,7 +17,6 @@ public static function match(
public function __construct(
public array $prefixes = [],
public array $domains = [],
public array $dingoVersions = [],
public array $alwaysInclude = [],
public array $alwaysExclude = []
)
Expand Down
1 change: 0 additions & 1 deletion src/Config/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ protected static function generateRoutesConfig(Routes $routesConfig): array
'match' => [
'prefixes' => $routesConfig->prefixes,
'domains' => $routesConfig->domains,
'versions' => $routesConfig->dingoVersions,
],
'include' => $routesConfig->alwaysInclude,
'exclude' => $routesConfig->alwaysExclude,
Expand Down
7 changes: 2 additions & 5 deletions src/Extracting/FindsFormRequestForMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Knuckles\Scribe\Extracting;

use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;
use Dingo\Api\Http\FormRequest as DingoFormRequest;
use Illuminate\Foundation\Http\FormRequest;
use ReflectionClass;
use ReflectionException;
use ReflectionFunctionAbstract;
Expand All @@ -27,9 +26,7 @@ protected function getFormRequestReflectionClass(ReflectionFunctionAbstract $met
continue;
}

if (
(class_exists(LaravelFormRequest::class) && $argumentClass->isSubclassOf(LaravelFormRequest::class))
|| (class_exists(DingoFormRequest::class) && $argumentClass->isSubclassOf(DingoFormRequest::class))) {
if ($argumentClass->isSubclassOf(FormRequest::class)) {
return $argumentClass;
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/Extracting/Strategies/GetFromFormRequestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use Illuminate\Routing\Route;
use Knuckles\Camel\Extraction\ExtractedEndpointData;
use Dingo\Api\Http\FormRequest as DingoFormRequest;
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;
use Illuminate\Foundation\Http\FormRequest;
use Knuckles\Scribe\Extracting\FindsFormRequestForMethod;
use Knuckles\Scribe\Extracting\ParsesValidationRules;
use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
Expand Down Expand Up @@ -43,7 +42,7 @@ public function getParametersFromFormRequest(ReflectionFunctionAbstract $method,
$formRequest = new $className;
}
// Set the route properly so it works for users who have code that checks for the route.
/** @var LaravelFormRequest|DingoFormRequest $formRequest */
/** @var FormRequest $formRequest */
$formRequest->setRouteResolver(function () use ($formRequest, $route) {
// Also need to bind the request to the route in case their code tries to inspect current request
return $route->bind($formRequest);
Expand All @@ -59,11 +58,9 @@ public function getParametersFromFormRequest(ReflectionFunctionAbstract $method,
}

/**
* @param LaravelFormRequest|DingoFormRequest $formRequest
*
* @return mixed
*/
protected function getRouteValidationRules($formRequest)
protected function getRouteValidationRules(FormRequest $formRequest)
{
if (method_exists($formRequest, 'validator')) {
$validationFactory = app(ValidationFactory::class);
Expand All @@ -77,10 +74,7 @@ protected function getRouteValidationRules($formRequest)
return [];
}

/**
* @param LaravelFormRequest|DingoFormRequest $formRequest
*/
protected function getCustomParameterData($formRequest)
protected function getCustomParameterData(FormRequest $formRequest)
{
if (method_exists($formRequest, $this->customParameterDataMethodName)) {
return call_user_func_array([$formRequest, $this->customParameterDataMethodName], []);
Expand Down
Loading

0 comments on commit 7fd97db

Please sign in to comment.