Merge branch 'issue305_internal_fixbug_posting_dates' into 'master'

Fix bug posting birth- and deathdate

See merge request Chill-Projet/chill-bundles!243
This commit is contained in:
Julien Fastré 2021-12-06 13:04:19 +00:00
commit 9924c3a3b7
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 * 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 * [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 * [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 ### 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\Entity\Person;
use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonRepository;
use DateTime; use DateTime;
use DateTimeImmutable;
use LogicException; use LogicException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
@ -114,18 +115,14 @@ class PersonJsonNormalizer implements
case 'birthdate': case 'birthdate':
$object = $this->denormalizer->denormalize($data[$item], DateTime::class, $format, $context); $object = $this->denormalizer->denormalize($data[$item], DateTime::class, $format, $context);
if ($object instanceof DateTime) { $person->setBirthdate($object);
$person->setBirthdate($object);
}
break; break;
case 'deathdate': 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; break;

View File

@ -353,6 +353,19 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/Person" $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: responses:
401: 401:
description: "Unauthorized" description: "Unauthorized"
@ -375,6 +388,19 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/Person" $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: responses:
200: 200:
description: "OK" description: "OK"