1
+ <?php
2
+
3
+ namespace SoliDry \Documentation ;
4
+
5
+ use SoliDry \Types \DefaultInterface ;
6
+ use SoliDry \Types \DocumentationInterface ;
7
+ use SoliDry \Types \PhpInterface ;
8
+
9
+ trait RelationsDoc
10
+ {
11
+ /**
12
+ * Sets OAS documentation for a related method
13
+ */
14
+ private function setRelated (): void
15
+ {
16
+ $ this ->openComment ();
17
+
18
+ $ this ->setStarredComment (DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES );
19
+
20
+ $ this ->setStarredComment ('path=" ' . PhpInterface::SLASH . $ this ->generator ->version . PhpInterface::SLASH
21
+ . strtolower ($ this ->generator ->objectName ) . PhpInterface::SLASH . '{id}/{related}", ' , 1 , 1 );
22
+
23
+ $ this ->setStarredComment ('summary="Get ' . $ this ->generator ->objectName . ' related objects", ' , 1 , 1 );
24
+
25
+ $ this ->setStarredComment ('tags={" ' . $ this ->generator ->objectName . DefaultInterface::CONTROLLER_POSTFIX
26
+ . '"}, ' , 1 , 1 );
27
+
28
+ $ this ->setParameter ([
29
+ 'in ' => '"query" ' ,
30
+ 'name ' => '"data" ' ,
31
+ 'required ' => 'false ' ,
32
+ ]);
33
+
34
+ $ this ->setParameter ([
35
+ 'in ' => '"path" ' ,
36
+ 'name ' => '"id" ' ,
37
+ 'required ' => 'true ' ,
38
+ ]);
39
+
40
+ $ this ->setParameter ([
41
+ 'in ' => '"path" ' ,
42
+ 'name ' => '"related" ' ,
43
+ 'required ' => 'true ' ,
44
+ ]);
45
+
46
+ $ this ->setResponse ([
47
+ 'response ' => '200 ' ,
48
+ 'description ' => '"" ' ,
49
+ ]);
50
+
51
+ $ this ->setStarredComment (PhpInterface::CLOSE_PARENTHESES );
52
+
53
+ $ this ->closeComment ();
54
+ $ this ->setNewLines ();
55
+ }
56
+
57
+ /**
58
+ * Sets OAS documentation for getting relations method
59
+ */
60
+ private function setRelations (): void
61
+ {
62
+ $ this ->openComment ();
63
+
64
+ $ this ->setStarredComment (DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES );
65
+
66
+ $ this ->setStarredComment ('path=" ' . PhpInterface::SLASH . $ this ->generator ->version . PhpInterface::SLASH
67
+ . strtolower ($ this ->generator ->objectName ) . PhpInterface::SLASH . '{id}/relationships/{relations}", ' , 1 , 1 );
68
+
69
+ $ this ->setStarredComment ('summary="Get ' . $ this ->generator ->objectName . ' relations objects", ' , 1 , 1 );
70
+
71
+ $ this ->setStarredComment ('tags={" ' . $ this ->generator ->objectName . DefaultInterface::CONTROLLER_POSTFIX
72
+ . '"}, ' , 1 , 1 );
73
+
74
+ $ this ->setParameter ([
75
+ 'in ' => '"query" ' ,
76
+ 'name ' => '"data" ' ,
77
+ 'required ' => 'false ' ,
78
+ ]);
79
+
80
+ $ this ->setParameter ([
81
+ 'in ' => '"path" ' ,
82
+ 'name ' => '"id" ' ,
83
+ 'required ' => 'true ' ,
84
+ ]);
85
+
86
+ $ this ->setParameter ([
87
+ 'in ' => '"path" ' ,
88
+ 'name ' => '"relations" ' ,
89
+ 'required ' => 'true ' ,
90
+ ]);
91
+
92
+ $ this ->setResponse ([
93
+ 'response ' => '200 ' ,
94
+ 'description ' => '"" ' ,
95
+ ]);
96
+
97
+ $ this ->setStarredComment (PhpInterface::CLOSE_PARENTHESES );
98
+
99
+ $ this ->closeComment ();
100
+ $ this ->setNewLines ();
101
+ }
102
+
103
+ /**
104
+ * Sets OAS documentation for creating relation method
105
+ */
106
+ private function setCreateRelation (): void
107
+ {
108
+ $ this ->openComment ();
109
+
110
+ $ this ->setStarredComment (DocumentationInterface::OA_POST . PhpInterface::OPEN_PARENTHESES );
111
+
112
+ $ this ->setStarredComment ('path=" ' . PhpInterface::SLASH . $ this ->generator ->version . PhpInterface::SLASH
113
+ . strtolower ($ this ->generator ->objectName ) . PhpInterface::SLASH . '{id}/relationships/{relations}", ' , 1 , 1 );
114
+
115
+ $ this ->setStarredComment ('summary="Create ' . $ this ->generator ->objectName . ' relation object", ' , 1 , 1 );
116
+
117
+ $ this ->setStarredComment ('tags={" ' . $ this ->generator ->objectName . DefaultInterface::CONTROLLER_POSTFIX
118
+ . '"}, ' , 1 , 1 );
119
+
120
+ $ this ->setParameter ([
121
+ 'in ' => '"path" ' ,
122
+ 'name ' => '"id" ' ,
123
+ 'required ' => 'true ' ,
124
+ ]);
125
+
126
+ $ this ->setParameter ([
127
+ 'in ' => '"path" ' ,
128
+ 'name ' => '"relations" ' ,
129
+ 'required ' => 'true ' ,
130
+ ]);
131
+
132
+ $ this ->setResponse ([
133
+ 'response ' => '200 ' ,
134
+ 'description ' => '"" ' ,
135
+ ]);
136
+
137
+ $ this ->setStarredComment (PhpInterface::CLOSE_PARENTHESES );
138
+
139
+ $ this ->closeComment ();
140
+ $ this ->setNewLines ();
141
+ }
142
+
143
+ /**
144
+ * Sets OAS documentation for updating relation method
145
+ */
146
+ private function setUpdateRelation (): void
147
+ {
148
+ $ this ->openComment ();
149
+
150
+ $ this ->setStarredComment (DocumentationInterface::OA_PATCH . PhpInterface::OPEN_PARENTHESES );
151
+
152
+ $ this ->setStarredComment ('path=" ' . PhpInterface::SLASH . $ this ->generator ->version . PhpInterface::SLASH
153
+ . strtolower ($ this ->generator ->objectName ) . PhpInterface::SLASH . '{id}/relationships/{relations}", ' , 1 , 1 );
154
+
155
+ $ this ->setStarredComment ('summary="Update ' . $ this ->generator ->objectName . ' relation object", ' , 1 , 1 );
156
+
157
+ $ this ->setStarredComment ('tags={" ' . $ this ->generator ->objectName . DefaultInterface::CONTROLLER_POSTFIX
158
+ . '"}, ' , 1 , 1 );
159
+
160
+ $ this ->setParameter ([
161
+ 'in ' => '"path" ' ,
162
+ 'name ' => '"id" ' ,
163
+ 'required ' => 'true ' ,
164
+ ]);
165
+
166
+ $ this ->setParameter ([
167
+ 'in ' => '"path" ' ,
168
+ 'name ' => '"relations" ' ,
169
+ 'required ' => 'true ' ,
170
+ ]);
171
+
172
+ $ this ->setResponse ([
173
+ 'response ' => '200 ' ,
174
+ 'description ' => '"" ' ,
175
+ ]);
176
+
177
+ $ this ->setStarredComment (PhpInterface::CLOSE_PARENTHESES );
178
+
179
+ $ this ->closeComment ();
180
+ $ this ->setNewLines ();
181
+ }
182
+
183
+ /**
184
+ * Sets OAS documentation for deleting relation method
185
+ */
186
+ private function setDeleteRelation (): void
187
+ {
188
+ $ this ->openComment ();
189
+
190
+ $ this ->setStarredComment (DocumentationInterface::OA_DELETE . PhpInterface::OPEN_PARENTHESES );
191
+
192
+ $ this ->setStarredComment ('path=" ' . PhpInterface::SLASH . $ this ->generator ->version . PhpInterface::SLASH
193
+ . strtolower ($ this ->generator ->objectName ) . PhpInterface::SLASH . '{id}/relationships/{relations}", ' , 1 , 1 );
194
+
195
+ $ this ->setStarredComment ('summary="Delete ' . $ this ->generator ->objectName . ' relation object", ' , 1 , 1 );
196
+
197
+ $ this ->setStarredComment ('tags={" ' . $ this ->generator ->objectName . DefaultInterface::CONTROLLER_POSTFIX
198
+ . '"}, ' , 1 , 1 );
199
+
200
+ $ this ->setParameter ([
201
+ 'in ' => '"path" ' ,
202
+ 'name ' => '"id" ' ,
203
+ 'required ' => 'true ' ,
204
+ ]);
205
+
206
+ $ this ->setParameter ([
207
+ 'in ' => '"path" ' ,
208
+ 'name ' => '"relations" ' ,
209
+ 'required ' => 'true ' ,
210
+ ]);
211
+
212
+ $ this ->setResponse ([
213
+ 'response ' => '200 ' ,
214
+ 'description ' => '"" ' ,
215
+ ]);
216
+
217
+ $ this ->setStarredComment (PhpInterface::CLOSE_PARENTHESES );
218
+
219
+ $ this ->closeComment ();
220
+ $ this ->setNewLines ();
221
+ }
222
+ }
0 commit comments