I recently had to come up with a solution to throttle an action in an API i’ve written.
First thing I did was to see what others had used (No reason to invent the wheel right?).
I came across this stackoverflow answer – which is basically what I will use in this blog post (mostly for a reminder to myself I guess).
Full credits go to Jarrod Dixon
Since it’s an attribute, we just annote it to an action
The attribute takes a unique name, amount of seconds and the message to return.
If the action is run more often than allowed, the action will return
409 - conflict
This is a quick way of removing the ‘try it out’ buttons from specific operation types, when using Swagger-ui for documentation
This will be a short one.
When using Swashbuckle to create documentation, you might want to remove the Try it out buttons, maybe all of them, or maybe just the ones on Put on Post operations
Well I’ve created a small script that is injected into swagger-ui through the
The following script will remove the TryItOut buttons from all Put and Post operations.
The script is injected through the SwaggerConfig.cs like so
Remember that the .js file needs to be an
Embedded Resource else it won’t work.