Qore RestSchemaValidator Module Reference 2.2.1
Loading...
Searching...
No Matches
RestSchemaValidator.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* RestSchemaValidator.qm Copyright (C) 2017 - 2024 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25
26// make sure we have the required qore version
27
28// requires the HttpServerUtil module
29
30// need mime definitions
31
32// supports using the DataProvider module to describe input and output records
33
34// supports logging with the Logger module
35
36
37
38
39
116 public hashdecl RestRequestClientInfo {
118 string uri_path;
120 string content;
122
124 *list<string> response_content;
126 *data body;
127 };
128
130 public hashdecl RestRequestServerInfo {
132 string path;
134 *hash<auto> query;
136 *hash<auto> path_args;
138 auto body;
140 hash<auto> info;
141 };
142
144 public hashdecl RestResponseClientInfo {
146 int code;
148 auto body;
150 hash<auto> hdr;
152 hash<auto> info;
153 };
154
156 public hashdecl RestExampleRequestInfo {
160 hash<auto> hdr;
162 string body;
163 };
164
166 public hashdecl RestExampleResponseInfo {
170 int code;
172 hash<auto> hdr;
174 string body;
175 };
176
178 public hashdecl RestQoreExampleCodeInfo {
180 hash<string, string> hashdecls();
181
183 string example;
184 };
185
188
189public:
192
193
195 constructor(Logger::LoggerInterface logger) ;
196
197
199
203 string getHash();
204
205
207
211 string getTargetUrl();
212
213
215
225 hash<RestRequestClientInfo> processRequest(string method, string path, auto body, *hash<auto> headers, *softlist<string> content_types);
226
227
229
244 hash<RestRequestServerInfo> parseRequest(string method, string path, *data http_body, reference<hash<auto>> headers);
245
246
248
270 hash<HttpResponseInfo> processResponse(string method, string path, int code, auto response_body, *hash<auto> headers, *softlist<string> content_types);
271
272
274
282 hash<RestResponseClientInfo> parseResponse(string method, string path, int code, *data response_body, hash<auto> hdr);
283
284
286
291 hash<RestQoreExampleCodeInfo> getQoreExampleRequest(string method, string path);
292
293
295
301 hash<RestExampleRequestInfo> getExampleRequest(string method, string path, *softlist<string> content_types);
302
303
305
311 hash<RestQoreExampleCodeInfo> getQoreExampleResponse(string method, string path, int code);
312
313
315
322 hash<RestExampleResponseInfo> getExampleResponse(string method, string path, int code, *softlist<string> content_types);
323
324
326
328 hash<string, list<string>> getPathOperationHash();
329
330
332
334 string getBasePath();
335
336
338
340 setBasePath(string basePath);
341
342
344
353 DataProvider::AbstractDataProvider getDataProvider(HTTPClient rest);
354
355
357
360
361
363
367 setTimeZoneLocale(*TimeZone tz);
368
369
371
375 *TimeZone getTimeZoneLocale();
376
377
379
388protected:
389 DataProvider::AbstractDataProvider getDataProviderImpl(HTTPClient rest);
390public:
391
392
394
398protected:
399 abstract string getHashImpl();
400public:
401
403
407protected:
408 abstract string getTargetUrlImpl();
409public:
410
412
422protected:
423 abstract hash<RestRequestClientInfo> processRequestImpl(string method, string path, auto body, *hash<auto> headers, *softlist<string> content_types);
424public:
425
427
438protected:
439 abstract hash<RestRequestServerInfo> parseRequestImpl(string method, string path, *data http_body, reference<hash> headers);
440public:
441
443
458protected:
459 abstract hash<HttpResponseInfo> processResponseImpl(string method, string path, int code, auto response_body, *hash<auto> headers, *softlist<string> content_types);
460public:
461
463
471protected:
472 abstract hash<RestResponseClientInfo> parseResponseImpl(string method, string path, int code, *data response_body, hash<auto> hdr);
473public:
474
476
478protected:
479 abstract hash<string, list<string>> getPathOperationHashImpl();
480public:
481
483
485protected:
486 abstract string getBasePathImpl();
487public:
488
490
492protected:
493 abstract setBasePathImpl(string basePath);
494public:
495
497
502protected:
503 abstract hash<RestQoreExampleCodeInfo> getQoreExampleRequestImpl(string method, string path);
504public:
505
507
513protected:
514 abstract hash<RestExampleRequestInfo> getExampleRequestImpl(string method, string path, *softlist<string> content_types);
515public:
516
518
524protected:
525 abstract hash<RestQoreExampleCodeInfo> getQoreExampleResponseImpl(string method, string path, int code);
526public:
527
529
536protected:
537 abstract hash<RestExampleResponseInfo> getExampleResponseImpl(string method, string path, int code, *softlist<string> content_types);
538public:
539
541
545protected:
546 abstract setTimeZoneLocaleImpl(*TimeZone tz);
547public:
548
550
554protected:
555 abstract *TimeZone getTimeZoneLocaleImpl();
556public:
557 };
558
561
562public:
565
566
567 const DataSerializationSupportList = keys DataSerializationSupport;
568
569 const DeserializeYaml = ...;
570
571 const DeserializeXml = ...;
572
573
576
577
579
581 const NullSchemaHashStr = "<null rest schema>";
582
585
586
588 constructor(Logger::LoggerInterface logger) ;
589
590
592
595
596
598
602protected:
603 string getHashImpl();
604public:
605
606
608
612protected:
614public:
615
616
618
628protected:
629 hash<RestRequestClientInfo> processRequestImpl(string method, string path, auto body, *hash<auto> headers, *softlist<string> content_types);
630public:
631
632
634
645protected:
646 hash<RestRequestServerInfo> parseRequestImpl(string method, string path, *data http_body, reference<hash> headers);
647public:
648
649
651
674protected:
675 hash<HttpResponseInfo> processResponseImpl(string method, string path, int code, auto response_body, *hash<auto> headers, *softlist<string> content_types);
676public:
677
678
680
688protected:
689 hash<RestResponseClientInfo> parseResponseImpl(string method, string path, int code, *data response_body, hash<auto> hdr);
690public:
691
692
694
703private:
704 bool checkResponseContentTypeHeader(reference<hash<HttpResponseInfo>> resp, auto body, *hash<auto> headers, *softlist<string> content_types);
705public:
706
707
709
711protected:
712 hash<string, list<string>> getPathOperationHashImpl();
713public:
714
715
717
719protected:
721public:
722
723
725
727protected:
728 setBasePathImpl(string basePath);
729public:
730
731
733
738protected:
739 hash<RestQoreExampleCodeInfo> getQoreExampleRequestImpl(string method, string path);
740public:
741
742
744
750protected:
751 hash<RestExampleRequestInfo> getExampleRequestImpl(string method, string path, *softlist<string> content_types);
752public:
753
754
756
762protected:
763 hash<RestQoreExampleCodeInfo> getQoreExampleResponseImpl(string method, string path, int code);
764public:
765
766
768
775protected:
776 hash<RestExampleResponseInfo> getExampleResponseImpl(string method, string path, int code, *softlist<string> content_types);
777public:
778
779
781
785protected:
787public:
788
789
791
795protected:
797public:
798
799 };
800};
transient *LoggerInterface logger
abstract REST schema validation classes
Definition RestSchemaValidator.qm.dox.h:187
bool managesUriPath()
returns True if the provider manages the URI path
abstract hash< RestRequestServerInfo > parseRequestImpl(string method, string path, *data http_body, reference< hash > headers)
processes and parses a client request and returns the deserialized message body (if any)
abstract hash< RestRequestClientInfo > processRequestImpl(string method, string path, auto body, *hash< auto > headers, *softlist< string > content_types)
processes a client-side REST request and returns a hash that can be used to make the outgoing client-...
abstract hash< RestExampleRequestInfo > getExampleRequestImpl(string method, string path, *softlist< string > content_types)
returns a hash of example message information for the given request
hash< RestRequestClientInfo > processRequest(string method, string path, auto body, *hash< auto > headers, *softlist< string > content_types)
processes a client-side REST request and returns a hash that can be used to make the outgoing client-...
abstract hash< RestResponseClientInfo > parseResponseImpl(string method, string path, int code, *data response_body, hash< auto > hdr)
parses and validates the response from the server and returns a hash of the processed info
abstract hash< RestExampleResponseInfo > getExampleResponseImpl(string method, string path, int code, *softlist< string > content_types)
returns a hash of example message information for the given request
hash< RestExampleRequestInfo > getExampleRequest(string method, string path, *softlist< string > content_types)
returns a hash of example message information for the given request
*TimeZone getTimeZoneLocale()
Returns the time zone locale used for serialization / deserialization.
DataProvider::AbstractDataProvider getDataProviderImpl(HTTPClient rest)
returns a data provider object for this connection, if supported by any REST schema validator object
string getTargetUrl()
returns the target URL for the schema
abstract string getHashImpl()
returns a unique hash for the schema that can be used to compare schemas
hash< RestQoreExampleCodeInfo > getQoreExampleRequest(string method, string path)
returns a hash of example Qore code for the given request
abstract setBasePathImpl(string basePath)
overrides the basePath value
hash< RestQoreExampleCodeInfo > getQoreExampleResponse(string method, string path, int code)
returns example Qore code for the given response
abstract setTimeZoneLocaleImpl(*TimeZone tz)
Allows the time zone locale to be set for serialization / deserialization.
abstract string getTargetUrlImpl()
returns the target URL for the schema
constructor(Logger::LoggerInterface logger)
Creates the object with the given logger.
abstract *TimeZone getTimeZoneLocaleImpl()
Returns the time zone locale used for serialization / deserialization.
constructor()
Creates the object without a logger.
abstract hash< string, list< string > > getPathOperationHashImpl()
returns a hash of URI paths as keys with values as lists of supported HTTP methods
hash< RestRequestServerInfo > parseRequest(string method, string path, *data http_body, reference< hash< auto > > headers)
processes and parses a client request and returns the deserialized message body (if any)
abstract string getBasePathImpl()
returns the base path prefix for all requests in this schema
hash< HttpResponseInfo > processResponse(string method, string path, int code, auto response_body, *hash< auto > headers, *softlist< string > content_types)
Processes a REST response with a serialized message body.
setTimeZoneLocale(*TimeZone tz)
Allows the time zone locale to be set for serialization / deserialization.
string getHash()
returns a unique hash for the schema that can be used to compare schemas
DataProvider::AbstractDataProvider getDataProvider(HTTPClient rest)
returns a data provider object for this connection, if supported by any REST schema validator object
hash< string, list< string > > getPathOperationHash()
returns a hash of URI paths as keys with values as lists of supported HTTP methods
hash< RestResponseClientInfo > parseResponse(string method, string path, int code, *data response_body, hash< auto > hdr)
parses and validates the response from the server and returns a hash of the processed info
abstract hash< RestQoreExampleCodeInfo > getQoreExampleResponseImpl(string method, string path, int code)
returns example Qore code for the given response
string getBasePath()
returns the base path prefix for all requests in this schema
abstract hash< RestQoreExampleCodeInfo > getQoreExampleRequestImpl(string method, string path)
returns a hash of example Qore code for the given request
abstract hash< HttpResponseInfo > processResponseImpl(string method, string path, int code, auto response_body, *hash< auto > headers, *softlist< string > content_types)
processes a REST response with a serialized message body, validates any response data against schema ...
hash< RestExampleResponseInfo > getExampleResponse(string method, string path, int code, *softlist< string > content_types)
returns a hash of example message information for the given request
setBasePath(string basePath)
overrides the basePath value
null REST validator; no schema is used but default serialization and deserialization is performed
Definition RestSchemaValidator.qm.dox.h:560
setBasePathImpl(string basePath)
overrides the basePath value
string getHashImpl()
returns a unique hash for the schema that can be used to compare schemas
const DataDeserializationSupport
Data deserialization support MIME types to codes and de/serialization functions.
Definition RestSchemaValidator.qm.dox.h:575
hash< RestExampleRequestInfo > getExampleRequestImpl(string method, string path, *softlist< string > content_types)
returns a hash of example message information for the given request
const DataSerializationSupport
Data serialization support mapping codes to MIME types and de/serialization functions.
Definition RestSchemaValidator.qm.dox.h:564
constructor(Logger::LoggerInterface logger)
Creates the object with the given logger.
*TimeZone getTimeZoneLocaleImpl()
Returns the time zone locale used for serialization / deserialization.
hash< RestRequestClientInfo > processRequestImpl(string method, string path, auto body, *hash< auto > headers, *softlist< string > content_types)
processes a client-side REST request and returns a hash that can be used to make the outgoing client-...
const NullSchemaHashStr
a unique hash for the null schema
Definition RestSchemaValidator.qm.dox.h:581
hash< HttpResponseInfo > processResponseImpl(string method, string path, int code, auto response_body, *hash< auto > headers, *softlist< string > content_types)
processes a REST response with a serialized message body, validates any response data against schema ...
setTimeZoneLocaleImpl(*TimeZone tz)
Allows the time zone locale to be set for serialization / deserialization.
string getTargetUrlImpl()
returns the target URL for the schema
bool managesUriPath()
returns True if the provider manages the URI path
hash< RestQoreExampleCodeInfo > getQoreExampleResponseImpl(string method, string path, int code)
returns example Qore code for the given response
hash< RestQoreExampleCodeInfo > getQoreExampleRequestImpl(string method, string path)
returns a hash of example Qore code for the given request
constructor()
Creates the object without a logger.
hash< RestRequestServerInfo > parseRequestImpl(string method, string path, *data http_body, reference< hash > headers)
processes and parses a client request and returns the deserialized message body (if any)
hash< RestExampleResponseInfo > getExampleResponseImpl(string method, string path, int code, *softlist< string > content_types)
returns a hash of example message information for the given request
string getBasePathImpl()
returns the base path prefix for all requests in this schema
hash< string, list< string > > getPathOperationHashImpl()
returns a hash of URI paths as keys with values as lists of supported HTTP methods
hash< RestResponseClientInfo > parseResponseImpl(string method, string path, int code, *data response_body, hash< auto > hdr)
parses and validates the response from the server and returns a hash of the processed info
bool checkResponseContentTypeHeader(reference< hash< HttpResponseInfo > > resp, auto body, *hash< auto > headers, *softlist< string > content_types)
Check if the headers contain a content-type header which is accepted and if so, modify the response h...
main namespace for all public RestSchemaValidator declarations
Definition RestSchemaValidator.qm.dox.h:114
a hash giving example info for example HTTP request messages
Definition RestSchemaValidator.qm.dox.h:156
string body
the HTTP request body
Definition RestSchemaValidator.qm.dox.h:162
hash< auto > hdr
the HTTP request header hash
Definition RestSchemaValidator.qm.dox.h:160
string request_uri
the HTTP request URI
Definition RestSchemaValidator.qm.dox.h:158
a hash giving example info for example HTTP response messages
Definition RestSchemaValidator.qm.dox.h:166
int code
the HTTP status code
Definition RestSchemaValidator.qm.dox.h:170
string response_uri
the HTTP response URI
Definition RestSchemaValidator.qm.dox.h:168
string body
the HTTP response body
Definition RestSchemaValidator.qm.dox.h:174
hash< auto > hdr
the HTTP response header hash
Definition RestSchemaValidator.qm.dox.h:172
a hash giving example information for building a request or response in Qore
Definition RestSchemaValidator.qm.dox.h:178
string example
a string giving the example code generation
Definition RestSchemaValidator.qm.dox.h:183
hash< string, string > hashdecls()
a hash giving example hashdecl declarations for hash objects in the message; keys are hashdecl names; str...
a hash of information about a client-side request
Definition RestSchemaValidator.qm.dox.h:116
*list< string > response_content
Content-Type for the response message if available.
Definition RestSchemaValidator.qm.dox.h:124
*data body
the serialized message body hash
Definition RestSchemaValidator.qm.dox.h:126
string content
the Content-Type for the message
Definition RestSchemaValidator.qm.dox.h:120
string uri_path
the URI path for the request
Definition RestSchemaValidator.qm.dox.h:118
a hash of information about a server-side request
Definition RestSchemaValidator.qm.dox.h:130
*hash< auto > path_args
any path arguments
Definition RestSchemaValidator.qm.dox.h:136
hash< auto > info
miscellaneous free-form info about the parsed request
Definition RestSchemaValidator.qm.dox.h:140
string path
the URI path without query arguments
Definition RestSchemaValidator.qm.dox.h:132
*hash< auto > query
any query arguments
Definition RestSchemaValidator.qm.dox.h:134
auto body
the deserialized message body data
Definition RestSchemaValidator.qm.dox.h:138
a hash of information about a response from the server
Definition RestSchemaValidator.qm.dox.h:144
hash< auto > hdr
the HTTP headers received
Definition RestSchemaValidator.qm.dox.h:150
int code
the HTTP status code
Definition RestSchemaValidator.qm.dox.h:146
hash< auto > info
miscellaneous free-form info about the parsed response
Definition RestSchemaValidator.qm.dox.h:152
auto body
the deserialized message body
Definition RestSchemaValidator.qm.dox.h:148