Projet

Général

Profil

0003-toulouse_maelis-use-create-family-schema-as-referenc.patch

Nicolas Roche, 13 septembre 2022 19:48

Télécharger (3,6 ko)

Voir les différences:

Subject: [PATCH 3/3] toulouse_maelis: use create family schema as reference
 (#69046)

 passerelle/contrib/toulouse_maelis/schemas.py | 26 +++++++------------
 1 file changed, 9 insertions(+), 17 deletions(-)
passerelle/contrib/toulouse_maelis/schemas.py
475 475
                    'description': 'Texte libre de description (max 500 caractères)',
476 476
                    'oneOf': [{'type': 'null'}, {'type': 'string'}],
477 477
                },
478 478
            },
479 479
        },
480 480
    ],
481 481
}
482 482

  
483
"""
484
I was borred with WSDL specificities and provide all field for the 3 concerned endpoints.
485
Ex: on createFamily, "fsl" will be accepted, even if it should not be provided.
486

  
487
  | enpoint      | bean            | fsl | dietcode | bPhoto | bLeaveAlone | paiInfoBean |
488
  | createFamily | ChildBean       |     |     X    |        |             |             |
489
  | createChild  | ChildCreateBean |     |          |    X   |      X      |      X      |
490
  | updateFamily | ChildInfoBean   |  X  |     X    |    X   |      X      |      X      |
491
"""
492 483
CHILD_SCHEMA = {
493 484
    '$schema': 'http://json-schema.org/draft-04/schema#',
494 485
    'title': 'Child',
495 486
    'description': "Informations sur la création d'un enfant",
496 487
    'type': 'object',
497 488
    'required': ['sexe', 'firstname', 'lastname'],
498 489
    'oneOf': [
499 490
        {'required': ['dateBirth']},  # createFamily
......
584 575
                    'type': 'array',
585 576
                    'items': FAMILYPERSON_SCHEMA,
586 577
                },
587 578
            ],
588 579
        },
589 580
    },
590 581
}
591 582

  
592
CREATE_FAMILY_SCHEMA = {
583
UPDATE_FAMILY_SCHEMA = {
593 584
    '$schema': 'http://json-schema.org/draft-04/schema#',
594 585
    'title': 'Family',
595 586
    'description': 'Informations pour créer ou mettre à jour une famille',
596 587
    'type': 'object',
597
    'required': ['rl1', 'categorie', 'situation'],
588
    'required': ['categorie', 'situation'],
598 589
    'properties': {
599 590
        'categorie': {
600 591
            'description': 'Categorie (depuis référenciel)',
601 592
            'type': 'string',
602 593
        },
603 594
        'situation': {
604 595
            'description': 'Situation familiale (depuis référenciel)',
605 596
            'type': 'string',
......
648 639
                    'items': CHILD_SCHEMA,
649 640
                },
650 641
            ],
651 642
        },
652 643
    },
653 644
    'unflatten': True,
654 645
}
655 646

  
656

  
657
UPDATE_FAMILY_SCHEMA = copy.deepcopy(CREATE_FAMILY_SCHEMA)
658
UPDATE_FAMILY_SCHEMA['required'] = ['categorie', 'situation']
659

  
660

  
661
# Schemas below describe parameters of Maelis wrapper around updateFamily endpoint
647
CREATE_FAMILY_SCHEMA = copy.deepcopy(UPDATE_FAMILY_SCHEMA)
648
CREATE_FAMILY_SCHEMA['required'] = ['rl1', 'categorie', 'situation']
649
create_family_child_schema = CREATE_FAMILY_SCHEMA['properties']['childList']['oneOf'][1]['items']
650
del create_family_child_schema['properties']['fsl']
651
del create_family_child_schema['properties']['bPhoto']
652
del create_family_child_schema['properties']['bLeaveAlone']
653
del create_family_child_schema['properties']['paiInfoBean']
662 654

  
663 655
UPDATE_COORDINATE_SCHEMA = {
664 656
    '$schema': 'http://json-schema.org/draft-04/schema#',
665 657
    'title': 'Update coordinate',
666 658
    'description': "Mise à jour des coordonnées d'un responsable légal",
667 659
    'type': 'object',
668 660
    'properties': {
669 661
        'adresse': ADDRESS_SCHEMA,
670
-