Translate the local property type to swagger type.
@return string
503261
protected function getSwaggerType()
    {
        $type = $this->getType();
        switch ($type) {
            case null:
                return PropertyType::STRING;

            case PropertyType::INTEGER:
            case PropertyType::STRING:
            case PropertyType::NUMBER:
            case PropertyType::BOOL:
            case PropertyType::OBJECT:
                return $type;

            case PropertyType::DATETIME:
                return PropertyType::STRING;

            default:
                throw new \InvalidArgumentException("Type cannot be matched with a swagger type.");
        }
    }
1266763
protected function getSwaggerDocumentation(): Swagger
    {
        if (!$this->cache instanceof Cache) {
            return \Swagger\scan($this->scanDir, $this->scanOptions);
        }

        return $this->cache->getOrSet($this->cacheKey, function () {
            return \Swagger\scan($this->scanDir, $this->scanOptions);
        }, $this->cacheDuration);
    }
402996
public function getTypes()
    {
        $types = $this->config()->get('types');
        $i18nTypes = array();
        $allowed_types = $this->config()->get('allowed_types');

        if ($this->allowed_types) {
            // Prioritise local field over global settings
            $allowed_types = $this->allowed_types;
        }

        if ($allowed_types) {
           foreach ($allowed_types as $type) {
                if (!array_key_exists($type, $types)) {
                    user_error("{$type} is not a valid link type");
                }
            }

            foreach (array_diff_key($types, array_flip($allowed_types)) as $key => $value) {
                unset($types[$key]);
            }
        }

        // Get translatable labels
        foreach ($types as $key => $label) {
            $i18nTypes[$key] = _t('Links.TYPE'.strtoupper($key), $label);
        }
        $this->extend('updateTypes', $i18nTypes);
        return $i18nTypes;
    }
1251917
private function getSwaggertype($type, $subType = null)
    {
        switch ($type) {
            case 'int32':
                return ['type' => 'integer', 'format' => 'int32'];

            case 'int':
            case 'integer':
                return ['type' => 'integer', 'format' => 'int64'];

            case 'float':
                return ['type' => 'number', 'format' => 'float'];

            case 'double':
                return ['type' => 'number', 'format' => 'double'];

            case 'string':
                return ['type' => 'string'];

            case 'bool':
            case 'boolean':
                return ['type' => 'boolean'];

            case '\\Cawa\\SwaggerServer\\DateTime':
            case '\\DateTime':
                return ['type' => 'string', 'format' => 'date-time'];

            case 'array':
                if (!$subType) {
                    throw new \Exception('array is not supported without detail');
                }

                if ($subType == 'json') {
                    return ['type' => 'string'];
                }

                if (is_null($subType)) {
                    throw new \Exception('array is not supported without map detail');
                }

                if ($subType == 'string') {
                    $additionalProperties['type'] = 'string';
                }

                if ($subType == 'int') {
                    $additionalProperties['type'] = 'integer';
                    $additionalProperties['format'] = 'int64';
                }

                if (!isset($additionalProperties)) {
                    throw new \Exception('array is not supported without map[string] or map[int]');
                }

                return ['type' => 'object', 'additionalProperties' => $additionalProperties];

            default:
                if (substr($type, -2) == '[]') {
                    $collectionType = $this->getSwaggertype(substr($type, 0, -2));

                    return ['type' => 'array', 'items' => $collectionType];
                }

                $this->fetchModel($type);

                return ['type' => 'object', '$ref' => '#/definitions/' . $this->normalizeType($type)];
        }
    }
1226165
private function generateFromGeneric()
    {
        $ctypes = $this->app['config']->get('contenttypes');

        $translatables = array_filter(
            array_keys($this->translatables),
            function ($key) {
                return substr($key, 0, 21) === 'contenttypes.generic.' && substr($key, 21, 6) !== 'group.';
            }
        );

        foreach ($translatables as $key) {
            foreach ($ctypes as $ctname => $ctype) {
                $setkey = 'contenttypes.' . $ctname . '.text.' . substr($key, 21);
                $this->translation[$setkey] = isset($this->saved[$setkey]) ? $this->saved[$setkey] : '';
                if ($this->translation[$setkey] === '') {
                    $generic = Trans::__($key);
                    // If not translated, add hint
                    if ($generic !== $key) {
                        $replacement = [];
                        if (strpos($generic, '%contenttypes%') !== false) {
                            $replacement['%contenttypes%'] = $ctname;
                        } elseif (strpos($generic, '%contenttype%') !== false) {
                            $replacement['%contenttype%'] = $ctname;
                        }
                        $this->hints[$setkey] = Trans::__($key, $replacement);
                    }
                }
            }
        }
    }
