Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I would like to disable
Try it Out
button in the API documentation. I have tried
"tryItOut": false
in the parameter and the configuration. Furthermore, I'm using swagger 2.0 which has 'Try it out' button is enabled by default and in 3.0 it is disabled by default. So, there should be option to configure it. How to disable
Try it out
button from the Swagger UI?
–
Set
supportedSubmitMethods
to an empty array
[]
in your Swagger UI configuration. This config option is supported in v. 3.10.0+.
const ui = SwaggerUIBundle({
"dom_id": "#swagger-ui",
url: "https://path/to/your/api.yaml",
supportedSubmitMethods: [] // <--------
This config can also disable "Try it out" selectively for specific HTTP methods. For example, supportedSubmitMethods: ["get", "head"]
keeps "Try it out" only for GET and HEAD, but disables it for POST, PUT, PATCH, DELETE and other methods.
app.UseSwaggerUI(options =>
options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API");
options.EnableTryItOutByDefault();
–
From the GitHub repository comments, the bellow code works to me
const DisableTryItOutPlugin = function() {
return {
statePlugins: {
spec: {
wrapSelectors: {
allowTryItOutFor: () => () => false
// elsewhere, when you call Swagger-UI...
SwaggerUI({
plugins: [
DisableTryItOutPlugin
Reference: https://github.com/swagger-api/swagger-ui/issues/3725#issuecomment-334899276
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.