aaieduhr / aosi-module-rest-server
AOSI REST Server Module
Package info
gitlab.opencode.hr/srce/aai-eduhr/aosi/aosi-module-rest-server
Type:aosi-module
pkg:composer/aaieduhr/aosi-module-rest-server
Requires
- php: >=8.2
Requires (Dev)
- aaieduhr/aosi: dev-rest-server
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpunit/phpunit: ^10 || ^11
- rector/rector: ^2.0
- slevomat/coding-standard: ^8
- squizlabs/php_codesniffer: ^3
This package is auto-updated.
Last update: 2026-07-03 12:17:01 UTC
README
Provides pluggable JSON endpoints for AOSI modules.
Installation
composer require aaieduhr/aosi-module-rest-server
Enable aaieduhr/aosi-module-rest-server in the AOSI modules.enabled
configuration. AOSI core registers methods returned by each enabled module's
getRestServerMethods() manifest method.
Calling a method
Every method is exposed through POST /AOSI.rest/{method} and requires an
application/json object body:
POST /AOSI.rest/anonSearch
Content-Type: application/json
{
"base": "dc=example,dc=org",
"filter": "(uid=test)",
"attributes": ["uid", "cn"]
}
Success:
{"data":{"uid=test,dc=example,dc=org":{"uid":["test"]}}}
Errors use RFC 9457-style application/problem+json responses and meaningful
HTTP status codes.
Providing methods
Return AaiEduHr\Aosi\RestServer\MethodDescriptor instances from an AOSI
module manifest's getRestServerMethods() method. Handlers may be container
services such as [ExampleHandler::class, 'example']; request parameters are
validated from their SchemaDescriptor definitions before invocation.
For small modules, returning descriptors directly from the manifest or a required config file is usually enough. For larger method sets, prefer an autoloaded provider class and keep the config file as a thin delegation, for example:
use Vendor\ExampleModule\Config\ExampleRestMethods;
return ExampleRestMethods::all();
This module's config/rest_methods.php follows that pattern. Avoid defining
shared closures inside config files as the reference style. Generic descriptor
helpers are available through AaiEduHr\Aosi\RestServer\DescriptorFactory;
module-specific helpers, such as default handler mapping or common parameter
groups, should remain in the module provider class.
The generated API descriptions are available at:
/rest-server-documentation/rest-server-openapi.json
Licence
This work is published under the European Union Public License v1.2.