RestAPI spec generator with Laravel test

2.0.1 2021-11-14 09:45 UTC

This package is auto-updated.

Last update: 2024-03-30 00:18:35 UTC


API Spec generator with Laravel test

This Package overrides json() When you use those function, API specs are going to be generated.

You can select spec below,

  • Rest
  • OpenAPI Specification


Output each specs

Just use ApiSpec\ApiSpecTestCase as base class for API-based test classes.

+use ApiSpec\ApiSpecTestCase;

class SomeTestCase extends ApiSpecTestCase

or use trait ApiSpec\ApiSpecOutput

+use ApiSpec\ApiSpecOutput;

class SomeTestCase extends TestCase
    +use ApiSpecOutput;

Aggregate output files

After Output each specs, this command aggregates all specs in one file. (only supports OAS mode)

php artisan apispec:aggregate


This package provides config file as apispec.php

return [
     // Whether to output spec files.
    'isExportSpec' => true,

     // Spec builder class name. You can choose ToOAS or ToHTTP.
    'builder'      => \ApiSpec\Builders\ToOAS::class,



The output format is recognized on several IDE.

ex) PHPStorm, IntelliJ IDEA...(2017.3 EAP https://blog.jetbrains.com/phpstorm/2017/09/editor-based-rest-client/


The output format is OpenAPI 3.0.0

Restrictions are below

  • Security Scheme type supports only JWT
  • All request body contents have required flag
  • Some parameters hard coded.