Skip to content

Commit e028c94

Browse files
Honour a client-supplied collection id on creation
POST /collections uses the id from the request body when one is supplied (normalised to a lower-case identifier), and derives the id from the title only when the body omits it, so a client can choose the collection id as the OGC contract and the Go tier allow.
1 parent 14f1144 commit e028c94

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

resource/collection/collection_helper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ def validate_collection_data(data, is_update=False):
120120
if "title" not in data:
121121
errors.append("Missing required field: title")
122122
else:
123-
validated["title"] = data["title"]
124-
validated["id"] = data["title"].lower().replace(" ", "_")
123+
validated["title"] = data["title"]
124+
# Honour a client-supplied id; otherwise derive one from the title.
125+
provided = data.get("id")
126+
if isinstance(provided, str) and provided.strip():
127+
validated["id"] = provided.strip().lower().replace(" ", "_")
128+
else:
129+
validated["id"] = data["title"].lower().replace(" ", "_")
125130
else: # Replace aka Put operation:
126131
if "title" in data:
127132
validated["title"] = data["title"]

0 commit comments

Comments
 (0)