Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250706) (a6b17d8f6bd)
core\router\schema\specification Class Reference
Inheritance diagram for core\router\schema\specification:

Public Member Functions

 __construct ()
 Constructor to configure base information.
 
 add_component (openapi_base $object)
 Add a component to the components object.
 
 add_path (string $component, route $route,)
 Add an API Path.
 
 add_server (string $url, string $description,)
 Add a server to the specification.
 
 get_common_request_responses ()
 Get the common request responses.
 
 get_openapi_schema_for_route (route $route, string $component, string $path,)
 Get the OpenAPI description for this route.
 
 get_schema ()
 Get the OpenAPI schema.
 
 is_reference_defined (string $ref,)
 Check whether a reference is defined.
 
 jsonSerialize ()
 Implement the json serialisation interface.
 

Public Attributes

string const OPENAPI_VERSION = '3.1.0'
 The OpenAPI version represented in this specification.
 

Protected Member Functions

 add_example (example $example,)
 Add an example to the shared components section of the specification.
 
 add_header (header_object $header,)
 Add a header to the shared components section of the specification.
 
 add_parameter (parameter $parameter,)
 Add a schema to the shared components section of the specification.
 
 add_request_body (request_body $body,)
 Add a request body to the shared components section of the specification.
 
 add_response (response $response,)
 Add a response to the shared components section of the specification.
 
 add_schema (type_base $schema,)
 Add a schema to the shared components section of the specification.
 
 finalise ()
 Finalise the data and prepare it for consumption.
 
 generate_common_responses ()
 Generate the callables for common responses that are frequently found in paths.
 

Protected Attributes

callable[] array $commonresponses = []
 A list of common responses that are frequently found in paths.
 
stdClass stdClass $data
 The data which forms the specification.
 
bool bool $finalised = false
 Whether the data has been finalised for output yet.
 

Member Function Documentation

◆ add_component()

core\router\schema\specification::add_component ( openapi_base $object)

Add a component to the components object.

https://spec.openapis.org/oas/v3.1.0#components-object

Note: The following component types are supported:

  • schemas
  • responses
  • parameters
  • examples
  • requestBodies
  • headers

At this time, other component types are not supported.

Parameters
openapi_base$object
Return values
specification
Exceptions
coding_exceptionIf the component type is unknown.

◆ add_example()

core\router\schema\specification::add_example ( example $example)
protected

Add an example to the shared components section of the specification.

Parameters
example$example
Return values
specification

◆ add_header()

core\router\schema\specification::add_header ( header_object $header)
protected

Add a header to the shared components section of the specification.

Parameters
header_object$header
Return values
self

◆ add_parameter()

core\router\schema\specification::add_parameter ( parameter $parameter)
protected

Add a schema to the shared components section of the specification.

Parameters
parameter$parameter
Return values
specification

◆ add_path()

core\router\schema\specification::add_path ( string $component,
route $route )

Add an API Path.

Parameters
string$componentThe Moodle component
route$routeThe route which handles this request
Return values
specification

◆ add_request_body()

core\router\schema\specification::add_request_body ( request_body $body)
protected

Add a request body to the shared components section of the specification.

Parameters
request_body$body
Return values
specification

◆ add_response()

core\router\schema\specification::add_response ( response $response)
protected

Add a response to the shared components section of the specification.

Parameters
response$response
Return values
specification

◆ add_schema()

core\router\schema\specification::add_schema ( type_base $schema)
protected

Add a schema to the shared components section of the specification.

Parameters
type_base$schema
Return values
specification

◆ add_server()

core\router\schema\specification::add_server ( string $url,
string $description )

Add a server to the specification.

Parameters
string$urlThe URL of the API base
string$description
Return values
specification

◆ generate_common_responses()

core\router\schema\specification::generate_common_responses ( )
protected

Generate the callables for common responses that are frequently found in paths.

Return values
specification

◆ get_common_request_responses()

core\router\schema\specification::get_common_request_responses ( )

Get the common request responses.

Return values
callable[]

◆ get_openapi_schema_for_route()

core\router\schema\specification::get_openapi_schema_for_route ( route $route,
string $component,
string $path )

Get the OpenAPI description for this route.

Parameters
route$route
string$component
string$path
Return values
stdClass

◆ get_schema()

core\router\schema\specification::get_schema ( )
final

Get the OpenAPI schema.

Return values
stdClass

◆ is_reference_defined()

core\router\schema\specification::is_reference_defined ( string $ref)

Check whether a reference is defined.

Parameters
string$ref
Return values
bool

◆ jsonSerialize()

core\router\schema\specification::jsonSerialize ( )

Implement the json serialisation interface.

Return values
mixed

The documentation for this class was generated from the following file: