Impact migration of the route GET /v1/schemas/{resource}/{localeOrCountry} to GET /v2/schemas/{resource}/{localeOrCountry}

  • Obsolète
  • 30 octobre 2024
  • 1 route liée

Context

Key benefits : Three modifications are made on the GET /v2/schemas/{resource}/{localeOrCountry} resource:

First modification: Since we have changed the "identity_number" fields to "identity.number" and "identity.type" objects on our API endpoints, the schema has not been updated, and we are still using "identity_number" on this resource. Therefore, this field needs to be modified to an object.

Second modification: The B2B backend wishes to determine that among {n} fields, only 1 is mandatory. Indeed, the "email" and "phone" fields are not displayed as mandatory in the schema, but in reality, one of the two must be filled in for the participant creation to work (CLIC rule dedicated to direct agencies). We then add an "anyOf" field that dynamically displays that the completion of at least one field is mandatory.

Third modification: All our API resources request/respond with "issuing_date" regarding identity documents. However, our Schema resource responds with "issue_date". Therefore, we rename this field to be consistent with the rest of our resources.

Impacts

Route to call :

  • GET - /v2/schemas/{resource}/{localeOrCountry}

Output

  • 1️⃣ Première modification : Transformer "identity_number" en objets "identity.number" et "identity.type"

Example value

{
    "identity": {
            "type": "object",
            "properties": {
              "number": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [ "CPF", "CUIL", "TAX_NUMBER", "SECURITY_NUMBER", "ID_NUMBER", "NATIONAL_REGISTER", "DNI" ]
              }
            },
            "required": ["number", "type"]
          }
  • 2️⃣ Deuxième modification : Ajout d'un champ ```anyOf````

Ajout d'un champ "anyOf" email/phone:

-                "phones": {
-                    "type": "object",
-                    "additionalProperties": false,
-                   "required": [
-                       "mobilePhones"
-                   ],
-                   "patternProperties": {
-                       "^Phones": {
-                           "type": "array",
-                           "items": {
-                               "title": "PhoneModel",
-                               "type": "object",
-                               "additionalProperties": false,
-                               "required": [
-                                   "type",
-                                   "number"
-                               ],
-                               "properties": {
-                                   "number": {
-                                       "type": "string",
-                                       "description": "Phone number",
-                                       "examples": [
-                                           "0623456789"
-                                       ],
-                                       "pattern": "^.{0,20}$"
-                                   },
-                                   "type": {
-                                       "type": "string",
-                                       "description": "Phone type",
-                                       "examples": [
-                                           "MOBILE"
-                                       ]
-                                   }
-                               }
-                           }
-                       }
-                   }
+                "phones": {
+                   "minItems": 1,
+                   "type": "array",
+                   "items": {
+                       "type": "object",
+                       "required": [
+                           "type",
+                           "number"
+                       ],
+                       "properties": {
+                        "type": {
+                               "type": "string",
+                               "enum": [
+                                   "MOBILE"
+                               ],
+                               "description": "Phone type",
+                               "examples": [
+                                   "MOBILE"
+                               ]
+                           },
+                           "number": {
+                               "type": "string",
+                               "pattern": "^.{0,20}$",
+                               "description": "Phone number",
+                               "examples": [
+                                   "0623456789"
+                               ]
+                           }
+                       }
+                   }
+               }
  • 3️⃣ Troisième modification : Renommer "issue_date" en issuing_date