mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 12:02:43 +00:00
[PHP] Non required enum property (#7723)
* Add required enum property
* Update samples
* Add test case which reproduce the problem
refs https://github.com/swagger-api/swagger-codegen/pull/7686#issuecomment-368200011
> 2. Non-required enum property is listed as invalid when omitted
* If the property is not empty, perform validation
* Update samples
* Use is_null() according to setter implementation
refs 377247f125/modules/swagger-codegen/src/main/resources/php/model_generic.mustache (L347)
* Update samples
This commit is contained in:
committed by
William Cheng
parent
227e2458d4
commit
32cf2f16f5
@@ -15,4 +15,20 @@ class EnumTestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(EnumTest::ENUM_NUMBER_1_DOT_1, 1.1);
|
||||
$this->assertSame(EnumTest::ENUM_NUMBER_MINUS_1_DOT_2, -1.2);
|
||||
}
|
||||
|
||||
public function testNonRequiredPropertyIsOptional()
|
||||
{
|
||||
$enum = new EnumTest([
|
||||
'enum_string_required' => 'UPPER',
|
||||
]);
|
||||
$this->assertSame([], $enum->listInvalidProperties());
|
||||
$this->assertTrue($enum->valid());
|
||||
}
|
||||
|
||||
public function testRequiredProperty()
|
||||
{
|
||||
$enum = new EnumTest();
|
||||
$this->assertSame(["'enum_string_required' can't be null"], $enum->listInvalidProperties());
|
||||
$this->assertFalse($enum->valid());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user