From 73bc67261ab843f7c27340c6323ef743777df6a0 Mon Sep 17 00:00:00 2001 From: nosvalds Date: Mon, 23 Aug 2021 14:57:59 -0400 Subject: [PATCH 1/4] use definitions for responses --- service/apim-iati-dev-apis.template.json | 34 +++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/service/apim-iati-dev-apis.template.json b/service/apim-iati-dev-apis.template.json index a3563fb..02f672d 100644 --- a/service/apim-iati-dev-apis.template.json +++ b/service/apim-iati-dev-apis.template.json @@ -497,6 +497,28 @@ ] } } + }, + "Existing Report missing query parameter": { + "type": "object", + "properties": { + "client_error": { + "type": "string" + } + }, + "example": { + "client_error": "Either the id, url or hash of the document as obtained from the IATI Registry must be supplied as a GET parameter" + } + }, + "Existing Report Not Found": { + "type": "object", + "properties": { + "client_error": { + "type": "string" + } + }, + "example": { + "client_error": "The requested report does not exist." + } } } } @@ -565,7 +587,9 @@ "representations": [ { "contentType": "application/json", - "sample": "{\r\n \"client_error\": \"Either the id, url or hash of the document as obtained from the IATI Registry must be supplied as a GET parameter\"\r\n}" + "sample": "{\r\n \"client_error\": \"Either the id, url or hash of the document as obtained from the IATI Registry must be supplied as a GET parameter\"\r\n}", + "schemaId": "1622545438727", + "typeName": "Existing Report missing query parameter" } ] }, @@ -585,7 +609,9 @@ "representations": [ { "contentType": "application/json", - "sample": "{ client_error: 'The requested report does not exist.' }" + "sample": "{\r\n \"client_error\": \"The requested report does not exist.\"\r\n}", + "schemaId": "1622545438727", + "typeName": "Existing Report Not Found" } ] }, @@ -652,7 +678,7 @@ "templateParameters": [], "description": "This route allows the user to POST an IATI document to the Validator in the body of the request, and receive a JSON validation report in the response.\n\n[GitHub Repository](https://github.com/IATI/js-validator-api) \n\n[Error ID Information](https://github.com/IATI/validator-rule-tracker)\n", "request": { - "description": "IATI XML document (activities or organisations)", + "description": "IATI XML document (organisations or activities)", "queryParameters": [ { "name": "group", @@ -769,7 +795,7 @@ "representations": [ { "contentType": "application/json", - "sample": "{\r\n \"valid\": true,\r\n \"fileType\": \"iati-activities\",\r\n \"iatiVersion\": \"string\",\r\n \"rulesetCommitSha\": \"string\",\r\n \"codelistCommitSha\": \"string\",\r\n \"orgIdPrefixFileName\": \"string\",\r\n \"apiVersion\": \"string\",\r\n \"summary\": {\r\n \"critical\": 0,\r\n \"error\": 0,\r\n \"warning\": 0\r\n },\r\n \"errors\": [\r\n {\r\n \"errors\": [\r\n {\r\n \"errors\": [\r\n {\r\n \"id\": \"string\",\r\n \"severity\": \"critical\",\r\n \"message\": \"string\",\r\n \"codelist\": \"string\",\r\n \"context\": [\r\n {\r\n \"text\": \"string\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"category\": \"string\"\r\n }\r\n ],\r\n \"identifier\": \"string\",\r\n \"title\": \"string\"\r\n }\r\n ]\r\n}", + "sample": "{\r\n \"valid\": false,\r\n \"fileType\": \"string\",\r\n \"iatiVersion\": \"string\",\r\n \"rulesetCommitSha\": \"string\",\r\n \"codelistCommitSha\": \"string\",\r\n \"orgIdPrefixFileName\": \"string\",\r\n \"apiVersion\": \"string\",\r\n \"summary\": {\r\n \"critical\": 0,\r\n \"error\": 0,\r\n \"warning\": 0\r\n },\r\n \"errors\": [\r\n {\r\n \"errors\": [\r\n {\r\n \"errors\": [\r\n {\r\n \"id\": \"string\",\r\n \"severity\": \"string\",\r\n \"message\": \"string\",\r\n \"codelist\": \"string\",\r\n \"context\": [\r\n {\r\n \"text\": \"string\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"category\": \"string\"\r\n }\r\n ],\r\n \"identifier\": \"string\",\r\n \"title\": \"string\"\r\n }\r\n ]\r\n}", "schemaId": "1622545438727", "typeName": "Validation Report Ad Hoc Validate" } From a016117a8b0b45f8ff0da2e89ca1b0057fcab007 Mon Sep 17 00:00:00 2001 From: nosvalds Date: Tue, 24 Aug 2021 11:26:45 -0400 Subject: [PATCH 2/4] try some escaped xml in ARM template --- service/apim-iati-dev-apis.template.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/service/apim-iati-dev-apis.template.json b/service/apim-iati-dev-apis.template.json index 02f672d..b986efb 100644 --- a/service/apim-iati-dev-apis.template.json +++ b/service/apim-iati-dev-apis.template.json @@ -714,11 +714,15 @@ "representations": [ { "contentType": "application/xml", - "sample": "\n\n \n NP-SWC-1234\n \n Test Org Nepal\n \n \n Test Org Nepal\n \n \n \n \n \n 25000000\n \n 2000000\n Budget Line\n \n \n \n\n" + "sample": "<?xml version="1.0" encoding="UTF-8"?><xml></xml>" }, { "contentType": "application/xml", - "sample": "\n\n\n\n\n\n \n \n\n \n AA-AAA-123456789-ABC123\n \n\n \n \n Organisation name\n Nom de l'organisme\n \n \n\n \n \n <narrative>Activity title</narrative>\n <narrative xml:lang=\"fr\">Titre de l'activité</narrative>\n <narrative xml:lang=\"es\">Título de la actividad</narrative>\n \n \n\n \n \n General activity description text. Long description of the activity with no particular structure.\n Activité générale du texte de description. Longue description de l'activité sans structure particulière.\n \n \n Objectives for the activity, for example from a logical framework.\n Objectifs de l'activité, par exemple à partir d'un cadre logique.\n \n \n Statement of groups targeted to benefit from the activity.\n Déclaration de groupes ciblés pour bénéficier de l'activité.\n \n \n\n \n \n Name of Agency B\n \n \n Name of Agency C\n \n \n Name of Agency A\n Nom de l'agence A\n \n \n\n \n \n \n Organisation name\n \n \n \n\n \n \n \n\n \n \n Planned start date of the activity\n Date prévue de début de l'activité\n \n \n \n \n\n \n \n \n Agency A\n \n \n Department B\n \n \n A. Example\n \n \n Transparency Lead\n \n 0044111222333444\n transparency@example.org\n http://www.example.org\n \n Transparency House, The Street, Town, City, Postcode\n \n \n \n\n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n \n Location name\n \n \n Location description\n \n \n A description that qualifies the activity taking place at the location.\n \n \n \n 31.616944 65.716944\n \n \n \n \n \n \n\n \n \n \n \n \n Location #2 name\n \n \n Location #2 description\n \n \n A description that qualifies the activity taking place at location #2\n \n \n \n 11.5500 104.9167\n \n \n \n \n \n \n\n \n \n \n \n Code A1\n \n \n\n \n \n A description of the tag\n \n \n A description of the tag\n \n \n\n \n \n \n \n Description text\n \n \n \n \n Description text\n \n \n \n \n\n \n \n \t Nepal Earthquake April 2015\n Népal Earthquake Avril 2015\n \n \n Nepal Earthquake April 2015\n \n \n\n \n \n \n \n Code A1\n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n \n\n \n \n \n\n \n \n \n \n 3000\n \n \n\n \n \n \n \n 3000\n \n Agency B\n \n \n Agency A\n \n \n \n\n \n \n \n \n 3000\n \n \n\n \n \n \n\n \n \n \n \n 1000\n \n Transaction description text\n \n \n Agency B\n \n \n Agency A\n \n \n \n \n \n \n \n \n \n \n\n \n \n \n <narrative>Project Report 2013</narrative>\n <narrative xml:lang=\"fr\">Rapport de projet 2013</narrative>\n \n \n Description of the content of the project report or guidance on where to access the relevant information in this report \n \n \n \n \n \n \n\n \n \n \n\n \n \n \n \n\n \n \n \n Conditions text\n Conditions texte\n \n \n \n\n \n \n \n <narrative>Result title</narrative>\n \n \n Result description text\n \n \n \n \n <narrative>Results Report 2013</narrative>\n \n \n Report of results\n \n \n \n \n \n\n\n\n\n\n \n \n <narrative>Indicator title</narrative>\n \n \n Indicator description text\n \n \n \n <narrative>Results Indicator Report 2013</narrative>\n \n \n Report of results indicator\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n <narrative>Results Baseline Report 2013</narrative>\n \n \n Report of results baseline\n \n \n \n \n \n \n Baseline comment text\n \n \n \n \n \n \n \n \n \n \n \n \n \n Target comment text\n \n \n \n <narrative>Results Period Target Report 2013</narrative>\n \n \n Report of results period target\n \n \n \n \n \n \n \n \n \n \n \n \n Actual comment text\n \n \n \n <narrative>Results Period Actual Report 2013</narrative>\n \n \n Report of results period actual\n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n 200000\n 1500000\n 0\n 0\n \n 21039\n \n \n\n \n \n 10000\n \n \n\n \n \n\n\n\n" + "sample": "" + }, + { + "contentType": "application/xml", + "sample": "<xml></xml>" } ] }, From 367fe40f8ad8aa06da3281da768c5a69223331c9 Mon Sep 17 00:00:00 2001 From: nosvalds Date: Tue, 24 Aug 2021 11:44:37 -0400 Subject: [PATCH 3/4] try a bunch of contentTypes --- service/apim-iati-dev-apis.template.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/service/apim-iati-dev-apis.template.json b/service/apim-iati-dev-apis.template.json index b986efb..1a4c00d 100644 --- a/service/apim-iati-dev-apis.template.json +++ b/service/apim-iati-dev-apis.template.json @@ -714,14 +714,22 @@ "representations": [ { "contentType": "application/xml", - "sample": "<?xml version="1.0" encoding="UTF-8"?><xml></xml>" + "sample": "Hello World" }, { - "contentType": "application/xml", + "contentType": "application/json", + "sample": "Hello World" + }, + { + "contentType": "text/plain", + "sample": "Hello World" + }, + { + "contentType": "text/xml", "sample": "" }, { - "contentType": "application/xml", + "contentType": "text/xml", "sample": "<xml></xml>" } ] From 3863ee3dc16f6a97a023bc6fa5d9ce29c7abb534 Mon Sep 17 00:00:00 2001 From: nosvalds Date: Tue, 24 Aug 2021 14:16:54 -0400 Subject: [PATCH 4/4] update validator services backend and parameterise --- service/apim-iati-dev-apis.template.json | 2 +- service/apim-iati-dev-backends.template.json | 28 +++++++++++-------- ...ces-get-pub-get-report-operationPolicy.xml | 2 +- ...-v2-get-pub-get-report-operationPolicy.xml | 2 +- ...0a46b0342160c523b5a90f-operationPolicy.xml | 24 ++++++++-------- ...14e44dd2a66d17c80f78ce-operationPolicy.xml | 24 ++++++++-------- ...ate-get-pub-get-report-operationPolicy.xml | 2 +- ...te-get-pub-get-version-operationPolicy.xml | 2 +- ...pvt-get-guidance-links-operationPolicy.xml | 2 +- ...et-publisher-documents-operationPolicy.xml | 2 +- ...get-pvt-get-publishers-operationPolicy.xml | 2 +- ...vt-get-single-document-operationPolicy.xml | 24 ++++++++-------- ...t-get-single-publisher-operationPolicy.xml | 24 ++++++++-------- ...te-pvt-post-adhoc-file-operationPolicy.xml | 24 ++++++++-------- 14 files changed, 84 insertions(+), 80 deletions(-) diff --git a/service/apim-iati-dev-apis.template.json b/service/apim-iati-dev-apis.template.json index 1a4c00d..c05136c 100644 --- a/service/apim-iati-dev-apis.template.json +++ b/service/apim-iati-dev-apis.template.json @@ -942,7 +942,7 @@ }, { "properties": { - "description": "Import from \"dev-func-validator-services\" Function App", + "description": "Validator Services Routes", "authenticationSettings": { "subscriptionKeyRequired": false }, diff --git a/service/apim-iati-dev-backends.template.json b/service/apim-iati-dev-backends.template.json index 0b33a4d..fb1fe3e 100644 --- a/service/apim-iati-dev-backends.template.json +++ b/service/apim-iati-dev-backends.template.json @@ -6,17 +6,21 @@ "type": "string" }, "Environment": { - "type": "string" + "type": "string" }, "SubscriptionId": { - "type": "string" + "type": "string" } }, + "variables": { + "ValidatorServicesNameWithEnv": "[concat('func-validator-services-', parameters('Environment'))]", + "ValidatorAPINameWithEnv": "[concat('func-iativalidator-', parameters('Environment'))]" + }, "resources": [ { "properties": { - "description": "[concat(parameters('Environment'), '-func-validator-services')]", - "resourceId": "[concat('https://management.azure.com/subscriptions/', parameters('SubscriptionId'), '/resourceGroups/rg-validator-services-', parameters('Environment'), '/providers/Microsoft.Web/sites/' , parameters('Environment'), '-func-validator-services')]", + "description": "[variables('ValidatorServicesNameWithEnv')]", + "resourceId": "[concat('https://management.azure.com/subscriptions/', parameters('SubscriptionId'), '/resourceGroups/rg-validator-services-', parameters('Environment'), '/providers/Microsoft.Web/sites/' , variables('ValidatorServicesNameWithEnv'))]", "credentials": { "header": { "x-functions-key": [ @@ -24,30 +28,30 @@ ] } }, - "url": "[concat( 'https://', parameters('Environment'), '-func-validator-services.azurewebsites.net/api')]", + "url": "[concat( 'https://', variables('ValidatorServicesNameWithEnv'), '.azurewebsites.net/api')]", "protocol": "http" }, - "name": "[concat(parameters('ApimServiceName'), '/', parameters('Environment'), '-func-validator-services')]", + "name": "[concat(parameters('ApimServiceName'), '/', variables('ValidatorServicesNameWithEnv'))]", "type": "Microsoft.ApiManagement/service/backends", "apiVersion": "2020-12-01" }, { "properties": { - "description": "[concat('func-iativalidator-', parameters('Environment'))]", - "resourceId": "[concat('https://management.azure.com/subscriptions/', parameters('SubscriptionId'), '/resourceGroups/rg-iativalidator-', parameters('Environment'), '/providers/Microsoft.Web/sites/func-iativalidator-', parameters('Environment'))]", + "description": "[variables('ValidatorAPINameWithEnv')]", + "resourceId": "[concat('https://management.azure.com/subscriptions/', parameters('SubscriptionId'), '/resourceGroups/rg-iativalidator-', parameters('Environment'), '/providers/Microsoft.Web/sites/', variables('ValidatorAPINameWithEnv'))]", "credentials": { "header": { "x-functions-key": [ - "[concat('{{func-iativalidator-', parameters('Environment'), '-key}}')]" + "[concat('{{',variables('ValidatorAPINameWithEnv'),'-key}}')]" ] } }, - "url": "[concat( 'https://func-iativalidator-', parameters('Environment'), '.azurewebsites.net/api')]", + "url": "[concat( 'https://', variables('ValidatorAPINameWithEnv'), '.azurewebsites.net/api')]", "protocol": "http" }, - "name": "[concat(parameters('ApimServiceName'), '/func-iativalidator-', parameters('Environment'))]", + "name": "[concat(parameters('ApimServiceName'), '/', variables('ValidatorAPINameWithEnv'))]", "type": "Microsoft.ApiManagement/service/backends", "apiVersion": "2020-12-01" } ] -} \ No newline at end of file +} diff --git a/service/policies/dev-func-validator-services-get-pub-get-report-operationPolicy.xml b/service/policies/dev-func-validator-services-get-pub-get-report-operationPolicy.xml index b18a3c9..14593c3 100644 --- a/service/policies/dev-func-validator-services-get-pub-get-report-operationPolicy.xml +++ b/service/policies/dev-func-validator-services-get-pub-get-report-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/iati-validator-v2-get-pub-get-report-operationPolicy.xml b/service/policies/iati-validator-v2-get-pub-get-report-operationPolicy.xml index b0f8604..730308b 100644 --- a/service/policies/iati-validator-v2-get-pub-get-report-operationPolicy.xml +++ b/service/policies/iati-validator-v2-get-pub-get-report-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/validator-services-private-610a46b0342160c523b5a90f-operationPolicy.xml b/service/policies/validator-services-private-610a46b0342160c523b5a90f-operationPolicy.xml index 2e92270..c7855f2 100644 --- a/service/policies/validator-services-private-610a46b0342160c523b5a90f-operationPolicy.xml +++ b/service/policies/validator-services-private-610a46b0342160c523b5a90f-operationPolicy.xml @@ -1,19 +1,19 @@ - - + diff --git a/service/policies/validator-services-private-6114e44dd2a66d17c80f78ce-operationPolicy.xml b/service/policies/validator-services-private-6114e44dd2a66d17c80f78ce-operationPolicy.xml index abb3a0a..7d38b84 100644 --- a/service/policies/validator-services-private-6114e44dd2a66d17c80f78ce-operationPolicy.xml +++ b/service/policies/validator-services-private-6114e44dd2a66d17c80f78ce-operationPolicy.xml @@ -1,19 +1,19 @@ - - + * diff --git a/service/policies/validator-services-private-get-pub-get-report-operationPolicy.xml b/service/policies/validator-services-private-get-pub-get-report-operationPolicy.xml index b18a3c9..14593c3 100644 --- a/service/policies/validator-services-private-get-pub-get-report-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pub-get-report-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/validator-services-private-get-pub-get-version-operationPolicy.xml b/service/policies/validator-services-private-get-pub-get-version-operationPolicy.xml index b18a3c9..14593c3 100644 --- a/service/policies/validator-services-private-get-pub-get-version-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pub-get-version-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/validator-services-private-get-pvt-get-guidance-links-operationPolicy.xml b/service/policies/validator-services-private-get-pvt-get-guidance-links-operationPolicy.xml index b33276e..d19c897 100644 --- a/service/policies/validator-services-private-get-pvt-get-guidance-links-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pvt-get-guidance-links-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/validator-services-private-get-pvt-get-publisher-documents-operationPolicy.xml b/service/policies/validator-services-private-get-pvt-get-publisher-documents-operationPolicy.xml index b18a3c9..14593c3 100644 --- a/service/policies/validator-services-private-get-pvt-get-publisher-documents-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pvt-get-publisher-documents-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/validator-services-private-get-pvt-get-publishers-operationPolicy.xml b/service/policies/validator-services-private-get-pvt-get-publishers-operationPolicy.xml index b33276e..d19c897 100644 --- a/service/policies/validator-services-private-get-pvt-get-publishers-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pvt-get-publishers-operationPolicy.xml @@ -1,7 +1,7 @@ - + diff --git a/service/policies/validator-services-private-get-pvt-get-single-document-operationPolicy.xml b/service/policies/validator-services-private-get-pvt-get-single-document-operationPolicy.xml index 2e92270..c7855f2 100644 --- a/service/policies/validator-services-private-get-pvt-get-single-document-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pvt-get-single-document-operationPolicy.xml @@ -1,19 +1,19 @@ - - + diff --git a/service/policies/validator-services-private-get-pvt-get-single-publisher-operationPolicy.xml b/service/policies/validator-services-private-get-pvt-get-single-publisher-operationPolicy.xml index 2e92270..c7855f2 100644 --- a/service/policies/validator-services-private-get-pvt-get-single-publisher-operationPolicy.xml +++ b/service/policies/validator-services-private-get-pvt-get-single-publisher-operationPolicy.xml @@ -1,19 +1,19 @@ - - + diff --git a/service/policies/validator-services-private-pvt-post-adhoc-file-operationPolicy.xml b/service/policies/validator-services-private-pvt-post-adhoc-file-operationPolicy.xml index abb3a0a..7d38b84 100644 --- a/service/policies/validator-services-private-pvt-post-adhoc-file-operationPolicy.xml +++ b/service/policies/validator-services-private-pvt-post-adhoc-file-operationPolicy.xml @@ -1,19 +1,19 @@ - - + *