Disabling Sandbox for NelmioApiDocs on Symfony 3.4

958 Views Asked by At

i want to disable the sandbox mode for NelmioApiDocs on Symfony "v3.4.11" and nelmio/api-doc-bundle "v3.2.1"

I've tried:

# app/config/config.yml

# nelmio_api_doc
nelmio_api_doc:
    documentation:
        sandbox:
            enabled: false

After that i cleared the cache for prod and dev. But it did not work, i can still send api tests with "Try it out".

Can someone help me to disable this "Try it out" feature?

Kind Regards, Benjamin

2

There are 2 best solutions below

0
On BEST ANSWER

Since the answer from Denis St-Michel was not working for me, i've added css to hide the button:

{# create in app\Resources\NelmioApiDocBundle\views\SwaggerUi\index.html.twig #}
{% extends '@!NelmioApiDoc/SwaggerUi/index.html.twig' %}

{% block stylesheets %}
{{ parent() }}
{#  Eine Config zur Deaktivierung des Buttons hat leider nicht funktioniert, daher einfach ausgeblended  #}
<style>
    .try-out {
        display: none;
    }
</style>
{% endblock stylesheets %}

Not the best way, but working for me.

1
On

@DasBen, I have the same setup as you, and I was able to disable the sandbox by adding a plugin to the init-swagger-ui.js

const DisableTryItOutPlugin = function() {
    return {
        statePlugins: {
            spec: {
                wrapSelectors: {
                    allowTryItOutFor: () => () => false
                }
            }
        }
    }
};

And then in const ui definition I added this plugin like this:

plugins: [
    DisableTryItOutPlugin
]

Refreshed, and the sandbox is gone. I would have prefered to disabled it via an option in the config.yml file under nelmio_api_doc, but at least it's disabled now. Hopes this helps.

I shall have no credit, though: https://github.com/swagger-api/swagger-ui/issues/3725#issuecomment-334899276