Loading...
Searching...
No Matches
RestSchemaValidator::NullRestSchemaValidator Class Reference

null REST validator; no schema is used but default serialization and deserialization is performed More...

Inheritance diagram for RestSchemaValidator::NullRestSchemaValidator:
[legend]

## Public Member Functions

private hash< RestExampleRequestInfo > | getExampleRequestImpl (string method, string path, *softlist< string > content_types)
| returns a hash of example message information for the given request More...
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 More...
bool | managesUriPath ()
| returns True if the provider manages the URI path More...
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 More...
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 definitions if possible More...
Public Member Functions inherited from RestSchemaValidator::AbstractRestSchemaValidator
| 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...
abstract private 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 > | getExampleResponse (string method, string path, int code, *softlist< string > content_types)
| returns a hash of example message information for the given request More...
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 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...
abstract private hash< RestQoreExampleCodeInfo > | getQoreExampleResponseImpl (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...
*TimeZone | getTimeZoneLocale ()
| Returns the time zone locale used for serialization / deserialization. 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...
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) 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...
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 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...
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-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...
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 definitions if possible More...
| setBasePath (string basePath)
| overrides the basePath value More...
| setLogger (Logger::Logger logger)
| Sets a new logger.
| setTimeZoneLocale (*TimeZone tz)
| Allows the time zone locale to be set for serialization / deserialization. More...

## Public Attributes

const | DataDeserializationSupport
| Data deserialization support MIME types to codes and de/serialization functions.
const | DataSerializationSupport
| Data serialization support mapping codes to MIME types and de/serialization functions.
const | NullSchemaHashStr = "<null rest schema>"
| a unique hash for the null schema More...

## Protected Member Functions

string | getBasePathImpl ()
| returns the base path prefix for all requests in this schema 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...
string | getTargetUrlImpl ()
| returns the target URL for the schema More...
*TimeZone | getTimeZoneLocaleImpl ()
| Returns the time zone locale used for serialization / deserialization. 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< 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...
| setBasePathImpl (string basePath)
| overrides the basePath value More...
| setTimeZoneLocaleImpl (*TimeZone tz)
| Allows the time zone locale to be set for serialization / deserialization. More...
Protected Member Functions inherited from RestSchemaValidator::AbstractRestSchemaValidator
abstract 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...
abstract string | getHashImpl ()
| returns a unique hash for the schema that can be used to compare schemas More...
abstract hash< string, list< string > > | getPathOperationHashImpl ()
| returns a hash of URI paths as keys with values as lists of supported HTTP methods More...
abstract hash< RestQoreExampleCodeInfo > | getQoreExampleRequestImpl (string method, string path)
| returns a hash of example Qore code for the given request More...
abstract string | getTargetUrlImpl ()
| returns the target URL for the schema More...
abstract *TimeZone | getTimeZoneLocaleImpl ()
| Returns the time zone locale used for serialization / deserialization. More...
abstract | setBasePathImpl (string basePath)
| overrides the basePath value More...
abstract | setTimeZoneLocaleImpl (*TimeZone tz)
| Allows the time zone locale to be set for serialization / deserialization. More...

## Private Member Functions

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 hash. More...

## Detailed Description

null REST validator; no schema is used but default serialization and deserialization is performed

## Member Function Documentation

## checkResponseContentTypeHeader()

internal bool RestSchemaValidator::NullRestSchemaValidator::checkResponseContentTypeHeader | ( | reference< hash< HttpResponseInfo > > | resp,
|  | auto | body,
|  | *hash< auto > | headers,
|  | *softlist< string > | content_types
| ) |  |

inline private

Check if the headers contain a content-type header which is accepted and if so, modify the response hash.

Parameters

  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

Returns
  whether the headers contained a `Content-Type` header and the rv was modified

Note
  if there are more `Content-Type` headers, then False is returned and response is not modified

## getBasePathImpl()

string RestSchemaValidator::NullRestSchemaValidator::getBasePathImpl | ( |  | ) |

protected virtual

returns the base path prefix for all requests in this schema

Returns
  the base path prefix for all requests in this schema

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getExampleRequestImpl()

private hash< RestExampleRequestInfo > RestSchemaValidator::NullRestSchemaValidator::getExampleRequestImpl | ( | string | method,
|  | string | path,
|  | *softlist< string > | content_types
| ) |  |

inline virtual

returns a hash of example message information for the given request

Parameters

  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

Returns
  a RestExampleRequestInfo of example message information for the given request

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getExampleResponseImpl()

private hash< RestExampleResponseInfo > RestSchemaValidator::NullRestSchemaValidator::getExampleResponseImpl | ( | string | method,
|  | string | path,
|  | int | code,
|  | *softlist< string > | content_types
| ) |  |

inline virtual

returns a hash of example message information for the given request

Parameters

  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

Returns
  a RestExampleResponseInfo hash giving example response message info

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getHashImpl()

string RestSchemaValidator::NullRestSchemaValidator::getHashImpl | ( |  | ) |

protected virtual

returns a unique hash for the schema that can be used to compare schemas

Returns
  a unique hash for the schema that can be used to compare schemas

Since
  RestSchemaValidator 2.0

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getPathOperationHashImpl()

hash< string, list< string > > RestSchemaValidator::NullRestSchemaValidator::getPathOperationHashImpl | ( |  | ) |

