zircote / swagger-php

A php swagger annotation and parsing library
http://zircote.github.io/swagger-php/
Apache License 2.0
5.03k stars 933 forks source link

The Authorization specified in HeaderParameter cannot correctly try it out. #1581

Closed SwankyTigerYY closed 1 month ago

SwankyTigerYY commented 2 months ago

success

[OA\HeaderParameter(name: 'Authorization1', description: 'token', in: 'header', required: true, schema: new OA\Schema(type: 'string'))]

error

[OA\HeaderParameter(name: 'Authorization', description: 'token', in: 'header', required: true, schema: new OA\Schema(type: 'string'))]

Is Authorization a Keyword?why?

DerManoMann commented 2 months ago

Could you provide some details about the error you are seeing?

SwankyTigerYY commented 2 months ago

image image

DerManoMann commented 2 months ago

There is nothing special about it in swagger-php. However, OpenApi has special handling for security - https://spec.openapis.org/oas/v3.1.0.html#security-scheme-object.

Instead of configuring a raw header the OA\SecurityScheme annotation should be used, something like:

/**
 *     @OA\SecurityScheme(
 *         type="apiKey",
 *         securityScheme="http"
 *     )
 */

You might need to adjust type for your needs and perhaps also use other options depending.