Skip to content

Instantly share code, notes, and snippets.

@tech-codivores
Created November 25, 2024 14:11
Show Gist options
  • Save tech-codivores/98e38a63a88adbaf842ab07963bad907 to your computer and use it in GitHub Desktop.
Save tech-codivores/98e38a63a88adbaf842ab07963bad907 to your computer and use it in GitHub Desktop.
Laravel Scramble - Request Header
<?php
namespace ...;
use Dedoc\Scramble\Extensions\OperationExtension;
use Dedoc\Scramble\Support\Generator\Operation;
use Dedoc\Scramble\Support\Generator\Parameter;
use Dedoc\Scramble\Support\Generator\Schema;
use Dedoc\Scramble\Support\Generator\Types\StringType;
use Dedoc\Scramble\Support\RouteInfo;
class RequestHeaderOperationExtension extends OperationExtension
{
public function handle(Operation $operation, RouteInfo $routeInfo): void
{
// Add 'X-Custom-Header' Request header.
$operation->addParameters([
Parameter::make('X-Custom-Header', 'header')
->setSchema(Schema::fromType(new StringType))
->description('Custom Header used for ...')
->required(true),
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment