#Disable "Try it out" (aka `tryItOutEnabled: false`)

1 messages · Page 1 of 1 (latest)

copper wadi
#

Hi there!

As per the Swagger docs, setting tryItOutEnabled should "Controls whether the "Try it out" section should be enabled by default.".

Trying to do that in the bootstrap file, seem to have no effect:

  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api', app, document, {
    swaggerOptions: {
      tryItOutEnabled: false,
      persistAuthorization: true,
    },
  });

persistAuthorization works, but tryItOutEnabled does not.

What am I missing?

copper wadi
#

I want to publish the docs but prevent users from trying the API.

valid geyser
keen heron
#

If you want to publish the docs, have a look at ReDoc https://redocly.github.io/redoc/. It works the same as swagger ui, but is much nicer. Also, the try out only works in their paid version.
Another alternative is RapiDoc - it allows so much more configuration and is arguably also much prettier than swagger-ui https://rapidocweb.com/

ReDoc Interactive Demo. OpenAPI/Swagger-generated API Reference Documentation

copper wadi
#

@valid geyser

I gave a quick try by making the changes in the transpiled files, before even attempting with the source code, but the tryItOutEnabled property, hard-coded as false has no effect.

Also, I'm a bit confused about the implementation: I would have expected the package to try reading the same configuration files as Swagger does (yaml file, configuration object, configUrl, key/value pairs).

#

@keen heron thanks for the suggestions. I'm happy with Swagger and I'd like to avoid having to install another package only for the documentation part.

valid geyser
# copper wadi <@524281921115652106> I gave a quick try by making the changes in the transpile...

Oof, yeah, looking through this again, I'd have to figure out what part of this actually builds those document entries. Probably the buildSwaggerInitJS (https://github.com/nestjs/swagger/blob/master/lib/swagger-ui/swagger-ui.ts#L8), but honestly I'm not 100% sure at the moment. I know there was some reason for swapping from using the swagger-ui packages to managing our own build version. I'll have to go find that PR again