Qore RestSchemaValidator Module Reference
2.1.2
|
abstract REST schema validation classes More...
Public Member Methods | |
constructor () | |
Creates the object without a logger. | |
constructor (Logger::Logger logger) | |
Creates the object with the given logger. | |
string | getBasePath () |
returns the base path prefix for all requests in this schema More... | |
DataProvider::AbstractDataProvider | getDataProvider (HTTPClient rest) |
returns a data provider object for this connection, if supported by any REST schema validator object More... | |
hash< RestExampleRequestInfo > | getExampleRequest (string method, string path, *softlist< string > content_types) |
returns a hash of example message information for the given request More... | |
hash< RestExampleResponseInfo > | getExampleResponse (string method, string path, int code, *softlist< string > content_types) |
returns a hash of example message information for the given request More... | |
string | getHash () |
returns a unique hash for the schema that can be used to compare schemas More... | |
hash< string, list< string > > | getPathOperationHash () |
returns a hash of URI paths as keys with values as lists of supported HTTP methods More... | |
hash< RestQoreExampleCodeInfo > | getQoreExampleRequest (string method, string path) |
returns a hash of example Qore code for the given request More... | |
hash< RestQoreExampleCodeInfo > | getQoreExampleResponse (string method, string path, int code) |
returns example Qore code for the given response More... | |
string | getTargetUrl () |
returns the target URL for the schema More... | |
bool | managesUriPath () |
returns True if the provider manages the URI path More... | |
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) More... | |
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 More... | |
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-side HTTP request More... | |
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. More... | |
setBasePath (string basePath) | |
overrides the basePath value More... | |
setLogger (Logger::Logger logger) | |
Sets a new logger. | |
Private Member Methods | |
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 hash. More... | |
string | getBasePathImpl () |
returns the base path prefix for all requests in this schema More... | |
DataProvider::AbstractDataProvider | getDataProviderImpl (HTTPClient rest) |
returns a data provider object for this connection, if supported by any REST schema validator object More... | |
hash< RestExampleRequestInfo > | getExampleRequestImpl (string method, string path, *softlist< string > content_types) |
returns a hash of example message information for the given request More... | |
hash< RestExampleResponseInfo > | getExampleResponseImpl (string method, string path, int code, *softlist< string > content_types) |
returns a hash of example message information for the given request More... | |
abstract string | getHashImpl () |
returns a unique hash for the schema that can be used to compare schemas More... | |
string | getHashImpl () |
returns a unique hash for the schema that can be used to compare schemas More... | |
hash< string, list< string > > | getPathOperationHashImpl () |
returns a hash of URI paths as keys with values as lists of supported HTTP methods More... | |
hash< RestQoreExampleCodeInfo > | getQoreExampleRequestImpl (string method, string path) |
returns a hash of example Qore code for the given request More... | |
hash< RestQoreExampleCodeInfo > | getQoreExampleResponseImpl (string method, string path, int code) |
returns example Qore code for the given response More... | |
abstract string | getTargetUrlImpl () |
returns the target URL for the schema More... | |
string | getTargetUrlImpl () |
returns the target URL for the schema More... | |
bool | managesUriPath () |
returns True if the provider manages the URI path More... | |
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) More... | |
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 More... | |
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-side HTTP request More... | |
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-side HTTP request More... | |
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 definitions if possible More... | |
setBasePathImpl (string basePath) | |
overrides the basePath value More... | |
Private Attributes | |
const | DataDeserializationSupport = ... |
Data deserialization support MIME types to codes and de/serialization functions. | |
const | DataSerializationSupport = ... |
processes and parses a client request and returns the deserialized message body (if any) /** More... | |
const | NullSchemaHashStr = "<null rest schema>" |
a unique hash for the null schema More... | |
abstract REST schema validation classes
|
private |
Check if the headers contain a content-type header which is accepted and if so, modify the response hash.
resp | response hash |
body | response body data (if any) |
headers | HTTP headers to include in the response |
content_types | the accepted MIME types in order of preference |
Content-Type
header and the rv was modifiedContent-Type
headers, then False is returned and response is not modified string RestSchemaValidator::AbstractRestSchemaValidator::getBasePath | ( | ) |
returns the base path prefix for all requests in this schema
|
private |
returns the base path prefix for all requests in this schema
DataProvider::AbstractDataProvider RestSchemaValidator::AbstractRestSchemaValidator::getDataProvider | ( | HTTPClient | rest | ) |
returns a data provider object for this connection, if supported by any REST schema validator object
rest | the RestClient object to make the connection |
DATA-PROVIDER-ERROR | this class does not support the data provider API |
RestClient
object; this parameter is declared with a base class to avoid a circular dependency between modules
|
private |
returns a data provider object for this connection, if supported by any REST schema validator object
rest | the RestClient object to make the connection |
DATA-PROVIDER-ERROR | this class does not support the data provider API |
RestClient
object; this parameter is declared with a base class to avoid a circular dependency between modules hash<RestExampleRequestInfo> RestSchemaValidator::AbstractRestSchemaValidator::getExampleRequest | ( | string | method, |
string | path, | ||
*softlist< string > | content_types | ||
) |
returns a hash of example message information for the given request
method | the HTTP method (case insensitive) |
path | the URI path of the request |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
|
private |
returns a hash of example message information for the given request
method | the HTTP method (case insensitive) |
path | the URI path of the request |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
hash<RestExampleResponseInfo> RestSchemaValidator::AbstractRestSchemaValidator::getExampleResponse | ( | string | method, |
string | path, | ||
int | code, | ||
*softlist< string > | content_types | ||
) |
returns a hash of example message information for the given request
method | the HTTP method of the original request (case insensitive) |
path | the URI path of the original request |
code | the HTTP response code of the response |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
|
private |
returns a hash of example message information for the given request
method | the HTTP method of the original request (case insensitive) |
path | the URI path of the original request |
code | the HTTP response code of the response |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
string RestSchemaValidator::AbstractRestSchemaValidator::getHash | ( | ) |
returns a unique hash for the schema that can be used to compare schemas
|
privatepure virtual |
returns a unique hash for the schema that can be used to compare schemas
|
private |
returns a unique hash for the schema that can be used to compare schemas
hash<string, list<string> > RestSchemaValidator::AbstractRestSchemaValidator::getPathOperationHash | ( | ) |
returns a hash of URI paths as keys with values as lists of supported HTTP methods
|
private |
returns a hash of URI paths as keys with values as lists of supported HTTP methods
hash<RestQoreExampleCodeInfo> RestSchemaValidator::AbstractRestSchemaValidator::getQoreExampleRequest | ( | string | method, |
string | path | ||
) |
returns a hash of example Qore code for the given request
method | the HTTP method (case insensitive) |
path | the URI path of the request |
|
private |
returns a hash of example Qore code for the given request
method | the HTTP method (case insensitive) |
path | the URI path of the request |
hash<RestQoreExampleCodeInfo> RestSchemaValidator::AbstractRestSchemaValidator::getQoreExampleResponse | ( | string | method, |
string | path, | ||
int | code | ||
) |
returns example Qore code for the given response
method | the HTTP method of the original request (case insensitive) |
path | the URI path of the original request |
code | the HTTP response code of the response |
|
private |
returns example Qore code for the given response
method | the HTTP method of the original request (case insensitive) |
path | the URI path of the original request |
code | the HTTP response code of the response |
string RestSchemaValidator::AbstractRestSchemaValidator::getTargetUrl | ( | ) |
returns the target URL for the schema
MISSING-TARGET-URL | no target URL provided for the schema |
|
privatepure virtual |
returns the target URL for the schema
MISSING-TARGET-URL | no target URL provided for the schema |
|
private |
returns the target URL for the schema
MISSING-TARGET-URL | no target URL provided for the schema |
bool RestSchemaValidator::AbstractRestSchemaValidator::managesUriPath | ( | ) |
|
private |
hash<RestRequestServerInfo> RestSchemaValidator::AbstractRestSchemaValidator::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)
method | the HTTP method (case-insensitive) |
path | the URI path with any query arguments |
http_body | the serialized message body |
headers | a reference to the hash of HTTP headers received; any default header values to be assumed by the server for the request will be added here |
DESERIALIZATION-ERROR | the request body could not be deserialized, results in a 400 Bad Request response returned to the caller |
SCHEMA-VALIDATION-ERROR | this exception should be thrown if there is a validation error in the request so that a 400 Bad Request response can be returned to the caller |
INVALID-METHOD | invalid HTTP method for the request; the arg argument should have a list of acceptable HTTP methods for this request |
|
private |
processes and parses a client request and returns the deserialized message body (if any)
method | the HTTP method (case-insensitive) |
path | the URI path with any query arguments |
http_body | the serialized message body |
headers | a reference to the hash of HTTP headers received; any default header values to be assumed by the server for the request will be added here |
DESERIALIZATION-ERROR | the request body could not be deserialized, results in a 400 Bad Request response returned to the caller |
SCHEMA-VALIDATION-ERROR | this exception should be thrown if there is a validation error in the request so that a 400 Bad Request response can be returned to the caller |
INVALID-METHOD | invalid HTTP method for the request; the arg argument should have a list of acceptable HTTP methods for this request |
hash<RestResponseClientInfo> RestSchemaValidator::AbstractRestSchemaValidator::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
method | the HTTP method (case insensitive) |
path | the URI path of the original request (without any query arguments) |
code | the HTTP response code |
response_body | the HTTP response body data (if any) |
hdr | as hash of HTTP headers received |
DESERIALIZATION-ERROR | the request body could not be deserialized or had an invalid Content-Type |
|
private |
parses and validates the response from the server and returns a hash of the processed info
method | the HTTP method (case insensitive) |
path | the URI path of the original request (without any query arguments) |
code | the HTTP response code |
response_body | the HTTP response body data (if any) |
hdr | as hash of HTTP headers received |
DESERIALIZATION-ERROR | the request body could not be deserialized or had an invalid Content-Type |
hash<RestRequestClientInfo> RestSchemaValidator::AbstractRestSchemaValidator::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-side HTTP request
method | the HTTP method (case-insensitive) |
path | the URI path with any query arguments |
body | the unserialized message body data |
headers | any headers to include in the request; note that the Content-Type header should not be sent here as it will be overridden when the message is serialized |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
SERIALIZATION-ERROR | unsupported message body MIME type requested or missing serialization module |
|
privatepure virtual |
processes a client-side REST request and returns a hash that can be used to make the outgoing client-side HTTP request
method | the HTTP method (case-insensitive) |
path | the URI path with any query arguments |
body | the unserialized message body data |
headers | any headers to include in the request; note that the Content-Type header should not be sent here as it will be overridden when the message is serialized |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
SERIALIZATION-ERROR | unsupported message body MIME type requested or missing serialization module |
|
private |
processes a client-side REST request and returns a hash that can be used to make the outgoing client-side HTTP request
method | the HTTP method (case-insensitive) |
path | the URI path with any query arguments |
body | the unserialized message body data |
headers | any headers to include in the request; note that the Content-Type header should not be sent here as it will be overridden when the message is serialized |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown |
SERIALIZATION-ERROR | unsupported message body MIME type requested or missing serialization module |
hash<HttpResponseInfo> RestSchemaValidator::AbstractRestSchemaValidator::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.
Validates any response data against schema definitions if possible
method | the HTTP method of the original request |
path | the URI path of the original request (without query arguments) |
code | the HTTP response code |
response_body | the response body data (if any) |
headers | HTTP headers to include in the response |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown; if this argument is not present, then json is preferred over yaml |
ACCEPT-ERROR | the response body could not be serialized because the client does not accept a supported type |
SERIALIZATION-ERROR | the response body could not be serialized due to an error |
Accept
header field is present, and if the server cannot send a response which is acceptable according to the combined Accept
field value, then the server SHOULD send a 406 (not acceptable) response. To ensure this happens, if an Accept
error of this nature occurs in this call, an "ACCEPT-ERROR"
must be thrown
|
private |
processes a REST response with a serialized message body, validates any response data against schema definitions if possible
method | the HTTP method of the original request |
path | the URI path of the original request (without query arguments) |
code | the HTTP response code |
response_body | the response body data (if any) |
headers | HTTP headers to include in the response |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown; if this argument is not present, then json is preferred over yaml |
ACCEPT-ERROR | the response body could not be serialized because the client does not accept a supported type |
SERIALIZATION-ERROR | the response body could not be serialized due to an error |
Accept
header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response. To ensure this happens, if an Accept
error of this nature occurs in this call, an "ACCEPT-ERROR"
must be thrown RestSchemaValidator::AbstractRestSchemaValidator::setBasePath | ( | string | basePath | ) |
overrides the basePath value
basePath | the new base path value; use an empty string here to clear the basePath |
|
private |
overrides the basePath value
basePath | the new base path value; use an empty string here to clear the basePath |
|
private |
processes and parses a client request and returns the deserialized message body (if any) /**
method | the HTTP method (case-insensitive) |
path | the URI path with any query arguments |
http_body | the serialized message body |
headers | a reference to the hash of HTTP headers received; any default header values to be assumed by the server for the request will be added here |
DESERIALIZATION-ERROR | the request body could not be deserialized, results in a 400 Bad Request response returned to the caller |
SCHEMA-VALIDATION-ERROR | this exception should be thrown if there is a validation error in the request so that a 400 Bad Request response can be returned to the caller |
INVALID-METHOD | invalid HTTP method for the request; the arg argument should have a list of acceptable HTTP methods for this request */ abstract hash<RestRequestServerInfo> parseRequestImpl(string method, string path, *data http_body, reference<hash> headers); #! processes a REST response with a serialized message body, validates any response data against schema definitions if possible /** |
method | the HTTP method of the original request |
path | the URI path of the original request (without query arguments) |
code | the HTTP response code |
response_body | the response body data (if any) |
headers | HTTP headers to include in the response |
content_types | the desired MIME types for serialization in order of preference; if none are usable then an exception is thrown; if this argument is not present, then json is preferred over yaml |
ACCEPT-ERROR | the response body could not be serialized because the client does not accept a supported type |
SERIALIZATION-ERROR | the response body could not be serialized due to an error |
|
private |
a unique hash for the null schema