swagger-php

Swagger PHP Security Schema referenced poorly


I'm using this SecuritySchema for definind a JWT security validation:

/*
     * @SWG\SecurityScheme(
     *   securityDefinition="JWT",
     *   type="apiKey",
     *   in="header",
     *   name="Authenticate"
     * ) */

And referencing it as:

/*
 * @SWG\Post(path="/ap/some/method",
 *   security={"JWT"={}},
 * )

and the specifications says I should reference as

{
...
"security":["JWT":[]]
...
}

but the truth is that Swagger-PHP generates:

{
...
"security":{"JWT":[]}
...
}

which shows as validation errors on Swagger UI.

The question is: How do I emulate the desired output to avoid Swagger UI AND Swagger PHP warnings/errors?


Solution

  • security":["JWT":[]] isn't valid json, but the specification does require an array for the security property.

    The desired output is:

    "security":[{"JWT":[]}]
    

    Which can be generated by:

    security={{"JWT":{}}}
    

    (note the additional brackets)