-
-
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-fetch] Add initOverrides #10050
[typescript-fetch] Add initOverrides #10050
Conversation
You can now pass in fetch initOverrides per request. This change is mainly to add support for request cancellation (via AbortSignal).
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
@badsyntax thanks for your contribution! |
Thanks for the merge @macjohnny I have just noticed an issue though, see: openapi-generator/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts Line 139 in e2ff39d
I believe this should be a syntax error due to double commas (', ,') I will follow up with another PR very shortly to fix this. Apologies for not spotting this. |
@macjohnny I've submitted a fix here: #10101 |
In the 5.2.1 tag the runtime BaseAPI request looks like this: protected async request(context: RequestOpts, initOverrides?: RequestInit): Promise<Response> {
const { url, init } = this.createFetchParams(context, initOverrides);
const response = await this.fetchApi(url, init);
if (response.status >= 200 && response.status < 300) {
return response;
}
throw response;
} But when generated with this: It is the one from previous versions: protected async request(context: RequestOpts): Promise<Response> {
const { url, init } = this.createFetchParams(context);
const response = await this.fetchApi(url, init);
if (response.status >= 200 && response.status < 300) {
return response;
}
throw response;
} Looks like the version should be correct:
This makes it so that it doesn't work since it generates the initOverrides but the request is the old one without the new added parameter. Created the issue here |
@mikkovor Can you provide the Can you also confirm you're definitely not using a custom template for |
I'm not able to replicate with: npx @openapitools/openapi-generator-cli generate -i https://petstore.swagger.io/v2/swagger.json -g typescript-fetch -o ./src |
@mikkovor Can you also please delete the |
Yeah, looks like the script file had an innocent looking line at the |
@badsyntax I'm at 5.3.1 and the runtime fetch generates still like How do I make it |
@simPod try delete the existing output dir first, as the generator won't overwrite existing files |
@badsyntax I do it before each run of |
@simPod are you using a custom template perhaps? |
Oh you're so right. Thanks! |
Fixes #4851
You can now pass in fetch initOverrides per request.
This change is mainly to add support for request cancellation (via AbortSignal), for example:
About the target branch, it's not clear to me if i should be targeting master, but I guess this change can be released as a patch release as it's non-breaking.
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.3.x
,6.0.x