mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
CollectionType not working in example tab (#1360)
* CollectionType not working in example tab Removed just line 179 and collectionType now working in example tab * Fix comments
This commit is contained in:
parent
29f3042754
commit
6e04137ee6
@ -91,10 +91,8 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
*
|
*
|
||||||
* @param FormConfigBuilderInterface $config
|
* @param FormConfigBuilderInterface $config
|
||||||
* @param $property
|
* @param $property
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
private function findFormType(FormConfigBuilderInterface $config, $property): bool
|
private function findFormType(FormConfigBuilderInterface $config, $property)
|
||||||
{
|
{
|
||||||
$type = $config->getType();
|
$type = $config->getType();
|
||||||
|
|
||||||
@ -103,7 +101,7 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, get_class($type->getInnerType())));
|
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, get_class($type->getInnerType())));
|
||||||
$property->setRef($this->modelRegistry->register($model));
|
$property->setRef($this->modelRegistry->register($model));
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -112,33 +110,33 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
if ('text' === $blockPrefix) {
|
if ('text' === $blockPrefix) {
|
||||||
$property->setType('string');
|
$property->setType('string');
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('number' === $blockPrefix) {
|
if ('number' === $blockPrefix) {
|
||||||
$property->setType('number');
|
$property->setType('number');
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('integer' === $blockPrefix) {
|
if ('integer' === $blockPrefix) {
|
||||||
$property->setType('integer');
|
$property->setType('integer');
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('date' === $blockPrefix) {
|
if ('date' === $blockPrefix) {
|
||||||
$property->setType('string');
|
$property->setType('string');
|
||||||
$property->setFormat('date');
|
$property->setFormat('date');
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('datetime' === $blockPrefix) {
|
if ('datetime' === $blockPrefix) {
|
||||||
$property->setType('string');
|
$property->setType('string');
|
||||||
$property->setFormat('date-time');
|
$property->setFormat('date-time');
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('choice' === $blockPrefix) {
|
if ('choice' === $blockPrefix) {
|
||||||
@ -157,13 +155,13 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('checkbox' === $blockPrefix) {
|
if ('checkbox' === $blockPrefix) {
|
||||||
$property->setType('boolean');
|
$property->setType('boolean');
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('collection' === $blockPrefix) {
|
if ('collection' === $blockPrefix) {
|
||||||
@ -174,11 +172,9 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
$property->setType('array');
|
$property->setType('array');
|
||||||
$itemsProp = $property->getItems();
|
$itemsProp = $property->getItems();
|
||||||
|
|
||||||
if (!$this->findFormType($subForm->getConfig(), $itemsProp)) {
|
$this->findFormType($subForm->getConfig(), $itemsProp);
|
||||||
$property->setExample(sprintf('[{%s}]', $subType));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('entity' === $blockPrefix) {
|
if ('entity' === $blockPrefix) {
|
||||||
@ -192,11 +188,9 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
$property->setFormat(sprintf('%s id', $entityClass));
|
$property->setFormat(sprintf('%s id', $entityClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
} while ($builtinFormType = $builtinFormType->getParent());
|
} while ($builtinFormType = $builtinFormType->getParent());
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,12 +235,10 @@ class FunctionalTest extends WebTestCase
|
|||||||
'dummies' => [
|
'dummies' => [
|
||||||
'items' => ['$ref' => '#/definitions/DummyType'],
|
'items' => ['$ref' => '#/definitions/DummyType'],
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'example' => sprintf('[{%s}]', DummyType::class),
|
|
||||||
],
|
],
|
||||||
'empty_dummies' => [
|
'empty_dummies' => [
|
||||||
'items' => ['$ref' => '#/definitions/DummyEmptyType'],
|
'items' => ['$ref' => '#/definitions/DummyEmptyType'],
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'example' => sprintf('[{%s}]', DummyEmptyType::class),
|
|
||||||
],
|
],
|
||||||
'quz' => [
|
'quz' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user