Skip to content

Need some help #53

@Dadinos

Description

@Dadinos

I use this repository to verifiy incomming and outgoing json requests and responses.
I want to rework the error output to another json format.

Currently it is, as example:

Error 400: 
{
    "message": "Request validation failed",
    "errors": [
        {
            "name": "catalogus",
            "code": "error_format",
            "value": "",
            "in": "query",
            "type": "string",
            "format": "uri"
        }
    ]
}

I tried to catch this error so i can modify the repsonse like this:

$mw = new HKarlstrom\Middleware\OpenApiValidation(__DIR__.'/catalog_openapi.json');
$mw->addFormat('string','duration',new myDurationFormat());

$options = [
		'validateRequest'=> false,
		'exampleResponse' => true,
		 'beforeHandler' => function (\Psr\Http\Message\ServerRequestInterface $request, array $errors) : \Psr\Http\Message\ServerRequestInterface {
			// Alter request modifiy the json reponse here !!!
			echo "tadaaaa"; <- never outputted
			return $request;
		}
	];

And finally in my route:

$app->get('/v1/zaaktypen[/{params:.*}]',\App\Action\ZTCZaaktypenAction::class)->add($mw,$options);

But it never touches the before- or errorHandler.

Any ideas how to get this working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions