@@ -67,6 +67,10 @@ public static function parse($api) {
67
67
$ Resource = singular ($ Resources );
68
68
$ ResourceArray = $ Resource .'[] ' ;
69
69
70
+ $ overrides = [
71
+ 'scope ' , 'ignore ' , 'summary ' , 'requestEntity ' , 'responseSchema '
72
+ ];
73
+
70
74
$ getEndpoint = new EndpointItem ();
71
75
$ getEndpoint ->method = 'get ' ;
72
76
$ getEndpoint ->path = "/ {$ resources }" ;
@@ -80,9 +84,10 @@ public static function parse($api) {
80
84
$ getEndpoint ->responseSchema = $ ResourceArray ;
81
85
if (isset ($ name2Method ['get ' ])) {
82
86
$ endpoint = EndpointItem::parse ($ name2Method ['get ' ]);
83
- if (isset ($ endpoint ->scope )) $ getEndpoint ->scope = $ endpoint ->scope ;
84
- if (isset ($ endpoint ->ignore )) $ getEndpoint ->ignore = $ endpoint ->ignore ;
85
- if (isset ($ endpoint ->summary )) $ getEndpoint ->summary = $ endpoint ->summary ;
87
+ foreach ($ overrides as $ override ) {
88
+ if (isset ($ endpoint ->{$ override }))
89
+ $ getEndpoint ->{$ override } = $ endpoint ->{$ override };
90
+ }
86
91
}
87
92
if (isset ($ item ->scope ) && !isset ($ getEndpoint ->scope )) $ getEndpoint ->scope = $ item ->scope ;
88
93
if (!isset ($ getEndpoint ->ignore )) $ item ->endpoints [] = $ getEndpoint ;
@@ -96,9 +101,10 @@ public static function parse($api) {
96
101
$ getByIdEndpoint ->responseSchema = $ Resource ;
97
102
if (isset ($ name2Method ['get ' ])) {
98
103
$ endpoint = EndpointItem::parse ($ name2Method ['get ' ]);
99
- if (isset ($ endpoint ->scope )) $ getByIdEndpoint ->scope = $ endpoint ->scope ;
100
- if (isset ($ endpoint ->ignore )) $ getByIdEndpoint ->ignore = $ endpoint ->ignore ;
101
- if (isset ($ endpoint ->summary )) $ getByIdEndpoint ->summary = $ endpoint ->summary ;
104
+ foreach ($ overrides as $ override ) {
105
+ if (isset ($ endpoint ->{$ override }))
106
+ $ getByIdEndpoint ->{$ override } = $ endpoint ->{$ override };
107
+ }
102
108
}
103
109
if (isset ($ item ->scope ) && !isset ($ getByIdEndpoint ->scope )) $ getByIdEndpoint ->scope = $ item ->scope ;
104
110
if (!isset ($ getByIdEndpoint ->ignore )) $ item ->endpoints [] = $ getByIdEndpoint ;
@@ -111,9 +117,10 @@ public static function parse($api) {
111
117
$ postEndpoint ->responseSchema = $ Resource ;
112
118
if (isset ($ name2Method ['post ' ])) {
113
119
$ endpoint = EndpointItem::parse ($ name2Method ['post ' ]);
114
- if (isset ($ endpoint ->scope )) $ postEndpoint ->scope = $ endpoint ->scope ;
115
- if (isset ($ endpoint ->ignore )) $ postEndpoint ->ignore = $ endpoint ->ignore ;
116
- if (isset ($ endpoint ->summary )) $ postEndpoint ->summary = $ endpoint ->summary ;
120
+ foreach ($ overrides as $ override ) {
121
+ if (isset ($ endpoint ->{$ override }))
122
+ $ postEndpoint ->{$ override } = $ endpoint ->{$ override };
123
+ }
117
124
}
118
125
if (isset ($ item ->scope ) && !isset ($ postEndpoint ->scope )) $ postEndpoint ->scope = $ item ->scope ;
119
126
if (!isset ($ postEndpoint ->ignore )) $ item ->endpoints [] = $ postEndpoint ;
@@ -127,9 +134,10 @@ public static function parse($api) {
127
134
$ putByIdEndpoint ->responseSchema = $ Resource ;
128
135
if (isset ($ name2Method ['put ' ])) {
129
136
$ endpoint = EndpointItem::parse ($ name2Method ['put ' ]);
130
- if (isset ($ endpoint ->scope )) $ putByIdEndpoint ->scope = $ endpoint ->scope ;
131
- if (isset ($ endpoint ->ignore )) $ putByIdEndpoint ->ignore = $ endpoint ->ignore ;
132
- if (isset ($ endpoint ->summary )) $ putByIdEndpoint ->summary = $ endpoint ->summary ;
137
+ foreach ($ overrides as $ override ) {
138
+ if (isset ($ endpoint ->{$ override }))
139
+ $ putByIdEndpoint ->{$ override } = $ endpoint ->{$ override };
140
+ }
133
141
}
134
142
if (isset ($ item ->scope ) && !isset ($ putByIdEndpoint ->scope )) $ putByIdEndpoint ->scope = $ item ->scope ;
135
143
if (!isset ($ putByIdEndpoint ->ignore )) $ item ->endpoints [] = $ putByIdEndpoint ;
@@ -142,9 +150,10 @@ public static function parse($api) {
142
150
$ putEndpoint ->responseSchema = $ ResourceArray ;
143
151
if (isset ($ name2Method ['put ' ])) {
144
152
$ endpoint = EndpointItem::parse ($ name2Method ['put ' ]);
145
- if (isset ($ endpoint ->scope )) $ putEndpoint ->scope = $ endpoint ->scope ;
146
- if (isset ($ endpoint ->ignore )) $ putEndpoint ->ignore = $ endpoint ->ignore ;
147
- if (isset ($ endpoint ->summary )) $ putEndpoint ->summary = $ endpoint ->summary ;
153
+ foreach ($ overrides as $ override ) {
154
+ if (isset ($ endpoint ->{$ override }))
155
+ $ putEndpoint ->{$ override } = $ endpoint ->{$ override };
156
+ }
148
157
}
149
158
if (isset ($ item ->scope ) && !isset ($ putEndpoint ->scope )) $ putEndpoint ->scope = $ item ->scope ;
150
159
if (!isset ($ putEndpoint ->ignore )) $ item ->endpoints [] = $ putEndpoint ;
@@ -158,9 +167,10 @@ public static function parse($api) {
158
167
$ patchByIdendpoint ->responseSchema = $ Resource ;
159
168
if (isset ($ name2Method ['patch ' ])) {
160
169
$ endpoint = EndpointItem::parse ($ name2Method ['patch ' ]);
161
- if (isset ($ endpoint ->scope )) $ patchByIdendpoint ->scope = $ endpoint ->scope ;
162
- if (isset ($ endpoint ->ignore )) $ patchByIdendpoint ->ignore = $ endpoint ->ignore ;
163
- if (isset ($ endpoint ->summary )) $ patchByIdendpoint ->summary = $ endpoint ->summary ;
170
+ foreach ($ overrides as $ override ) {
171
+ if (isset ($ endpoint ->{$ override }))
172
+ $ patchByIdendpoint ->{$ override } = $ endpoint ->{$ override };
173
+ }
164
174
}
165
175
if (isset ($ item ->scope ) && !isset ($ patchByIdendpoint ->scope )) $ patchByIdendpoint ->scope = $ item ->scope ;
166
176
if (!isset ($ patchByIdendpoint ->ignore )) $ item ->endpoints [] = $ patchByIdendpoint ;
@@ -173,9 +183,10 @@ public static function parse($api) {
173
183
$ patchEndpoint ->responseSchema = $ ResourceArray ;
174
184
if (isset ($ name2Method ['patch ' ])) {
175
185
$ endpoint = EndpointItem::parse ($ name2Method ['patch ' ]);
176
- if (isset ($ endpoint ->scope )) $ patchEndpoint ->scope = $ endpoint ->scope ;
177
- if (isset ($ endpoint ->ignore )) $ patchEndpoint ->ignore = $ endpoint ->ignore ;
178
- if (isset ($ endpoint ->summary )) $ patchEndpoint ->summary = $ endpoint ->summary ;
186
+ foreach ($ overrides as $ override ) {
187
+ if (isset ($ endpoint ->{$ override }))
188
+ $ patchEndpoint ->{$ override } = $ endpoint ->{$ override };
189
+ }
179
190
}
180
191
if (isset ($ item ->scope ) && !isset ($ patchEndpoint ->scope )) $ patchEndpoint ->scope = $ item ->scope ;
181
192
if (!isset ($ patchEndpoint ->ignore )) $ item ->endpoints [] = $ patchEndpoint ;
@@ -188,9 +199,10 @@ public static function parse($api) {
188
199
$ deleteEndpoint ->responseSchema = $ Resource ;
189
200
if (isset ($ name2Method ['delete ' ])) {
190
201
$ endpoint = EndpointItem::parse ($ name2Method ['delete ' ]);
191
- if (isset ($ endpoint ->scope )) $ deleteEndpoint ->scope = $ endpoint ->scope ;
192
- if (isset ($ endpoint ->ignore )) $ deleteEndpoint ->ignore = $ endpoint ->ignore ;
193
- if (isset ($ endpoint ->summary )) $ deleteEndpoint ->summary = $ endpoint ->summary ;
202
+ foreach ($ overrides as $ override ) {
203
+ if (isset ($ endpoint ->{$ override }))
204
+ $ deleteEndpoint ->{$ override } = $ endpoint ->{$ override };
205
+ }
194
206
}
195
207
if (isset ($ item ->scope ) && !isset ($ deleteEndpoint ->scope )) $ deleteEndpoint ->scope = $ item ->scope ;
196
208
if (!isset ($ deleteEndpoint ->ignore )) $ item ->endpoints [] = $ deleteEndpoint ;
0 commit comments