1074411
public function dataLoad()
    {
        $paramName = $this->__get('DataPath');
        $paramName = array_pop($paramName);

        $this->contextDataExists = false;
        $this->contextDataValue  = null;

        if ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_REQUEST) {
            return $this->loadRequestBody();
        }
        elseif ($paramName === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && $this->getType() === self::TYPE_RESPONSE) {
            return $this->loadResponseBody();
        }
        elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER) {
            return $this->loadRequestHeader($paramName);
        }
        elseif ($this->getType() === self::TYPE_RESPONSE && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_HEADER) {
            return $this->loadResponseHeader($paramName);
        }
        elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_FORM) {
            return $this->loadRequestFormData($paramName);
        }
        elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_PATH) {
            return $this->loadRequestPath($paramName);
        }
        elseif ($this->getType() === self::TYPE_REQUEST && $this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_QUERY) {
            return $this->loadRequestQuery($paramName);
        }
        elseif ($this->getLocation() === \SwaggerValidator\Common\FactorySwagger::LOCATION_BODY && !$this->checkIsEmpty($this->getDataValue())) {
            if (is_array($this->getDataValue()) && array_key_exists($paramName, $this->getDataValue())) {
                $this->contextDataExists = true;
                $value                   = $this->getDataValue();
                $this->contextDataValue  = $value[$paramName];
            }
            elseif (is_object($this->getDataValue()) && property_exists($this->getDataValue(), $paramName)) {
                $this->contextDataExists = true;
                $this->contextDataValue  = $this->getDataValue()->$paramName;
            }
        }

        return $this->checkDataIsEmpty();
    }
1239909
private function getPropertyTypes()
    {
        $reflection = new \ReflectionClass('ONGR\ElasticsearchBundle\Annotation\Property');

        return $this
            ->getContainer()
            ->get('es.annotations.cached_reader')
            ->getPropertyAnnotation($reflection->getProperty('type'), 'Doctrine\Common\Annotations\Annotation\Enum')
            ->value;
    }
52515
public function toJavaScript()
    {
        $lines = [];

        foreach (get_object_vars($this) as $key => $value) {
            if (!is_null($value)) {
                $line = $key . ": ";

                if ($key == 'version') {
                    $line .= 'new Version({ ' . $value->toJavaScript() . ' })';
                } elseif ($key == 'family') {
                    $line .= 'new Family({ ' . $value->toJavaScript() . ' })';
                } elseif ($key == 'using') {
                    $line .= 'new Using({ ' . $value->toJavaScript() . ' })';
                } else {
                    switch (gettype($value)) {
                        case 'boolean':
                            $line .= $value ? 'true' : 'false';
                            break;
                        case 'string':
                            $line .= '"' . addslashes($value) . '"';
                            break;
                        case 'integer':
                            $line .= $value;
                            break;
                    }
                }

                $lines[] = $line;
            }
        }

        return implode($lines, ", ");
    }
379115
public function toJson() {
    	$result = array();
    	$result['name'] = $this->getName();
    	$result['comment'] = $this->getMoufPhpDocComment()->getJsonArray();
    	
    	/*$properties = $this->getAnnotations("Property");
    		if (!empty($properties)) {
    	$result['moufProperty'] = true;*/
    	
    	try {
    		$result['default'] = $this->getDefault();
    		
	    	// TODO: is there a need to instanciate a  MoufPropertyDescriptor?
	    	$moufPropertyDescriptor = new MoufPropertyDescriptor($this);
	    	$types = $moufPropertyDescriptor->getTypes();
	    	$result['types'] = $types->toJson();
	    	 
	    	if ($types->getWarningMessage()) {
	    		$result['classinerror'] = $types->getWarningMessage();
	    	}
	    		    	
    	} catch (\Exception $e) {
    		$result['classinerror'] = $e->getMessage();
    	}
    	/*if ($moufPropertyDescriptor->isAssociativeArray()) {
    		$result['keytype'] = $moufPropertyDescriptor->getKeyType();
    	}
    	if ($moufPropertyDescriptor->isArray()) {
    		$result['subtype'] = $moufPropertyDescriptor->getSubType();
    	}*/
    	//}
    
    	return $result;
    }
