Repository: microsoft/AzureTRE (python)

Issue:
Default values for properties in a bundle overridden by API app
**Describe the bug**
Admin sets default value for Workspace property to be applied for any workspace creation in a bundle
When trying to create it default value is empty

**Steps to reproduce**

1. Update default value in bundle temple.json and build/register bundle
1. Try to create the workspace default is not set
1. Code merging props overrides it https://github.com/microsoft/AzureTRE/blob/main/api_app/services/schema_service.py#L28-L30 


Pull request description:
change merge properties sequence for defaults
# Resolves #2575

## What is being addressed

Defaults set by Admins in bundle template definition are overridden by API default template

## How is this addressed

- Change order of priority for the template properties

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd9db0db..3ceb9675 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ FEATURES:
 
 ENHANCEMENTS:
 * Remove Porter's Docker mixin as it's not in use ([#2889](https://github.com/microsoft/AzureTRE/pull/2889))
+* Enable properties defined within the API to be overridden by the bundle template - enables default values to be set. ([#2576](https://github.com/microsoft/AzureTRE/pull/2576))
 * Support template version update ([#2908](https://github.com/microsoft/AzureTRE/pull/2908))
 * Support updating the firewall when installing via makefile/CICD ([#2942](https://github.com/microsoft/AzureTRE/pull/2942))
 
diff --git a/api_app/_version.py b/api_app/_version.py
index 22049ab2..63af8876 100644
--- a/api_app/_version.py
+++ b/api_app/_version.py
@@ -1,1 +1,1 @@
-__version__ = "0.6.2"
+__version__ = "0.6.3"
diff --git a/api_app/services/schema_service.py b/api_app/services/schema_service.py
index 76a54dfe..f01e2038 100644
--- a/api_app/services/schema_service.py
+++ b/api_app/services/schema_service.py
@@ -40,8 +40,8 @@ def read_schema(schema_file: str) -> Tuple[List[str], Dict]:
 def enrich_template(original_template, extra_properties, is_update: bool = False, is_workspace_scope: bool = True) -> dict:
     template = original_template.dict(exclude_none=True)
 
-    all_required = [template["required"]] + [definition[0] for definition in extra_properties]
-    all_properties = [template["properties"]] + [definition[1] for definition in extra_properties]
+    all_required = [definition[0] for definition in extra_properties] + [template["required"]]
+    all_properties = [definition[1] for definition in extra_properties] + [template["properties"]]
 
     template["required"] = merge_required(all_required)
     template["properties"] = merge_properties(all_properties)


Test patch:
diff --git a/api_app/tests_ma/test_services/test_schema_service.py b/api_app/tests_ma/test_services/test_schema_service.py
index f7bcc62f..76cae2ea 100644
--- a/api_app/tests_ma/test_services/test_schema_service.py
+++ b/api_app/tests_ma/test_services/test_schema_service.py
@@ -67,12 +67,12 @@ def test_enrich_user_resource_template_enriches_with_user_resource_defaults(enri
         {'client_id': {'type': 'string'}},
         {'description': {'type': 'string'}, 'display_name': {'type': 'string'}, 'client_id': {'type': 'string'}}
     ),
-    # duplicate names - different types
+    # duplicate names - different defaults
     (
-        {'description': {'type': 'bool'}},
-        {'description': {'type': 'string'}, 'display_name': {'type': 'string'}},
+        {'description': {'type': 'string', 'default': 'service description'}, 'display_name': {'type': 'string'}},
+        {'description': {'type': 'string', 'default': ''}},
         {'client_id': {'type': 'string'}},
-        {'description': {'type': 'string'}, 'display_name': {'type': 'string'}, 'client_id': {'type': 'string'}}
+        {'description': {'type': 'string', 'default': 'service description'}, 'display_name': {'type': 'string'}, 'client_id': {'type': 'string'}}
     )])
 def test_enrich_template_combines_properties(original, extra1, extra2, expected, basic_resource_template):
     original_template = basic_resource_template