Skip to content

Commit

Permalink
Melhorias na geracao de collection para postman
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrodiogenes committed Jun 5, 2020
1 parent acc0c22 commit 8f1c416
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
trim_trailing_whitespace = false

[*.md]
trim_trailing_whitespace = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function getBodyParametersFromValidationRules(array $validationRules, arr
// Make sure the user-specified description comes first.
$userSpecifiedDescription = $userSpecifiedParameterInfo['description'] ?? '';
$validationDescription = trim($parameterData['description'] ?: '');
$fullDescription = trim($userSpecifiedDescription . ' ' . trim($validationDescription));
$fullDescription = trim($userSpecifiedDescription . ($userSpecifiedDescription && $validationDescription?'<br>':' ') . trim($validationDescription));
// Let's have our sentences end with full stops, like civilized people.🙂
$parameterData['description'] = $fullDescription ? rtrim($fullDescription, '.') . '.' : $fullDescription;

Expand Down Expand Up @@ -368,7 +368,7 @@ protected function parseRule($rule, &$parameterData)
break;
case 'min_words':
$parameterData['type'] = $parameterData['type'] ?: 'number';
$parameterData['description'] .= "*O campo precisa conter no minimo {$arguments[0]} ".plural('palavra.','palavras.',$arguments[0]).' ';
$this->changeDescription($parameterData,"*O campo precisa conter no minimo {$arguments[0]} ".plural('palavra.','palavras.',$arguments[0]).' ');
break;
case 'digits':
$parameterData['type'] = $parameterData['type'] ?: 'number';
Expand Down
4 changes: 2 additions & 2 deletions src/Extracting/Strategies/Responses/UseApiResourceTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ private function getClassToBeTransformedAndAttributes(array $tags): array
$relations = [];
$pagination = [];
if ($modelTag) {
['content' => $type, 'attributes' => $attributes] = a::parseIntoContentAndAttributes($modelTag->getContent(), ['states', 'with', 'paginate','relations','useFactory']);
['content' => $type, 'attributes' => $attributes] = a::parseIntoContentAndAttributes($modelTag->getContent(), ['states', 'with', 'paginate','relations','Use-Factory']);
$states = $attributes['states'] ? explode(',', $attributes['states']) : [];
$useFactory = !!$attributes['useFactory'];
$useFactory = !!$attributes['Use-Factory'];
$relations = $attributes['with'] ? explode(',', $attributes['with']) : [];
if(empty($relations)){
$relations = $attributes['relations'] ? explode(',', $attributes['relations']) : [];
Expand Down
16 changes: 16 additions & 0 deletions src/Writing/PostmanCollectionWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ protected function resolvePostmanEvents($route)
->values()
->all();
}





protected function parseFormDataParameters(array &$route){
foreach ($route['cleanBodyParameters'] as $key => $value) {
if(is_array($value)){
foreach($value as $subkey => $subval){
$route['cleanBodyParameters']["{$key}[$subkey]"] = $subval;
}
unset($route['cleanBodyParameters'][$key]);
}
}
}
protected function getBodyData(array $route): array
{

Expand All @@ -122,6 +137,7 @@ protected function getBodyData(array $route): array

switch ($mode) {
case 'formdata':
$this->parseFormDataParameters($route);
foreach ($route['cleanBodyParameters'] as $key => $value) {
$params = [
'key' => $key,
Expand Down

0 comments on commit 8f1c416

Please # to comment.