1153848
private static SwaggerType toSwaggerType(final String type) {
        if (INTEGER_TYPES.contains(type))
            return SwaggerType.INTEGER;

        if (DOUBLE_TYPES.contains(type))
            return SwaggerType.NUMBER;

        if (BOOLEAN.equals(type) || PRIMITIVE_BOOLEAN.equals(type))
            return SwaggerType.BOOLEAN;

        if (STRING.equals(type))
            return SwaggerType.STRING;

        return SwaggerType.OBJECT;
    }
1084551
final public function export()
    {
        $properties = [
            'status'  => $this->status,
            'name'    => $this->name,
            'variant' => $this->variant,
            'label'   => $this->label,
            'class'   => get_class($this),
            'type'    => $this->type,
            'valid'   => false,
            'path'    => $this->componentPath,
            'docs'    => $this->getDocumentationDirectory(),
        ];

        // Export the component properties
        try {
            $properties            = array_merge($properties, $this->exportInternal());
            $properties['request'] = $this->exportRequest();
            $properties['valid']   = true;

            // In case of an error
        } catch (\Exception $e) {
            $properties['error'] = $e->getMessage();
        }

        return $properties;
    }
1336450
public static function getPropertyMap()
    {
        if (self::$property_map !== null) {
            return self::$property_map;
        }

        /** @var array<string, array<string, string>> */
        $property_map = require_once(__DIR__ . '/../PropertyMap.php');

        self::$property_map = [];

        foreach ($property_map as $key => $value) {
            $cased_key = strtolower($key);
            self::$property_map[$cased_key] = $value;
        }

        return self::$property_map;
    }
85345
public function getProperty()
    {
        return '
    /**
     * @var ' . $this->getType()->getType() . ' $' . $this->getPropertyName() . '
     */
    protected $' . $this->getPropertyName() . ' = ' . $this->getDefault(true) . ';';
    }
199706
private function export()
    {
        $exported = new StdClass;
        foreach ($this as $name => $field) {
            if ((new ReflectionProperty($this, $name))->isPublic()) {
                if (is_object($field)) {
                    $traits = class_uses($field);
                    if (isset($traits['Ornament\Model'])
                        || isset($traits['Ornament\JsonModel'])
                    ) {
                        $exported->$name = $field->getPrimaryKey();
                    } else {
                        $exported->$name = "$field";
                    }
                } else {
                    $exported->$name = $field;
                }
            }
        }
        return $exported;
    }
947949
public function jsonSerialize()
    {
        $output = [];
        foreach ($this::getReflection()->getProperties() as $propertyName => $property) {

            $value = $this->{$propertyName};
            if ($value instanceof Entity\Collection || $value instanceof Entity) {
                $output[$propertyName] = $value->jsonSerialize();
            } elseif ($value instanceof \DateTime
                && $property->getType() === Entity\Reflection\Property::TYPE_DATE
            ) {
                $output[$propertyName] = (array) $value;
                $output[$propertyName]["date"] = $value->format(self::$dateFormat);
            } else {
                $output[$propertyName] = $value;
            }
        }

        return $output;
    }
1138367
public function formProperty()
    {
        if ($this->formProperty === null) {
            $this->formProperty = false;

            if ($this->objType() && $this->propertyIdent()) {
                $propertyIdent = $this->propertyIdent();

                $model = $this->modelFactory()->create($this->objType());
                $props = $model->metadata()->properties();

                if (isset($props[$propertyIdent])) {
                    $propertyMetadata = $props[$propertyIdent];

                    $property = $this->propertyFactory()->create($propertyMetadata['type']);

                    $property->setIdent($propertyIdent);
                    $property->setData($propertyMetadata);

                    $this->formProperty = $property;
                }
            }
        }

        return $this->formProperty;
    }
454043
public function elfinderConfigAsJson()
    {
        $property = $this->formProperty();
        $settings = [];

        if ($this->elfinderConfig['client']) {
            $settings = $this->elfinderConfig['client'];
        }

        $settings['lang'] = $this->translator()->getLocale();

        if ($property) {
            $mimeTypes = filter_input(INPUT_GET, 'filetype', FILTER_SANITIZE_STRING);

            if ($mimeTypes) {
                if ($mimeTypes === 'file') {
                    $mimeTypes = [];
                }

                $settings['onlyMimes'] = (array)$mimeTypes;
            } elseif ($property instanceof FileProperty) {
                $settings['onlyMimes'] = $property->acceptedMimetypes();
            }

            $settings['rememberLastDir'] = !($property instanceof FileProperty);
        }

        return json_encode($settings, (JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
    }