Skip to content

Commit

Permalink
Fix array return type
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometee committed May 25, 2020
1 parent ea02af3 commit 84bd0f2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Swagger/SwaggerOperationsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,14 @@ public function processOperation(
return;
}

$returnType = $this->processOperationReturnType($operationConfiguration);

$operationMethodGenerator = $this->methodFactory->createOperationMethodGenerator(
$classGenerator->getUsesGenerator()
);

$operationMethodName = $this->helper::getOperationMethodName($path, $operation, $operationConfiguration);
$operationMethodGenerator->setName($operationMethodName);

$returnType = $this->processOperationReturnType($operationConfiguration);
$operationMethodGenerator->addReturnType($returnType);

if (isset($operationConfiguration['description'])) {
Expand Down Expand Up @@ -363,7 +364,8 @@ public function getClassNameAndNamespaceFromPath(string $path, string $classPref
$classParts = explode('/', $classPath);
$className = array_pop($classParts);
$namespace = implode('\\', $classParts);
$namespace = $this->namespace . ($namespace === '' ? '' : $namespace);
$namespace = ($namespace === '' ? '' : '\\'.$namespace);
$namespace = $this->namespace . $namespace;

return [
$namespace,
Expand All @@ -376,13 +378,18 @@ public function getClassNameAndNamespaceFromPath(string $path, string $classPref
*/
public function getPhpNameFromType(string $type): string
{
$class = $type;
if (preg_match('$^#/definitions/$', $type)) {
$className = preg_replace('$#/definitions/$', '', $type);
$className = $this->helper::camelize($className);
return '\\' . $this->modelNamespace . '\\' . $className;
$class = '\\' . $this->modelNamespace . '\\' . $className;
}

if (preg_match('#\[]$#', $type) && $class !== $type) {
$class .= "[]";
}

return $type;
return $class;
}

/**
Expand Down

0 comments on commit 84bd0f2

Please sign in to comment.