Skip to content

Commit c3b16b4

Browse files
authored
Merge pull request #14 from Kambarov/feat/additional-changes
additional changes for the documentation
2 parents b09d170 + b9853b8 commit c3b16b4

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/Attributes/Parameter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ public function __construct(
1717
public string $description = '',
1818
public bool $deprecated = false,
1919
public mixed $example = null,
20+
public mixed $parameters = null,
2021
) {}
2122
}

src/Services/EnhancedResponseAnalyzer.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
use Illuminate\Contracts\Config\Repository;
88
use Illuminate\Database\Eloquent\ModelNotFoundException;
9-
use Illuminate\Http\JsonResponse;
10-
use Illuminate\Http\Resources\Json\JsonResource;
11-
use Illuminate\Http\Response;
129
use Illuminate\Validation\ValidationException;
1310
use JkBennemann\LaravelApiDocumentation\Attributes\DataResponse;
1411
use JkBennemann\LaravelApiDocumentation\Attributes\Parameter;
@@ -1092,9 +1089,21 @@ private function applyParameterAttributesToSchema(?array $schema, string $contro
10921089
if ($enhancement->deprecated) {
10931090
$property['deprecated'] = true;
10941091
}
1092+
1093+
unset($parameterEnhancements[$propertyName]);
10951094
}
10961095
}
10971096

1097+
foreach ($parameterEnhancements as $parameterEnhancement) {
1098+
$schema['properties'][$parameterEnhancement->name] = [
1099+
'type' => $parameterEnhancement->type ? $this->mapParameterTypeToOpenApi($parameterEnhancement->type) : 'string',
1100+
'format' => $parameterEnhancement->format,
1101+
'description' => $parameterEnhancement->description,
1102+
'example' => $parameterEnhancement->example,
1103+
'deprecated' => $parameterEnhancement->deprecated,
1104+
];
1105+
}
1106+
10981107
return $schema;
10991108

11001109
} catch (\Throwable $e) {

src/Services/RequestAnalyzer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ private function extractParameterAttributes(ReflectionClass $reflection): array
324324
if ($parameter->example !== null) {
325325
$parameters[$parameter->name]['example'] = $parameter->example;
326326
}
327+
328+
if ($parameter->parameters !== null) {
329+
$parameters[$parameter->name]['parameters'] = $parameter->parameters;
330+
}
327331
}
328332

329333
// Then check for attributes on the rules() method if it exists

src/Services/ResponseAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ private function getPaginatedResponse(string $collectionClass): array
738738
* Rule: Keep the code modular and easy to understand
739739
* Rule: Write concise, technical PHP code with accurate examples
740740
*/
741-
private function analyzeJsonResourceResponse(string $resourceClass): array
741+
public function analyzeJsonResourceResponse(string $resourceClass): array
742742
{
743743
try {
744744
// Rule: Project Context - Laravel API Documentation is a PHP package that provides the ability to automatically generate API documentation

0 commit comments

Comments
 (0)