Disable "Try it out" feature of Swagger UI
Swagger UI is a great way to view API documentation. It's even got a cool feature where you can excercise the api right from the documentation.
However that may not be wanted or necessary in every occasion. Turning it off wasn't as straightforward as I'd have expected.
The Swagger UI documentation shows a configuration option called
tryItOutEnabled. This sounds promising and the description even states:
Controls whether the "Try it out" section should be enabled by default.
So using our knowledge on how to configure Swagger UI through rswag, we try:
Rswag::Ui.configure do |c| c.config_object["tryItOutEnabled"] = false end
However we'll find that this doesn't do anything 😕
Later I found that this particular option sets whether or not the "Try it out" feature is open by default.
If we utilize the config option of
supportedSubmitMethods and provide an empty array, we'll get something more usable.
Rswag::Ui.configure do |c| c.config_object["supportedSubmitMethods"] =  end
Now the button will completely disappear!