-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typescript] change accessToken name parameter to optional #3555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think this change is good, since the accessToken
function is called with a name
parameter in some cases, but not in all cases, see
openapi-generator/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache
Lines 83 to 100 in 3f7653a
{{#isBasicBearer}} | |
// http bearer authentication required | |
if (configuration && configuration.accessToken) { | |
const accessToken = typeof configuration.accessToken === 'function' | |
? configuration.accessToken() | |
: configuration.accessToken; | |
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken; | |
} | |
{{/isBasicBearer}} | |
{{#isOAuth}} | |
// oauth required | |
if (configuration && configuration.accessToken) { | |
const localVarAccessTokenValue = typeof configuration.accessToken === 'function' | |
? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) | |
: configuration.accessToken; | |
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; | |
} | |
{{/isOAuth}} |
@blackdev1l thanks for the PR. Could you please re-generate and commit the samples? |
hey @macjohnny thanks for the review, |
running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@blackdev1l thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553 |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master
,4.1.x
,5.0.x
. Default:master
.Description of the PR
fixes #2956
Iif you generate an axios API, you get a compilation error if tsconfig is set to 'strict'
because
configuration.accessToken()
requires name as paramater (not optional) but here in the code generated it callsconfiguration.accessToken()
without passing any parameters.I just made name an optional parameter.
I don't know if this is the right way to solve the issue, i would like to have some feedback about this.
@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07)