Skip to content

Commit 8bf5e56

Browse files
committed
update route processor
1 parent de5e7f1 commit 8bf5e56

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/Processors/RouteProcessor.php

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,25 @@ protected function processRoute(Route $route)
9090
// return [];
9191
// }
9292

93+
if ($this->config['include_doc_comments']) {
94+
$description = (new DocBlockProcessor)($reflectionMethod);
95+
}
96+
9397
$data = [
9498
'name' => $route->uri(),
95-
'request' => $this->processRequest(
96-
$method,
97-
$uri,
98-
$this->config['enable_formdata'] ? (new FormDataProcessor)->process($reflectionMethod) : collect()
99+
'request' => array_merge(
100+
$this->processRequest(
101+
$method,
102+
$uri,
103+
$this->config['enable_formdata'] ? (new FormDataProcessor)->process($reflectionMethod) : collect()
104+
),
105+
['description' => $description ?? '']
99106
),
100107
'response' => [],
108+
109+
'protocolProfileBehavior' => [
110+
'disableBodyPruning' => $this->config['protocol_profile_behavior']['disable_body_pruning'] ?? false,
111+
],
101112
];
102113

103114
if ($this->config['structured']) {
@@ -139,19 +150,26 @@ protected function processRequest(string $method, Stringable $uri, Collection $r
139150
->all(),
140151
],
141152
])
142-
->when($rules, function (Collection $collection, Collection $rules) {
153+
->when($rules, function (Collection $collection, Collection $rules) use ($method) {
143154
if ($rules->isEmpty()) {
144155
return $collection;
145156
}
146157

158+
$rules->transform(fn ($rule) => [
159+
'key' => $rule['name'],
160+
'value' => $this->config['formdata'][$rule['name']] ?? null,
161+
'description' => $this->config['print_rules'] ? $this->parseRulesIntoHumanReadable($rule['name'], $rule['description']) : null,
162+
]);
163+
164+
if ($method === 'GET') {
165+
return $collection->put('url', [
166+
'query' => $rules->map(fn ($value) => array_merge($value, ['disabled' => false]))
167+
]);
168+
}
169+
147170
return $collection->put('body', [
148171
'mode' => 'urlencoded',
149-
'urlencoded' => $rules->map(fn ($rule) => [
150-
'key' => $rule['name'],
151-
'value' => $this->config['formdata'][$rule['name']] ?? null,
152-
'type' => 'text',
153-
'description' => $this->config['print_rules'] ? $this->parseRulesIntoHumanReadable($rule['name'], $rule['description']) : null,
154-
]),
172+
'urlencoded' => $rules->map(fn ($value) => array_merge($value, ['type' => 'text'])),
155173
]);
156174
})
157175
->all();

0 commit comments

Comments
 (0)