comparison OrthancFramework/Sources/RestApi/RestApiCall.h @ 4399:80fd140b12ba

New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Dec 2020 12:21:03 +0100
parents 3af1d763763a
children 4cb9f66a1c7c
comparison
equal deleted inserted replaced
4398:38c22715bb56 4399:80fd140b12ba
21 21
22 22
23 #pragma once 23 #pragma once
24 24
25 #include "../HttpServer/HttpToolbox.h" 25 #include "../HttpServer/HttpToolbox.h"
26 #include "RestApiCallDocumentation.h"
26 #include "RestApiPath.h" 27 #include "RestApiPath.h"
27 #include "RestApiOutput.h" 28 #include "RestApiOutput.h"
28 29
29 #include <boost/noncopyable.hpp> 30 #include <boost/noncopyable.hpp>
30 31
42 const char* username_; 43 const char* username_;
43 const HttpToolbox::Arguments& httpHeaders_; 44 const HttpToolbox::Arguments& httpHeaders_;
44 const HttpToolbox::Arguments& uriComponents_; 45 const HttpToolbox::Arguments& uriComponents_;
45 const UriComponents& trailing_; 46 const UriComponents& trailing_;
46 const UriComponents& fullUri_; 47 const UriComponents& fullUri_;
48 HttpMethod method_; // To create RestApiCallDocumentation on demand
49 std::unique_ptr<RestApiCallDocumentation> documentation_; // Lazy creation
47 50
48 public: 51 public:
49 RestApiCall(RestApiOutput& output, 52 RestApiCall(RestApiOutput& output,
50 RestApi& context, 53 RestApi& context,
51 RequestOrigin origin, 54 RequestOrigin origin,
52 const char* remoteIp, 55 const char* remoteIp,
53 const char* username, 56 const char* username,
57 HttpMethod method,
54 const HttpToolbox::Arguments& httpHeaders, 58 const HttpToolbox::Arguments& httpHeaders,
55 const HttpToolbox::Arguments& uriComponents, 59 const HttpToolbox::Arguments& uriComponents,
56 const UriComponents& trailing, 60 const UriComponents& trailing,
57 const UriComponents& fullUri) : 61 const UriComponents& fullUri) :
58 output_(output), 62 output_(output),
61 remoteIp_(remoteIp), 65 remoteIp_(remoteIp),
62 username_(username), 66 username_(username),
63 httpHeaders_(httpHeaders), 67 httpHeaders_(httpHeaders),
64 uriComponents_(uriComponents), 68 uriComponents_(uriComponents),
65 trailing_(trailing), 69 trailing_(trailing),
66 fullUri_(fullUri) 70 fullUri_(fullUri),
71 method_(method)
67 { 72 {
68 } 73 }
69 74
70 RestApiOutput& GetOutput() 75 RestApiOutput& GetOutput()
71 { 76 {
125 { 130 {
126 return username_; 131 return username_;
127 } 132 }
128 133
129 virtual bool ParseJsonRequest(Json::Value& result) const = 0; 134 virtual bool ParseJsonRequest(Json::Value& result) const = 0;
135
136 RestApiCallDocumentation& GetDocumentation();
137
138 bool IsDocumentation() const
139 {
140 return (origin_ == RequestOrigin_Documentation);
141 }
130 }; 142 };
131 } 143 }