API Platform version(s) affected: 2.6.1
Description
Given a pattern with regex delimiters for \Symfony\Component\Validator\Constraints\Regex, it cannot be used as http://dev.w3.org/html5/spec/single-page.html#the-pattern-attribute
How to reproduce
with '/^([-a-zA-Z0-9_])+$/' is used in OpenAPI documentation for property:
...
properties:
property:
pattern: '/^([-a-zA-Z0-9_])+$/
description: '...'
type: string
...
Correct would be (without delimiters):
...
properties:
property:
pattern: '([-a-zA-Z0-9_])+'
description: '...'
type: string
...
Possible Solution
In \ApiPlatform\Core\Bridge\Symfony\Validator\Metadata\Property\Restriction\PropertySchemaRegexRestriction::create(), instead of $constraint->pattern use $constraint->getHtmlPattern()
See https://github.com/symfony/validator/blob/367afc5864bfdb07508668dc0dfc06e56b6b89d5/Constraints/Regex.php#L99
Additional Context
https://swagger.io/docs/specification/data-models/data-types/#pattern
API Platform version(s) affected: 2.6.1
Description
Given a pattern with regex delimiters for \Symfony\Component\Validator\Constraints\Regex, it cannot be used as http://dev.w3.org/html5/spec/single-page.html#the-pattern-attribute
How to reproduce
with
'/^([-a-zA-Z0-9_])+$/'is used in OpenAPI documentation for property:Correct would be (without delimiters):
Possible Solution
In \ApiPlatform\Core\Bridge\Symfony\Validator\Metadata\Property\Restriction\PropertySchemaRegexRestriction::create(), instead of
$constraint->patternuse$constraint->getHtmlPattern()See https://github.com/symfony/validator/blob/367afc5864bfdb07508668dc0dfc06e56b6b89d5/Constraints/Regex.php#L99
Additional Context
https://swagger.io/docs/specification/data-models/data-types/#pattern