Description
When you generate a PHP Client and you try to get data from a resource that has a property with a minLength it throws an exception if the value is null. The problem is that this behaviour is right if the property is required, but if it is not required the check is the same so it cannot be null and it becomes required when it isn't.
Swagger-codegen version
api version: 2.2.0-SNAPSHOT
Swagger declaration file content or url
https://gist.github.com/joskfg/96633d30a8788bde414c1b77d696fdaa
Command line used for generation
Used online generator.
{
"swaggerUrl": "http://localhost/swagger.json",
"options": {
"modelPackage": "Company\\Package\\Model",
"apiPackage": "Company\\Package\\Api",
"invokerPackage": "Company\\Package",
"packagePath": "Package",
"srcBasePath": "src",
"composerVendorName": "company",
"composerProjectName": "package",
"artifactVersion": "1.0.0"
}
}
Steps to reproduce
Create a PHP Client for a given resource with non-required properties with minLength and maxLength. When you'll retrieve data from the resource if the non-required parameter is null you'll get an error telling that it needs to have al least N chars (the defined in the swagger), but it is not required so it should allow null values.
Related issues
Not found
Suggest a Fix
If the properties are not required the validations should be applied if there is some value in the property, if it is null, the property shouldn't be checked.
Description
When you generate a PHP Client and you try to get data from a resource that has a property with a minLength it throws an exception if the value is null. The problem is that this behaviour is right if the property is required, but if it is not required the check is the same so it cannot be null and it becomes required when it isn't.
Swagger-codegen version
api version: 2.2.0-SNAPSHOT
Swagger declaration file content or url
Command line used for generation
Used online generator.
{ "swaggerUrl": "http://localhost/swagger.json", "options": { "modelPackage": "Company\\Package\\Model", "apiPackage": "Company\\Package\\Api", "invokerPackage": "Company\\Package", "packagePath": "Package", "srcBasePath": "src", "composerVendorName": "company", "composerProjectName": "package", "artifactVersion": "1.0.0" } }Steps to reproduce
Create a PHP Client for a given resource with non-required properties with minLength and maxLength. When you'll retrieve data from the resource if the non-required parameter is null you'll get an error telling that it needs to have al least N chars (the defined in the swagger), but it is not required so it should allow null values.
Related issues
Not found
Suggest a Fix
If the properties are not required the validations should be applied if there is some value in the property, if it is null, the property shouldn't be checked.