mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-15 14:03:15 +03:00
Last fixes
This commit is contained in:
parent
8ec31194a2
commit
97b722f97d
@ -65,7 +65,7 @@ final class NelmioApiDocExtension extends Extension implements PrependExtensionI
|
|||||||
$nameAliases = $this->findNameAliases($config['models']['names'], $area);
|
$nameAliases = $this->findNameAliases($config['models']['names'], $area);
|
||||||
|
|
||||||
$container->register(sprintf('nelmio_api_doc.generator.%s', $area), ApiDocGenerator::class)
|
$container->register(sprintf('nelmio_api_doc.generator.%s', $area), ApiDocGenerator::class)
|
||||||
->setPublic(false)
|
->setPublic(true)
|
||||||
->addMethodCall('setAlternativeNames', [$nameAliases])
|
->addMethodCall('setAlternativeNames', [$nameAliases])
|
||||||
->setArguments([
|
->setArguments([
|
||||||
new TaggedIteratorArgument(sprintf('nelmio_api_doc.describer.%s', $area)),
|
new TaggedIteratorArgument(sprintf('nelmio_api_doc.describer.%s', $area)),
|
||||||
|
@ -29,9 +29,9 @@ class ConfigurationTest extends TestCase
|
|||||||
{
|
{
|
||||||
$processor = new Processor();
|
$processor = new Processor();
|
||||||
$config = $processor->processConfiguration(new Configuration(), [['areas' => $areas = [
|
$config = $processor->processConfiguration(new Configuration(), [['areas' => $areas = [
|
||||||
'default' => ['path_patterns' => ['/foo'], 'documentation' => []],
|
'default' => ['path_patterns' => ['/foo'], 'host_patterns' => [], 'documentation' => []],
|
||||||
'internal' => ['path_patterns' => ['/internal'], 'host_patterns' => ['^swagger\.']],
|
'internal' => ['path_patterns' => ['/internal'], 'host_patterns' => ['^swagger\.'], 'documentation' => []],
|
||||||
'commercial' => ['path_patterns' => ['/internal'], 'host_patterns' => []],
|
'commercial' => ['path_patterns' => ['/internal'], 'host_patterns' => [], 'documentation' => []],
|
||||||
]]]);
|
]]]);
|
||||||
|
|
||||||
$this->assertSame($areas, $config['areas']);
|
$this->assertSame($areas, $config['areas']);
|
||||||
|
@ -19,7 +19,8 @@ class FunctionalTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
public function testConfiguredDocumentation()
|
public function testConfiguredDocumentation()
|
||||||
{
|
{
|
||||||
$this->assertEquals('My Test App', $this->getSwaggerDefinition()->getInfo()->getTitle());
|
$this->assertEquals('My Default App', $this->getSwaggerDefinition()->getInfo()->getTitle());
|
||||||
|
$this->assertEquals('My Test App', $this->getSwaggerDefinition('test')->getInfo()->getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUndocumentedAction()
|
public function testUndocumentedAction()
|
||||||
|
@ -41,6 +41,7 @@ class SwaggerUiTest extends WebTestCase
|
|||||||
yield ['/docs', 'default', $expected];
|
yield ['/docs', 'default', $expected];
|
||||||
|
|
||||||
// Api-platform documentation
|
// Api-platform documentation
|
||||||
|
$expected['info']['title'] = 'My Test App';
|
||||||
$expected['paths'] = [
|
$expected['paths'] = [
|
||||||
'/api/dummies' => $expected['paths']['/api/dummies'],
|
'/api/dummies' => $expected['paths']['/api/dummies'],
|
||||||
'/api/foo' => $expected['paths']['/api/foo'],
|
'/api/foo' => $expected['paths']['/api/foo'],
|
||||||
|
@ -119,7 +119,7 @@ class TestKernel extends Kernel
|
|||||||
$c->loadFromExtension('nelmio_api_doc', [
|
$c->loadFromExtension('nelmio_api_doc', [
|
||||||
'documentation' => [
|
'documentation' => [
|
||||||
'info' => [
|
'info' => [
|
||||||
'title' => 'My Test App',
|
'title' => 'My Default App',
|
||||||
],
|
],
|
||||||
'definitions' => [
|
'definitions' => [
|
||||||
'Test' => [
|
'Test' => [
|
||||||
@ -138,23 +138,6 @@ class TestKernel extends Kernel
|
|||||||
'default' => [
|
'default' => [
|
||||||
'path_patterns' => ['^/api(?!/admin)'],
|
'path_patterns' => ['^/api(?!/admin)'],
|
||||||
'host_patterns' => ['^api\.'],
|
'host_patterns' => ['^api\.'],
|
||||||
'documentation' => [
|
|
||||||
'info' => [
|
|
||||||
'title' => 'My Test App',
|
|
||||||
],
|
|
||||||
'definitions' => [
|
|
||||||
'Test' => [
|
|
||||||
'type' => 'string',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'parameters' => [
|
|
||||||
'test' => [
|
|
||||||
'name' => 'id',
|
|
||||||
'in' => 'path',
|
|
||||||
'required' => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
'test' => [
|
'test' => [
|
||||||
'path_patterns' => ['^/test'],
|
'path_patterns' => ['^/test'],
|
||||||
@ -163,18 +146,6 @@ class TestKernel extends Kernel
|
|||||||
'info' => [
|
'info' => [
|
||||||
'title' => 'My Test App',
|
'title' => 'My Test App',
|
||||||
],
|
],
|
||||||
'definitions' => [
|
|
||||||
'Test' => [
|
|
||||||
'type' => 'string',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'parameters' => [
|
|
||||||
'test' => [
|
|
||||||
'name' => 'id',
|
|
||||||
'in' => 'path',
|
|
||||||
'required' => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -22,11 +22,11 @@ class WebTestCase extends BaseWebTestCase
|
|||||||
return new TestKernel();
|
return new TestKernel();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSwaggerDefinition()
|
protected function getSwaggerDefinition($area = 'default')
|
||||||
{
|
{
|
||||||
static::createClient([], ['HTTP_HOST' => 'api.example.com']);
|
static::createClient([], ['HTTP_HOST' => 'api.example.com']);
|
||||||
|
|
||||||
return static::$kernel->getContainer()->get('nelmio_api_doc.generator')->generate();
|
return static::$kernel->getContainer()->get(sprintf('nelmio_api_doc.generator.%s', $area))->generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getModel($name): Schema
|
protected function getModel($name): Schema
|
||||||
|
Loading…
x
Reference in New Issue
Block a user