Basics • Settings • ValidationExtras

Available settings

Setting Type Default
controller_method boolean false
controller_prefix string ""
route_bind boolean false
strict boolean false
validate_request boolean false
validate_response boolean false

How to use

OpenApi constructor takes array of settings as second aargument.

use Phrity\Slim\OpenApi;
use Slim\Factory\AppFactory;

$slim = AppFactory::create();
$openapi = new OpenApi('openapi.json', [
    'controller_method' => true,
    'controller_prefix' => "Test/",
    'route_bind' => true,
    'strict' => true,



If set to true and method is not defined in operationId, requests will be mapped to methods that correspond to HTTP methods. Standard HTTP methods are get, post, put, delete, head, patch and options. If method is defined in schema, this setting will have no effect.

See example.


Will prefix operationId when mapping container classes. Typically used to hide namespace paths from OpenApi schema.

See example.


Will attach corresponding OpenApi route as a request attribute. It can then be accessed in your controller as openapi-route.

class MyController
    public function get($request, $response, array $arguments)
        $route = $request->getAttribute('openapi-route');
        return $response;


Will validate OpenApi schema when loaded, and throw RuntimeException if schema is invalid.


Will add middleware that validates incoming Request, and throws Exception if invalid.

See example.


Will add middleware that validates outgoing Response, and throws Exception if invalid.

See example.