getServiceManager()->get(OpenAPISchemaValidateRequestMiddleware::SERVICE_ID) ->addSchema($this->getOpenApiMiddlewareContext()); $middlewareHandler = $this->getServiceManager()->get(MiddlewareManager::class) ->append($this->getMiddlewareContext())->getMiddlewareHandler(); $this->getServiceManager()->register(OpenAPISchemaValidateRequestMiddleware::SERVICE_ID, $openApiMiddleware); $this->getServiceManager()->register(MiddlewareRequestHandler::SERVICE_ID, $middlewareHandler); return Report::createSuccess('OpenAPIValidationMiddleware successfully installed'); } private function getMiddlewareContext(): MiddlewareContext { return new MiddlewareContext( [ MiddlewareContext::PARAM_ROUTE => '/taoMediaManager/SharedStimulus/patch', MiddlewareContext::PARAM_MIDDLEWARE_ID => OpenAPISchemaValidateRequestMiddleware::SERVICE_ID ] ); } private function getOpenApiMiddlewareContext(): OpenApiMiddlewareContext { return new OpenApiMiddlewareContext([ OpenApiMiddlewareContext::PARAM_ROUTE => '/taoMediaManager/SharedStimulus/patch', OpenApiMiddlewareContext::PARAM_SCHEMA_PATH => self::OPENAPI_SPEC_PATH, ]); } }