openapi-generator
openapi-generator copied to clipboard
[BUG] [Kotlin] Missing support for multiple apikey security
Description
With the following spec:
...
components:
securitySchemes:
Apikey:
type: apiKey
in: header
name: apikey
Loginkey:
type: apiKey
in: header
name: loginkey
...
Kotlin generator produces this:
import org.openapitools.client.auth.ApiKeyAuth
import org.openapitools.client.auth.ApiKeyAuth
References:
- https://swagger.io/docs/specification/authentication/api-keys/ (Multiple API Keys section)
- https://swagger.io/specification/
openapi-generator version
Tested both on 5.4.0 and 6.0.1.
I can confirm this, in general Authentication/Authorization is very buggy at the moment and should be redone from scratch, good code is not when there is nothing more to add, its when there is nothing more to delete
Same here. Did you manage to go around this issue in any way?
Same here. Did you manage to go around this issue in any way?
The trick is I did not. I've adjusted my backend to avoid this issue, so what I've got now is one securitySchemes entry (Apikey
) and second entry (Loginkey
) being passed via headers in each request. It's not perfect but does the job.
Hey, I also had this issue (retrofit library) and I managed to make a more general workaround by simply removing the imports and using fully-qualified names of classes. It's not super pretty, but it's generated code so it's not that big of a deal.
I don't think the imports can be fixed properly in the template otherwise, using the variables that are currently being passed... If there's a way to customise those, too, then maybe, but I couldn't find how.
This is the modified template file in case anyone is interested: template.zip