Closed vabalazs82 closed 3 years ago
@vabalazs82 can you please provide an example? An yaml perhaps, bc we do have some tests with nullable properties which are working fine but maybe we're not covering this specific use case...
The config like this:
` TestSchema1: type: object required:
TestSchema4: type: object nullable: true properties: id: type: string required: -id
The http response contains : testProp4: null
Hello @vabalazs82 Currently, if a schema property is nullable, we just don't define it as "required". As a quick solution this is what you should probably do imo. But you are right, we should probably handle this case too.
Ok, indeed I'm able to reproduce it, here's the faulty generated code:
public function toSchema(array $payload): TestSchema1
{
...
return new TestSchema1($this->testProp4Mapper->toSchema($payload['testProp4']));
}
and
/**
* @throws UnexpectedResponseBodyException
*
* @return TestSchema4
*/
public function toSchema(array $payload): ?TestSchema4
{
...
checking how we can fix it
thanks
Dear all,
When the schema`s property is nullable=true and the data which comes is null, then we have Argument 1 passed to ...Mapper::toSchema() must be of the type array, null given
Please check it.