From bd53b3820add59aa3d5b7ad4dfa69f0a1ef78240 Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Mon, 29 Jul 2024 18:12:06 +0200 Subject: [PATCH] OpenAPI Definition Grundschema --- package.yml | 6 +- pages/yform.ymca.openapi_definition.php | 99 +++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 pages/yform.ymca.openapi_definition.php diff --git a/package.yml b/package.yml index 67dcb88..5e3e3ab 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: ymca -version: 2.2.0 +version: 2.3.0 author: alex+ Digitales Marketing, Alexander Walther supportpage: https://github.com/alexplusde/ymca @@ -20,6 +20,10 @@ pages: title: 'RESTful-API' icon: rex-icon fa-fast-forward perm: admin + yform/ymca/openapi_definition: + title: 'OpenAPI Definition' + icon: rex-icon fa-fast-forward + perm: admin yform/ymca/docs: title: 'Docs' icon: rex-icon fa-fast-forward diff --git a/pages/yform.ymca.openapi_definition.php b/pages/yform.ymca.openapi_definition.php new file mode 100644 index 0000000..5b7da54 --- /dev/null +++ b/pages/yform.ymca.openapi_definition.php @@ -0,0 +1,99 @@ +
+
+ + getArray("SELECT table_name FROM rex_yform_table ORDER BY table_name"); + $t = []; + foreach ($tables as $table) { + $t[] = $table['table_name']; + } + + $definition = []; + + $definition['openapi'] = '3.1.0'; + $definition['info']['title'] = '<>Klassenname> API'; + $definition['info']['description'] = 'API zur Abfrage von Daten zu .'; + $definition['info']['version'] = '1.0.0'; + $definition['servers'][] = ['url' => 'https://'.rex::getServer(), 'description' => 'Live-Server']; + + + + /* %1$s = Tabellenname, %2$s = Klassenname */ + + foreach ($t as $table) { + + $table_name = $table; + $class_name = str_replace('rex_', '', $table); + + $path = ['/rest/addonname/klassenname/1.0.0/']; + + $results = rex_sql::factory()->getArray("SELECT `id`, `table_name`, `prio`, `type_name`, `type_id`, `db_type`, `name`, `label` FROM `rex_yform_field` WHERE `type_name` != 'validate' AND `table_name` = '$table' ORDER BY `prio`"); + + $get = []; + $post = []; + + foreach ($results as $result) { + + if ($result['type_name'] === 'fieldset') { + continue; + } + + if ($result['type_name'] === 'html') { + continue; + } + if ($result['type_name'] === 'prio') { + continue; + } + if ($result['type_name'] === 'be_manager_relation') { + continue; + } + + if ($result['type_id'] === 'value') { + + $get[] = $result['name']; + $post[] = $result['name']; + + } + + } + + $path['get']['fields']["$table_name"] = $get; + $path['post']['fields']["$table_name"] = $post; + + $definition['paths'] = $path; + + $definition + ?> + +
+ + +
+ +
+
+
+ +
+

NOCH NICHT FERTIG ENTWICKELT, UNTERSTÜTZUNG BENÖTIGT!

+

Fogelnden Code kopieren:

+

Tipp: im Nachgang eigenständig \rex_string::yamlEungen in der .

+ + +
+
+ + +
+ + + +
+