Skip to content

Commit

Permalink
ensure backward compatibility of ignoreDefaultRoutes method (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko authored Feb 3, 2025
1 parent 91ded13 commit 9482d3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Scramble.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Scramble
*/
public static array $enforceSchemaRules = [];

public static bool $defaultRoutesIgnored = false;

/**
* Extensions registered using programmatic API.
*
Expand All @@ -47,7 +49,7 @@ class Scramble
*/
public static function ignoreDefaultRoutes(): void
{
static::configure()->expose(false);
static::$defaultRoutesIgnored = true;
}

public static function registerApi(string $name, array $config = []): GeneratorConfig
Expand Down
4 changes: 4 additions & 0 deletions src/ScrambleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public function bootingPackage()
$transformers->append($operationExtensions);
});

if (Scramble::$defaultRoutesIgnored) {
Scramble::configure()->expose(false);
}

$this->app->booted(function (Application $app) {
Scramble::configure()
->withParametersExtractors(function (ParametersExtractors $parametersExtractors) {
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ protected function tearDown(): void

Scramble::$tagResolver = null;
Scramble::$enforceSchemaRules = [];
Scramble::$defaultRoutesIgnored = false;

parent::tearDown();
}
Expand Down

0 comments on commit 9482d3c

Please sign in to comment.