@@ -159,25 +159,64 @@ function TOpenApiAnalyzer.BuildMetaMethod(Method: TMetaMethod; const Path: strin
159
159
end ;
160
160
161
161
procedure TOpenApiAnalyzer.BuildMetaParam (MetaParam: TMetaParam; Param: TParameter; const MethodName: string);
162
+
163
+ procedure DefineStyleAndExplode (DefaultStyle: TStyle; out Style: TStyle; out Explode: Boolean);
164
+ begin
165
+ if Param.Style.IsAssigned then
166
+ Style := Param.Style
167
+ else
168
+ Style := DefaultStyle;
169
+ if Param.Explode.IsAssigned then
170
+ Explode := Param.Explode
171
+ else
172
+ Explode := Style = TStyle.Form;
173
+ end ;
174
+
175
+ var
176
+ Style: TStyle;
177
+ Explode: Boolean;
162
178
begin
179
+ if Param.Schema = nil then
180
+ raise EOpenApiAnalyzerException.CreateFmt(' %.%s: missing schema' , [MethodName, Param.Name ]);
181
+ if Param.Content <> nil then
182
+ raise EOpenApiAnalyzerException.CreateFmt(' %.%s: content property not supported' , [MethodName, Param.Name ]);
183
+
163
184
MetaParam.RestName := Param.Name ;
164
185
MetaParam.CodeName := ProcessNaming(Param.Name , Options.ServiceOptions.ParamNaming);
165
186
case Param.&In of
166
187
Query:
167
188
begin
189
+ DefineStyleAndExplode(TStyle.Form, Style, Explode);
190
+ if Style <> TStyle.Form then
191
+ raise EOpenApiAnalyzerException.CreateFmt(' %.%s: style not supported' , [MethodName, Param.Name ]);
192
+
168
193
MetaParam.ParamType := MetaTypeFromSchema(Param.Schema, MethodName + Param.Name , TListType.ltAuto);
169
194
MetaParam.Location := TParamLocation.plQuery;
170
195
end ;
171
196
Path:
172
197
begin
198
+ DefineStyleAndExplode(TStyle.Simple, Style, Explode);
199
+ if Style <> TStyle.Simple then
200
+ raise EOpenApiAnalyzerException.CreateFmt(' %.%s: style not supported' , [MethodName, Param.Name ]);
201
+
173
202
MetaParam.ParamType := MetaTypeFromSchema(Param.Schema, MethodName + Param.Name , TListType.ltAuto);
174
203
MetaParam.Location := TParamLocation.plUrl;
175
204
end ;
176
205
Header:
177
206
begin
207
+ DefineStyleAndExplode(TStyle.Simple, Style, Explode);
208
+ if Style <> TStyle.Simple then
209
+ raise EOpenApiAnalyzerException.CreateFmt(' %.%s: style not supported' , [MethodName, Param.Name ]);
210
+
178
211
MetaParam.ParamType := MetaTypeFromSchema(Param.Schema, MethodName + Param.Name , TListType.ltAuto);
179
212
MetaParam.Location := TParamLocation.plHeader;
180
213
end ;
214
+ // Cookie:
215
+ // begin
216
+ // DefineStyleAndExplode(TStyle.Form, Style, Explode);
217
+ // MetaParam.ParamType := MetaTypeFromSchema(Param.Schema, MethodName + Param.Name, TListType.ltAuto);
218
+ // MetaParam.Location := TParamLocation.plCookie;
219
+ // end;
181
220
else
182
221
raise EOpenApiAnalyzerException.CreateFmt(' Unsupported parameter type: %s' , [GetEnumName(TypeInfo(TLocation), Ord(Param.&In ))]);
183
222
end ;
0 commit comments