Change the way we define and update open api definitions

This commit is contained in:
David Bomba 2023-02-11 14:54:54 +11:00
parent 8df6ce826d
commit 0edc825e5a
8 changed files with 38197 additions and 1 deletions

View File

@ -0,0 +1,74 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Console\Commands;
use DirectoryIterator;
use Faker\Factory;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class OpenApiYaml extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:openapi';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Build OpenApi YAML';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
$this->faker = Factory::create();
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$path = base_path('openapi');
$directory = new DirectoryIterator($path);
$this->info($directory);
foreach ($directory as $file) {
$this->info($file);
Storage::disk('base')->delete('/openapi/api-docs.yaml');
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/info.yaml'));
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/paths/paths.yaml'));
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/components.yaml'));
Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/misc/misc.yaml'));
}
}
}

View File

@ -32,6 +32,22 @@ return [
'disks' => [
'base' => [
'driver' => 'local',
'root' => base_path(),
'permissions' => [
'file' => [
'public' => 0664,
'private' => 0600,
],
'dir' => [
'public' => 0775,
'private' => 0700,
],
],
'throw' => false,
],
'local' => [
'driver' => 'local',
'root' => storage_path('app'),

View File

@ -161,7 +161,7 @@ return [
/*
* Set this to `true` to generate a copy of documentation in yaml format
*/
'generate_yaml_copy' => env('L5_SWAGGER_GENERATE_YAML_COPY', false),
'generate_yaml_copy' => env('L5_SWAGGER_GENERATE_YAML_COPY', true),
/*
* Edit to trust the proxy's ip address - needed for AWS Load Balancer

19053
openapi/api-docs.yaml Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

17
openapi/info.yaml Normal file
View File

@ -0,0 +1,17 @@
openapi: 3.0.0
info:
title: 'Invoice Ninja'
description: |
# Invoice Ninja.
## Self hosted Invoicing lives here.
termsOfService: 'https://invoiceninja.github.io/docs/legal/terms_of_service/#page-content'
contact:
email: contact@invoiceninja.com
license:
name: 'Elastic License'
url: 'https://www.elastic.co/licensing/elastic-license'
version: 1.0.30
servers:
-
url: 'https://demo.invoiceninja.com'
description: 'Demo API Server InvoiceNinja, you can use the demo API key `TOKEN` to test the endpoints.'

12
openapi/misc/misc.yaml Normal file
View File

@ -0,0 +1,12 @@
tags:
-
name: login
description: Authentication
externalDocs:
description: 'Find out more'
url: 'https://invoiceninja.github.io'
externalDocs:
description: 'https://invoiceninja.github.io'
url: 'https://invoiceninja.github.io'
security:
- []

14925
openapi/paths/paths.yaml Normal file

File diff suppressed because it is too large Load Diff