I’ve using l5-swagger in Laravel and I need sanctum authorization with bearer token
But when I set bearer token and try an API that used this token, the swagger return this error:
“darkaonline/l5-swagger”: “^8.5”,
“zircote/swagger-php”: “^4.8”
TypeError: P.forEach is not a function
at applySecurities (build-request.js:106:12)
at buildRequest (build-request.js:16:9)
at Object.execute_buildRequest [as buildRequest] (index.js:249:11)
at actions.js:454:24
at index.js:174:16
at redux.mjs:331:12
at wrap-actions.js:33:10
at Object.newAction (system.js:175:26)
at Object.executeRequest (system.js:487:17)
at actions.js:501:22
(anonymous) @ system.js:490
(anonymous) @ actions.js:501
(anonymous) @ index.js:174
(anonymous) @ redux.mjs:331
(anonymous) @ wrap-actions.js:9
newAction @ system.js:175
(anonymous) @ system.js:487
handleValidationResultPass @ execute.jsx:66
handleValidationResult @ execute.jsx:80
onClick @ execute.jsx:90
....
This is my l5-swagger config
'securityDefinitions' => [
'securitySchemes' => [
/*
* Examples of Security schemes
*/
'sanctum' => [ // Unique name of security
'securityDefinition' => "Bearer",
'type' => 'apiKey', // Valid values are "basic", "apiKey" or "oauth2".
'description' => 'Enter token in format (Bearer <token>)',
'name' => 'Authorization', // The name of the header or query parameter to be used.
'in' => 'header', // The location of the API key. Valid values are "query" or "header".
],
],
'security' => [
/*
* Examples of Securities
*/
[
'sanctum' => []
/*
'oauth2_security_example' => [
'read',
'write'
],
'passport' => []
*/
],
],
],
This is OA annotation that I’ve used in my controller:
/**
* @OAPost(
* path="/manager/user/add",
* tags={"Manager"},
* security={"sanctum": {}},
* @OAResponse(response="200", description="An example resource",@OAJsonContent()),
* @OAResponse(response="401", description="unAutosize",@OAJsonContent()),
* @OARequestBody(
* required=true,
* @OAJsonContent(
* required={"name", "email","password"},
* @OAProperty(
* property="name",
* type="string",
* ),
* @OAProperty(
* property="email",
* type="string",
* ),
* @OAProperty(
* property="password",
* type="string"
* )
* )))
* )
*/