Symfony 4 was released on November 30th.
Update now to the best Symfony ever!

Sandbox

2.x version
Maintained

Sandbox

This bundle provides a sandbox mode in order to test API methods. You can configure this sandbox using the following parameters:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# app/config/config.yml
nelmio_api_doc:
    sandbox:
        authentication:             # default is `~` (`null`), if set, the sandbox automatically
                                    # send authenticated requests using the configured `delivery`

            name: access_token      # access token name or query parameter name or header name

            delivery: http          # `query`, `http`, and `header` are supported

            # Required if http delivery is selected.
            type:     basic         # `basic`, `bearer` are supported

            custom_endpoint: true   # default is `false`, if `true`, your user will be able to
                                    # specify its own endpoint

        enabled:  true              # default is `true`, you can set this parameter to `false`
                                    # to disable the sandbox

        endpoint: http://sandbox.example.com/   # default is `/app_dev.php`, use this parameter
                                                # to define which URL to call through the sandbox

        accept_type: application/json           # default is `~` (`null`), if set, the value is
                                                # automatically populated as the `Accept` header

        body_format:
            formats: [ form, json ]             # array of enabled body formats,
                                                # remove all elements to disable the selectbox
            default_format: form                # default is `form`, determines whether to send
                                                # `x-www-form-urlencoded` data or json-encoded
                                                # data (by setting this parameter to `json`) in
                                                # sandbox requests

        request_format:
            formats:                            # default is `json` and `xml`,
                json: application/json          # override to add custom formats or disable
                xml: application/xml            # the default formats

            method: format_param    # default is `format_param`, alternately `accept_header`,
                                    # decides how to request the response format

            default_format: json    # default is `json`,
                                    # default content format to request (see formats)

        entity_to_choice: false     # default is `true`, if `false`, entity collection
                                    # will not be mapped as choice

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.