Fix bug posting birth- and deathdate

This commit is contained in:
LenaertsJ 2021-12-06 13:04:19 +00:00 committed by Julien Fastré
parent 5669f62fdc
commit cea7160d5a
3 changed files with 31 additions and 7 deletions

View File

@ -52,6 +52,7 @@ and this project adheres to
* add an endpoint for checking permissions. See https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/232
* [activity] for a new activity: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties
* [calendar] for a new rdv: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties
* [bugfix] posting of birth- and deathdate through api fixed.
### Test release 2021-11-22

View File

@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\PersonRepository;
use DateTime;
use DateTimeImmutable;
use LogicException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
@ -114,18 +115,14 @@ class PersonJsonNormalizer implements
case 'birthdate':
$object = $this->denormalizer->denormalize($data[$item], DateTime::class, $format, $context);
if ($object instanceof DateTime) {
$person->setBirthdate($object);
}
$person->setBirthdate($object);
break;
case 'deathdate':
$object = $this->denormalizer->denormalize($data[$item], DateTime::class, $format, $context);
$object = $this->denormalizer->denormalize($data[$item], DateTimeImmutable::class, $format, $context);
if ($object instanceof DateTime) {
$person->setDeathdate($object);
}
$person->setDeathdate($object);
break;

View File

@ -353,6 +353,19 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Person"
examples:
Update a person:
value:
type: "person"
firstName: "string"
lastName: "string"
birthdate:
datetime: "2016-06-01T00:00:00+02:00"
deathdate:
datetime: "2021-06-01T00:00:00+02:00"
phonenumber: "string"
mobilenumber: "string"
gender: "male"
responses:
401:
description: "Unauthorized"
@ -375,6 +388,19 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Person"
examples:
Create a new person:
value:
type: "person"
firstName: "string"
lastName: "string"
birthdate:
datetime: "2016-06-01T00:00:00+02:00"
deathdate:
datetime: "2021-06-01T00:00:00+02:00"
phonenumber: "string"
mobilenumber: "string"
gender: "male"
responses:
200:
description: "OK"