laravel-openapi icon indicating copy to clipboard operation
laravel-openapi copied to clipboard

Multiple parameter route

Open rizqi-perdana opened this issue 4 years ago • 3 comments

Hi, I have such issues with multiple parameter as follow:

I code route with 3 parameter, but cannot generate the doc.

Route::prefix('activity')->group(function () {
    Route::GET('/{activity}/{personalflag}/{houseid}',
    [
      'as' => 'activity.show',
      'uses' => 'ActivityController@show',
    ]);
  });

Below is the error that I got while using 3 parameter at route.

Symfony\Component\Debug\Exception\FatalThrowableError  : Argument 1 passed to Vyuldashev\LaravelOpenApi\SchemaHelpers::guessFromReflectionType() must be an instance of ReflectionType, null given, called in D:\xampp7.3.0\htdocs\laravel\layanesia\vendor\vyuldashev\laravel-openapi\src\Builders\Paths\Operation\ParametersBuilder.php on line 39

  at D:\xampp7.3.0\htdocs\laravel\layanesia\vendor\vyuldashev\laravel-openapi\src\SchemaHelpers.php:10
     6| use ReflectionType;
     7|
     8| class SchemaHelpers
     9| {
  > 10|     public static function guessFromReflectionType(ReflectionType $reflectionType): Schema
    11|     {
    12|         switch ($reflectionType->getName()) {
    13|             case 'int':
    14|                 return Schema::integer();

  Exception trace:

  1   Vyuldashev\LaravelOpenApi\SchemaHelpers::guessFromReflectionType()
      D:\xampp7.3.0\htdocs\laravel\layanesia\vendor\vyuldashev\laravel-openapi\src\Builders\Paths\Operation\ParametersBuilder.php:39

  2   Vyuldashev\LaravelOpenApi\Builders\Paths\Operation\ParametersBuilder::Vyuldashev\LaravelOpenApi\Builders\Paths\Operation\{closure}(["houseid"])
      [internal]:0

  Please use the argument -v to see more details.

rizqi-perdana avatar Jul 27 '20 04:07 rizqi-perdana

Also experienced this, it seems to looking at the variable name rather than type You can hack around if it you edit line 39 to add some if conditions to handle specific cases to return Schema::integer(), Schema::string(), etc. but would be great to fix this up

coderintherye avatar Aug 06 '20 08:08 coderintherye

could you please paste your controller and action definition (without contents)?

vyuldashev avatar Aug 06 '20 21:08 vyuldashev

public function show($id, $layMyPersonalFlag, $houseid)

rizqi-perdana avatar Aug 11 '20 10:08 rizqi-perdana