comparison OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp @ 4405:5466f336b09f

gathering statistics about progress of api documentation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Dec 2020 09:37:30 +0100
parents f34634916d8c
children 5784a9eaf502
comparison
equal deleted inserted replaced
4404:f34634916d8c 4405:5466f336b09f
101 return *this; 101 return *this;
102 } 102 }
103 103
104 104
105 RestApiCallDocumentation& RestApiCallDocumentation::SetUriArgument(const std::string& name, 105 RestApiCallDocumentation& RestApiCallDocumentation::SetUriArgument(const std::string& name,
106 Type type,
106 const std::string& description) 107 const std::string& description)
107 { 108 {
108 if (uriArguments_.find(name) != uriArguments_.end()) 109 if (uriArguments_.find(name) != uriArguments_.end())
109 { 110 {
110 throw OrthancException(ErrorCode_ParameterOutOfRange, "URI argument \"" + name + "\" is already documented"); 111 throw OrthancException(ErrorCode_ParameterOutOfRange, "URI argument \"" + name + "\" is already documented");
111 } 112 }
112 else 113 else
113 { 114 {
114 uriArguments_[name] = Parameter(Type_String, description, true); 115 uriArguments_[name] = Parameter(type, description, true);
115 return *this; 116 return *this;
116 } 117 }
117 } 118 }
118 119
119 120
316 schema["properties"][field->first] = p; 317 schema["properties"][field->first] = p;
317 } 318 }
318 } 319 }
319 } 320 }
320 321
321 if (sampleJson_.type() != Json::nullValue) 322 for (AllowedTypes::const_iterator it = answerTypes_.begin();
322 { 323 it != answerTypes_.end(); ++it)
323 target["responses"]["200"]["content"][EnumerationToString(MimeType_Json)]["schema"]["example"] = sampleJson_; 324 {
324 } 325 if (it->first == MimeType_Json &&
325 else if (answerTypes_.find(MimeType_Json) != answerTypes_.end()) 326 sampleJson_.type() != Json::nullValue)
326 { 327 {
327 target["responses"]["200"]["content"][EnumerationToString(MimeType_Json)]["examples"] = Json::objectValue; 328 target["responses"]["200"]["content"][EnumerationToString(MimeType_Json)]["schema"]["example"] = sampleJson_;
329 }
330 else if (it->first == MimeType_PlainText &&
331 hasSampleText_)
332 {
333 // Handled below
334 }
335 else
336 {
337 // No sample for this MIME type
338 target["responses"]["200"]["content"][EnumerationToString(it->first)]["examples"] = Json::objectValue;
339 }
328 } 340 }
329 341
330 if (hasSampleText_) 342 if (hasSampleText_)
331 { 343 {
332 target["responses"]["200"]["content"][EnumerationToString(MimeType_PlainText)]["example"] = sampleText_; 344 target["responses"]["200"]["content"][EnumerationToString(MimeType_PlainText)]["example"] = sampleText_;