kotamat / laravel-apispec-generator
RestAPI spec generator with Laravel test
Installs: 54 585
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 1
Forks: 2
Open Issues: 1
Requires
- laravel/framework: >=7.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-11-30 01:56:23 UTC
README
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
Usage
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
Configurations
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, ];
Output
Rest
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/
OAS
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.