laravel-apidoc-generator: @response does not show up

/**
 * @response {
 *  data: [],
 *}
 */

What I have to do to make it work ? 1.7.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 16 (1 by maintainers)

Most upvoted comments

I’ve been looking at the code and from what I can tell, @response doc tags are only available for the latest development version (meaning that if you are using the tagged 2.0 version then you are not getting it; you need to use the master branch).

It also seems that the Dingo generator does not have the feature enabled (only LaravelGenerator has had it’s code changed with the @response and @transformer tags in the master branch)

Version 1.7.0 obviously does not get @response tag support, and it most likely will not. I’m currently working on a 1.7 fork (since I am stuck with Laravel 5.2 and cannot upgrade to 5.4 at this time) that will enable this feature, and once I get something working I’ll see if @mpociot will merge it as potentially 1.7.1 (depends on his willingness to support older releases)

Same here. I fix it by use command to replace characters:

namespace App\Console\Commands;

use Illuminate\Console\Command;

class GenerateApiDoc extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'api:docs {version}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate API documents';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $version = $this->argument('version');
        $this->call('api:generate', ['--routePrefix' => "{$version}/*", '--force' => 'true']);

        $file = __DIR__ . '/../../../public/docs/index.html';
        if (file_exists($file)) {
            $html = file_get_contents($file);

            $html = str_replace('\n', '<br>', $html);
            $html = str_replace('"{', '{', $html);
            $html = str_replace('}"', '}', $html);
            $html = str_replace('\"', '"', $html);

            file_put_contents($file, $html);
        }
    }
}

Result:

screenshot 26

Using dev-master with laravel 5.5 and am not seeing the response output.

I did the steps said by @filtration, now I can see the response but its not well formatted “{\n data: ["123":"123"],\n}” Image bad format

Hey @Punksolid your issue has been fixed in #271. Going to tag a new release soon.

This is what I did.

  • Deleted public/docs folder.
  • Deleted vendors/mcociot folder.
  • Deleted any reference to the package from my composer.json file.
  • Ran command: composer require mpociot/laravel-apidoc-generator:dev-master
  • Ran command: php artisan api:generate --routePrefix='api/v1/*'

At this point the @response tag was showing up, but not correctly formatted.

Creating a command and using the code from @uocgansoi worked and the example response is now present and correctly formatted.

Hope this helps.

@almightynassar thanks. You saved me hours. I updated my composer.json to use the master branch

composer require mpociot/laravel-apidoc-generator:dev-master

I have the same problem in Laravel 5.4 and mpociot 2.0 !!!

also typical docblock tags like for example @param and @return are not show up

For me neither.