array to string conversion
- [x] I confirm that I have read and attempted the tips in the Troubleshooting Guide.
when adding nested array it fails in generating the docs and gives the error below ,
it fails because of the filter.categories_ids and filter.brands_ids are arrays
I'm facing a similar problem, so I'll add some information.
Points:
- 'example_languages': "bash", "javascript", "php", etc
- Route method must be "get"
Case 1.
routes/api.php:
/**
* ?param[id][0]=1
* @queryParam param object
* @queryParam param.id integer[] required
*/
Route::get("/test", function () {
return "Test";
});
Then
at vendor/knuckleswtf/scribe/src/Tools/WritingUtils.php:119
115▕ } else {
116▕ // Hash query param (eg filter[name]=john should become "filter[name]": "john")
117▕ foreach ($value as $item => $itemValue) {
118▕ $output .= str_repeat(" ", $spacesIndentation);
➜ 119▕ $output .= "$startLinesWith$quote$parameter" . "[$item]$quote$delimiter $quote$itemValue$quote$endLinesWith\n";
120▕ }
121▕ }
122▕ }
123▕ }
+9 vendor frames
10 storage/framework/views/a445359943839067f85d5861bd9b00bd1213813a.php:15
Knuckles\Scribe\Tools\WritingUtils::printQueryParamsAsKeyValue([], "'", "=>", "[]")
+8 vendor frames
19 storage/framework/views/82d66105162ba1e5469d368df4c08c33adede6c9.php:21
Illuminate\View\View::render()
Case 2.
routes/api.php:
/**
* ?param[0][id]=1
* @queryParam param object[]
* @queryParam param.*.id integer required
*/
Route::get("/test", function () {
return "Test";
});
Then
at vendor/knuckleswtf/scribe/src/Tools/WritingUtils.php:114
110▕ }
111▕ if (array_keys($value)[0] === 0) {
112▕ // List query param (eg filter[]=haha should become "filter[]": "haha")
113▕ $output .= str_repeat(" ", $spacesIndentation);
➜ 114▕ $output .= "$startLinesWith$quote$parameter" . "[]$quote$delimiter $quote$value[0]$quote$endLinesWith\n";
115▕ } else {
116▕ // Hash query param (eg filter[name]=john should become "filter[name]": "john")
117▕ foreach ($value as $item => $itemValue) {
118▕ $output .= str_repeat(" ", $spacesIndentation);
+9 vendor frames
10 storage/framework/views/a445359943839067f85d5861bd9b00bd1213813a.php:15
Knuckles\Scribe\Tools\WritingUtils::printQueryParamsAsKeyValue([], "'", "=>", "[]")
+8 vendor frames
19 storage/framework/views/82d66105162ba1e5469d368df4c08c33adede6c9.php:21
Illuminate\View\View::render()
My environment:
- PHP version: 8.0.8
- Framework: Laravel
- Laravel/Lumen version: v9.0.2
- Scribe version: 3.26.0
My Scribe config (minus the comments):
<?php
use Knuckles\Scribe\Extracting\Strategies;
return [
'theme' => 'default',
'title' => null,
'description' => '',
'base_url' => null,
'routes' => [
[
'match' => [
'prefixes' => ['api/*'],
'domains' => ['*'],
'versions' => ['v1'],
],
'include' => [
],
'exclude' => [
],
'apply' => [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'response_calls' => [
'methods' => ['GET'],
'config' => [
'app.env' => 'documentation',
],
'queryParams' => [
],
'bodyParams' => [
],
'fileParams' => [
],
'cookies' => [
],
],
],
],
],
'type' => 'static',
'static' => [
'output_path' => 'public/docs',
],
'laravel' => [
'add_routes' => true,
'docs_url' => '/docs',
'middleware' => [],
],
'try_it_out' => [
'enabled' => true,
'base_url' => null,
'use_csrf' => false,
'csrf_url' => '/sanctum/csrf-cookie',
],
'auth' => [
'enabled' => false,
'default' => false,
'in' => 'bearer',
'name' => 'key',
'use_value' => env('SCRIBE_AUTH_KEY'),
'placeholder' => '{YOUR_AUTH_KEY}',
'extra_info' => 'You can retrieve your token by visiting your dashboard and clicking <b>Generate API token</b>.',
],
'intro_text' => "",
'example_languages' => [
"php",
// 'bash',
// 'javascript',
],
'postman' => [
'enabled' => true,
'overrides' => [
],
],
'openapi' => [
'enabled' => true,
'overrides' => [
],
],
'default_group' => 'Endpoints',
'logo' => false,
'faker_seed' => null,
'strategies' => [
'metadata' => [
Strategies\Metadata\GetFromDocBlocks::class,
],
'urlParameters' => [
Strategies\UrlParameters\GetFromLaravelAPI::class,
Strategies\UrlParameters\GetFromLumenAPI::class,
Strategies\UrlParameters\GetFromUrlParamTag::class,
],
'queryParameters' => [
Strategies\QueryParameters\GetFromFormRequest::class,
Strategies\QueryParameters\GetFromInlineValidator::class,
Strategies\QueryParameters\GetFromQueryParamTag::class,
],
'headers' => [
Strategies\Headers\GetFromRouteRules::class,
Strategies\Headers\GetFromHeaderTag::class,
],
'bodyParameters' => [
Strategies\BodyParameters\GetFromFormRequest::class,
Strategies\BodyParameters\GetFromInlineValidator::class,
Strategies\BodyParameters\GetFromBodyParamTag::class,
],
'responses' => [
Strategies\Responses\UseTransformerTags::class,
Strategies\Responses\UseApiResourceTags::class,
Strategies\Responses\UseResponseTag::class,
Strategies\Responses\UseResponseFileTag::class,
Strategies\Responses\ResponseCalls::class,
],
'responseFields' => [
Strategies\ResponseFields\GetFromResponseFieldTag::class,
],
],
'fractal' => [
'serializer' => null,
],
'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class,
'database_connections_to_transact' => [config('database.default')]
];
Sorry💦 maybe the problem mentioned in my reply is a duplicate of issue #308
This should be fixed by https://github.com/knuckleswtf/scribe/pull/603. Let me know if it's still an issue.
Hi @shalvah it works with PHP, JS and Python, but not with bash