Skip to content

Commit

Permalink
Remove redundant commands and update installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Feb 12, 2018
2 parents dec90fd + 88288d0 commit 48eaa70
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 172 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ env:
matrix:
fast_finish: true
include:
- php: 7.0
- php: 7.1
- php: 7.2
env: REPORT_TESTS_COVERAGE=1
cache:
directories:
Expand All @@ -26,6 +26,7 @@ before_script:
- ./cc-test-reporter before-build
script:
- chown -R travis:travis /home/travis/build/DarkaOnLine/L5-Swagger
- mkdir -p tests/storage/logs/test-reports
- chmod -R 777 /home/travis/build/DarkaOnLine/L5-Swagger
- vendor/bin/phpunit
- cp tests/storage/logs/test-reports/clover.xml clover.xml
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ This package is a wrapper of [Swagger-php](https://github.com/zircote/swagger-ph
Installation
============

For Swagger 2.0

Laravel | Swagger UI| OpenAPI Spec compatibility | L5-Swagger
:---------|:----------|:---------------------------|:----------
5.1.x | 2.2 | 1.1, 1.2, 2.0 | ```php composer require "darkaonline/l5-swagger:~3.0" ```
Expand All @@ -24,13 +22,16 @@ For Swagger 2.0
5.4.x | 2.2 | 1.1, 1.2, 2.0 | ```php composer require "darkaonline/l5-swagger:~4.0" ```
5.4.x | 3 | 2.0 | ```php composer require "darkaonline/l5-swagger:5.4.*" ```
5.5.x | 3 | 2.0 | ```php composer require "darkaonline/l5-swagger:5.5.*" ```
5.6.x | 3 | 2.0 | ```php composer require "darkaonline/l5-swagger:5.6.*" ```

You can publish L5-Swagger's config and view files into your project by running:

For Swagger 1.0
```php
composer require darkaonline/l5-swagger
```bash
$ php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'
```

For Laravel >=5.5, no need to manually add `L5SwaggerServiceProvider` into config. It uses package auto discovery feature. Skip this if you are on >=5.5, if not:

Open your `AppServiceProvider` (located in `app/Providers`) and add this line in `register` function
```php
$this->app->register(\L5Swagger\L5SwaggerServiceProvider::class);
Expand All @@ -40,17 +41,14 @@ or open your `config/app.php` and add this line in `providers` section
L5Swagger\L5SwaggerServiceProvider::class,
```

For Laravel 5.5, no need to manually add `L5SwaggerServiceProvider` into config. It uses package auto discovery feature.

Using Swagger UI with Passport
============
The easiest way to build and test your Laravel-based API using Swagger-php is to use Passport's `CreateFreshApiToken` middleware. This middleware, built into Laravel's core, adds a cookie to all responses, and the cookie authenticates all subsequent requests through Passport's `TokenGuard`.

To get started, first publish L5-Swagger's config and view files into your own project:

```bash
$ php artisan l5-swagger:publish-config
$ php artisan l5-swagger:publish-views
$ php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'
```

Next, edit your `config/l5-swagger.php` configuration file. Locate the `l5-swagger.routes.middleware` section, and add the following middleware list to the `api` route:
Expand Down Expand Up @@ -131,10 +129,12 @@ Migrate from 3.0|4.0 to 5.0

Configuration
============
### For versions < 5.5
- Run `l5-swagger:publish` to publish everything
- Run `l5-swagger:publish-config` to publish configs (`config/l5-swagger.php`)
- Run `l5-swagger:publish-assets` to publish swagger-ui to your public folder (`public/vendor/l5-swagger`)
- Run `l5-swagger:publish-views` to publish views (`resources/views/vendor/l5-swagger`) - only for versions <= 4.0
### For all versions
- Run `l5-swagger:generate` to generate docs or set `generate_always` param to `true` in your config or .env file

Swagger-php
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
}
],
"require": {
"php": "^7.0",
"laravel/framework": "5.5.*",
"php": ">=7.1.3",
"laravel/framework": "5.6.*",
"zircote/swagger-php": "~2.0",
"swagger-api/swagger-ui": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "6.*",
"phpunit/phpunit": "7.*",
"mockery/mockery": "0.9.*",
"orchestra/testbench": "3.5.*",
"orchestra/testbench": "3.6.*",
"satooshi/php-coveralls": "^1.0"
},
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./tests/storage/logs/test-reports" charset="UTF-8"
<log type="coverage-html" target="tests/storage/logs/test-reports" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80" />
<log type="coverage-clover" target="./tests/storage/logs/test-reports/clover.xml"/>
<log type="junit" target="./tests/storage/logs/test-reports/junit.xml" logIncompleteSkipped="false"/>
<log type="coverage-clover" target="tests/storage/logs/test-reports/clover.xml"/>
<log type="junit" target="tests/storage/logs/test-reports/junit.xml" logIncompleteSkipped="false"/>
</logging>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
Expand Down
35 changes: 0 additions & 35 deletions src/Console/PublishCommand.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Console/PublishConfigCommand.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Console/PublishViewsCommand.php

This file was deleted.

29 changes: 3 additions & 26 deletions src/L5SwaggerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace L5Swagger;

use L5Swagger\Console\PublishCommand;
use Illuminate\Support\ServiceProvider;
use L5Swagger\Console\GenerateDocsCommand;
use L5Swagger\Console\PublishViewsCommand;
use L5Swagger\Console\PublishConfigCommand;

class L5SwaggerServiceProvider extends ServiceProvider
{
Expand All @@ -32,10 +29,12 @@ public function boot()
], 'views');

//Include routes

\Route::group(['namespace' => 'L5Swagger'], function ($router) {
require __DIR__.'/routes.php';
});

//Register commands
$this->commands([GenerateDocsCommand::class]);
}

/**
Expand All @@ -48,28 +47,9 @@ public function register()
$configPath = __DIR__.'/../config/l5-swagger.php';
$this->mergeConfigFrom($configPath, 'l5-swagger');

$this->app->singleton('command.l5-swagger.publish', function () {
return new PublishCommand();
});

$this->app->singleton('command.l5-swagger.publish-config', function () {
return new PublishConfigCommand();
});

$this->app->singleton('command.l5-swagger.publish-views', function () {
return new PublishViewsCommand();
});

$this->app->singleton('command.l5-swagger.generate', function () {
return new GenerateDocsCommand();
});

$this->commands(
'command.l5-swagger.publish',
'command.l5-swagger.publish-config',
'command.l5-swagger.publish-views',
'command.l5-swagger.generate'
);
}

/**
Expand All @@ -80,9 +60,6 @@ public function register()
public function provides()
{
return [
'command.l5-swagger.publish',
'command.l5-swagger.publish-config',
'command.l5-swagger.publish-views',
'command.l5-swagger.generate',
];
}
Expand Down
24 changes: 2 additions & 22 deletions tests/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,9 @@ public function canPublish()
{
$this->setAnnotationsPath();

Artisan::call('l5-swagger:publish');
Artisan::call('vendor:publish', ['--provider' => "'L5Swagger\L5SwaggerServiceProvider'"]);

$this->assertTrue(file_exists(config_path('l5-swagger.php')));
$this->assertTrue(file_exists(config('l5-swagger.paths.views').'/index.blade.php'));
}

/** @test */
public function canPublishConfig()
{
$this->setAnnotationsPath();

Artisan::call('l5-swagger:publish-config');

$this->assertTrue(file_exists(config_path('l5-swagger.php')));
}

/** @test */
public function canPublishViews()
{
$this->setAnnotationsPath();

Artisan::call('l5-swagger:publish-views');

$this->assertTrue(file_exists(config('l5-swagger.paths.views').'/index.blade.php'));
$this->assertTrue(file_exists(config('l5-swagger.paths.views') . '/index.blade.php'));
}
}

0 comments on commit 48eaa70

Please sign in to comment.