forked from lobbywatch/lobbywatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi_generator.php
151 lines (143 loc) · 6.35 KB
/
openapi_generator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
require_once dirname(__FILE__) . '/public_html/common/utils.php';
$workflow_tables_overwritten = Constants::$workflow_tables;
$workflow_tables_overwritten['interessengruppe'] = 'Lobbygruppe (Interessengruppe)';
$tables = [];
$tables = array_merge($tables, array_map(function ($table, $name) { return ['id' => $table, 'name' => $name, 'type' => 'flat', 'call_type' => 'table', 'idCall' => true, 'listCall' => true, 'searchCall' => true]; }, array_keys($workflow_tables_overwritten), $workflow_tables_overwritten));
$tables = array_merge($tables, array_map(function ($table, $name) { return ['id' => $table, 'name' => $name, 'type' => 'flat', 'call_type' => 'relation', 'idCall' => false, 'listCall' => true, 'searchCall' => false]; }, array_keys(Constants::getAllEnrichedRelations()), Constants::getAllEnrichedRelations()));
$tables[] = ['id' => 'parlamentarier', 'name' => 'aggregierter Parlamentarier', 'type' => 'aggregated', 'call_type' => 'table', 'idCall' => true, 'listCall' => false, 'searchCall' => false];
$tables[] = ['id' => 'zutrittsberechtigung', 'name' => 'aggregierter Gast', 'type' => 'aggregated', 'call_type' => 'table', 'idCall' => true, 'listCall' => false, 'searchCall' => false];
$tables[] = ['id' => 'organisation', 'name' => 'aggregierte Organisation', 'type' => 'aggregated', 'call_type' => 'table', 'idCall' => true, 'listCall' => false, 'searchCall' => false];
$tables[] = ['id' => 'interessengruppe', 'name' => 'aggregierte Lobbygruppe (Interessengruppe)', 'type' => 'aggregated', 'call_type' => 'table', 'idCall' => true, 'listCall' => false, 'searchCall' => false];
$tables[] = ['id' => 'branche', 'name' => 'aggregierte Branche', 'type' => 'aggregated', 'call_type' => 'table', 'idCall' => true, 'listCall' => false, 'searchCall' => false];
$tables[] = ['id' => 'parlament-partei', 'name' => 'aggregierte Parlament-Partei', 'type' => 'aggregated', 'call_type' => 'query', 'idCall' => false, 'listCall' => true, 'searchCall' => false];
$ref = '$ref';
foreach($tables as $table) {
$table_id = $table['id'];
$table_id_camel = ucfirst($table_id);
$type = $table['type'];
$type_camel = ucfirst($type);
$name = $table['name'];
$name_camel = ucfirst($name);
$call_type = $table['call_type'];
$call_type_camel = ucfirst($table['call_type']);
if ($table['idCall']) {
print("
/$call_type/$table_id/$type/id/{id}:
get:
operationId: get${type_camel}${table_id_camel}Id
summary: Get $name by ID
description: Return a single $name
tags:
- By ID
- $type_camel
- $name_camel
- $call_type_camel
parameters:
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/limitParam'
- $ref: '#/components/parameters/filterSimpleParam'
- $ref: '#/components/parameters/filterListParam'
- $ref: '#/components/parameters/likeParam'
- $ref: '#/components/parameters/selectFieldsParam'
- $ref: '#/components/parameters/langParam'
- $ref: '#/components/parameters/includeUnpublishedParam'
- $ref: '#/components/parameters/includeInactiveParam'
- $ref: '#/components/parameters/includeConfidentialDataParam'
- $ref: '#/components/parameters/includeMetaDataParam'
responses:
200:
description: Returns $name
content:
application/json:
schema:
$ref: '#/components/schemas/GenericIdData'
examples:
Successful:
$ref: '#/components/examples/Successful'
Error:
$ref: '#/components/examples/Error'
404:
$ref: '#/components/responses/NotFound'
"
);
}
if ($table['listCall']) {
print("
/$call_type/$table_id/$type/list:
get:
operationId: get${type_camel}${table_id_camel}List
summary: Get list of $name
description: Return a list of $name
tags:
- List
- $type_camel
- $name_camel
- $call_type_camel
parameters:
- $ref: '#/components/parameters/limitParam'
- $ref: '#/components/parameters/filterSimpleParam'
- $ref: '#/components/parameters/filterListParam'
- $ref: '#/components/parameters/likeParam'
- $ref: '#/components/parameters/selectFieldsParam'
- $ref: '#/components/parameters/langParam'
- $ref: '#/components/parameters/includeUnpublishedParam'
- $ref: '#/components/parameters/includeInactiveParam'
- $ref: '#/components/parameters/includeConfidentialDataParam'
- $ref: '#/components/parameters/includeMetaDataParam'
responses:
200:
description: Returns list of $name
content:
application/json:
schema:
$ref: '#/components/schemas/GenericListData'
examples:
Successful:
$ref: '#/components/examples/Successful'
Error:
$ref: '#/components/examples/Error'
"
);
}
if ($table['searchCall']) {
print("
/$call_type/$table_id/$type/list/{str}:
get:
operationId: get${type_camel}${table_id_camel}List
summary: Get list of $name
description: Return a list of $name
tags:
- Search
- $type_camel
- $name_camel
- $call_type_camel
parameters:
- $ref: '#/components/parameters/searchStrParam'
- $ref: '#/components/parameters/limitParam'
- $ref: '#/components/parameters/filterSimpleParam'
- $ref: '#/components/parameters/filterListParam'
- $ref: '#/components/parameters/likeParam'
- $ref: '#/components/parameters/selectFieldsParam'
- $ref: '#/components/parameters/langParam'
- $ref: '#/components/parameters/includeUnpublishedParam'
- $ref: '#/components/parameters/includeInactiveParam'
- $ref: '#/components/parameters/includeConfidentialDataParam'
- $ref: '#/components/parameters/includeMetaDataParam'
responses:
200:
description: Returns list of $name whose name contain the search string
content:
application/json:
schema:
$ref: '#/components/schemas/GenericListData'
examples:
Successful:
$ref: '#/components/examples/Successful'
Error:
$ref: '#/components/examples/Error'
"
);
}
print("\n");
}