diff --git a/composer.json b/composer.json index d912455..9f328d2 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Swagger yaml generator", "keywords": ["api", "swagger", "open auth"], "license": "MIT", - "version": "1.4.4", + "version": "1.4.5", "authors": [ { "name": "Digit", diff --git a/oa/BaseValueDescribed.php b/oa/BaseValueDescribed.php index 8033339..8e5e079 100644 --- a/oa/BaseValueDescribed.php +++ b/oa/BaseValueDescribed.php @@ -75,6 +75,17 @@ abstract class BaseValueDescribed extends BaseAnnotation */ protected ?string $_phpType = null; + /** + * BaseValueDescribed constructor. + * + * @param array $values + */ + public function __construct(array $values) + { + $this->configureSelf($values, 'name'); + $this->processType(); + } + /** * Check that variable name is nested (with dots) * @return bool @@ -153,17 +164,6 @@ public function toArrayRecursive(array &$target): void } } - /** - * BaseValueDescribed constructor. - * - * @param array $values - */ - public function __construct(array $values) - { - $this->configureSelf($values, 'name'); - $this->processType(); - } - /** * Get object string representation. * diff --git a/oa/Parameter.php b/oa/Parameter.php index cca682e..6b0703b 100644 --- a/oa/Parameter.php +++ b/oa/Parameter.php @@ -16,6 +16,7 @@ * @Attribute("name",type="string"), * @Attribute("type",type="string"), * @Attribute("in",type="string"), + * @Attribute("style",type="string"), * @Attribute("description",type="string"), * }) */ @@ -112,7 +113,7 @@ protected static function getDefaultStyles(): array return [ // 'in.type' => 'style', // 'in.*' => 'style', - 'query.array' => 'deepObject', + 'query.array' => 'form', ]; } } diff --git a/src/RoutesParser.php b/src/RoutesParser.php index 8da2f6d..e631bf1 100644 --- a/src/RoutesParser.php +++ b/src/RoutesParser.php @@ -445,13 +445,21 @@ protected function convertRequestBodyIntoQueryParams(array $body): ?array $properties = $bodyByContentType['schema']['properties']; foreach ($properties as $property => $row) { $type = $row['type'] ?? null; + $paramName = $property; // Parse objects if ($type === Variable::SW_TYPE_OBJECT) { - $paramsPlain = $this->convertRequestBodyObjectToPlainParamsForQuery($row, $property); + $paramsPlain = $this->convertRequestBodyObjectToPlainParamsForQuery($row, $paramName); $params = array_merge($params, $paramsPlain); continue; } - $param = new Parameter(array_merge($row, ['in' => 'query', 'name' => $property])); + // Modify array + if ($type === Variable::SW_TYPE_ARRAY) { + $paramName .= '[]'; + $typeItems = $row['items'] ?? Variable::SW_TYPE_STRING; + $typeItems = is_array($typeItems) ? $typeItems['type'] ?? Variable::SW_TYPE_STRING : $typeItems; + $row = array_merge($row, ['items' => $typeItems]); + } + $param = new Parameter(array_merge($row, ['in' => 'query', 'name' => $paramName])); $params[$property] = $param->toArray(); } }