Swagger-php: Swagger doctrine/zircote bearer Authorization code

Created on 21 Feb 2017  路  5Comments  路  Source: zircote/swagger-php

i'm trying to use swagger zircote to create the swagger ui json. for my application i use JWT and i need the following swagger code in my json:

"securityDefinitions": {
    "Bearer": {
      "in": "header",
      "type": "accessToken",
      "name": "Authorization"
    }
},

But i dont know how i create that code with swaggers zircote. I've tried the following code:

 * @SWG\Swagger(
 *     schemes={"https"},
 *     @SWG\SecurityDefinitions(
 *         bearer={
 *             type="apiKey",
 *             name="Authorization",
 *             in="header"
 *         }
 *     ),

but this results in the following error:

The annotation "@Swagger\Annotations\SecurityDefinitions" in .\index.php on line 2 does not exist, or could not be auto-loaded.

Can someone help me, i cant find any good documentation about this, maybe its to specific, but i hope someone can help me.

Thanks!

https://stackoverflow.com/questions/42362488/swagger-doctrine-zircote-bearer-authorization-code

Most helpful comment

You're almost there:

 * @SWG\Swagger(
 *     schemes={"https"},
 *     @SWG\SecurityScheme(
 *         securityDefinition="Bearer",
 *         type="apiKey",
 *         name="Authorization",
 *         in="header"
 *     ),

I had to lookup the annotation too, the list is here
I named the annotation annotation SecurityScheme as that is the name that is used in the spec SecurityDefinition might have been a better name.

All 5 comments

You're almost there:

 * @SWG\Swagger(
 *     schemes={"https"},
 *     @SWG\SecurityScheme(
 *         securityDefinition="Bearer",
 *         type="apiKey",
 *         name="Authorization",
 *         in="header"
 *     ),

I had to lookup the annotation too, the list is here
I named the annotation annotation SecurityScheme as that is the name that is used in the spec SecurityDefinition might have been a better name.

Did you get this working with the Swagger UI? Using Swagger UI, it builds the Auth form, but when I enter a key, and perform an API request it does not append the headder

I'm having the exact same issue as @mattbryson

Swagger-PHP is only responsible for generating the swagger.json

Report issues to swagger-ui when the json is correct, but the client doesn't behave as expected.

@bfanger hi,

Is it possible to do that automatic authentication? After one (login) API point return token without manually adding to authorise section?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aqlx86 picture aqlx86  路  3Comments

jfiala picture jfiala  路  5Comments

beeradmoore picture beeradmoore  路  5Comments

DerManoMann picture DerManoMann  路  3Comments

mostafaabdelbaset picture mostafaabdelbaset  路  5Comments