Mercurial > hg > orthanc
comparison OrthancFramework/Sources/RestApi/RestApi.cpp @ 4401:354ea95b294a
documenting system calls
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Dec 2020 15:13:45 +0100 |
parents | 029366f95217 |
children | ad646ff506d0 |
comparison
equal
deleted
inserted
replaced
4400:029366f95217 | 4401:354ea95b294a |
---|---|
149 if (paths_.isMember(path)) | 149 if (paths_.isMember(path)) |
150 { | 150 { |
151 throw OrthancException(ErrorCode_InternalError); | 151 throw OrthancException(ErrorCode_InternalError); |
152 } | 152 } |
153 | 153 |
154 std::set<std::string> uriArguments; | |
155 | |
156 for (HttpToolbox::Arguments::const_iterator | |
157 it = components.begin(); it != components.end(); ++it) | |
158 { | |
159 assert(it->second.empty()); | |
160 uriArguments.insert(it->first.c_str()); | |
161 } | |
162 | |
154 if (resource.HasHandler(HttpMethod_Get)) | 163 if (resource.HasHandler(HttpMethod_Get)) |
155 { | 164 { |
156 StringHttpOutput o1; | 165 StringHttpOutput o1; |
157 HttpOutput o2(o1, false); | 166 HttpOutput o2(o1, false); |
158 RestApiOutput o3(o2, HttpMethod_Get); | 167 RestApiOutput o3(o2, HttpMethod_Get); |
166 Json::Value v; | 175 Json::Value v; |
167 | 176 |
168 try | 177 try |
169 { | 178 { |
170 ok = (resource.Handle(call) && | 179 ok = (resource.Handle(call) && |
171 call.GetDocumentation().FormatOpenApi(v)); | 180 call.GetDocumentation().FormatOpenApi(v, uriArguments)); |
172 } | 181 } |
173 catch (OrthancException&) | 182 catch (OrthancException&) |
174 { | 183 { |
175 } | 184 } |
176 catch (boost::bad_lexical_cast&) | 185 catch (boost::bad_lexical_cast&) |
201 Json::Value v; | 210 Json::Value v; |
202 | 211 |
203 try | 212 try |
204 { | 213 { |
205 ok = (resource.Handle(call) && | 214 ok = (resource.Handle(call) && |
206 call.GetDocumentation().FormatOpenApi(v)); | 215 call.GetDocumentation().FormatOpenApi(v, uriArguments)); |
207 } | 216 } |
208 catch (OrthancException&) | 217 catch (OrthancException&) |
209 { | 218 { |
210 } | 219 } |
211 catch (boost::bad_lexical_cast&) | 220 catch (boost::bad_lexical_cast&) |
236 Json::Value v; | 245 Json::Value v; |
237 | 246 |
238 try | 247 try |
239 { | 248 { |
240 ok = (resource.Handle(call) && | 249 ok = (resource.Handle(call) && |
241 call.GetDocumentation().FormatOpenApi(v)); | 250 call.GetDocumentation().FormatOpenApi(v, uriArguments)); |
242 } | 251 } |
243 catch (OrthancException&) | 252 catch (OrthancException&) |
244 { | 253 { |
245 } | 254 } |
246 catch (boost::bad_lexical_cast&) | 255 catch (boost::bad_lexical_cast&) |
271 Json::Value v; | 280 Json::Value v; |
272 | 281 |
273 try | 282 try |
274 { | 283 { |
275 ok = (resource.Handle(call) && | 284 ok = (resource.Handle(call) && |
276 call.GetDocumentation().FormatOpenApi(v)); | 285 call.GetDocumentation().FormatOpenApi(v, uriArguments)); |
277 } | 286 } |
278 catch (OrthancException&) | 287 catch (OrthancException&) |
279 { | 288 { |
280 } | 289 } |
281 catch (boost::bad_lexical_cast&) | 290 catch (boost::bad_lexical_cast&) |
475 void RestApi::GenerateOpenApiDocumentation(Json::Value& target) | 484 void RestApi::GenerateOpenApiDocumentation(Json::Value& target) |
476 { | 485 { |
477 OpenApiVisitor visitor(*this); | 486 OpenApiVisitor visitor(*this); |
478 | 487 |
479 UriComponents root; | 488 UriComponents root; |
480 root_.ExploreAllResources(visitor, root); | 489 std::set<std::string> uriArguments; |
490 root_.ExploreAllResources(visitor, root, uriArguments); | |
481 | 491 |
482 target = Json::objectValue; | 492 target = Json::objectValue; |
483 | 493 |
484 target["info"]["version"] = ORTHANC_VERSION; | 494 target["info"]["version"] = ORTHANC_VERSION; |
485 target["info"]["title"] = "Orthanc"; | 495 target["info"]["title"] = "Orthanc"; |