From fc9b27008755eacf7e768d00e3ed0c9991529bd5 Mon Sep 17 00:00:00 2001 From: Andreas Huber <anh@fjd.de> Date: Mon, 18 May 2020 12:35:17 +0200 Subject: [PATCH] =?UTF-8?q?CR-1:=20Discriminator=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/applicant-contact-info.json | 11 ++ .../application/applicant-organization.json | 25 +++- models/application/applicant-person.json | 70 ++-------- models/application/applicant.json | 11 +- models/common/address-international.json | 43 +++--- models/common/address-national.json | 122 +++++++----------- models/common/address-postbox.json | 43 ++++++ models/common/individual.json | 17 ++- models/destination-no-id.json | 13 +- 9 files changed, 198 insertions(+), 157 deletions(-) create mode 100644 models/common/address-postbox.json diff --git a/models/application/applicant-contact-info.json b/models/application/applicant-contact-info.json index 20d3e9bc..90278b9e 100644 --- a/models/application/applicant-contact-info.json +++ b/models/application/applicant-contact-info.json @@ -8,10 +8,21 @@ { "$ref": "../common/address-national.json" }, + { + "$ref": "../common/address-postbox.json" + }, { "$ref": "../common/address-international.json" } ], + "discriminator": { + "propertyName": "type", + "mapping": { + "national": "../common/address-national.json", + "postbox": "../common/address-postbox.json", + "international": "../common/address-international.json" + } + }, "description": "Physikalische (Post-)Adresse" }, "telephone": { diff --git a/models/application/applicant-organization.json b/models/application/applicant-organization.json index 5f7f3c7d..125cd3fb 100644 --- a/models/application/applicant-organization.json +++ b/models/application/applicant-organization.json @@ -1,7 +1,8 @@ { - "title": "Applicant Organisation", "type": "object", + "title": "Applicant Organisation", "description": "Antragsteller in Form von einer Organisation, z.B. einem Unternehmen", + "additionalProperties": false, "properties": { "identifier": { "type": "array", @@ -57,10 +58,21 @@ { "$ref": "../common/address-national.json" }, + { + "$ref": "../common/address-postbox.json" + }, { "$ref": "../common/address-international.json" } ], + "discriminator": { + "propertyName": "type", + "mapping": { + "national": "../common/address-national.json", + "postbox": "../common/address-postbox.json", + "international": "../common/address-international.json" + } + }, "description": "Offizielle Adresse" }, "legalRepresentatives": { @@ -84,6 +96,15 @@ "required": [ "method" ] + }, + "type": { + "type": "string", + "enum": [ + "organization" + ] } - } + }, + "required": [ + "type" + ] } \ No newline at end of file diff --git a/models/application/applicant-person.json b/models/application/applicant-person.json index 3b5a780f..8e51e383 100644 --- a/models/application/applicant-person.json +++ b/models/application/applicant-person.json @@ -1,7 +1,8 @@ { - "title": "Applicant Person", "type": "object", + "title": "Applicant Person", "description": "Antragstellerdaten für eine natürliche Person", + "additionalProperties": false, "properties": { "identifier": { "type": "array", @@ -18,64 +19,15 @@ }, "contactInfo": { "$ref": "./applicant-contact-info.json" + }, + "type": { + "type": "string", + "enum": [ + "person" + ] } }, - "x-examples": { - "example-1": { - "identifier": [ - { - "id": "918", - "schemeName": "Antragsportal", - "schemeId": "urn:com:example:antragsportal:user" - } - ], - "contactInfo": { - "physicalAddress": { - "street": "Kurzer Weg", - "houseNumber": 7, - "postalCode": "12345", - "city": "string", - "addressSupplement": "string" - }, - "telephone": [ - { - "number": "+49 89 32168-42", - "mobile": true, - "description": "string" - } - ], - "electronicAddresses": [ - { - "channelType": "Service-Account-Mailbox", - "address": "string" - } - ] - }, - "identityInfo": { - "gender": "m", - "nationality": "string", - "familyName": "string", - "givenName": "string", - "birthName": "string", - "doctoralDegrees": "string", - "artisticName": "string", - "dateOfBirth": "2020-04-16", - "placeOfBirth": "string", - "placeOfResidence": { - "street": "string", - "houseNumber": null, - "houseNumberSuffix": "st", - "postalCode": "strin", - "city": "string", - "addressSupplement": "string" - } - }, - "authentificationInfo": { - "timestamp": "2020-04-16T06:50:39Z", - "authentificationToken": {}, - "authentificationMethod": "string", - "assuranceLevel": "low" - } - } - } + "required": [ + "type" + ] } \ No newline at end of file diff --git a/models/application/applicant.json b/models/application/applicant.json index a07958d6..8a7b2117 100644 --- a/models/application/applicant.json +++ b/models/application/applicant.json @@ -1,4 +1,6 @@ { + "title": "Applicant", + "description": "Ein Antragsteller, entweder eine Organisation oder eine natürliche Person", "oneOf": [ { "$ref": "./applicant-person.json" @@ -7,6 +9,11 @@ "$ref": "./applicant-organization.json" } ], - "title": "Applicant", - "description": "Ein Antragsteller, entweder eine Organisation oder eine natürliche Person" + "discriminator": { + "propertyName": "type", + "mapping": { + "person": "./applicant-person.json", + "organization": "./applicant-organization.json" + } + } } \ No newline at end of file diff --git a/models/common/address-international.json b/models/common/address-international.json index 1d9067e8..df51e991 100644 --- a/models/common/address-international.json +++ b/models/common/address-international.json @@ -3,6 +3,22 @@ "title": "International Address", "description": "Eine internationale Adresse, bestehend aus ein bis fünf Adresszeilen.", "additionalProperties": false, + "x-examples": { + "example-1": { + "lines": [ + "760 United Nations Plaza", + "Manhattan, New York City, New York 10017" + ], + "country": "368" + }, + "example-2": { + "lines": [ + "Threadneedle Street", + "London EC2R 8AH" + ], + "country": "168" + } + }, "properties": { "lines": { "type": "array", @@ -20,26 +36,17 @@ "minLength": 3, "maxLength": 3, "pattern": "^[0-9]{3}$" + }, + "type": { + "type": "string", + "enum": [ + "international" + ] } }, "required": [ "lines", - "country" - ], - "x-examples": { - "example-1": { - "lines": [ - "760 United Nations Plaza", - "Manhattan, New York City, New York 10017" - ], - "country": "368" - }, - "example-2": { - "lines": [ - "Threadneedle Street", - "London EC2R 8AH" - ], - "country": "168" - } - } + "country", + "type" + ] } \ No newline at end of file diff --git a/models/common/address-national.json b/models/common/address-national.json index 6dd95751..322a019f 100644 --- a/models/common/address-national.json +++ b/models/common/address-national.json @@ -9,79 +9,57 @@ "city": "Ankh-Morpork" } }, - "oneOf": [ - { - "additionalProperties": false, - "properties": { - "street": { - "type": "string", - "description": "Straße", - "maxLength": 55 - }, - "houseNumber": { - "type": [ - "string", - "integer" - ], - "description": "Hausnummer", - "maxLength": 9, - "pattern": "^[1-9][0-9]{0,3}(-[1-9][0-9]{0,3})?$", - "minimum": 1 - }, - "houseNumberSuffix": { - "type": "string", - "description": "Hausnummerzusatz", - "maxLength": 2, - "pattern": "^[\\p{L}0-9. ]*$" - }, - "postalCode": { - "type": "string", - "description": "Postleitzahl", - "minLength": 5, - "maxLength": 5, - "pattern": "^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$" - }, - "city": { - "type": "string", - "description": "Ort", - "maxLength": 50 - }, - "addressSupplement": { - "type": "string", - "description": "Adresszusatz" - } - }, - "required": [ - "street", - "postalCode", - "city" - ] + "type": "object", + "additionalProperties": false, + "properties": { + "street": { + "type": "string", + "description": "Straße", + "maxLength": 55 + }, + "houseNumber": { + "type": [ + "string", + "integer" + ], + "description": "Hausnummer", + "maxLength": 9, + "pattern": "^[1-9][0-9]{0,3}(-[1-9][0-9]{0,3})?$", + "minimum": 1 + }, + "houseNumberSuffix": { + "type": "string", + "description": "Hausnummerzusatz", + "maxLength": 2, + "pattern": "^[\\p{L}0-9. ]*$" + }, + "postalCode": { + "type": "string", + "description": "Postleitzahl", + "minLength": 5, + "maxLength": 5, + "pattern": "^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$" }, - { - "additionalProperties": false, - "properties": { - "postOfficeBox": { - "type": "string", - "description": "Postfach" - }, - "postalCode": { - "type": "string", - "description": "Postleitzahl", - "minLength": 5, - "maxLength": 5, - "pattern": "^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$" - }, - "city": { - "type": "string", - "description": "Ort", - "maxLength": 50 - } - }, - "required": [ - "postalCode", - "city" + "city": { + "type": "string", + "description": "Ort", + "maxLength": 50 + }, + "addressSupplement": { + "type": "string", + "description": "Adresszusatz" + }, + "type": { + "type": "string", + "enum": [ + "national" ] } - ], - "type": "object" + }, + "required": [ + "street", + "postalCode", + "city", + "type" + ] } \ No newline at end of file diff --git a/models/common/address-postbox.json b/models/common/address-postbox.json new file mode 100644 index 00000000..b7366a6c --- /dev/null +++ b/models/common/address-postbox.json @@ -0,0 +1,43 @@ +{ + "title": "Postfach Address", + "description": "Eine Adresse eines Postfachs.", + "x-examples": { + "example-1": { + "street": "Kurzer Weg", + "houseNumber": 7, + "postalCode": "12345", + "city": "Ankh-Morpork" + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "postOfficeBox": { + "type": "string", + "description": "Postfach" + }, + "postalCode": { + "type": "string", + "description": "Postleitzahl", + "minLength": 5, + "maxLength": 5, + "pattern": "^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$" + }, + "city": { + "type": "string", + "description": "Ort", + "maxLength": 50 + }, + "type": { + "type": "string", + "enum": [ + "postbox" + ] + } + }, + "required": [ + "postalCode", + "city", + "type" + ] +} \ No newline at end of file diff --git a/models/common/individual.json b/models/common/individual.json index 123e4cf7..10231231 100644 --- a/models/common/individual.json +++ b/models/common/individual.json @@ -40,12 +40,23 @@ "description": "Adresse als Alternative (Choice) von nationaler und internationaler Adresse.", "oneOf": [ { - "$ref": "../common/address-national.json" + "$ref": "./address-national.json" }, { - "$ref": "../common/address-international.json" + "$ref": "./address-postbox.json" + }, + { + "$ref": "./address-international.json" } - ] + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "national": "./address-national.json", + "postbox": "./address-postbox.json", + "international": "./address-international.json" + } + } }, "identifiers": { "type": "array", diff --git a/models/destination-no-id.json b/models/destination-no-id.json index 8e9860a2..d00068c5 100644 --- a/models/destination-no-id.json +++ b/models/destination-no-id.json @@ -40,10 +40,21 @@ { "$ref": "./common/address-national.json" }, + { + "$ref": "./common/address-postbox.json" + }, { "$ref": "./common/address-international.json" } - ] + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "national": "./common/address-national.json", + "postbox": "./common/address-postbox.json", + "international": "./common/address-international.json" + } + } }, "identifiers": { "type": "array", -- GitLab