const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
const DisableTryItOutPlugin = function() {
return {
statePlugins: {
spec: {
wrapSelectors: {
allowTryItOutFor: () => () => false
const options = {
swaggerOptions: {
plugins: [
DisableTryItOutPlugin
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
const DisableTryItOutPlugin = function() {
return {
statePlugins: {
spec: {
wrapSelectors: {
allowTryItOutFor: () => () => false
const options = {
swaggerOptions: {
plugins: [
DisableTryItOutPlugin
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
const options = {
swaggerOptions: {
supportedSubmitMethods: []
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(require('./docs/build.json'),options));
@scottie1984
Hey, i'm opening this issue up and raising it again.
Since the time this solution was presented here,
the Swagger UI
folks created a built-in option to disable the "try it out" button altogether.
Here is a reference to their doc which includes this option, and here's the thread (THE SAME ONE that raised that plugin work-around fix) with a comment down at the very bottom that says "hey, this work-around plugin thingy is no longer needed, since it is now built-in", and here's another.
I would love to see the support from the swagger-ui-express
side as well! ❤️
Could it please be implemented here as well?
--- UPDATE ---
I tried it, it works 100%!
I passed tryItOutEnabled: true to the swaggerOptions, and now the "try it out" button is automatically clicked. The plugin override is not needed anymore. The built-in solution works great.
Those options can be set already via the swaggerOptions and will be passed through to swagger-ui:
https://github.com/scottie1984/swagger-ui-express#custom-swagger-options