[BUG] [Symfony] Backslashes in namespaces passed to the Assert\Type ctor are not escaped
Created by: nicolas-girod
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix ([example]
Description
Version 4.3.0
If any part of the namespace of a type starts with an escape character, the string is mangled (contains a unicode or non-printable character) when passed to the constructor to Assert\Type.
Generated code for the controller with "invokerPackage": "Api\\v1"
in the configuration file:
// Deserialize the input values that needs it
try {
$body = $this->deserialize($body, 'Api\v1\Model\MyType', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
>>> $asserts[] = new Assert\Type("Api\v1\Model\MyType");
$asserts[] = new Assert\Valid();
$response = $this->validate($body, $asserts);
Here \v is converted to the vertical tab character.
Suggest a fix
Escape the backslashes or use single quotes for the string passed to the constructor of Assert\Type