mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 07:41:43 +03:00
Merge pull request #117 from gregholland/master
Add a config option for a default Accept header
This commit is contained in:
commit
026fcc4761
@ -39,6 +39,7 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->scalarNode('enabled')->defaultTrue()->end()
|
||||
->scalarNode('endpoint')->defaultNull()->end()
|
||||
->scalarNode('accept_type')->defaultValue('')->end()
|
||||
->arrayNode('request_format')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
|
@ -32,6 +32,7 @@ class NelmioApiDocExtension extends Extension
|
||||
$container->setParameter('nelmio_api_doc.sandbox.enabled', $config['sandbox']['enabled']);
|
||||
$container->setParameter('nelmio_api_doc.sandbox.endpoint', $config['sandbox']['endpoint']);
|
||||
$container->setParameter('nelmio_api_doc.sandbox.request_format.method', $config['sandbox']['request_format']['method']);
|
||||
$container->setParameter('nelmio_api_doc.sandbox.accept_type', $config['sandbox']['accept_type']);
|
||||
$container->setParameter('nelmio_api_doc.sandbox.request_format.default_format', $config['sandbox']['request_format']['default_format']);
|
||||
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
@ -45,6 +45,11 @@ class HtmlFormatter extends AbstractFormatter
|
||||
*/
|
||||
private $requestFormatMethod;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $acceptType;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -90,6 +95,14 @@ class HtmlFormatter extends AbstractFormatter
|
||||
$this->engine = $engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $acceptType
|
||||
*/
|
||||
public function setAcceptType($acceptType)
|
||||
{
|
||||
$this->acceptType = $acceptType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
*/
|
||||
@ -144,6 +157,7 @@ class HtmlFormatter extends AbstractFormatter
|
||||
'endpoint' => $this->endpoint,
|
||||
'enableSandbox' => $this->enableSandbox,
|
||||
'requestFormatMethod' => $this->requestFormatMethod,
|
||||
'acceptType' => $this->acceptType,
|
||||
'defaultRequestFormat' => $this->defaultRequestFormat,
|
||||
'date' => date(DATE_RFC822),
|
||||
'css' => file_get_contents(__DIR__ . '/../Resources/public/css/screen.css'),
|
||||
|
@ -213,7 +213,7 @@ configure this sandbox using the following parameters:
|
||||
delivery: query # only query delivery is supported for now
|
||||
enabled: true # default: true, you can set this parameter to `false` to disable the sandbox
|
||||
endpoint: http://sandbox.example.com/ # default: /app_dev.php, use this parameter to define which URL to call through the sandbox
|
||||
|
||||
accept_type: application/json # default null, if set, the value is automatically populated as the Accept header
|
||||
|
||||
The bundle provides a way to register multiple `input` parsers. The first parser that can handle the specified
|
||||
input is used, so you can configure their priorities via container tags. Here's an example parser service registration:
|
||||
|
@ -43,6 +43,9 @@
|
||||
<call method="setDefaultRequestFormat">
|
||||
<argument>%nelmio_api_doc.sandbox.request_format.default_format%</argument>
|
||||
</call>
|
||||
<call method="setAcceptType">
|
||||
<argument>%nelmio_api_doc.sandbox.accept_type%</argument>
|
||||
</call>
|
||||
<call method="setAuthentication">
|
||||
<argument>%nelmio_api_doc.sandbox.authentication%</argument>
|
||||
</call>
|
||||
|
@ -211,6 +211,14 @@
|
||||
<fieldset class="headers">
|
||||
<legend>Headers</legend>
|
||||
|
||||
{% if acceptType %}
|
||||
<p class="tuple">
|
||||
<input type="text" class="key" value="Accept" />
|
||||
<span>=</span>
|
||||
<input type="text" class="value" value="{{ acceptType }}" /> <span class="remove">-</span>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<p class="tuple">
|
||||
<input type="text" class="key" placeholder="Key" />
|
||||
<span>=</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user