Closed
Description
I'm using a third-party API which has this securityScheme
:
components:
securitySchemes:
jwtAuth:
type: apiKey
in: header
name: Auth
and this path (redacted as it is not my API):
/auth/login:
put:
security:
- {}
tags:
- Authentication
requestBody:
content:
.
.
.
responses:
'200':
headers:
auth:
schema:
type: string
description:
format: jwt
The generated code for this API is:
@attr.s(auto_attribs=True)
class AuthenticatedClient(Client):
"""A Client which has been authenticated for use on secured endpoints"""
token: str
def get_headers(self) -> Dict[str, str]:
"""Get headers to be used in authenticated endpoints"""
return {"Authorization": f"Bearer {self.token}", **self.headers}
The desired code is:
@attr.s(auto_attribs=True)
class AuthenticatedClient(Client):
"""A Client which has been authenticated for use on secured endpoints"""
token: str
def get_headers(self) -> Dict[str, str]:
"""Get headers to be used in authenticated endpoints"""
return {"Auth": self.token, **self.headers}