[PHP] Skip length validation for DateTime model properties
Merged
22
5mo ago+70+70+01234567890123456789-26-26-01234567890123456789
Fixes #24229.
What changed
- Skips generated
minLength/maxLengthmb_strlen()checks for PHP model properties generated as\DateTime(date/date-time). - Keeps string length validation intact for normal
stringproperties. - Applies the same template fix to
phpandphp-nextgen. - Adds generator regression coverage for both PHP clients so a
date-timefield with length constraints does not emitmb_strlen(), while a regular string field still does.
Validation
- Passed locally on Windows with Temurin JDK 17:
./mvnw -pl modules/openapi-generator -am \
-Dtest=org.openapitools.codegen.php.PhpClientCodegenTest#testDateTimeLengthValidationIsNotGenerated,org.openapitools.codegen.php.PhpNextgenClientCodegenTest#testDateTimeLengthValidationIsNotGenerated \
-Dsurefire.failIfNoSpecifiedTests=false test
Result: Tests run: 2, Failures: 0, Errors: 0, Skipped: 0.
Summary by cubic
Skip length validation for PHP \DateTime model properties (date/date-time) so we don’t call mb_strlen on dates while keeping string checks. Applies to php and php-nextgen; fixes #24229.
- Bug Fixes
- Wrapped
maxLength/minLengthin{{#isString}} ... {{/isString}}in bothmodel_generic.mustachetemplates. - Added regression tests for
phpandphp-nextgen(plusTestUtilsimport fix) and refreshed PHP samples to avoid drift.
- Wrapped