NativeSchema
extends Schema
in package
Defines a builtin schema that provides all available metadata for the API. This schema is used to generate a file containing all the metadata for endpoint, model and field definitions. It is intended to be used by custom applications that need more context about the API than other schemas can provide.
Table of Contents
Constants
- SCHEMA_DIR = '/usr/local/pkg/RESTAPI/.resources/schemas/'
- The directory where schema files are stored.
Properties
- $content_type : string
- $file_name : string
- $file_path : string
Methods
- __construct() : mixed
- build_schema_url() : void
- Builds a unique endpoint URL for this schema in the pfSense webroot directory.
- endpoint_to_metadata() : array<string|int, mixed>
- Extracts all applicable metadata from a given endpoint object
- field_to_metadata() : array<string|int, mixed>
- Extracts all applicable metadata from a given field object
- get_class_fqn() : string
- Obtains the fully qualified name of the called class.
- get_class_shortname() : string
- Obtains the shortname of the called class.
- get_classes_in_namespace() : array<string|int, mixed>
- Obtains all classes associated with this class's current namespace.
- get_schema_str() : string
- Obtains the full schema string for this Schema class in JSON format
- log_error() : void
- Logs an error to the syslog.
- model_to_metadata() : array<string|int, mixed>
- Extracts all applicable metadata from a given model object
- read_schema_from_file() : string
- Reads the schema from file.
- save_schema() : void
- Saves the schema to file.
Constants
SCHEMA_DIR
The directory where schema files are stored.
public
mixed
SCHEMA_DIR
= '/usr/local/pkg/RESTAPI/.resources/schemas/'
Properties
$content_type
public
string
$content_type
= 'text/plain'
The content type for this schema. This is used to determine how the schema is formatted and displayed when accessed via the URL.
$file_name
public
string
$file_name
= 'native.json'
The file name for this schema.
$file_path
public
string
$file_path
The full file path to the schema file.
Methods
__construct()
public
__construct() : mixed
build_schema_url()
Builds a unique endpoint URL for this schema in the pfSense webroot directory.
public
build_schema_url() : void
endpoint_to_metadata()
Extracts all applicable metadata from a given endpoint object
public
endpoint_to_metadata(Endpoint $endpoint) : array<string|int, mixed>
Parameters
- $endpoint : Endpoint
-
The endpoint object to extract metadata from
Return values
array<string|int, mixed> —An associative array containing metadata about the endpoint.
field_to_metadata()
Extracts all applicable metadata from a given field object
public
field_to_metadata(Field $field) : array<string|int, mixed>
Parameters
- $field : Field
Return values
array<string|int, mixed>get_class_fqn()
Obtains the fully qualified name of the called class.
public
get_class_fqn() : string
Return values
string —The FQN for this object's class.
get_class_shortname()
Obtains the shortname of the called class.
public
get_class_shortname() : string
Return values
string —The shortname for this object's class.
get_classes_in_namespace()
Obtains all classes associated with this class's current namespace.
public
get_classes_in_namespace([bool $shortnames = false ]) : array<string|int, mixed>
Parameters
- $shortnames : bool = false
Return values
array<string|int, mixed> —An array of classes currently in this object's namespace
get_schema_str()
Obtains the full schema string for this Schema class in JSON format
public
get_schema_str() : string
Return values
string —The full schema string for this Schema class in JSON format
log_error()
Logs an error to the syslog.
public
static log_error(string $message) : void
Parameters
- $message : string
-
The error message to write to the syslog
model_to_metadata()
Extracts all applicable metadata from a given model object
public
model_to_metadata(Model $model) : array<string|int, mixed>
Parameters
- $model : Model
-
The model object to extract metadata from
Return values
array<string|int, mixed> —An associative array containing metadata about the model.
read_schema_from_file()
Reads the schema from file.
public
read_schema_from_file() : string
Return values
string —The schema as a string.
save_schema()
Saves the schema to file.
public
save_schema() : void