protected virtual

returns a hash of URI paths as keys with values as lists of supported HTTP methods

Returns
  a hash of URI paths as keys with values as lists of supported HTTP methods

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getQoreExampleRequestImpl()

hash< RestQoreExampleCodeInfo > RestSchemaValidator::NullRestSchemaValidator::getQoreExampleRequestImpl | ( | string | method,
|  | string | path
| ) |  |

protected virtual

returns a hash of example Qore code for the given request

Parameters

  method | the HTTP method (case insensitive)
  path | the URI path of the request

Returns
  a RestQoreExampleCodeInfo hash giving example Qore code to generate the given request message

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getQoreExampleResponseImpl()

hash< RestQoreExampleCodeInfo > RestSchemaValidator::NullRestSchemaValidator::getQoreExampleResponseImpl | ( | string | method,
|  | string | path,
|  | int | code
| ) |  |

protected virtual

returns example Qore code for the given response

Parameters

  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

Returns
  a RestQoreExampleCodeInfo hash giving example Qore code to generate the given response message

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getTargetUrlImpl()

string RestSchemaValidator::NullRestSchemaValidator::getTargetUrlImpl | ( |  | ) |

protected virtual

returns the target URL for the schema

Returns
  the target URL for the schema

Exceptions

  MISSING-TARGET-URL | no target URL provided for the schema

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## getTimeZoneLocaleImpl()

*TimeZone RestSchemaValidator::NullRestSchemaValidator::getTimeZoneLocaleImpl | ( |  | ) |

protected virtual

Returns the time zone locale used for serialization / deserialization.

Returns
  the time zone locale to set

Since
  RestSchemaValidator 2.1.3

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## managesUriPath()

bool RestSchemaValidator::NullRestSchemaValidator::managesUriPath | ( |  | ) |

returns True if the provider manages the URI path

This method returns False

## parseRequestImpl()

hash< RestRequestServerInfo > RestSchemaValidator::NullRestSchemaValidator::parseRequestImpl | ( | string | method,
|  | string | path,
|  | *data | http_body,
|  | reference< hash > | headers
| ) |  |

protected virtual

processes and parses a client request and returns the deserialized message body (if any)

Parameters

  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

Returns
  a RestRequestServerInfo hash of request information

Exceptions

  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

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## parseResponseImpl()

private hash< RestResponseClientInfo > RestSchemaValidator::NullRestSchemaValidator::parseResponseImpl | ( | string | method,
|  | string | path,
|  | int | code,
|  | *data | response_body,
|  | hash< auto > | hdr
| ) |  |

inline virtual

parses and validates the response from the server and returns a hash of the processed info

Parameters

  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

Exceptions

  DESERIALIZATION-ERROR | the request body could not be deserialized or had an invalid `Content-Type`

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## processRequestImpl()

hash< RestRequestClientInfo > RestSchemaValidator::NullRestSchemaValidator::processRequestImpl | ( | string | method,
|  | string | path,
|  | auto | body,
|  | *hash< auto > | headers,
|  | *softlist< string > | content_types
| ) |  |

protected

processes a client-side REST request and returns a hash that can be used to make the outgoing client-side HTTP request

Parameters

  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

Returns
  a RestRequestClientInfo hash with information about the request

Exceptions

  SERIALIZATION-ERROR | unsupported message body MIME type requested or missing serialization module

## processResponseImpl()

private hash< HttpResponseInfo > RestSchemaValidator::NullRestSchemaValidator::processResponseImpl | ( | string | method,
|  | string | path,
|  | int | code,
|  | auto | response_body,
|  | *hash< auto > | headers,
|  | *softlist< string > | content_types
| ) |  |

inline virtual

processes a REST response with a serialized message body, validates any response data against schema definitions if possible

Parameters

  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; note that if this value contains a `Content-Type` key, this type will be used for the response serialization if it is supported and if the client can accept it, otherwise an `ACCEPT-ERROR` exception is raised resulting in a `406 Not Acceptable` error being returned to the client
  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

Returns
  an HttpResponseInfo hash for the response

Exceptions

  ACCEPT-ERROR | the response body could not be serialized because the client does not accept a supported type; results in a `406 Not Acceptable` error being returned to the client
  SERIALIZATION-ERROR | the response body could not be serialized due to an error

Note
  <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html>RFC 2616 section 14</a>: If an \c 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 \c Accept error of this nature occurs in this call, an \c "ACCEPT-ERROR" must be thrown

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## setBasePathImpl()

RestSchemaValidator::NullRestSchemaValidator::setBasePathImpl | ( | string | basePath | ) |

protected virtual

overrides the basePath value

Parameters

  basePath | the new base path value; use an empty string here to clear the basePath

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## setTimeZoneLocaleImpl()

RestSchemaValidator::NullRestSchemaValidator::setTimeZoneLocaleImpl | ( | *TimeZone | tz | ) |

protected virtual

Allows the time zone locale to be set for serialization / deserialization.

Parameters

  tz | the time zone locale to set

Since
  RestSchemaValidator 2.1.3

Implements RestSchemaValidator::AbstractRestSchemaValidator.

## Member Data Documentation

## NullSchemaHashStr

const RestSchemaValidator::NullRestSchemaValidator::NullSchemaHashStr = "<null rest schema>"

a unique hash for the null schema

Since
  RestSchemaValidator 2.0