update after stop build
All checks were successful
All checks were successful
This commit is contained in:
13
vendor/knuckleswtf/scribe/src/Config/AuthIn.php
vendored
Normal file
13
vendor/knuckleswtf/scribe/src/Config/AuthIn.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Knuckles\Scribe\Config;
|
||||
|
||||
enum AuthIn: string
|
||||
{
|
||||
case BEARER = 'bearer';
|
||||
case BASIC = 'basic';
|
||||
case HEADER = 'header';
|
||||
case QUERY = 'query';
|
||||
case BODY = 'body';
|
||||
case QUERY_OR_BODY = 'query_or_body';
|
||||
}
|
||||
52
vendor/knuckleswtf/scribe/src/Config/Defaults.php
vendored
Normal file
52
vendor/knuckleswtf/scribe/src/Config/Defaults.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Knuckles\Scribe\Config;
|
||||
|
||||
use Knuckles\Scribe\Extracting\Strategies;
|
||||
|
||||
class Defaults
|
||||
{
|
||||
public const METADATA_STRATEGIES = [
|
||||
Strategies\Metadata\GetFromDocBlocks::class,
|
||||
Strategies\Metadata\GetFromMetadataAttributes::class,
|
||||
];
|
||||
|
||||
public const HEADERS_STRATEGIES = [
|
||||
Strategies\Headers\GetFromHeaderAttribute::class,
|
||||
Strategies\Headers\GetFromHeaderTag::class,
|
||||
];
|
||||
|
||||
public const URL_PARAMETERS_STRATEGIES = [
|
||||
Strategies\UrlParameters\GetFromLaravelAPI::class,
|
||||
Strategies\UrlParameters\GetFromUrlParamAttribute::class,
|
||||
Strategies\UrlParameters\GetFromUrlParamTag::class,
|
||||
];
|
||||
|
||||
public const QUERY_PARAMETERS_STRATEGIES = [
|
||||
Strategies\QueryParameters\GetFromFormRequest::class,
|
||||
Strategies\QueryParameters\GetFromInlineValidator::class,
|
||||
Strategies\QueryParameters\GetFromQueryParamAttribute::class,
|
||||
Strategies\QueryParameters\GetFromQueryParamTag::class,
|
||||
];
|
||||
|
||||
public const BODY_PARAMETERS_STRATEGIES = [
|
||||
Strategies\BodyParameters\GetFromFormRequest::class,
|
||||
Strategies\BodyParameters\GetFromInlineValidator::class,
|
||||
Strategies\BodyParameters\GetFromBodyParamAttribute::class,
|
||||
Strategies\BodyParameters\GetFromBodyParamTag::class,
|
||||
];
|
||||
|
||||
public const RESPONSES_STRATEGIES = [
|
||||
Strategies\Responses\UseResponseAttributes::class,
|
||||
Strategies\Responses\UseTransformerTags::class,
|
||||
Strategies\Responses\UseApiResourceTags::class,
|
||||
Strategies\Responses\UseResponseTag::class,
|
||||
Strategies\Responses\UseResponseFileTag::class,
|
||||
Strategies\Responses\ResponseCalls::class,
|
||||
];
|
||||
|
||||
public const RESPONSE_FIELDS_STRATEGIES = [
|
||||
Strategies\ResponseFields\GetFromResponseFieldAttribute::class,
|
||||
Strategies\ResponseFields\GetFromResponseFieldTag::class,
|
||||
];
|
||||
}
|
||||
58
vendor/knuckleswtf/scribe/src/Config/helpers.php
vendored
Normal file
58
vendor/knuckleswtf/scribe/src/Config/helpers.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Knuckles\Scribe\Config;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
// Strategies can be:
|
||||
// 1. (Original) A class name, e.g. Strategies\Responses\ResponseCalls::class
|
||||
// 2. (New) A tuple containing the class name (or "static_data") as item 1, and its settings array as item 2
|
||||
|
||||
/**
|
||||
* Remove one or more strategies from a list of strategies.
|
||||
*/
|
||||
function removeStrategies(array $strategiesList, array $strategyNamesToRemove): array
|
||||
{
|
||||
$correspondingStrategies = Arr::where($strategiesList, function ($strategy) use ($strategyNamesToRemove) {
|
||||
$strategyName = is_string($strategy) ? $strategy : $strategy[0];
|
||||
|
||||
return in_array($strategyName, $strategyNamesToRemove);
|
||||
});
|
||||
|
||||
foreach ($correspondingStrategies as $key => $value) {
|
||||
unset($strategiesList[$key]);
|
||||
}
|
||||
|
||||
return $strategiesList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/replace a strategy and its settings in a list of strategies.
|
||||
* This method generates a tuple containing [strategyName, settingsArray],
|
||||
* and adds or replaces the strategy entry in the list.
|
||||
*
|
||||
* @param array $configurationTuple Tuple of [strategyName, settingsArray].
|
||||
* By default, all strategies support the "only" and "except" setting to apply them to specific endpoints.
|
||||
* You can easily create the tuple by calling Strategy::wrapWithSettings(only: [], except: []).
|
||||
*/
|
||||
function configureStrategy(array $strategiesList, array $configurationTuple): array
|
||||
{
|
||||
$strategyFound = false;
|
||||
$strategiesList = array_map(function ($strategy) use ($configurationTuple, &$strategyFound) {
|
||||
$strategyName = is_string($strategy) ? $strategy : $strategy[0];
|
||||
if ($strategyName === $configurationTuple[0]) {
|
||||
$strategyFound = true;
|
||||
|
||||
return $configurationTuple;
|
||||
}
|
||||
|
||||
return $strategy;
|
||||
}, $strategiesList);
|
||||
|
||||
// If strategy wasn't in there, add it.
|
||||
if (! $strategyFound) {
|
||||
$strategiesList = array_merge($strategiesList, [$configurationTuple]);
|
||||
}
|
||||
|
||||
return $strategiesList;
|
||||
}
|
||||
Reference in New Issue
Block a user