Bug Report Checklist
Description
When multiple security options are listed, the openapi specs specifies that they should be options :
A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request.
However the generated dart client function that adds security headers will attempt to add all of them instead of only one (see sample code below)
openapi-generator version
v 4.3.1
OpenAPI declaration file content or url
Here is the generated function responsible :
void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
authNames.forEach((authName) {
Authentication auth = _authentications[authName];
if (auth == null) throw ArgumentError("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams);
});
}
Here is the security object of the scheme in the spec
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
]
Command line used for generation
openapi-generator generate -v -i spec.json -g dart -o api-client/ --api-name-suffix myproject -c config.json
Steps to reproduce
- generate a dart client including a schema with multiple security options.
- try to make a related call with only one security option set (e.g only ApiKeyAuth)
- client throws an exception because "BearerAuth" is undefined
Suggest a fix
Provide an argument to select a preferred security options or when a valid authorization header is set, ignore the others.
Bug Report Checklist
Description
When multiple security options are listed, the openapi specs specifies that they should be options :
A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request.
However the generated dart client function that adds security headers will attempt to add all of them instead of only one (see sample code below)
openapi-generator version
v 4.3.1
OpenAPI declaration file content or url
Here is the generated function responsible :
Here is the security object of the scheme in the spec
Command line used for generation
openapi-generator generate -v -i spec.json -g dart -o api-client/ --api-name-suffix myproject -c config.json
Steps to reproduce
Suggest a fix
Provide an argument to select a preferred security options or when a valid authorization header is set, ignore the others.