231 hash<RestRequestClientInfo>
processRequest(
string method,
string path,
auto body, *hash<auto> headers,
232 *softlist<string> content_types) {
252 hash<RestRequestServerInfo>
parseRequest(
string method,
string path, *data http_body,
253 reference<hash<auto>> headers) {
280 hash<HttpResponseInfo>
processResponse(
string method,
string path,
int code,
auto response_body,
281 *hash<auto> headers, *softlist<string> content_types) {
294 hash<RestResponseClientInfo>
parseResponse(
string method,
string path,
int code, *data response_body,
317 hash<RestExampleRequestInfo>
getExampleRequest(
string method,
string path, *softlist<string> content_types);
339 *softlist<string> content_types) {
341 if (!rv.response_uri)
342 rv.response_uri = sprintf(
"HTTP/1.1 %d %s", code, HttpCodes{code} ??
"Unknown");
443 private abstract hash<RestRequestClientInfo>
processRequestImpl(
string method,
string path,
auto body,
444 *hash<auto> headers, *softlist<string> content_types);
458 private abstract hash<RestRequestServerInfo>
parseRequestImpl(
string method,
string path, *data http_body,
459 reference<hash> headers);
478 auto response_body, *hash<auto> headers, *softlist<string> content_types);
489 private abstract hash<RestResponseClientInfo>
parseResponseImpl(
string method,
string path,
int code,
490 *data response_body, hash<auto> hdr);
531 *softlist<string> content_types);
552 *softlist<string> content_types);
580 MimeTypeJson: \make_json(),
583 MimeTypeYamlRpc: \make_yaml(),
584 MimeTypeYaml: \make_yaml(),
587 MimeTypeXml: \make_xmlrpc_value(),
588 MimeTypeXmlApp:
string sub (
auto v) {
589 switch (v.typeCode()) {
590 case NT_LIST:
return make_xml((
"list": (
"element": v)));
591 case NT_HASH:
return v.size() == 1 && v.firstValue().lsize() == 1 ? make_xml(v) : make_xml((
"value": v));
593 return make_xml((
"value": v));
596 MimeTypeFormUrlEncoded:
string sub (
auto v) {
597 if (v.typeCode() == NT_HASH)
598 return mime_get_form_urlencoded_string(v);
599 throw "FORMURLENCODING-ERROR", sprintf(
"form URL encoding can only encode hashes; type %y requested", v.type());
601 MimeTypeText: data sub (
auto s) {
602 switch (s.typeCode()) {
611 throw "TEXT-SERIALIZATION-ERROR", sprintf(
"cannot serialize type %y without YAML support", s.type());
615 MimeTypeOctetStream: binary sub (
auto s) {
616 switch (s.typeCode()) {
622 # issue #3547: send as a YAML-serialized string if possible to catch unserializable data
624 return binary(make_yaml(s));
626 throw "BINARY-SERIALIZATION-ERROR", sprintf(
"cannot serialize type %y without YAML support", s.type());
634 const DeserializeYaml = ...;
636 const DeserializeXml = ...;
641 MimeTypeFormUrlEncoded: (
643 "in": \mime_parse_form_urlencoded_string(),
652 MimeTypeYamlRpc: DeserializeYaml,
653 MimeTypeYaml: DeserializeYaml,
656 MimeTypeXml: DeserializeXml,
657 MimeTypeXmlApp: DeserializeXml,
661 "in": data sub (data s) {
return s; },
664 MimeTypeOctetStream: {
666 "in": binary sub (data s) {
667 return s.typeCode() == NT_BINARY ? s : binary(s);
715 hash<RestRequestClientInfo>
processRequestImpl(
string method,
string path,
auto body, *hash<auto> headers, *softlist<string> content_types);
732 hash<RestRequestServerInfo>
parseRequestImpl(
string method,
string path, *data http_body, reference<hash> headers);
760 private hash<HttpResponseInfo>
processResponseImpl(
string method,
string path,
int code,
auto response_body,
761 *hash<auto> headers, *softlist<string> content_types) {
762 hash<HttpResponseInfo> rv((
767 if (exists response_body);
770 rv.body = response_body;
785 *data response_body, hash<auto> hdr) {
786 hash<RestResponseClientInfo> rv((
791 if (response_body.val());
808 *hash<auto> headers, *softlist<string> content_types) {
810 if (body.typeCode() != NT_BINARY && body.typeCode() != NT_STRING)
814 *list ct = map $1, keys headers, $1 ==1i;
817 if (ct && ct.size() == 1);
865 *softlist<string> content_types) {
866 return new hash<RestExampleRequestInfo>();
890 *softlist<string> content_types) {
891 return new hash<RestExampleResponseInfo>();
abstract REST schema validation classes
Definition: RestSchemaValidator.qm.dox.h:184
bool managesUriPath()
returns True if the provider manages the URI path
abstract private 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-...
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-...
Definition: RestSchemaValidator.qm.dox.h:231
abstract private hash< RestExampleRequestInfo > getExampleRequestImpl(string method, string path, *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 private hash< RestQoreExampleCodeInfo > getQoreExampleResponseImpl(string method, string path, int code)
returns example Qore code for the given response
abstract private 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 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.
constructor(Logger::Logger logger)
Creates the object with the given logger.
abstract string getTargetUrlImpl()
returns the target URL for the schema
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)
Definition: RestSchemaValidator.qm.dox.h:252
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.
Definition: RestSchemaValidator.qm.dox.h:280
setLogger(Logger::Logger logger)
Sets a new logger.
setTimeZoneLocale(*TimeZone tz)
Allows the time zone locale to be set for serialization / deserialization.
abstract private 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 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
abstract private 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< 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
Definition: RestSchemaValidator.qm.dox.h:294
abstract private 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)
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
hash< RestExampleResponseInfo > getExampleResponse(string method, string path, int code, *softlist< string > content_types)
returns a hash of example message information for the given request
Definition: RestSchemaValidator.qm.dox.h:338
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:574
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:640
private 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
Definition: RestSchemaValidator.qm.dox.h:784
const DataSerializationSupport
Data serialization support mapping codes to MIME types and de/serialization functions.
Definition: RestSchemaValidator.qm.dox.h:578
*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:675
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
private hash< RestExampleResponseInfo > getExampleResponseImpl(string method, string path, int code, *softlist< string > content_types)
returns a hash of example message information for the given request
Definition: RestSchemaValidator.qm.dox.h:889
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)
internal 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...
Definition: RestSchemaValidator.qm.dox.h:807
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
private 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 ...
Definition: RestSchemaValidator.qm.dox.h:760
private hash< RestExampleRequestInfo > getExampleRequestImpl(string method, string path, *softlist< string > content_types)
returns a hash of example message information for the given request
Definition: RestSchemaValidator.qm.dox.h:864
main namespace for all public RestSchemaValidator declarations
Definition: RestSchemaValidator.qm.dox.h:111
a hash giving example info for example HTTP request messages
Definition: RestSchemaValidator.qm.dox.h:153
string body
the HTTP request body
Definition: RestSchemaValidator.qm.dox.h:159
hash< auto > hdr
the HTTP request header hash
Definition: RestSchemaValidator.qm.dox.h:157
string request_uri
the HTTP request URI
Definition: RestSchemaValidator.qm.dox.h:155
a hash giving example info for example HTTP response messages
Definition: RestSchemaValidator.qm.dox.h:163
int code
the HTTP status code
Definition: RestSchemaValidator.qm.dox.h:167
string response_uri
the HTTP response URI
Definition: RestSchemaValidator.qm.dox.h:165
string body
the HTTP response body
Definition: RestSchemaValidator.qm.dox.h:171
hash< auto > hdr
the HTTP response header hash
Definition: RestSchemaValidator.qm.dox.h:169
a hash giving example information for building a request or response in Qore
Definition: RestSchemaValidator.qm.dox.h:175
string example
a string giving the example code generation
Definition: RestSchemaValidator.qm.dox.h:180
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:113
*list< string > response_content
Content-Type for the response message if available.
Definition: RestSchemaValidator.qm.dox.h:121
*data body
the serialized message body hash
Definition: RestSchemaValidator.qm.dox.h:123
string content
the Content-Type for the message
Definition: RestSchemaValidator.qm.dox.h:117
string uri_path
the URI path for the request
Definition: RestSchemaValidator.qm.dox.h:115
a hash of information about a server-side request
Definition: RestSchemaValidator.qm.dox.h:127
*hash< auto > path_args
any path arguments
Definition: RestSchemaValidator.qm.dox.h:133
hash< auto > info
miscellaneous free-form info about the parsed request
Definition: RestSchemaValidator.qm.dox.h:137
string path
the URI path without query arguments
Definition: RestSchemaValidator.qm.dox.h:129
*hash< auto > query
any query arguments
Definition: RestSchemaValidator.qm.dox.h:131
auto body
the deserialized message body data
Definition: RestSchemaValidator.qm.dox.h:135
a hash of information about a response from the server
Definition: RestSchemaValidator.qm.dox.h:141
hash< auto > hdr
the HTTP headers received
Definition: RestSchemaValidator.qm.dox.h:147
int code
the HTTP status code
Definition: RestSchemaValidator.qm.dox.h:143
hash< auto > info
miscellaneous free-form info about the parsed response
Definition: RestSchemaValidator.qm.dox.h:149
auto body
the deserialized message body
Definition: RestSchemaValidator.qm.dox.h:145