From aac28a47ed181087c25d60e81f7a27692ffbf46e Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 23 Jul 2024 14:07:25 +1000 Subject: [PATCH] Make blueprint an optional dependency (#52) Fix up CI image --- composer.json | 8 +++++--- readme.md | 2 +- src/Provider/DingoServiceProvider.php | 24 +++++++++++++----------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 0188d64..68bbd3b 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,6 @@ }], "require": { "php": "^8.0", - "dingo/blueprint": "~0.4", "illuminate/routing": "^9.0|^10.0|^11.0", "illuminate/support": "^9.0|^10.0|^11.0", "league/fractal": "^0.20" @@ -33,10 +32,13 @@ "mockery/mockery": "~1.0", "phpunit/phpunit": "^9.0|^10.0", "squizlabs/php_codesniffer": "~2.0", - "php-open-source-saver/jwt-auth": "^1.4 | ^2.2" + "php-open-source-saver/jwt-auth": "^1.4 | ^2.2", + "dingo/blueprint": "~0.4" }, "suggest": { - "php-open-source-saver/jwt-auth": "Protect your API with JSON Web Tokens." + "php-open-source-saver/jwt-auth": "Protect your API with JSON Web Tokens.", + "specialtactics/laravel-api-boilerplate": "API Boilerplate for Laravel", + "dingo/blueprint": "Legacy package which can produce API docs from dingo/api" }, "autoload": { "psr-4": { diff --git a/readme.md b/readme.md index 6cd163d..0c972c4 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ Please note, we do not actively maintain the Lumen support of this project. If y The Dingo API package is meant to provide you, the developer, with a set of tools to help you easily and quickly build your own API. While the goal of this package is to remain as flexible as possible it still won't cover all situations and solve all problems. -[!Build Status](https://github.com/api-ecosystem-for-laravel/dingo-api/actions/workflows/ci.yml/badge.svg?branch=master) +[![CI Tests](https://github.com/api-ecosystem-for-laravel/dingo-api/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/api-ecosystem-for-laravel/dingo-api/actions) [![License](https://img.shields.io/packagist/l/api-ecosystem-for-laravel/dingo-api.svg?style=flat-square)](LICENSE) [![Development Version](https://img.shields.io/packagist/vpre/api-ecosystem-for-laravel/dingo-api.svg?style=flat-square)](https://packagist.org/packages/api-ecosystem-for-laravel/dingo-api) [![Monthly Installs](https://img.shields.io/packagist/dm/api-ecosystem-for-laravel/dingo-api.svg?style=flat-square)](https://packagist.org/packages/api-ecosystem-for-laravel/dingo-api) diff --git a/src/Provider/DingoServiceProvider.php b/src/Provider/DingoServiceProvider.php index 7800f04..aef606b 100644 --- a/src/Provider/DingoServiceProvider.php +++ b/src/Provider/DingoServiceProvider.php @@ -186,16 +186,18 @@ protected function registerTransformer() */ protected function registerDocsCommand() { - $this->app->singleton(\Dingo\Api\Console\Command\Docs::class, function ($app) { - return new Command\Docs( - $app[\Dingo\Api\Routing\Router::class], - $app[\Dingo\Blueprint\Blueprint::class], - $app[\Dingo\Blueprint\Writer::class], - $this->config('name'), - $this->config('version') - ); - }); - - $this->commands([\Dingo\Api\Console\Command\Docs::class]); + if (class_exists(\Dingo\Blueprint\Blueprint::class)) { + $this->app->singleton(\Dingo\Api\Console\Command\Docs::class, function ($app) { + return new Command\Docs( + $app[\Dingo\Api\Routing\Router::class], + $app[\Dingo\Blueprint\Blueprint::class], + $app[\Dingo\Blueprint\Writer::class], + $this->config('name'), + $this->config('version') + ); + }); + + $this->commands([\Dingo\Api\Console\Command\Docs::class]); + } } }