VaporOpenAPI icon indicating copy to clipboard operation
VaporOpenAPI copied to clipboard

Authorization header in RouteContext

Open alexandrehsaad opened this issue 1 year ago • 1 comments

How can I define the Authorization header? The following doesn't work:

internal struct MyRouteContext: RouteContext {
    internal let success: ResponseContext<String> = .init { (response) in
        response.status = .ok
        response.version = .http1_1
        response.headers = [
            HTTPHeaders.Name.authorization.description: "Bearer",
            HTTPHeaders.Name.contentType.description: HTTPMediaType.json.serialize()
        ]
    }
    ...
}

alexandrehsaad avatar Mar 01 '24 00:03 alexandrehsaad

This question is related to https://github.com/mattpolzin/VaporOpenAPI/issues/11. In short, this is not supported yet. It would be a nice enhancement. I think ideally the authorization information would be encoded as an OpenAPI security scheme even (above and beyond being a header).

mattpolzin avatar Mar 01 '24 17:03 mattpolzin