Clever / wag

sWAGger - Web API Generator
Apache License 2.0
77 stars 6 forks source link

Support per-request options #338

Open taylor-sutton opened 3 years ago

taylor-sutton commented 3 years ago

Right now, there are various options exposed on the generated client such as timeout and retries. Sometimes it would be nice to set these options different for a single request. To do that now, it requires either creating a new client, or temporarily setting the options on the existing client (which doesn't play well if that client is shared across go-routines, for example).

Two example patterns of ways to implement this:

taylor-sutton commented 2 years ago

Another option in a somewhat orthogonal direction to adding it to the client methods is to support this customization on the server-side by adding fields to the swagger file, like x-wag-timeout. This probably works best in combination with the above, so that clients can maintain control: x-wag-timeout would change the default timeout of the generated client, but an actual user of the client can use the new client options to override.