Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6596
Closed
Open
Issue created Jun 09, 2020 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[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

Assignee
Assign to
Time tracking