Repository: camptocamp/python-geoservercloud

Issue:
Add support for FeatureType without `keyword`
```
File ~/code/python-geoservercloud/geoservercloud/models/featuretype.py:133, in FeatureType.from_get_response_payload(cls, content)
    121 else:
    122     metadata_links = None
    124 return cls(
    125     namespace_name=feature_type["namespace"]["name"],
    126     name=feature_type["name"],
    127     native_name=feature_type["nativeName"],
    128     workspace_name=workspace_name,
    129     store_name=store_name,
    130     title=title,
    131     abstract=abstract,
    132     srs=feature_type["srs"],
--> 133     keywords=feature_type["keywords"]["string"],
    134     attributes=feature_type["attributes"]["attribute"],
    135     metadata_links=metadata_links,
    136     enabled=feature_type["enabled"],
    137     circular_arc_present=feature_type["circularArcPresent"],
    138     overriding_service_srs=feature_type["overridingServiceSRS"],
    139     pad_with_zeros=feature_type["padWithZeros"],
    140     projection_policy=feature_type["projectionPolicy"],
    141     service_configuration=feature_type["serviceConfiguration"],
    142     advertised=feature_type.get("advertised"),
    143     encode_measures=feature_type.get("encodeMeasures"),
    144     forced_decimals=feature_type.get("forcedDecimals"),
    145     simple_conversion_enabled=feature_type.get("simpleConversionEnabled"),
    146     skip_number_match=feature_type.get("skipNumberMatch"),
    147 )

KeyError: 'keywords'
```

Discussion:

Patch:
diff --git a/geoservercloud/models/featuretype.py b/geoservercloud/models/featuretype.py
index 2b761d4..d117d47 100644
--- a/geoservercloud/models/featuretype.py
+++ b/geoservercloud/models/featuretype.py
@@ -41,7 +41,7 @@ class FeatureType(EntityModel):
         namespace_name: str | None = None,
         title: dict[str, str] | str | None = None,
         abstract: dict[str, str] | str | None = None,
-        keywords: list[str] | None = [],
+        keywords: list[str] | None = None,
         native_bounding_box: dict[str, Any] | None = None,
         lat_lon_bounding_box: dict[str, Any] | None = None,
         attributes: list[dict[str, Any]] | None = None,
@@ -130,7 +130,6 @@ class FeatureType(EntityModel):
             title=title,
             abstract=abstract,
             srs=feature_type["srs"],
-            keywords=feature_type["keywords"]["string"],
             attributes=feature_type["attributes"]["attribute"],
             metadata_links=metadata_links,
             enabled=feature_type["enabled"],
@@ -142,6 +141,7 @@ class FeatureType(EntityModel):
             advertised=feature_type.get("advertised"),
             native_bounding_box=feature_type.get("nativeBoundingBox"),
             lat_lon_bounding_box=feature_type.get("latLonBoundingBox"),
+            keywords=feature_type.get("keywords", {}).get("string", []),
             encode_measures=feature_type.get("encodeMeasures"),
             forced_decimals=feature_type.get("forcedDecimals"),
             simple_conversion_enabled=feature_type.get("simpleConversionEnabled"),
@@ -194,8 +194,10 @@ class FeatureType(EntityModel):
 
     def post_payload(self) -> dict[str, Any]:
         content = self.asdict()
-        content["attributes"] = {"attribute": self.attributes}
-        content["keywords"] = {"string": self.keywords}
+        if self.attributes is not None:
+            content["attributes"] = {"attribute": self.attributes}
+        if self.keywords is not None:
+            content["keywords"] = {"string": self.keywords}
         return {"featureType": content}
 
     def put_payload(self) -> dict[str, Any]:


Test patch:
diff --git a/tests/models/test_featuretype.py b/tests/models/test_featuretype.py
index 100a112..b1ce5f3 100644
--- a/tests/models/test_featuretype.py
+++ b/tests/models/test_featuretype.py
@@ -252,3 +252,29 @@ def test_featuretype_repr():
     expected_repr = json.dumps(feature_type.post_payload(), indent=4)
 
     assert repr(feature_type) == expected_repr
+
+
+def test_featuretype_create_no_keyword():
+    feature_type = FeatureType(
+        namespace_name="test_namespace",
+        workspace_name="test_workspace",
+        store_name="test_store",
+        name="test_name",
+        native_name="test_native_name",
+        keywords=None,
+    )
+
+    assert feature_type.post_payload()["featureType"].get("keywords") is None
+
+    feature_type = FeatureType(
+        namespace_name="test_namespace",
+        workspace_name="test_workspace",
+        store_name="test_store",
+        name="test_name",
+        native_name="test_native_name",
+        keywords=[],
+    )
+
+    assert (
+        feature_type.post_payload()["featureType"].get("keywords").get("string") == []
+    )