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);
             }
         }
     }
 }
 public function handle($className, Property $property)
 {
     foreach ($this->getJsonSchemaConstraintsForClass($className) as $constraint) {
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\PolymorphicType && $constraint->property == $property->getName()) {
             $property->setPolymorphicType($constraint->type);
         }
     }
     foreach ($this->getJsonSchemaConstraintsForProperty($className, $property) as $constraint) {
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Minimum) {
             $property->setMinimum($constraint->minimum);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\ExclusiveMinimum) {
             $property->setExclusiveMinimum(true);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Maximum) {
             $property->setMaximum($constraint->maximum);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\ExclusiveMaximum) {
             $property->setExclusiveMaximum(true);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Disallow) {
             $property->setDisallowed($constraint->disallowed);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Type) {
             $types = (array) $constraint->type;
             $property->setType($types);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Locale) {
             $property->setEnumeration(array_keys(Intl::getLocaleBundle()->getLocaleNames()));
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Title) {
             $property->setTitle($constraint->name);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\DefaultValue) {
             $property->setDefaultValue($constraint->value);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Description) {
             $property->setDescription($constraint->name);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Format) {
             $property->setFormat($constraint->format);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Options) {
             $property->setOptions($constraint->options);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Enum) {
             if ($constraint->callback) {
                 if (!is_callable($choices = $constraint->callback)) {
                     throw new ConstraintDefinitionException('The Enum constraint expects a valid callback');
                 }
                 $choices = call_user_func($choices);
             } else {
                 $choices = $constraint->enum;
             }
             $property->setEnumeration($choices);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Multiple) {
             $property->setMultiple(true);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Ignore) {
             $property->setIgnored(true);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Required) {
             $property->setRequired($constraint->isRequired);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\ReadOnly) {
             $property->setReadOnly(true);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\Object) {
             $property->setObject($constraint->alias);
             $property->setMultiple($constraint->multiple);
         }
         if ($constraint instanceof \Knp\JsonSchemaBundle\Annotations\LinkTo) {
             $link = new Link();
             $link->setHref($this->router->generate($constraint->route, $constraint->params, \Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL));
             $link->setMethod($constraint->method);
             $property->setLink($link);
         }
     }
 }