mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Added definition when is provided.
This commit is contained in:
parent
e3103c073a
commit
b7f5fb58d4
@ -45,5 +45,10 @@ class SwaggerConfigCompilerPass implements CompilerPassInterface
|
|||||||
$formatter->addMethodCall('setSwaggerVersion', array($container->getParameter('nelmio_api_doc.swagger.swagger_version')));
|
$formatter->addMethodCall('setSwaggerVersion', array($container->getParameter('nelmio_api_doc.swagger.swagger_version')));
|
||||||
$formatter->addMethodCall('setInfo', array($container->getParameter('nelmio_api_doc.swagger.info')));
|
$formatter->addMethodCall('setInfo', array($container->getParameter('nelmio_api_doc.swagger.info')));
|
||||||
|
|
||||||
|
$authentication = $container->getParameter('nelmio_api_doc.sandbox.authentication');
|
||||||
|
|
||||||
|
if ($authentication !== null) {
|
||||||
|
$formatter->addMethodCall('setAuthenticationConfig', array($authentication));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,6 +54,16 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
DataTypes::DATETIME => 'date-time',
|
DataTypes::DATETIME => 'date-time',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $authConfig = null;
|
||||||
|
|
||||||
|
public function setAuthenticationConfig(array $config)
|
||||||
|
{
|
||||||
|
$this->authConfig = $config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a collection of documentation data.
|
* Format a collection of documentation data.
|
||||||
*
|
*
|
||||||
@ -115,7 +125,25 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
|
|
||||||
protected function getAuthorizations()
|
protected function getAuthorizations()
|
||||||
{
|
{
|
||||||
return array();
|
$auth = array();
|
||||||
|
|
||||||
|
if ($this->authConfig === null) {
|
||||||
|
return $auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = $this->authConfig;
|
||||||
|
|
||||||
|
if ($config['delivery'] === 'http') {
|
||||||
|
return $auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
$auth['apiKey'] = array(
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'passAs' => $config['delivery'],
|
||||||
|
'keyname' => $config['name'],
|
||||||
|
);
|
||||||
|
|
||||||
|
return $auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,7 +185,7 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
'models' => array(),
|
'models' => array(),
|
||||||
'produces' => array(),
|
'produces' => array(),
|
||||||
'consumes' => array(),
|
'consumes' => array(),
|
||||||
'authorizations' => array(),
|
'authorizations' => $this->getAuthorizations(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$main = null;
|
$main = null;
|
||||||
|
@ -53,6 +53,10 @@ jms_serializer:
|
|||||||
auto_detection: true
|
auto_detection: true
|
||||||
|
|
||||||
nelmio_api_doc:
|
nelmio_api_doc:
|
||||||
|
sandbox:
|
||||||
|
authentication:
|
||||||
|
delivery: header
|
||||||
|
name: access_token
|
||||||
cache:
|
cache:
|
||||||
enabled: true
|
enabled: true
|
||||||
exclude_sections: ["private", "exclusive"]
|
exclude_sections: ["private", "exclusive"]
|
||||||
|
@ -61,7 +61,13 @@ class SwaggerFormatterTest extends WebTestCase
|
|||||||
'licenseUrl' => 'http://opensource.org/licenses/MIT',
|
'licenseUrl' => 'http://opensource.org/licenses/MIT',
|
||||||
),
|
),
|
||||||
'authorizations' =>
|
'authorizations' =>
|
||||||
array(),
|
array(
|
||||||
|
'apiKey' => array(
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'passAs' => 'header',
|
||||||
|
'keyname' => 'access_token',
|
||||||
|
)
|
||||||
|
),
|
||||||
'apis' =>
|
'apis' =>
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
@ -419,7 +425,13 @@ With multiple lines.',
|
|||||||
'consumes' =>
|
'consumes' =>
|
||||||
array(),
|
array(),
|
||||||
'authorizations' =>
|
'authorizations' =>
|
||||||
array(),
|
array(
|
||||||
|
'apiKey' => array(
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'passAs' => 'header',
|
||||||
|
'keyname' => 'access_token',
|
||||||
|
)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -539,7 +551,13 @@ With multiple lines.',
|
|||||||
'consumes' =>
|
'consumes' =>
|
||||||
array(),
|
array(),
|
||||||
'authorizations' =>
|
'authorizations' =>
|
||||||
array(),
|
array(
|
||||||
|
'apiKey' => array(
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'passAs' => 'header',
|
||||||
|
'keyname' => 'access_token',
|
||||||
|
)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -721,7 +739,12 @@ With multiple lines.',
|
|||||||
array (
|
array (
|
||||||
),
|
),
|
||||||
'authorizations' =>
|
'authorizations' =>
|
||||||
array (
|
array(
|
||||||
|
'apiKey' => array(
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'passAs' => 'header',
|
||||||
|
'keyname' => 'access_token',
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user