diff --git a/app/Console/Commands/OpenApiYaml.php b/app/Console/Commands/OpenApiYaml.php index 8ffc478a4996..9c43a7408a9e 100644 --- a/app/Console/Commands/OpenApiYaml.php +++ b/app/Console/Commands/OpenApiYaml.php @@ -32,6 +32,11 @@ class OpenApiYaml extends Command */ protected $description = 'Build OpenApi YAML'; + private array $directories = [ + '/components/schemas', + '/paths/' + ]; + /** * Create a new command instance. * @@ -65,11 +70,43 @@ class OpenApiYaml extends Command 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.'/paths/clients.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.'/paths.yaml')); + + //iterate paths + $directory = new DirectoryIterator($path . '/paths/'); + + foreach ($directory as $file) { + + if ($file->isFile() && ! $file->isDot()) + { + + Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents("{$path}/paths/{$file->getFilename()}")); + + } + + } + + + + Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components.yaml')); Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/schemas.yaml')); - Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/schemas/account.yaml')); + + //iterate schemas + + $directory = new DirectoryIterator($path . '/components/schemas/'); + + foreach ($directory as $file) { + + if ($file->isFile() && ! $file->isDot()) + { + + Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents("{$path}/components/schemas/{$file->getFilename()}")); + + } + + } + + // Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/components/schemas/account.yaml')); Storage::disk('base')->append('/openapi/api-docs.yaml', file_get_contents($path.'/misc/misc.yaml')); diff --git a/openapi/api-docs.yaml b/openapi/api-docs.yaml index c1e16d090397..dda5cf709088 100644 --- a/openapi/api-docs.yaml +++ b/openapi/api-docs.yaml @@ -1,6 +1,6 @@ openapi: 3.0.0 info: - title: 'Invoice Ninja API Reference - Where self host Invoicing lives.' + title: 'Invoice Ninja API Reference - Where self host invoicing lives.' description: | ---
@@ -15,7 +15,7 @@ info: license: name: 'Elastic License' url: 'https://www.elastic.co/licensing/elastic-license' - version: 1.0.30 + version: 5.5.70 servers: - url: 'https://demo.invoiceninja.com' @@ -19355,6 +19355,10 @@ components: description: 'The account hashed id' type: string example: AS3df3A + account_sms_verified: + description: 'Boolean flag if the account has been verified by sms' + type: string + example: true type: object tags: - diff --git a/openapi/components/components.yaml b/openapi/components.yaml similarity index 100% rename from openapi/components/components.yaml rename to openapi/components.yaml diff --git a/openapi/components/schemas/account.yaml b/openapi/components/schemas/account.yaml index 1d81cf0208f4..924d6ea87e31 100644 --- a/openapi/components/schemas/account.yaml +++ b/openapi/components/schemas/account.yaml @@ -4,4 +4,8 @@ description: 'The account hashed id' type: string example: AS3df3A + account_sms_verified: + description: 'Boolean flag if the account has been verified by sms' + type: string + example: true type: object \ No newline at end of file diff --git a/openapi/paths/paths.yaml b/openapi/paths.yaml similarity index 100% rename from openapi/paths/paths.yaml rename to openapi/paths.yaml