private function getConstraintsForProperty($className, Property $property)
 {
     $classMetadata = $this->classMetadataFactory->getMetadataFor($className);
     foreach ($classMetadata->properties as $propertyMetadata) {
         if ($propertyMetadata->name === $property->getName()) {
             return $propertyMetadata->constraints;
         }
     }
     return array();
 }
 private function getJsonSchemaConstraintsForProperty($className, Property $property)
 {
     $reflectionProperties = $this->reflectionFactory->getClassProperties($className);
     foreach ($reflectionProperties as $reflectionProperty) {
         if ($reflectionProperty->getName() == $property->getName()) {
             return $this->reader->getPropertyAnnotations($reflectionProperty);
         }
     }
 }
 private function getJsonSchemaConstraintsForProperty($className, Property $property)
 {
     $refClass = $this->reflectionFactory->create($className);
     return $this->reader->getPropertyAnnotations($refClass->getProperty($property->getName()));
 }
 public function handle($className, Property $property)
 {
     try {
         if ($type = $this->guesser->guessType($className, $property->getName())) {
             $property->addType($this->getPropertyType($type));
             $property->setFormat($this->getPropertyFormat($type));
             if (in_array($type->getType(), array('document', 'entity'))) {
                 $options = $type->getOptions();
                 if (isset($options['class']) && $this->registry->hasNamespace($options['class'])) {
                     $alias = $this->registry->getAlias($options['class']);
                     if ($alias) {
                         $property->setObject($alias);
                         if (isset($options['multiple']) && $options['multiple'] == true) {
                             $property->setMultiple(true);
                         }
                     }
                 }
             }
         }
         if ($required = $this->guesser->guessRequired($className, $property->getName())) {
             $property->setRequired($required->getValue());
         }
         if ($pattern = $this->guesser->guessPattern($className, $property->getName())) {
             $property->setPattern($pattern->getValue());
         }
         if ($maximum = $this->guesser->guessMaxLength($className, $property->getName())) {
             $property->setMaximum($maximum->getValue());
         }
         if ($property->getTitle() == null) {
             $title = ucwords(str_replace('_', ' ', Inflector::tableize($property->getName())));
             $property->setTitle($title);
         }
     } catch (MappingException $e) {
     }
 }
 public function handle($className, Property $property)
 {
     try {
         $metadata = $this->containerInterface->get('doctrine.odm.mongodb.document_manager')->getClassMetadata($className);
     } catch (MappingException $e) {
         return;
         //entity doens't support mongo reflection
     }
     if ($metadata->hasReference($property->getName())) {
         $targetDocumentClass = $this->containerInterface->get('doctrine.odm.mongodb.document_manager')->getClassMetadata($metadata->fieldMappings[$property->getName()]['targetDocument']);
         $targetDocumentType = $targetDocumentClass->isIdGeneratorIncrement() ? Property::TYPE_INTEGER : Property::TYPE_STRING;
         $isCollection = $metadata->isCollectionValuedReference($property->getName());
         $property->setType($targetDocumentType);
         $link = new Link();
         /**
          * @var ResourceTypeInterface $targetDocument
          */
         $targetDocument = $targetDocumentClass->getReflectionClass()->newInstance();
         $resourceName = $targetDocument->getResourceType()->getValue();
         $link->setHref($this->containerInterface->get('router')->generate("get_{$resourceName}", array('id' => '{$}'), \Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL));
         $property->setLink($link);
     } else {
         if ($metadata->hasEmbed($property->getName()) && !empty($metadata->fieldMappings[$property->getName()]['discriminatorMap'])) {
             $property->setType(Property::TYPE_OBJECT);
             if ($property->getPolymorphicType()) {
                 $property->setObject($this->containerInterface->get('json_schema.registry')->getAlias($metadata->fieldMappings[$property->getName()]['discriminatorMap'][$property->getPolymorphicType()]));
             } else {
                 $property->setOneOf($this->containerInterface->get('json_schema.generator')->getOneOf($metadata->fieldMappings[$property->getName()]['discriminatorMap']));
             }
         } else {
             if (is_array($metadata->getIdentifierFieldNames()) && !empty($metadata->getIdentifierFieldNames()) && $metadata->getIdentifierFieldNames()[0] == $property->getName()) {
                 //$property->setIgnored(true);
                 $property->setType($metadata->isIdGeneratorIncrement() ? Property::TYPE_INTEGER : Property::TYPE_STRING);
             }
         }
     }
 }