-
Notifications
You must be signed in to change notification settings - Fork 760
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
Feature Request: Ability to abort tagged operations #2349
Comments
char0n
added a commit
that referenced
this issue
Dec 21, 2021
- support was added to HTTP Client for OAS operations - support was added to Tags Interface Older versions of swagger-client can use request interceptors to inject abort signal into requests. Refs #2349
10 tasks
Hi @SeanLMcCullough, I've issued a PR #2380 which adds support for abort signals in HTTP Client for OAS operations as well as to Tags Interface. The feature will be release in couple of minutes as [email protected]. For older versions of swagger-client, there is workaround in using const SwaggerClient = require('swagger-client');
const AbortController = require('abort-controller');
const controller = new AbortController();
const { signal } = controller;
const interfaceLevelRequestInterceptor = (req) => {
req.signal = signal;
return req;
};
new SwaggerClient({
url: 'http://petstore.swagger.io/v2/swagger.json',
requestInterceptor: topLevelRequestInterceptor,
}).then((client) =>
client.apis.user.getUserByName(
{ username: 'username' },
{
requestInterceptor: interfaceLevelRequestInterceptor,
}
)
);
controller.abort(); |
char0n
added a commit
that referenced
this issue
Dec 21, 2021
- support was added to HTTP Client for OAS operations - support was added to Tags Interface Older versions of swagger-client can use request interceptors to inject abort signal into requests. Refs #2349
swagger-bot
pushed a commit
that referenced
this issue
Dec 21, 2021
# [3.18.0](v3.17.0...v3.18.0) (2021-12-21) ### Features * add support aborting requests in tags interface ([7b6bdc2](7b6bdc2)), closes [#2349](#2349)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unsure if this is a closer fit for a bug or feature, as the direct
SwaggerClient.http.http()
method is documented to support AbortController signals.Content & configuration
Swagger/OpenAPI definition:
https://petstore3.swagger.io/api/v3/openapi.json
Swagger-Client usage:
Is your feature request related to a problem?
I would like the ability to cancel requests made by the
client.apis.{tag}.{operationId}
API. This feature is present withSwaggerClient.http()
but does not work with tagged operations. This would allow me as a to ensure that race conditions do not occur, by using a native browser feature.Describe the solution you'd like
I would like to be able to supply an
AbortController
signal (and ideally any other init parameters to fetch) such that I can cancel requests.Describe alternatives you've considered
A workaround for this problem could be achieved by using request/response interceptors or more complex flow control around the usage of the client - but I have not explored these in depth.
Additional context
AbortController is documented to be usable with
SwaggerClient.http()
and works as documented. This same parameter does not work with tagged API operations, possibly because buildRequest discards aditional init params.The text was updated successfully, but these errors were encountered: