Created
November 25, 2024 14:11
-
-
Save tech-codivores/98e38a63a88adbaf842ab07963bad907 to your computer and use it in GitHub Desktop.
Laravel Scramble - Request Header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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