-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from P3D-Legacy/develop
- Loading branch information
Showing
34 changed files
with
637 additions
and
604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use cebe\openapi\exceptions\IOException; | ||
use cebe\openapi\exceptions\TypeErrorException; | ||
use cebe\openapi\exceptions\UnresolvableReferenceException; | ||
use cebe\openapi\Reader; | ||
use cebe\openapi\Writer; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class UpdateAPIDocs extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'api:docs'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Update the API documentation in JSON format from the OpenAPI documentation in YAML format.'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
// Generate Scribe API Docs | ||
Artisan::call('scribe:generate'); | ||
|
||
// Get YAML from storage | ||
$file_path = storage_path('app/scribe/openapi.yaml'); | ||
try { | ||
$openapi = Reader::readFromYamlFile($file_path); | ||
} catch (IOException|TypeErrorException|UnresolvableReferenceException $e) { | ||
$this->error($e->getMessage()); | ||
|
||
return Command::FAILURE; | ||
} | ||
$json = Writer::writeToJson($openapi); | ||
// Save JSON to storage | ||
$file_path = storage_path('app/scribe/openapi.json'); | ||
file_put_contents($file_path, $json); | ||
$this->info('API documentation updated.'); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.